Hello,
I need a long push on button function. Have you idea to do the long time push button ?
When I click on the button with long push, I want repeat the execution of the macro. I can't find parameter in the button to do it.
It's like you up the volume of your music player.
I use the same button in the "simple com sender" project. This "button" come from "Creation".
Thank you so much.
Long push on button
- Nico595
- Posts: 95
- http://meble-kuchenne.info.pl
- Joined: Tue Jul 04, 2023 4:17 pm
- Has thanked: 18 times
- Been thanked: 4 times
-
- Matrix Staff
- Posts: 1954
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 626 times
- Been thanked: 656 times
Re: Long push on button
What I do for long and short press detection is have a loop with a counter, timeout and a delay that continues all the time the button is pressed.
All the time the button is pressed the loop will continue until the button is released or the loop count is over a certain value i.e. for timeout.
Just after the loop if the loop count over a fixed value then its along press, otherwise it's a short press.
All the time the button is pressed the loop will continue until the button is released or the loop count is over a certain value i.e. for timeout.
Just after the loop if the loop count over a fixed value then its along press, otherwise it's a short press.
Martin
Re: Long push on button
Thank you Martin for your fast answer 
If I understand good, no parameter in the button exist to do it.
I use your method in my embedded project, it work fine with a keyboard interrupt.
With PC App the macro is firstly called by the button and it's very good. We don't need check the state of the button every time in the App.
But with a long push function we must check the state of the button to call the macro.
If the macro of the button is not called by the button, the macro process maybe disconnected by other process. It's again a problem with the priority level. When the macro is called by the button, the macro process is run in first time, probably with the high level priority.
Can you customise proprieties of this button to obtain the long push parameter with repeat the called macro ?
Like this we keep the high level priority of the process for the last pushed button.

If I understand good, no parameter in the button exist to do it.
I use your method in my embedded project, it work fine with a keyboard interrupt.
With PC App the macro is firstly called by the button and it's very good. We don't need check the state of the button every time in the App.
But with a long push function we must check the state of the button to call the macro.
If the macro of the button is not called by the button, the macro process maybe disconnected by other process. It's again a problem with the priority level. When the macro is called by the button, the macro process is run in first time, probably with the high level priority.
Can you customise proprieties of this button to obtain the long push parameter with repeat the called macro ?
Like this we keep the high level priority of the process for the last pushed button.
Re: Long push on button
I find a solution in mixing two macro with interrupt on the long push macro. Work fine some minutes and the Interrupt stop without reason.
I added a simple counter on the "Simple Com Sender". Push on "Interrupt" button, you can see the interrupt itself stopped around 1300, 2600 ...
Have you this problem ?
Thank you for your support.
I added a simple counter on the "Simple Com Sender". Push on "Interrupt" button, you can see the interrupt itself stopped around 1300, 2600 ...
Have you this problem ?
Thank you for your support.
-
- Valued Contributor
- Posts: 1512
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 138 times
- Been thanked: 725 times
Re: Long push on button
One thing to try:
Move NumericIndicator1:SetValue(compt_test1) to the loop in main. I'm not sure about app developer - but in general you need to keep interrupt handlers as short as possible (if another interrupt occurs before the handler is finished then the code will lock up...)
I cranked up the interrupt rate a bit and it runs for longer (counts to 6000 then resets) - and repeats... If it locks - and it seems to eventually then the code seems to be still running.. I added a simple 'flashing' indicator - and that flashes even after the counter stops being updated (so maybe a bug in the numeric indicator? - or the timer interrupt stops?)
Martin
Move NumericIndicator1:SetValue(compt_test1) to the loop in main. I'm not sure about app developer - but in general you need to keep interrupt handlers as short as possible (if another interrupt occurs before the handler is finished then the code will lock up...)
I cranked up the interrupt rate a bit and it runs for longer (counts to 6000 then resets) - and repeats... If it locks - and it seems to eventually then the code seems to be still running.. I added a simple 'flashing' indicator - and that flashes even after the counter stops being updated (so maybe a bug in the numeric indicator? - or the timer interrupt stops?)
Martin
- Attachments
-
- PC Dev Simple USB Sender.fcsx
- (40.09 KiB) Downloaded 28 times
Re: Long push on button
Your var ".i" is no incremented by the interrupt but by the main. I placed "i" var in the macro started by the interrupt.
Work if you don't push button but when you push a button like "Vol Up" the interrupt is stopped.
I think the delay is also a problem in the main.
Work if you don't push button but when you push a button like "Vol Up" the interrupt is stopped.
I think the delay is also a problem in the main.
Re: Long push on button
Hi Martin,
So, we can't use the Interrupt without your trigger ?
I use successfully the Interrupt in my embedded project, it work fine but because we can set the level priority of the Interrupt in the C code. Without Interrupt we can't design a a big project.
The problem about Interrupt in PC App that we have no priority level, the Interrupt are stopped by push on button or by the main.
I checked the updated project with "i" in counter macro, same problem. Without delay in the main, the Interrupt was not stopped by push on button but stopped in the time without reason.
So, we can't use the Interrupt without your trigger ?
I use successfully the Interrupt in my embedded project, it work fine but because we can set the level priority of the Interrupt in the C code. Without Interrupt we can't design a a big project.
The problem about Interrupt in PC App that we have no priority level, the Interrupt are stopped by push on button or by the main.
I checked the updated project with "i" in counter macro, same problem. Without delay in the main, the Interrupt was not stopped by push on button but stopped in the time without reason.