Hello, new challenge awaits me...
I got this code from the internet, it's for Arduino and Nextion.
On Arduino it works well. On ESP32 no. The buttons seem not to work. The LEDs light up, as a setup. But nothing happens. Any idea?
If I send data from a BME280 + ESP32 to the Nextio as txt no problem, reads and updates the data on the display, but simple buttons or dual state nothing to do.
I also modified the files Nextion.h,Hardaware.h and put txt extension to the files NextionUplod.h and NextionUpload.ccp as described by the site Nextion.ca,tutorial ESP32.
I tried them all.
Thanks
chipxx
ps allego codice
#include "Nextion.h"
const int led_01 = 12;
const int led_02 = 14;
const int led_03 = 27;
NexButton b0 = NexButton(0, 4, "b0");
NexDSButton bt0 = NexDSButton(0, 1, "bt0");
NexDSButton bt1 = NexDSButton(0, 2, "bt1");
NexDSButton bt2 = NexDSButton(0, 3, "bt2");
NexTouch *nex_listen_list[] =
{
&b0,
&bt0,&bt1,&bt2,
NULL
};
void b0_Apagar(void *ptr);
void Funcion_bt0(void *ptr);
void Funcion_bt1(void *ptr);
void Funcion_bt2(void *ptr);
void setup(void)
{
nexInit();//Inicio la comunicacion entre el Arduino y la Pantalla
pinMode(led_01, OUTPUT);
pinMode(led_02, OUTPUT);
pinMode(led_03, OUTPUT);
digitalWrite(led_01, HIGH);
digitalWrite(led_02, HIGH);
digitalWrite(led_03, HIGH);
//Registro el llamado a la funcion del evento de Dual State Button
b0.attachPop(b0_Apagar);
bt0.attachPop(Funcion_bt0, &bt0);
bt1.attachPop(Funcion_bt1, &bt1);
bt2.attachPop(Funcion_bt2, &bt2);
}
void loop(void)
{
nexLoop(nex_listen_list);
}
void b0_Apagar(void *ptr)
{
digitalWrite(led_01, HIGH);
digitalWrite(led_02, HIGH);
digitalWrite(led_03, HIGH);
}
void Funcion_bt0(void *ptr){
uint32_t Estado_dual;
bt0.getValue(&Estado_dual);
if(Estado_dual){digitalWrite(led_01, LOW);}
else{digitalWrite(led_01, HIGH); }
}
void Funcion_bt1(void *ptr){
uint32_t Estado_dual;
bt1.getValue(&Estado_dual);
if(Estado_dual){digitalWrite(led_02, LOW);}
else{digitalWrite(led_02, HIGH); }
}
void Funcion_bt2(void *ptr){
uint32_t Estado_dual;
bt2.getValue(&Estado_dual);
if(Estado_dual){digitalWrite(led_03, LOW);}
else{digitalWrite(led_03, HIGH); }
}