Documentation
For Arduino users
CompProgressBar.ino
1 
20 #include "Nextion.h"
21 
22 NexProgressBar j0 = NexProgressBar(0, 3, "j0");
23 NexButton btn_up = NexButton(0, 1, "btn_up");
24 NexButton btn_down = NexButton(0, 2, "btn_down");
25 
26 NexTouch *nex_listen_list[] =
27 {
28  &btn_up,
29  &btn_down,
30  NULL
31 };
32 
33 void buttonUpPopCallback(void *ptr)
34 {
35  uint32_t number = 0;
36  dbSerialPrintln("buttonUpPopCallback");
37 
38  j0.getValue(&number);
39 
40  number += 5;
41  if (number >= 100)
42  {
43  number = 100;
44  }
45 
46  j0.setValue(number);
47 }
48 
49 void buttonDownPopCallback(void *ptr)
50 {
51  uint32_t number = 0;
52  dbSerialPrintln("buttonDownPopCallback");
53 
54  j0.getValue(&number);
55 
56  if (number >= 5)
57  {
58  number -= 5;
59  }
60 
61  j0.setValue(number);
62 }
63 
64 void setup(void)
65 {
66  nexInit();
67  btn_up.attachPop(buttonUpPopCallback);
68  btn_down.attachPop(buttonDownPopCallback);
69  dbSerialPrintln("setup done");
70 }
71 
72 void loop(void)
73 {
74  nexLoop(nex_listen_list);
75 }
76 
void nexLoop(NexTouch *nex_listen_list[])
Listen touch event and calling callbacks attached before.
bool setValue(uint32_t number)
Set the value of progress bar.
void attachPop(NexTouchEventCb pop, void *ptr=NULL)
Attach an callback function of pop touch event.
Definition: NexTouch.cpp:39
bool nexInit(void)
Init Nextion.
NexButton component.
Definition: NexButton.h:35
The header file including all other header files provided by this library.
bool getValue(uint32_t *number)
Get the value of progress bar.
Father class of the components with touch events.
Definition: NexTouch.h:53
NexProgressBar component.