Documentation
For Arduino users
CompCrop.ino
1 
18 #include "Nextion.h"
19 
20 /*
21  * Declare a crop object [page id:0,component id:1, component name: "q0"].
22  */
23 NexCrop q0 = NexCrop(0, 1, "q0");
24 
25 NexTouch *nex_listen_list[] =
26 {
27  &q0,
28  NULL
29 };
30 
31 /*
32  * Crop component pop callback function.
33  * In this example,the image of current crop component will be changed every time when it is released.
34  */
35 void q0PopCallback(void *ptr)
36 {
37  uint32_t number = 0;
38  dbSerialPrintln("q0PopCallback");
39 
40  q0.getPic(&number);
41 
42  number += 1;
43  number %= 2;
44 
45  q0.setPic(number);
46 }
47 
48 void setup(void)
49 {
50  nexInit();
51  q0.attachPop(q0PopCallback);
52  dbSerialPrintln("setup done");
53 }
54 
55 void loop(void)
56 {
57  nexLoop(nex_listen_list);
58 }
59 
void nexLoop(NexTouch *nex_listen_list[])
Listen touch event and calling callbacks attached before.
bool getPic(uint32_t *number)
Get the number of picture.
Definition: NexCrop.cpp:46
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.
bool setPic(uint32_t number)
Set the number of picture.
Definition: NexCrop.cpp:55
NexCrop component.
Definition: NexCrop.h:30
Father class of the components with touch events.
Definition: NexTouch.h:53