| Documentation For Arduino users

- Main Page
- Related Pages
- Modules
- Classes
- Files
- Examples

- File List
- File Members

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