Double click query

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

Moderator: Benj

Post Reply
ChrisT66
Posts: 67
Joined: Mon Jul 13, 2020 3:00 pm
Contact:

Double click query

Post by ChrisT66 »

Hi, I am looking for a solution to the following problem: I want to query two states with one button. With a single click the first reaction occurs and with a double click the second one. The running program must not be blocked by the button query.
And the button is actually a switch that has any state at startup (0 or 1).

Does anyone have an idea?

Thanks a lot! Greeting Chris

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Double click query

Post by Benj »

Hi Chris,

I would use a timer interrupt and maybe an edge driven interrupt.

The edge driven interrupt would monitor the switch input and determine when the switch was pressed.

The timer interrupt would monitor the passing of time.

Assuming the interrupt fires on each switch state change, If the switch changes state once or twice within a certain amount of time then do task 1, if the switch changes state three or four times within the time period then do task 2, otherwise do no task. The time period should probably reset on the first state change to allow you proper time to do the double click.

Here's a simple example.
DoubleClick.fcfx
(12.86 KiB) Downloaded 134 times

ChrisT66
Posts: 67
Joined: Mon Jul 13, 2020 3:00 pm
Contact:

Re: Double click query

Post by ChrisT66 »

Hello, Ben,

thank you very much for the fast help!

Great that you have created an example for me.

Greetings Chris

ChrisT66
Posts: 67
Joined: Mon Jul 13, 2020 3:00 pm
Contact:

Re: Double click query

Post by ChrisT66 »

Hi Ben,

i have tested your code and it works great for switches as needed! Thanks.
Now I wanted to implement the whole thing for changing signal widths. i.e. as soon as the signal width changes once LED 1 goes on, if it changes twice in a short time (double click) LED 2 goes on.
I used the pulse width measurement you once wrote me. I have only one problem: the double click does not work at the beginning, it must have been LED1 on first for the double click to work. A double click to start also switches only LED1 on and not LED2.
I can't find the error, I have inserted the code here... Maybe you or someone can help. Thanks a lot!
Attachments
DoubleClick.fcfx
(12.86 KiB) Downloaded 122 times

ChrisT66
Posts: 67
Joined: Mon Jul 13, 2020 3:00 pm
Contact:

Re: Double click query

Post by ChrisT66 »

Problem solved! Due to too long timer intervals....

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Double click query

Post by Benj »

Excellent, thanks for letting us know and well done :D

Post Reply