API
For Arduino developers
CompCrop.ino
1 
16 #include "NexCrop.h"
17 
18 NexCrop q0 = NexCrop(0, 1, "q0");
19 
20 NexTouch *nex_listen_list[] =
21 {
22  &q0,
23  NULL
24 };
25 
26 void q0PopCallback(void *ptr)
27 {
28  uint32_t number = 0;
29  dbSerialPrintln("q0PopCallback");
30 
31  q0.getPic(&number);
32 
33  number += 1;
34  number %= 2;
35 
36  q0.setPic(number);
37 }
38 
39 
40 void setup(void)
41 {
42  dbSerialBegin(9600);
43  nexInit();
44  q0.attachPop(q0PopCallback);
45  dbSerialPrintln("setup done");
46 }
47 
48 void loop(void)
49 {
50  nexLoop(nex_listen_list);
51 }
52 
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 NexCrop.
void attachPop(NexTouchEventCb pop, void *ptr=NULL)
Register crop pop callback function.
Definition: NexCrop.cpp:72
NexCrop,subclass of NexTouch,provides simple methods to control crop component.
Definition: NexCrop.h:25
Root Class of Nextion Components.
Definition: NexTouch.h:57