Documentation: NexTouch.cpp Source File

| Documentation For Arduino users

- Main Page
- Related Pages
- Modules
- Classes
- Files
- Examples

- File List
- File Members

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
27 void NexTouch::attachPush(NexTouchEventCb push, void *ptr)
28 {
29 this->__cb_push = push;
30 this->__cbpush_ptr = ptr;
31 }
32
33 void NexTouch::detachPush(void)
34 {
35 this->__cb_push = NULL;
36 this->__cbpush_ptr = NULL;
37 }
38
39 void NexTouch::attachPop(NexTouchEventCb pop, void *ptr)
40 {
41 this->__cb_pop = pop;
42 this->__cbpop_ptr = ptr;
43 }
44
45 void NexTouch::detachPop(void)
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
NexTouch::detachPop
void detachPop(void)
Detach an callback function.
Definition: NexTouch.cpp:45
NexTouch::attachPop
void attachPop(NexTouchEventCb pop, void *ptr=NULL)
Attach an callback function of pop touch event.
Definition: NexTouch.cpp:39
NexTouchEventCb
void(* NexTouchEventCb)(void *ptr)
Type of callback funciton when an touch event occurs.
Definition: NexTouch.h:45
NexTouch::detachPush
void detachPush(void)
Detach an callback function.
Definition: NexTouch.cpp:33
NEX_EVENT_PUSH
#define NEX_EVENT_PUSH
Push touch event occuring when your finger or pen coming to Nextion touch pannel. ...
Definition: NexTouch.h:32
NexTouch::NexTouch
NexTouch(uint8_t pid, uint8_t cid, const char *name)
Constructor.
Definition: NexTouch.cpp:18
NexTouch.h
The definition of class NexTouch.
NEX_EVENT_POP
#define NEX_EVENT_POP
Pop touch event occuring when your finger or pen leaving from Nextion touch pannel.
Definition: NexTouch.h:37
NexObject
Root class of all Nextion components.
Definition: NexObject.h:32
NexTouch
Father class of the components with touch events.
Definition: NexTouch.h:53
NexObject::printObjInfo
void printObjInfo(void)
Print current object'address, page id, component id and name.
Definition: NexObject.cpp:39
NexTouch::attachPush
void attachPush(NexTouchEventCb push, void *ptr=NULL)
Attach an callback function of push touch event.
Definition: NexTouch.cpp:27