mirror of
https://github.com/itead/ITEADLIB_Arduino_Nextion.git
synced 2026-03-03 08:44:00 +01:00
Remove while(true) in nexLoop API. Remove example's dbSerial info.
Signed-off-by: shennongmin <wupangfee@gmail.com>
This commit is contained in:
@@ -16,10 +16,10 @@
|
||||
#ifndef __NexSerialConfig_H__
|
||||
#define __NexSerialConfig_H__
|
||||
|
||||
/*enable debug serial*/
|
||||
/* enable debug serial */
|
||||
#define DEBUG_SERIAL_ENABLE
|
||||
|
||||
/*define serial for debug*/
|
||||
/* define serial for debug */
|
||||
#define dbSerial Serial
|
||||
|
||||
#ifdef DEBUG_SERIAL_ENABLE
|
||||
@@ -32,7 +32,7 @@
|
||||
#define dbSerialBegin(a)
|
||||
#endif
|
||||
|
||||
/*define serial for communicate with Nextion screen*/
|
||||
/* define serial for communicate with Nextion screen */
|
||||
#define nexSerial Serial2
|
||||
|
||||
#endif
|
||||
|
||||
48
NexTouch.cpp
48
NexTouch.cpp
@@ -27,34 +27,30 @@ uint8_t NexTouch::mainEventLoop(NexTouch **list)
|
||||
{
|
||||
uint16_t i;
|
||||
uint8_t c;
|
||||
//while (true)
|
||||
{
|
||||
while (nexSerial.available() > 0)
|
||||
{
|
||||
delay(10);
|
||||
c = nexSerial.read();
|
||||
|
||||
if (NEX_RET_EVENT_TOUCH_HEAD == c)
|
||||
while (nexSerial.available() > 0)
|
||||
{
|
||||
delay(10);
|
||||
c = nexSerial.read();
|
||||
|
||||
if (NEX_RET_EVENT_TOUCH_HEAD == c)
|
||||
{
|
||||
if (nexSerial.available() >= 6)
|
||||
{
|
||||
if (nexSerial.available() >= 6)
|
||||
__buffer[0] = c;
|
||||
for (i = 1; i < 7; i++)
|
||||
{
|
||||
//memset(__buffer, 0, sizeof(__buffer));
|
||||
__buffer[0] = c;
|
||||
for (i = 1; i < 7; i++)
|
||||
{
|
||||
__buffer[i] = nexSerial.read();
|
||||
}
|
||||
__buffer[i] = 0x00;
|
||||
|
||||
if (0xFF == __buffer[4] && 0xFF == __buffer[5] && 0xFF == __buffer[6])
|
||||
{
|
||||
iterate(list, (NexPid)__buffer[1], (NexCid)__buffer[2], (NexEventType)__buffer[3]);
|
||||
}
|
||||
|
||||
__buffer[i] = nexSerial.read();
|
||||
}
|
||||
__buffer[i] = 0x00;
|
||||
|
||||
if (0xFF == __buffer[4] && 0xFF == __buffer[5] && 0xFF == __buffer[6])
|
||||
{
|
||||
iterate(list, (NexPid)__buffer[1], (NexCid)__buffer[2], (NexEventType)__buffer[3]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -417,13 +413,13 @@ bool nexInit(void)
|
||||
/**
|
||||
* Call mainEventLoop,watting for Nextion's touch event.
|
||||
*
|
||||
* @param nexListenList - index to Nextion Components list.
|
||||
* @param nex_listen_list - index to Nextion Components list.
|
||||
*
|
||||
* @retval false - failed.
|
||||
*/
|
||||
bool nexLoop(NexTouch **nexListenList)
|
||||
bool nexLoop(NexTouch **nex_listen_list)
|
||||
{
|
||||
NexTouch::mainEventLoop(nexListenList);
|
||||
NexTouch::mainEventLoop(nex_listen_list);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ private: /* data */
|
||||
};
|
||||
|
||||
bool nexInit(void);
|
||||
bool nexLoop(NexTouch **nexListenList);
|
||||
bool nexLoop(NexTouch **nex_listen_list);
|
||||
bool sendCurrentPageId(uint8_t* pageId);
|
||||
bool touchCalibration(void);
|
||||
bool disableTouchFocus(void);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
NexButton b0 = NexButton(0, 1, "b0");
|
||||
char buffer[100] = {0};
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
NexTouch *nex_listen_list[] =
|
||||
{
|
||||
&b0,
|
||||
NULL
|
||||
@@ -54,6 +54,5 @@ void setup(void)
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerialPrintln("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
nexLoop(nex_listen_list);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
NexHotspot hot0 = NexHotspot(0, 1, "hot0");
|
||||
NexHotspot hot1 = NexHotspot(0, 2, "hot1");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
NexTouch *nex_listen_list[] =
|
||||
{
|
||||
&hot0,
|
||||
&hot1,
|
||||
@@ -66,6 +66,5 @@ void setup(void)
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerialPrintln("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
nexLoop(nex_listen_list);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ NexPage page1 = NexPage(1, 0, "page1");
|
||||
NexPage page2 = NexPage(2, 0, "page2");
|
||||
NexPage page3 = NexPage(3, 0, "page3");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
NexTouch *nex_listen_list[] =
|
||||
{
|
||||
&page0,
|
||||
&page1,
|
||||
@@ -69,6 +69,5 @@ void setup(void)
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerialPrintln("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
nexLoop(nex_listen_list);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
NexPicture p0 = NexPicture(0, 1, "p0");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
NexTouch *nex_listen_list[] =
|
||||
{
|
||||
&p0,
|
||||
NULL
|
||||
@@ -53,7 +53,6 @@ void setup(void)
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerialPrintln("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
nexLoop(nex_listen_list);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ NexPointer pointer = NexPointer(0, 1, "pointer");
|
||||
NexButton btn_up = NexButton(0, 2, "btn_up");
|
||||
NexButton btn_down = NexButton(0, 3, "btn_down");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
NexTouch *nex_listen_list[] =
|
||||
{
|
||||
&btn_up,
|
||||
&btn_down,
|
||||
@@ -70,7 +70,6 @@ void setup(void)
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerialPrintln("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
nexLoop(nex_listen_list);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ NexProgressBar j0 = NexProgressBar(0, 3, "j0");
|
||||
NexButton btn_up = NexButton(0, 1, "btn_up");
|
||||
NexButton btn_down = NexButton(0, 2, "btn_down");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
NexTouch *nex_listen_list[] =
|
||||
{
|
||||
&btn_up,
|
||||
&btn_down,
|
||||
@@ -72,7 +72,6 @@ void setup(void)
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerialPrintln("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
nexLoop(nex_listen_list);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
NexSlice q0 = NexSlice(0, 1, "q0");
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
NexTouch *nex_listen_list[] =
|
||||
{
|
||||
&q0,
|
||||
NULL
|
||||
@@ -47,7 +47,6 @@ void setup(void)
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerialPrintln("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
nexLoop(nex_listen_list);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ NexButton b1 = NexButton(0, 3, "b1", b1PopCallback);
|
||||
|
||||
char buffer[100] = {0};
|
||||
|
||||
NexTouch *nexListenList[] =
|
||||
NexTouch *nex_listen_list[] =
|
||||
{
|
||||
&t0,
|
||||
&b0,
|
||||
@@ -87,7 +87,6 @@ void setup(void)
|
||||
|
||||
void loop(void)
|
||||
{
|
||||
dbSerialPrintln("nexLoop");
|
||||
nexLoop(nexListenList);
|
||||
nexLoop(nex_listen_list);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user