Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Realtime Swipe and Press Gestures and Dual-state buttons #1

Open
marcelerkel opened this issue Jul 31, 2022 · 1 comment
Open

Realtime Swipe and Press Gestures and Dual-state buttons #1

marcelerkel opened this issue Jul 31, 2022 · 1 comment

Comments

@marcelerkel
Copy link

Great work on the gesture detection!

When using dual-state buttons, the Nextion firmware immediately changes the state of the button on touch. So if you start a gesture on a dual-state button then the button has an incorrect state after the gesture is detected. I fixed this by adding the following code to invert the state of the button again when a gesture is detected:

    if(b[tc0.val].type==53) // Swipe triggered, restore dual-state button state
    {
      b[tc0.val].val=b[tc0.val].val^1
    }

These few lines of code are added to the Timer Event code in the following location:

  //
  // Movement > 100px => SWIPE
  if(dsq>10000)
  {
    if(b[tc0.val].type==53) // Swipe triggered, restore dual state button state
    {
      b[tc0.val].val=b[tc0.val].val^1
    }
    if(dx>100)
    {
      //>>
      gest_type=1 // right
      //page 0  // <- CUSTOM*** live action here
      //      t1.txt=">>" // ***DEGBUG/DEMO
    }else if(dx<-100)

Normally I would have created a PR, but unfortunately HMI files are binary files. Instead of updating the Tips_and_Tricks.HMI file I thought it would be better to just create an issue with the solution.

@krizkontrolz
Copy link
Owner

Thanks for the tip.
I'll test this out and look at adding it when I next get a chance to update the project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants