API
For Arduino developers
CompPicture.ino
1 
16 #include "NexPicture.h"
17 
18 NexPicture p0 = NexPicture(0, 1, "p0");
19 
20 NexTouch *nex_listen_list[] =
21 {
22  &p0,
23  NULL
24 };
25 
26 void p0PopCallback(void *ptr)
27 {
28  uint32_t number = 0;
29  dbSerialPrintln("p0PopCallback");
30 
31  p0.getPic(&number);
32 
33  if (number == 1)
34  {
35  number = 2;
36  }
37  else
38  {
39  number = 1;
40  }
41 
42  p0.setPic(number);
43 }
44 
45 
46 void setup(void)
47 {
48  dbSerialBegin(9600);
49  nexInit();
50  p0.attachPop(p0PopCallback);
51  dbSerialPrintln("setup done");
52 }
53 
54 void loop(void)
55 {
56  nexLoop(nex_listen_list);
57 }
58 
bool nexInit(void)
Init Nextion's baudrate,page id.
Definition: NexTouch.cpp:404
bool setPic(uint32_t number)
Set picture's number.
Definition: NexPicture.cpp:52
bool nexLoop(NexTouch **nex_listen_list)
Call mainEventLoop,watting for Nextion's touch event.
Definition: NexTouch.cpp:420
NexPicture,subclass of NexTouch,provides simple methods to control picture component.
Definition: NexPicture.h:25
void attachPop(NexTouchEventCb pop, void *ptr=NULL)
Register picture pop callback function.
Definition: NexPicture.cpp:72
bool getPic(uint32_t *number)
Get picture's number.
Definition: NexPicture.cpp:35
Root Class of Nextion Components.
Definition: NexTouch.h:57
API of NexPicture.