I’m trying to program a red side/blue side selector menu on the V5 controller’s screen, but I don’t know how to make the controller screen display “buttons” (images?) that I can select using either the joysticks or buttons. Can someone point me in the right direction?
It’s three separate steps: drawing things on the screen, waiting for the screen to be pressed, then doing something based on where it was pressed. Here is an example I wrote in Robot Mesh Studio C++ a while back: link. There are also Blockly and Python versions.
What programming environment? PROS, RMS, or VCS?
PROS offers a port of LittlevGL which gives you plenty of building block components: buttons, screens, tabs, animations, and more. It’s the most powerful option currently available, but is going to be more complex than simply drawing a rectangle/text.
I thought the controller screen could only display text. You’d need to do buttons on the Brain screen or a menu on the controller.
Here is the Python code @John TYler linked to above:
# VEX V5 Python Project import sys import vex #region config brain = vex.Brain(); motor_R = vex.Motor(vex.Ports.PORT15, vex.GearSetting.RATIO18_1, True) motor_L = vex.Motor(vex.Ports.PORT16, vex.GearSetting.RATIO18_1, False) dt = vex.Drivetrain(motor_L, motor_R, 319.1764, 292.1, vex.DistanceUnits.MM) #endregion config #For the purposes of this program, we assume the brain is oriented as on the claw bot with the bottom of the screen facing forward. #That is, the +Y direction (top to bottom) on our screen matches the forward direction on our robot. brain.screen.render(True,False) #This sets the screen to not refresh on a schedule, #but do wait for us to tell it to render something #This prevents screen flickering and tearing while True: brain.screen.clear_screen() #Clears the screen with default color (black) for i in range(0,2): brain.screen.draw_line(160*(i+1),0,160*(i+1),240) #Draws a vertical line brain.screen.draw_line(0,80*(i+1),480,80*(i+1)) #draws a horizontal line brain.screen.render() #Render what we just drew all at once ("swap the buffer") if brain.screen.pressing(): #did the screen get pressed? brain.screen.draw_circle(brain.screen.x_position(),brain.screen.y_position(),16) #draws a circle where the finger just pressed brain.screen.render() #swap the buffer to display our circle sys.sleep(1) #wait for the finger to get clear if brain.screen.y_position() > 160: #bottom third of screen (robot front) if brain.screen.x_position() < 160: #left third of screen (robot right) dt.turn_for(vex.TurnType.RIGHT,45) elif brain.screen.x_position() > 320: #right third of screen (robot left) dt.turn_for(vex.TurnType.LEFT,45) else: #middle third of bottom third dt.drive_for(vex.DirectionType.FWD,6,vex.DistanceUnits.IN) elif brain.screen.y_position() < 80: #top third of screen (robot back) if brain.screen.x_position() < 160: #left third of screen (robot right) dt.turn_for(vex.TurnType.RIGHT,135) elif brain.screen.x_position() > 320: #right third of screen (robot left) dt.turn_for(vex.TurnType.LEFT,135) else: #middle third of top third dt.drive_for(vex.DirectionType.REV,6,vex.DistanceUnits.IN) else: #middle horizontal band of screen if brain.screen.x_position() < 160: #left third of screen (robot right) dt.turn_for(vex.TurnType.RIGHT,90) elif brain.screen.x_position() > 320: #right third of screen (robot left) dt.turn_for(vex.TurnType.LEFT,90) else: #center ninth of screen pass#do nothing
@edjubuh I’m using C++ Pro
@Rick TYler would it work with C++ Pro?
It will work on Robot Mesh Studio C++, and should work in VCS. We don’t use or test on VCS, though. Give RM Studio a try.
The C++ code version linked above and linked here for ease.
Not the python code Rick posted.
There’s no drivetrain class in VCS, so it will not build without modification.
@tabor473 Thanks! I’ll take a look at that.
I end up writing my own GUI system, still a work-in-progress but hopefully it’ll be ready for the competitions in January.
Might post it up if people are interested in seeing it work.
would this work on vex coding studio and if not what would?
@jpearman already answered this:
You can always modify the code linked here to work in VCS, or you can create your own code to accomplish the same goal.
Alternatively, searching the forum reveals this project, which appears to be exactly what you are looking for
Please do not revive dead threads where there is no readily cognizable value in doing so.