API
For Arduino developers
CompHotspot.ino
1 
16 #include "NexHotspot.h"
17 
18 NexHotspot hot0 = NexHotspot(0, 1, "hot0");
19 NexHotspot hot1 = NexHotspot(0, 2, "hot1");
20 
21 NexTouch *nex_listen_list[] =
22 {
23  &hot0,
24  &hot1,
25  NULL
26 };
27 
28 void hot0PushCallback(void *ptr)
29 {
30  dbSerialPrintln("hot0PushCallback");
31  dbSerialPrint("ptr=");
32  dbSerialPrintln((uint32_t)ptr);
33 }
34 
35 void hot1PushCallback(void *ptr)
36 {
37  dbSerialPrintln("hot1PushCallback");
38  dbSerialPrint("ptr=");
39  dbSerialPrintln((uint32_t)ptr);
40 }
41 
42 void hot0PopCallback(void *ptr)
43 {
44  dbSerialPrintln("hot0PopCallback");
45  dbSerialPrint("ptr=");
46  dbSerialPrintln((uint32_t)ptr);
47 }
48 
49 void hot1PopCallback(void *ptr)
50 {
51  dbSerialPrintln("hot1PopCallback");
52  dbSerialPrint("ptr=");
53  dbSerialPrintln((uint32_t)ptr);
54 }
55 
56 void setup(void)
57 {
58  dbSerialBegin(9600);
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 }
bool nexInit(void)
Init Nextion's baudrate,page id.
Definition: NexTouch.cpp:404
bool nexLoop(NexTouch **nex_listen_list)
Call mainEventLoop,watting for Nextion's touch event.
Definition: NexTouch.cpp:420
API of NexHotspot.
NexHotspot,subclass of NexTouch,provides simple methods to control hotspot component.
Definition: NexHotspot.h:25
void attachPop(NexTouchEventCb pop, void *ptr=NULL)
Register hotspot pop callback function.
Definition: NexHotspot.cpp:55
Root Class of Nextion Components.
Definition: NexTouch.h:57
void attachPush(NexTouchEventCb push, void *ptr=NULL)
Register hotspot push callback function.
Definition: NexHotspot.cpp:35