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?
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…
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.
Sounds very interesting and it would solve my needs.
Please, could you be a little more precise.
Especially, how can I assign a pic number depending on the state?
I have 3 pics completetly overlapped and I would need allways the right one (depending on the state) on top.
You need only one single pic component. Let’s assume that it’s called p8. Let’s further assume, you have imported the 3 pictures which you want to display in the picture resource pane with the ids 40, 41, 42.
Then in event code:
if(state.val<1)
{
p8.picc=40
}
else if(state.val==1)
{
p8.picc=41
}
else if(state.val>1)
{
p8.picc=42
}
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).