Support the Dual State Button widget
DanNixon opened this issue · 7 comments
A new widget in v0.29 of the Nextion editor and firmware.
This supports touch events, colours and holds a numerical value.
Functionally this is just a check box styled to look like a button.
I'm having trouble getting this to work. I'm trying to read the value of the button but I am getting no feedback?
Have you tried the examples that come with the library?
i was writing to a text value in the loop without a delay. I managed to get it to work. Thanks
is there a way to limit read write correctly. I have some issues where buttons do not communicate with the arduino/photon correctly. I'm looking into using millis() to limit the update rate.
Your logic needs to handle communication at a sensible rate.
millis()
is a good way to do this.
Note that the rate limiting need only be for outbound communication, you can poll as much as you like as this is just checking the length of the serial buffer.
I'm pushing string variables to text components on the nextion device. A time, day, weekday, and month variable.
I am yet to test this latest version, but it looks like so:
I made a function called setText();
it is called in the loop();
void setText(){
unsigned long lastUpdate = 0;
unsigned long displayUpdate = 1000;
if ((millis() - lastUpdate) > displayUpdate)
{
cpuProgressBar.setValue(cpu);
// itoa(timer,values,10);
times= (String)Time.hour()+":"+ Time.minute();
day = (String)Time.day() +"";
timeText.setText(times);
dayText.setText(day);
weekdayText.setText(weekday[Time.weekday() -1]);
monthText.setText(months[Time.month()-1]);
tempText.setText((String)temperature +"");
lastUpdate = millis();
}
}
Lets hope this works.
You need to either move lastUpdate
to global scope or make it static
as it is the if condition will always be true after 1000ms after startup.