Wait until function

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Has thanked: 49 times

Wait until function

Post by echase »

Is the there a ‘wait until’ function which stops the code till a defined event occurs?

e.g. for the macro

Line 1: Display a value on LCD
Do nothing and wait until any button is pressed
If any button not pressed for 5 seconds go to somewhere else/end macro.
Increment value by one if it is button A
Or decrement by 1 if button B.
Go to line 1

Only way I can think of implementing this is using a loop (instead of ‘wait until’) which runs continuously until a counter reaches a certain value. On each run through the loop the buttons are read and the value in/decremented according to any button pressed. Also a counter is incremented by one for each loop pass and is reset to zero for every button press.

If no button is pressed for 5 seconds the counter reaches the certain value so that the loop ends.

User avatar
Steve
Matrix Staff
Posts: 3433
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Post by Steve »

The switches component has macros "WaitUntilLow" and "WaitUntilHigh", but these do not have a timeout.

The way you have suggested - i.e. using a loop - is one way you can do it.

Post Reply