mirror of
https://github.com/itead/ITEADLIB_Arduino_Nextion.git
synced 2026-03-24 10:56:54 +01:00
@@ -14,12 +14,6 @@
|
||||
*/
|
||||
#include "NexHardware.h"
|
||||
|
||||
typedef enum {
|
||||
NEX_EVENT_POP = 0x00,
|
||||
NEX_EVENT_PUSH = 0x01,
|
||||
NEX_EVENT_NULL
|
||||
} NexEventType;
|
||||
|
||||
/*The first byte of Nextoin's return value*/
|
||||
#define NEX_RET_CMD_FINISHED (0x01)
|
||||
#define NEX_RET_EVENT_LAUNCHED (0x88)
|
||||
@@ -224,34 +218,6 @@ bool recvRetCommandFinished(uint32_t timeout)
|
||||
}
|
||||
|
||||
|
||||
static void iterate(NexTouch **list, NexPid pid, NexCid cid, NexEventType event)
|
||||
{
|
||||
NexTouch *e = NULL;
|
||||
uint16_t i = 0;
|
||||
|
||||
if (NULL == list)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(i = 0; (e = list[i]) != NULL; i++)
|
||||
{
|
||||
if (e->getPid() == pid && e->getCid() == cid)
|
||||
{
|
||||
e->print();
|
||||
if (NEX_EVENT_PUSH == event)
|
||||
{
|
||||
e->push();
|
||||
}
|
||||
else if (NEX_EVENT_POP == event)
|
||||
{
|
||||
e->pop();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Watting for Nextion's touch event.
|
||||
@@ -284,7 +250,7 @@ static void mainEventLoop(NexTouch **list)
|
||||
|
||||
if (0xFF == __buffer[4] && 0xFF == __buffer[5] && 0xFF == __buffer[6])
|
||||
{
|
||||
iterate(list, (NexPid)__buffer[1], (NexCid)__buffer[2], (NexEventType)__buffer[3]);
|
||||
NexTouch::iterate(list, (NexPid)__buffer[1], (NexCid)__buffer[2], (NexEventType)__buffer[3]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
29
NexTouch.cpp
29
NexTouch.cpp
@@ -140,3 +140,32 @@ void NexTouch::pop(void)
|
||||
}
|
||||
}
|
||||
|
||||
void NexTouch::iterate(NexTouch **list, NexPid pid, NexCid cid, NexEventType event)
|
||||
{
|
||||
NexTouch *e = NULL;
|
||||
uint16_t i = 0;
|
||||
|
||||
if (NULL == list)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(i = 0; (e = list[i]) != NULL; i++)
|
||||
{
|
||||
if (e->getPid() == pid && e->getCid() == cid)
|
||||
{
|
||||
e->print();
|
||||
if (NEX_EVENT_PUSH == event)
|
||||
{
|
||||
e->push();
|
||||
}
|
||||
else if (NEX_EVENT_POP == event)
|
||||
{
|
||||
e->pop();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
15
NexTouch.h
15
NexTouch.h
@@ -24,12 +24,21 @@ typedef uint8_t NexCid;
|
||||
|
||||
typedef void (*NexTouchEventCb)(void *ptr);
|
||||
|
||||
typedef enum {
|
||||
NEX_EVENT_POP = 0x00,
|
||||
NEX_EVENT_PUSH = 0x01,
|
||||
NEX_EVENT_NULL
|
||||
} NexEventType;
|
||||
|
||||
/**
|
||||
* Root Class of Nextion Components.
|
||||
*
|
||||
*/
|
||||
class NexTouch
|
||||
{
|
||||
public: /* static methods */
|
||||
static void iterate(NexTouch **list, NexPid pid, NexCid cid, NexEventType event);
|
||||
|
||||
public: /* methods */
|
||||
NexTouch(NexPid pid, NexCid cid, char *name,
|
||||
NexTouchEventCb pop = NULL, void *pop_ptr = NULL,
|
||||
@@ -38,9 +47,6 @@ public: /* methods */
|
||||
NexPid getPid(void);
|
||||
NexCid getCid(void);
|
||||
const char *getObjName(void);
|
||||
void print(void);
|
||||
void push(void);
|
||||
void pop(void);
|
||||
|
||||
protected: /* methods */
|
||||
void attachPush(NexTouchEventCb push, void *ptr = NULL);
|
||||
@@ -49,6 +55,9 @@ protected: /* methods */
|
||||
void detachPop(void);
|
||||
|
||||
private: /* methods */
|
||||
void print(void);
|
||||
void push(void);
|
||||
void pop(void);
|
||||
|
||||
private: /* data */
|
||||
NexPid pid; /* Page ID */
|
||||
|
||||
Reference in New Issue
Block a user