Start a new topic

Changing button picture

 I want to change brightness of LED with one button in three stages. First press will Turn on LED on 100%, second on 50% and third on 10%. I already made five buttons (off, pressed, 100%, 50% and 10%) and I want to change picture of the button according to set brightness. So is there any option to change it? I know it's possible to change picture when used as component picture but I don't know how to change it  for buttons.


I also think itead should give more publication about components!


Maybe this thread will help you:

http://support.iteadstudio.com/support/discussions/topics/1000062462


You can try something like this:

b1.pic=2

ref b1 


It is possible to use commands to change attributes written with green color in the right pane:


http://wiki.iteadstudio.com/Nextion_Editor_Quick_Start_Guide#Components




I made an off/on/auto button and was able to get the image to programmatically switch as the button was pressed just as Raphael has stated.
I tried and thanks it works. I didn't know I can change green attributes via serial.

And now I have another question. How can I send value of slider to serial? I want to send just character B (print B) and value of slider (one byte) and CRLF (printh 0d 0a). Is it possible?

 

I want to send just character B (print B) and value of slider (one byte) and CRLF (printh 0d 0a). Is it possible?
See this thread:
http://support.iteadstudio.com/support/discussions/topics/1000063242

 I see now it's possible to get value but not directly with (get h0.val).


It's more complicated but it's possible to do. I can use get h0.val and printh 0d 0a and parse out the value ...

I am trying to make a on  /off button , if "on" i have one pic in button, if "off" i have the other pic1 in button.

Can some one help with code for arduino and maybe a printscreen of the settings from the button and his actions.





png
(2.4 KB)

I am trying to make a on  /off button , if "on" i have one pic in button, if "off" i have the other pic1 in button.

Maybe this thread will help you:

http://support.iteadstudio.com/support/discussions/topics/1000062462


Raphael,


I have used this code


  if (B01State==true)

    {

      B01State = false;

      b0.setPic(4);

    }

    else

    {

      B01State = true;

      b0.setPic(5);

     }



b0 is the button ID

b0.setPic(4);


Is the function "setPic" defined by yourself or in a library?

I have no setpic and use the library fro Matt http://support.iteadstudio.com/support/discussions/topics/1000062462



Where put i b0.setPic(4); in the code

I don't know if I misunderstand something, but b0.setPic(4); is already in your code :-)

 

  if (B01State==true)
    {
      B01State = false;
      b0.setPic(4);  // <<<<<<<<<<<<<<<<<<<<<<< HERE
    }
    else
    {
      B01State = true;
      b0.setPic(5);
     }

 


By my self in code 

And in button library Nexbutton.h


 /** Change Picture on Button */

 bool getPic(uint32_t *number);

    bool setPic(uint32_t number);

};

Login or Signup to post a comment