Hold button for set time to enter a routine

For general Flowcode discussion that does not belong in the other sections.
Post Reply
Maverick
Posts: 68
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 10:58 am
Has thanked: 27 times
Been thanked: 8 times

Hold button for set time to enter a routine

Post by Maverick »

Hi
I'm trying to detect that if a button is pressed for >=to 5s a calibration routine will run and then goto normal mode. if the button is released before the 5s then normal mode is run. due to other hardware the push button needs to be on port E1. Attached is a test fcfx attempt which doesn't work. Pleased advise if there is a solution either with the attached fcfx or another
Attachments
CALIBRATION_ENTRY_TEST_1.fcfx
(21.36 KiB) Downloaded 46 times

medelec35
Matrix Staff
Posts: 1457
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 513 times
Been thanked: 473 times

Re: Hold button for set time to enter a routine

Post by medelec35 »

Hello
The reason you are having an issue is that if using a switch set to Active low and using the ReadState()
Then if the switch is pressed the ReadState() value will be true (1).
This will be the same as the pin voltage at 0v on your hardware.
If you want the simulation value to be false (0) then instead of using ReadState() you will need to use an input command icon.
I have attached an example using ReadState() macro function that should work with the simulator and on hardware.
Attachments
CALIBRATION_ENTRY_TEST_1.fcfx
(28.64 KiB) Downloaded 49 times
Martin

Maverick
Posts: 68
Joined: Wed Dec 02, 2020 10:58 am
Has thanked: 27 times
Been thanked: 8 times

Re: Hold button for set time to enter a routine

Post by Maverick »

Hi Martin

Thanks for that prompt and excellent solution

Post Reply