Nextion User Manual
For Arduino developers
NexTouch.cpp
Go to the documentation of this file.
1 
15 #include "NexTouch.h"
16 
17 
18 NexTouch::NexTouch(uint8_t pid, uint8_t cid, const char *name)
19  :NexObject(pid, cid, name)
20 {
21  this->__cb_push = NULL;
22  this->__cb_pop = NULL;
23  this->__cbpop_ptr = NULL;
24  this->__cbpush_ptr = NULL;
25 }
26 
28 {
29  this->__cb_push = push;
30  this->__cbpush_ptr = ptr;
31 }
32 
34 {
35  this->__cb_push = NULL;
36  this->__cbpush_ptr = NULL;
37 }
38 
40 {
41  this->__cb_pop = pop;
42  this->__cbpop_ptr = ptr;
43 }
44 
46 {
47  this->__cb_pop = NULL;
48  this->__cbpop_ptr = NULL;
49 }
50 
51 void NexTouch::push(void)
52 {
53  if (__cb_push)
54  {
55  __cb_push(__cbpush_ptr);
56  }
57 }
58 
59 void NexTouch::pop(void)
60 {
61  if (__cb_pop)
62  {
63  __cb_pop(__cbpop_ptr);
64  }
65 }
66 
67 void NexTouch::iterate(NexTouch **list, uint8_t pid, uint8_t cid, int32_t event)
68 {
69  NexTouch *e = NULL;
70  uint16_t i = 0;
71 
72  if (NULL == list)
73  {
74  return;
75  }
76 
77  for(i = 0; (e = list[i]) != NULL; i++)
78  {
79  if (e->getObjPid() == pid && e->getObjCid() == cid)
80  {
81  e->printObjInfo();
82  if (NEX_EVENT_PUSH == event)
83  {
84  e->push();
85  }
86  else if (NEX_EVENT_POP == event)
87  {
88  e->pop();
89  }
90 
91  break;
92  }
93  }
94 }
95 
void detachPop(void)
Detach an callback function.
Definition: NexTouch.cpp:45
void attachPop(NexTouchEventCb pop, void *ptr=NULL)
Attach an callback function of pop touch event.
Definition: NexTouch.cpp:39
void(* NexTouchEventCb)(void *ptr)
Type of callback funciton when an touch event occurs.
Definition: NexTouch.h:45
void detachPush(void)
Detach an callback function.
Definition: NexTouch.cpp:33
#define NEX_EVENT_PUSH
Push touch event occuring when your finger or pen coming to Nextion touch pannel. ...
Definition: NexTouch.h:32
NexTouch(uint8_t pid, uint8_t cid, const char *name)
Constructor.
Definition: NexTouch.cpp:18
The definition of class NexTouch.
#define NEX_EVENT_POP
Pop touch event occuring when your finger or pen leaving from Nextion touch pannel.
Definition: NexTouch.h:37
Root class of all Nextion components.
Definition: NexObject.h:32
Father class of the components with touch events.
Definition: NexTouch.h:53
void printObjInfo(void)
Print current object'address, page id, component id and name.
Definition: NexObject.cpp:39
void attachPush(NexTouchEventCb push, void *ptr=NULL)
Attach an callback function of push touch event.
Definition: NexTouch.cpp:27