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