Documentation
For Arduino users
CompProgressBar_v0_32.ino
1 
22 #include "Nextion.h"
23 
24 NexProgressBar j0 = NexProgressBar(0, 3, "j0");
25 NexButton btn_up = NexButton(0, 1, "btn_up");
26 NexButton btn_down = NexButton(0, 2, "btn_down");
27 
28 NexTouch *nex_listen_list[] =
29 {
30  &btn_up,
31  &btn_down,
32  NULL
33 };
34 
35 void buttonUpPopCallback(void *ptr)
36 {
37  uint32_t number = 0;
38  dbSerialPrintln("buttonUpPopCallback");
39 
40  j0.getValue(&number);
41 
42  number += 5;
43  if (number >= 100)
44  {
45  number = 100;
46  }
47 
48  j0.setValue(number);
49 }
50 
51 void buttonDownPopCallback(void *ptr)
52 {
53  uint32_t number = 0;
54  dbSerialPrintln("buttonDownPopCallback");
55 
56  j0.getValue(&number);
57 
58  if (number >= 5)
59  {
60  number -= 5;
61  }
62 
63  j0.setValue(number);
64 }
65 
66 void setup(void)
67 {
68  nexInit();
69  btn_up.attachPop(buttonUpPopCallback);
70  btn_down.attachPop(buttonDownPopCallback);
71  dbSerialPrintln("setup done");
72 }
73 
74 void loop(void)
75 {
76  nexLoop(nex_listen_list);
77 }
78 
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.