Start a new topic

How to control Dual-State button graphics display (picture select)?

I want to have a dual-state button with two graphics images:



I only want to change to the second state once the arduino has completed execution of the command.


How do I:


1. Prevent the Nextion display from changing to the second picture as soon as I release the button?


2. Allow the Arduino to tell the button to change to the second picture?



BTW... NICE Button Generators:

https://www.imagefu.com/create/button

http://dabuttonfactory.com/


Thank You



1 person likes this idea

WOW... bug in the forum Software.  I posted TWO images.  Only 1 showed up.
Try again:


And


Those are the two pics (graphics images)
.

 


1 person likes this

Hi Andrew,

you have this example what ??

youtube[DOT]com/watch?v=LJ9fauuAhaA

HMI

1 person likes this
OK.. Great... That answered it for the most part.

bt0.val=0
bt1.val=0
bt2.val=0
bt3.val=0
bt4.val=0
bt5.val=0
bt7.val=0

So I can even make the button action clear itself, and then wait for the arduino to come back with btX.val=1 to confirm execution of the command.

Thanks



 

The solution above will work quite well, but you can also manipulate the picture attributes of a button. In your case, I might even suggest using a regular button instead of a 2-state button. You could do the following.

Then, when your Arduino is done processing, have it change the image:

 

b0.pic=1
ref b0

 

 With your particular example, both methods will accomplish the same thing. So it probably doesn't matter, but I wanted to offer another approach.


I might suggest, however, that if you use a regular button, you can set a third image in pic2 (it only appears while the button is being pressed) so that the user get's some visual feedback of the button press while they wait for the Arduino to execute the request and change the button.


In my application, I have added a number of pictures to my project that I assign to buttons programmatically. In my case I have three images per button:


  • Off State
  • Pressed State (which gets changed on button press)
  • On State (which gets changed on confirmation from the Arduino)


Also, you can generate generic button images and overlay text onto a blank button.

 

I know this is and old thread. But is the code available. I have and issue in my code when I use the setText("ON") or off command but this is causing the the code to stall or slow. Maybe this could kill two birds, one not needing the extra text box and two improving the code My code needs to report back when the digital output pin state changes then reports back the output is on or off. I would rather change the button colour to green or red once the digital output changes not the button is pressed as some codes like in the YouTube are not a direct on off from the button. Thanks Ben.
Login or Signup to post a comment