Nextion User Manual
For Arduino developers
CompHotspot.ino
1 
17 #include "Nextion.h"
18 
19 NexHotspot hot0 = NexHotspot(0, 1, "hot0");
20 NexHotspot hot1 = NexHotspot(0, 2, "hot1");
21 
22 NexTouch *nex_listen_list[] =
23 {
24  &hot0,
25  &hot1,
26  NULL
27 };
28 
29 void hot0PushCallback(void *ptr)
30 {
31  dbSerialPrintln("hot0PushCallback");
32  dbSerialPrint("ptr=");
33  dbSerialPrintln((uint32_t)ptr);
34 }
35 
36 void hot1PushCallback(void *ptr)
37 {
38  dbSerialPrintln("hot1PushCallback");
39  dbSerialPrint("ptr=");
40  dbSerialPrintln((uint32_t)ptr);
41 }
42 
43 void hot0PopCallback(void *ptr)
44 {
45  dbSerialPrintln("hot0PopCallback");
46  dbSerialPrint("ptr=");
47  dbSerialPrintln((uint32_t)ptr);
48 }
49 
50 void hot1PopCallback(void *ptr)
51 {
52  dbSerialPrintln("hot1PopCallback");
53  dbSerialPrint("ptr=");
54  dbSerialPrintln((uint32_t)ptr);
55 }
56 
57 void setup(void)
58 {
59  nexInit();
60  hot0.attachPush(hot0PushCallback, &hot0);
61  hot0.attachPop(hot0PopCallback, &hot0);
62  hot1.attachPush(hot1PushCallback, &hot1);
63  hot1.attachPop(hot1PopCallback, &hot1);
64  dbSerialPrintln("setup done");
65 }
66 
67 void loop(void)
68 {
69  nexLoop(nex_listen_list);
70 }
void nexLoop(NexTouch *nex_listen_list[])
Listen touch event and calling callbacks attached before.
void attachPop(NexTouchEventCb pop, void *ptr=NULL)
Attach an callback function of pop touch event.
Definition: NexTouch.cpp:39
bool nexInit(void)
Init Nextion.
The header file including all other header files provided by this library.
NexHotspot component.
Definition: NexHotspot.h:30
Father class of the components with touch events.
Definition: NexTouch.h:53
void attachPush(NexTouchEventCb push, void *ptr=NULL)
Attach an callback function of push touch event.
Definition: NexTouch.cpp:27