Help with a trigger script


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.

1 2 wait_for_trigger_press 3 return 4 5 sub trigger 6 8 get_position 255 greater_than 7 return 8 9 sub wait_for_trigger_press 10 wait_for_trigger_press_100ms 11 12 sub wait_for_trigger_press_100ms 13 get_ms 14 begin 15 trigger 16 if 17 get_ms over minus 100 greater_than 18 if drop return endif 19 else 20 drop get_ms 21 endif 22 repeat 23 24 25 main_loop:


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

sub trigger
  8 get_position 255 greater_than

sub wait_for_trigger_press_100ms
      get_ms over minus 100 greater_than
      if drop return endif
      drop get_ms


I also simplified your original code by removing the subroutine whose sole purpose is to call another subroutine.

- Amanda

Thank you very much Amanda!