Documentation
For Arduino users
CompPicture.ino
1 
19 #include "Nextion.h"
20 
21 /*
22  * Declare a picture object [page id:0,component id:1, component name: "p0"].
23  */
24 NexPicture p0 = NexPicture(0, 1, "p0");
25 
26 NexTouch *nex_listen_list[] =
27 {
28  &p0,
29  NULL
30 };
31 
32 void p0PopCallback(void *ptr)
33 {
34  uint32_t number = 0;
35  dbSerialPrintln("p0PopCallback");
36 
37  p0.getPic(&number);
38 
39  if (number == 1)
40  {
41  number = 2;
42  }
43  else
44  {
45  number = 1;
46  }
47 
48  p0.setPic(number);
49 }
50 
51 
52 void setup(void)
53 {
54  nexInit();
55  p0.attachPop(p0PopCallback);
56  dbSerialPrintln("setup done");
57 }
58 
59 void loop(void)
60 {
61  nexLoop(nex_listen_list);
62 }
63 
void nexLoop(NexTouch *nex_listen_list[])
Listen touch event and calling callbacks attached before.
bool setPic(uint32_t number)
Set picture's number.
Definition: NexPicture.cpp:55
void attachPop(NexTouchEventCb pop, void *ptr=NULL)
Attach an callback function of pop touch event.
Definition: NexTouch.cpp:39
bool nexInit(void)
Init Nextion.
NexPicture component.
Definition: NexPicture.h:30
The header file including all other header files provided by this library.
bool getPic(uint32_t *number)
Get picture's number.
Definition: NexPicture.cpp:46
Father class of the components with touch events.
Definition: NexTouch.h:53