diff --git a/NexSerialConfig.h b/NexSerialConfig.h index e68ac37..32cc066 100644 --- a/NexSerialConfig.h +++ b/NexSerialConfig.h @@ -22,6 +22,9 @@ /* define serial for debug */ #define dbSerial Serial +/* define serial for communicate with Nextion screen */ +#define nexSerial Serial2 + #ifdef DEBUG_SERIAL_ENABLE #define dbSerialPrint(a) dbSerial.print(a) #define dbSerialPrintln(a) dbSerial.println(a) @@ -32,7 +35,4 @@ #define dbSerialBegin(a) #endif -/* define serial for communicate with Nextion screen */ -#define nexSerial Serial2 - #endif diff --git a/NexTouch.cpp b/NexTouch.cpp index 63ec52e..47feef5 100644 --- a/NexTouch.cpp +++ b/NexTouch.cpp @@ -403,6 +403,7 @@ bool NexTouch::getBrightness(uint32_t *brightness) */ bool nexInit(void) { + dbSerialBegin(9600); nexSerial.begin(9600); NexTouch::sendCommand(""); NexTouch::sendCommand("page 0"); diff --git a/examples/CompButton/CompButton.ino b/examples/CompButton/CompButton.ino index 96883b9..40d734e 100644 --- a/examples/CompButton/CompButton.ino +++ b/examples/CompButton/CompButton.ino @@ -45,8 +45,7 @@ void b0PopCallback(void *ptr) } void setup(void) -{ - dbSerialBegin(9600); +{ nexInit(); b0.attachPop(b0PopCallback, &b0); dbSerialPrintln("setup done"); diff --git a/examples/CompCrop/CompCrop.ino b/examples/CompCrop/CompCrop.ino index 84adf39..58b5182 100644 --- a/examples/CompCrop/CompCrop.ino +++ b/examples/CompCrop/CompCrop.ino @@ -39,7 +39,6 @@ void q0PopCallback(void *ptr) void setup(void) { - dbSerialBegin(9600); nexInit(); q0.attachPop(q0PopCallback); dbSerialPrintln("setup done"); diff --git a/examples/CompHotspot/CompHotspot.ino b/examples/CompHotspot/CompHotspot.ino index 73c0160..436cca3 100644 --- a/examples/CompHotspot/CompHotspot.ino +++ b/examples/CompHotspot/CompHotspot.ino @@ -55,7 +55,6 @@ void hot1PopCallback(void *ptr) void setup(void) { - dbSerialBegin(9600); nexInit(); hot0.attachPush(hot0PushCallback, &hot0); hot0.attachPop(hot0PopCallback, &hot0); diff --git a/examples/CompPage/CompPage.ino b/examples/CompPage/CompPage.ino index 60a8ff8..0b3d05d 100644 --- a/examples/CompPage/CompPage.ino +++ b/examples/CompPage/CompPage.ino @@ -55,7 +55,6 @@ void page3PopCallback(void *ptr) void setup(void) { - dbSerialBegin(9600); nexInit(); dbSerialPrintln("setup begin"); diff --git a/examples/CompPicture/CompPicture.ino b/examples/CompPicture/CompPicture.ino index 7c22ef2..2e8918b 100644 --- a/examples/CompPicture/CompPicture.ino +++ b/examples/CompPicture/CompPicture.ino @@ -45,7 +45,6 @@ void p0PopCallback(void *ptr) void setup(void) { - dbSerialBegin(9600); nexInit(); p0.attachPop(p0PopCallback); dbSerialPrintln("setup done"); diff --git a/examples/CompPointer/CompPointer.ino b/examples/CompPointer/CompPointer.ino index e874fc3..e68e827 100644 --- a/examples/CompPointer/CompPointer.ino +++ b/examples/CompPointer/CompPointer.ino @@ -61,7 +61,6 @@ void buttonDownPopCallback(void *ptr) void setup(void) { - dbSerialBegin(9600); nexInit(); btn_up.attachPop(buttonUpPopCallback); btn_down.attachPop(buttonDownPopCallback); diff --git a/examples/CompProgressBar/CompProgressBar.ino b/examples/CompProgressBar/CompProgressBar.ino index c31af63..a7bd22c 100644 --- a/examples/CompProgressBar/CompProgressBar.ino +++ b/examples/CompProgressBar/CompProgressBar.ino @@ -61,9 +61,6 @@ void buttonDownPopCallback(void *ptr) void setup(void) { - uint32_t brightness = 0; - - dbSerialBegin(9600); nexInit(); btn_up.attachPop(buttonUpPopCallback); btn_down.attachPop(buttonDownPopCallback); diff --git a/examples/CompText/CompText.ino b/examples/CompText/CompText.ino index a298022..24e2429 100644 --- a/examples/CompText/CompText.ino +++ b/examples/CompText/CompText.ino @@ -80,7 +80,6 @@ void b1PopCallback(void *ptr) void setup(void) { - dbSerialBegin(9600); nexInit(); dbSerialPrintln("setup done"); }