Nextion - short/long presses

Hi
Does anyone know how to detect short vs long press events on the Nextion displays?

What I'd like to do is to have a button over the whole area of the display, with a short press toggling a relay (for the room light) and a long press showing an information page that would revert after a couple of minutes.

Is it possible?

Hello Duncan_a,
Welcome to the forum.

Yes, it should be possible although I have never tried to do it. If you look in the Nextion editor at the attributes for each button there is a 'touch press event' and a 'touch release event'. If you put different code under each then you can identify when the button was pressed and when it was released, measure the time between them and do whatever you need. Can I suggest 2 things:

  • Don't bother with the Nextion libraries
  • Try my demonstration 'Using Nextion displays with Arduino' at the top of the 'Displays' forum.

Once you understand how my code deals with button presses it should be a simple matter to modify it to deal with a press followed by a release.

I don't mind offering help on what you try as long as what you try is based on my methods as per my demonstration. If you prefer to use the libraries then I can't help, sorry.