Hello,
I want to increase a number field using a button. If button is pressed and hold, number field should be increase rapidly. This is a basic function of lot of HMIs. But, I couldn't do it in Nextion.
I read below topic and there is no any function in Nextion for get button press and hold time.
https://forum.arduino.cc/index.php?topic=608169.0
If anyone can help me, greatly appreciated.
Thank in advanced
The Nextion buttons only support events for pressing and events for releasing a button, not events for keeping your finger on a button.
You will need:
- A timer that counts milliseconds and increments the number when it expires, then starts itself again if the button is still pressed. There are timers available in the IDE.
- Something in touch press event that triggers the timer.
- Something in touch release event that stops the timer.
I've never done this, it would be helpful to me and others if you solve this if you would post the solution.
Hello
There is a useful example that can help you with your question on the tutorial I have recently made
You can find this at:
https://forum.arduino.cc/index.php?topic=634237.msg4294068#msg4294068
Here is a sample of the tutorial:
@< tm0 > is a timer with a setted time delay 300ms. It is enabled through < b1> press event and disabled by < b1 > release event. Every 300ms, it triggers the < click > command.
In the timer's event, we write: click b1,0 click b1,1
<< click , >
is component's .id or .objname attribute of component to refresh
1 to trigger Press Event, 0 to trigger Release Event.
The result of this is that when we hold down the < b1 > button, the text will scroll down continusly.
The same thing happens with < b0 >, only the text scrolls up continusly by < tm1 >.
I hope this helps you and for further questions you may have, don't hesitate to ask.