Hi guys,
Just a mental block: I made a circuit that when i press a button on page0, it switch an IO port to LOW:
...
//=============CONFIGURAÇÕES============
void b0PopCallback(void *ptr)
{
digitalWrite(22, LOW);
}
void setup ()
{
nexInit();
Serial2.begin(9600);
Wire.begin();
b0.attachPop(b0PopCallback, &b0);
page0.attachPush(page0PushCallback);
page1.attachPush(page1PushCallback);
page2.attachPush(page2PushCallback);
page3.attachPush(page3PushCallback);
page4.attachPush(page4PushCallback);
page5.attachPush(page5PushCallback);
page6.attachPush(page6PushCallback);
pinMode(22, OUTPUT);
digitalWrite(22, HIGH);
}
//======================================
//=============PROGRAMA PRINCIPAL=======
void loop()
{
nexLoop(nex_listen_list);
}
//======================================
...
So far, so good. But when i put more functions on loop, my button b0 doesn't respond on time. I have to push several times so it can sync and send the callback function.
...
//=============PROGRAMA PRINCIPAL=======
void loop()
{
digitalClockDisplay();
if(CurrentPage == 6)
{
temp_umid();
}
nexLoop(nex_listen_list);
}
//======================================
...
I have tried a lot of solutions that i found here:
- increase baud rate;
- call functions only in the current page;
- Put a delay on loop;
- Put a timer before calling the function:
...
if(isPage0)
{
if(millis() - previousMillis >= maxTime)
{
previousMillis = millis();
updateDHTInfo(); //pega os valores do DHT22 e então manda para o NEXTION
}
}
...
But nothing works.
So please, if anyone know what to do or a link with some other solution, i'll be very grateful.
Regards,
Jimmy