Unofficial Nextion/TJC User Forum

Three state button

Hello,

I want to create a three state button: As the name suggests the button shall have three states. Lets call them green, orange and red. The colour and appearence shall be controlled from the microcontroller.

For this purpose I have generated three images of the button in the mentioned colors. These images are made as background images so that the “crop image” function can be applied.

My Problem is, that I cannot assign three images to the Button and switch them from the microcontroller to set the correct colour.

Is there a possibility to increase the number of attributes to a button?

Is there a better solution?

Best regards

Alexander

No need to use a button. Use a simple picture component and assign a .pic number from your picture resources depending on the state. This allows not only three states, but 4, 5, 6…

But there is no action at the Microcontroller for an image if I click on it …

There is no convenient “automatic” action. But you can write your custom routine, i.e. using the printh function, in the touch and release events of the picture component to fully emulate the “send ID” behavior and even more.


This forum is in no way affiliated with NEXTION®, ITEAD STUDIO®, TJC®, or anyone else really. All product names, logos, and brands are property of their respective owners. All company, product, and service names used in this website are for identification purposes only. Use of these names, logos, and brands does not imply endorsement from the respective rights holder(s).