I need a little help with a trigger script I put together for a my new Maestro 12 if somebody would be so kind.
I have a infra red sensor hooked up to the Maestro, and want the main loop to start only after the sensor has been activated for over 100ms (to eliminate noise).
This is the trigger loop I cobbled together and it works. When I run the script in the control center I can see it looping waiting for the sensor to be activated. The problem is that I don’t know how to tell the script to then run the main loop when the trigger is activated. So I get an error every time the sensor is tripped because it doesn’t know what to do.
Any help would be appreciated.
5 sub trigger
6 8 get_position 255 greater_than
9 sub wait_for_trigger_press
12 sub wait_for_trigger_press_100ms
17 get_ms over minus 100 greater_than
18 if drop return endif
20 drop get_ms
I added code tags ([code ] [ /code ] without the spaces) to your post to make it easier to read; please use this method to post code in the future.
I briefly looked at your code, and it looks like your script attempts to return (line 3 in your code) once the trigger is pressed, which it cannot do because it has no where to return to. One solution would be to use a
goto statement to jump to your
main_loop label after your sensor has been activated for over 100ms. I modified your code slightly, and it worked with my setup (I used a 12-channel Maestro and a button input on channel 8).
Here is the code I used:
wait_for_trigger_press_100ms #start first by calling a subroutine
goto main_loop #return after trigger is pressed for 100ms and go to main_loop
8 get_position 255 greater_than
get_ms over minus 100 greater_than
if drop return endif
I also simplified your original code by removing the subroutine whose sole purpose is to call another subroutine.
Thank you very much Amanda!