is there any way to print more than one value to a controller when I try to print more than one value it only shows the value that is first in order
we are using python in RMS
Thanks in advance
is there any way to print more than one value to a controller when I try to print more than one value it only shows the value that is first in order
we are using python in RMS
Thanks in advance
Yes.
Hmm, could you post the code you have at the moment?
There are three different lines to print to. If you repeatedly print to the same one it will just overwrite what was there before. Also, VEXos ignores any controller messages sent within 50ms of a previous message, so you need to space out your print commands as we do not keep track of that delay for you.
I fully ignore that, and every 20 ms, I send a new clear LCD and all the commands again. This makes the LCD change every 60 milliseconds. I have not had a problem with this, but should I not do it?
If the controller is tethered to the robot the delay is shorter. Other than that, it’s possible something changed in a recent VEXos update that I am not aware of. Do you have a link to the project where you’re doing this so I can see it in action?
@John_TYler how can i make the time more that 50 ms so that i can print more than one value at a time
here is our code
https://www.robotmesh.com/studio/5e0e2df13d68603bcb94933b
sys.sleep(0.05)
between sending messages to the controller. You might want to start a thread whose only job is to write to the controller screen so that nothing else gets slowed down by that much waiting:
message1 = ""
message2 = ""
message3 = ""
def controller_thread():
while True:
con.screen.set_cursor(1, 1)
con.screen.print_(message1)
sys.sleep(0.05)
con.screen.set_cursor(2, 1)
con.screen.print_(message2)
sys.sleep(0.05)
con.screen.set_cursor(3, 1)
con.screen.print_(message3)
sys.sleep(0.05)
sys.run_in_thread(controller_thread)
def some_other_thing():
global message1, message2, message3
message1 = "some_other_thing start"
if condition:
message2 = "condition true"
else:
message2 = "condition false"
Etc.
@John_TYler so just put that as a definition in the while loop??
@John_TYler How about now??
Not quite. A thread is a section of code that runs alongside other code, and starts with the call to sys.run_in_thread, when you give it the function that you want to run alongside the rest of your code. That function is packed with a controller print every 50ms, so it would by the only place to have controller prints in your code. The second function shows how you could pass messages to that thread with global variables, being message1, message2, and message3 in this example.
And for future reference, copying code that someone provides as an example straight into your code without understanding it first is very bad practice. You should ask questions before you copy.
@John_TYler How about now??