Documentation: examples/CompGauge/CompGauge_v0_32.ino Source File

| Documentation For Arduino users

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

- File List
- File Members

CompGauge_v0_32.ino
1
21 #include "Nextion.h"
22
23 NexGauge pointer = NexGauge(0, 1, "pointer");
24 NexButton btn_up = NexButton(0, 2, "btn_up");
25 NexButton btn_down = NexButton(0, 3, "btn_down");
26
27 NexTouch *nex_listen_list[] =
28 {
29 &btn_up,
30 &btn_down,
31 NULL
32 };
33
34 void buttonUpPopCallback(void *ptr)
35 {
36 uint32_t number = 0;
37 dbSerialPrintln("buttonUpPopCallback");
38
39 pointer.getValue(&number);
40
41 number += 5;
42 if (number >= 360)
43 {
44 number = 0;
45 }
46
47 pointer.setValue(number);
48 }
49 void buttonDownPopCallback(void *ptr)
50 {
51 uint32_t number = 0;
52 dbSerialPrintln("buttonDownPopCallback");
53
54 pointer.getValue(&number);
55
56 if (number >= 5)
57 {
58 number -= 5;
59 }
60
61 pointer.setValue(number);
62 }
63
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
NexGauge
NexGauge component.
Definition: NexGauge.h:30
nexLoop
void nexLoop(NexTouch *nex_listen_list[])
Listen touch event and calling callbacks attached before.
Definition: NexHardware.cpp:235
NexTouch::attachPop
void attachPop(NexTouchEventCb pop, void *ptr=NULL)
Attach an callback function of pop touch event.
Definition: NexTouch.cpp:39
NexGauge::setValue
bool setValue(uint32_t number)
Set the value of gauge.
Definition: NexGauge.cpp:32
nexInit
bool nexInit(void)
Init Nextion.
Definition: NexHardware.cpp:220
NexButton
NexButton component.
Definition: NexButton.h:35
NexGauge::getValue
bool getValue(uint32_t *number)
Get the value of gauge.
Definition: NexGauge.cpp:23
Nextion.h
The header file including all other header files provided by this library.
NexTouch
Father class of the components with touch events.
Definition: NexTouch.h:53