Hello there,
I have a question regarding exiting a yield statement, after a certain time elapsed. I am changing a global variable according to a keypress (using yield viztask.waitKeyDown) within a function, if that keypress should not happen, I want to exit the yield statement after a certain time interval. And continue the protocol with the unchanged global variable.
I might be wrong using yield, and there is some other way (I read about python threading?Running a timer parallel to yield?), could you point me to some example code? I couldn't find this scenario in the tutorial.
Thank you.
Code:
Step=1
Motion = 15
def control():
global Motion
..... #dosomething with Motion
for i in range(1,x)
d = viz.Data()
yield viztask.waitKeyDown(['y','n'],d) #or, if no key was pressed, after 2 sec exit yield
if d.key == 'y':
Motion = Motion - Step
elif d.key == 'n':
Motion = Motion + Step