A simple library for Nextion display that uses only four functions. You can easily benefit from Nextion's wide range of features and advantages in just a few easy steps. The library uses a custom protocol that can prove to be a powerful tool for advanced users as it can be easily modified to meet one’s needs.
I use EasyNextionLibrary for connect ESP32 with Nextion display. It crashes when I press touch buttons. One or two press is ok, but many presses or quick press again crash. I call myNex.NextionListen(); every 50ms.
Thanks, Jan.
Debug trace:
Guru Meditation Error: Core 1 panic'ed (InstrFetchProhibited). Exception was unhandled.
xTaskCreatePinnedToCore(
nextionUpdate, // Function that should be called
"nextionUpdate", // Name of the task (for debugging)
8000, // Stack size (bytes)
NULL, // Parameter to pass
8, // Task priority
NULL, // Task handle
app_cpu // core
);
}`
and here is trigger for buttons:
`void trigger9()
{
/* Create a button on Nextion
* Write in the Touch Release Event of the button
* this command: printh 23 02 54 09
* Every time the button is pressed, the trigger0() function will run
* and the code inside will be executed once
*/
nexBlTimer = MAX_NEXTION_BACKLIGHT_TIMER;
nexChange = 11;
float tempTmp = thermostat_get_temperatureD() + 0.5;
thermostat_setD(tempTmp);
// myNex.writeStr("t16.txt", String(tempTmp) + String(" °C"));
// mySerialPrintLn(F("TD+"));
}
void trigger10()
{
/* Create a button on Nextion
* Write in the Touch Release Event of the button
* this command: printh 23 02 54 0A
* Every time the button is pressed, the trigger0() function will run
* and the code inside will be executed once
*/
nexBlTimer = MAX_NEXTION_BACKLIGHT_TIMER;
nexChange = 11;
float tempTmp = thermostat_get_temperatureD() - 0.5;
thermostat_setD(tempTmp);
// myNex.writeStr("t16.txt", String(tempTmp) + String(" °C"));
// mySerialPrintLn(F("TD-"));
}
void trigger11()
{
/* Create a button on Nextion
* Write in the Touch Release Event of the button
* this command: printh 23 02 54 0B
* Every time the button is pressed, the trigger0() function will run
* and the code inside will be executed once
*/
nexBlTimer = MAX_NEXTION_BACKLIGHT_TIMER;
nexChange = 11;
float tempTmp = thermostat_get_temperatureK() + 0.5;
thermostat_setK(tempTmp);
// myNex.writeStr("t18.txt", String(tempTmp) + String(" °C"));
// mySerialPrintLn(F("TK+"));
}
void trigger12()
{
/* Create a button on Nextion
* Write in the Touch Release Event of the button
* this command: printh 23 02 54 0C
* Every time the button is pressed, the trigger0() function will run
* and the code inside will be executed once
*/
nexBlTimer = MAX_NEXTION_BACKLIGHT_TIMER;
nexChange = 11;
float tempTmp = thermostat_get_temperatureK() - 0.5;
thermostat_setK(tempTmp);
// myNex.writeStr("t18.txt", String(tempTmp) + String(" °C"));
// mySerialPrintLn(F("TK-"));
Hello,
I use EasyNextionLibrary for connect ESP32 with Nextion display. It crashes when I press touch buttons. One or two press is ok, but many presses or quick press again crash. I call myNex.NextionListen(); every 50ms.
Thanks, Jan.
Debug trace:
Guru Meditation Error: Core 1 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 1 register dump: PC : 0x00000000 PS : 0x00060130 A0 : 0x800fd058 A1 : 0x3ffd7e30 A2 : 0x3ffc88d8 A3 : 0x0001303d A4 : 0x00013080 A5 : 0x00060123
A6 : 0x00060120 A7 : 0x00000001 A8 : 0x800fd07c A9 : 0x00000054 A10 : 0x00000001 A11 : 0x3ffd7e2f A12 : 0x00000001 A13 : 0x10624dd3
A14 : 0x00000001 A15 : 0x003fffff SAR : 0x0000000a EXCCAUSE: 0x00000014
EXCVADDR: 0x00000000 LBEG : 0x40090f84 LEND : 0x40090f8e LCOUNT : 0x00000000
Backtrace: 0xfffffffd:0x3ffd7e30 0x400fd055:0x3ffd7e50 0x400dd11d:0x3ffd7e70
0 0xfffffffd:0x3ffd7e30 in ?? ??:0
1 0x400fd055:0x3ffd7e50 in EasyNex::NextionListen() at lib/Easy Nextion Library/src/EasyNextionLibrary.cpp:340
2 0x400dd11d:0x3ffd7e70 in nextionUpdate(void*) at src/thread_nextionUpdate.cpp:348
ELF file SHA256: e10a9f359f05384c
E (6371) esp_core_dump_flash: Core dump flash config is corrupted! CRC=0x7bd5c66f instead of 0x0 Rebooting... ets Jun 8 2016 00:22:57
`void nextionUpdate(void* pvParameters) { for (;;) {
nexChange=0; myNex.NextionListen();
cntNextion++; if (cntNextion == 1) {
if (getNexBl()) { myNex.writeNum("dim", MAX_NEXTION_BACKLIGHT); } else { if (nexBlTimer > 0) { int dimmerShadow = map(nexBlTimer, 0, MAX_NEXTION_BACKLIGHT_TIMER, 0, MAX_NEXTION_BACKLIGHT); myNex.writeNum("dim", dimmerShadow); } else { myNex.writeNum("dim", 0); nexBlTimer = 0; } nexBlTimer--; } }
}
void nextion_begin(void) { myNex.begin(115200);
}`
and here is trigger for buttons:
`void trigger9() {
}
void trigger10() {
}
void trigger11() {
}
void trigger12() {
}`