Start a new topic
Not Taken

Button press repeat events

It would be nice to get a button press option where it will repeat after a delay so you can hold a button and have the value increment without releasing / touching again.


3 people like this idea

Dual state button + Timer can solve the issue.

Hello,

Might send an example of how to read the value of the Dual button from an Arduino.

thank you,


1 person likes this
Hi,
This might be a little late but here is my approach:

I used a normal button and created two timer object. First timer is to sending the message repetadly. Second timer is to determine if the button held enough.
Button is b0
Timer for the repeated message is tm0
Timer for hold recognition is tm1

in tm0 Timer Event write the message you want to pass. For example let it be "123"
get "123"

 make sure en 0 and tim value is fairly small (like 100) in the properties section. time value will determine how fast it will repeat the action. If it is 100, it will repeat the message in every 100ms as long as the button pressed.


Select tm1. User Code is:

tm0.en=1

 Again make sure en = 0 in the properties section. For the tim value enter a number a little bit larger this time. I think 1000 is good. If it is 1000, if the button is held for 1 second, it trigger the first timer which will starts to repeat the message.


Select b0. Enter the following code to the Touch Press Event

tm1.en=1

and to the Touch Release Event enter

tm1.en=0
tm0.en=0
get "123"

 This way, when the button is pressed, it will trigger tm1 and tm1 will trigger tm0 if the button pressed long enough. If the button is released it will disable both timers. And submit the message one more time.


But there is a slight problem with this approach. Somehow counting down for tm1 is not working well every time. It works correct for the first time, but after a while it sometimes takes more less time to trigger tm0 then it should be. I guess even though you disable the timer, internally it continues to counting (I am not sure) There is another slight issue. If for example you want to hold and single press command to be different commands it wont work well cause right now button sends the message in the touch release event regardless of it has been hold or not.


To fix these I added a variable (va0) and used tm1 to modify this value. I changed the time value to 50ms which is the minimum limit and added 50ms to the va0 value until it reaches 500. This is like a simple for loop which iterates 10 times. Afterwards I reset the va0 value in the touch press and touch release events of the button so next time it starts from 0 again.


I also wrapped the message in the touch release event with an if statement to make sure that no command will pass is the tm0 was active during that time. So if the button was in the hold state, it wont pass the push button command anymore.


I attached the modified file.


I suspect there may be simpler ways to do that though.



 

HMI
(7.23 KB)

1 person likes this

I trying to make rewind numbers using a timer, but only 4 timer can be used here. How to use the buttons b4 and b5?

HMI
(16.6 KB)

I am now reviewing all of the Feature Requests, this will take some time, patience please.

This can be implemented in code.  Perhaps include in tutorials

This post has been review.

In case if anyone is still looking for a solution. 


HMI

yep, but I am mostly certain that either

  something was found or it was abandoned considering the ask was Nov 9, 2015, No?

Login or Signup to post a comment