How to use?
Up to Scripts
I made this working code:
def lightdemo():
dark = 0
orig_light_level = float(tux.status.requestOne('light_level')[0])
speak("Autonomous mode activated")
while dark == 0:
current_light_level = float(tux.status.requestOne('light_level')[0])
if current_light_level <= (orig_light_level-4):
speak("Hey! Who turned out the lights?")
dark = 1
while dark == 1:
current_light_level = float(tux.status.requestOne('light_level')[0])
if current_light_level >= (orig_light_level-1):
speak("Ah, That is much better!")
dark = 0
And i want to trigger it with the head botton. Can someone show me how? I think you use...
self.tux.button.head.registerEventOnPressed
that's it. You should register a function to be called when the button is pressed. In your case something like
tux.button.head.registerEventOnPressed(lightdemo)
you should also keep your script running with a loop like
while(not tux.button.remote.waitPressed(10.0, K_STANDBY)):
pass
which wait until the stand by key the remote is pressed.
See http://gist.github.com/40256 for a complete script that use the remote. I cannot test it right now, but I believe that using the head and flippers buttons is the same (but there is no second argument in registerEventOnPressed and waitPressed).