Nextion User Manual
For Arduino developers
CompWaveform.ino
1 
17 #include "Nextion.h"
18 
19 #define LEVEL_HIGH (30)
20 #define LEVEL_LOW (0)
21 
22 #define CH0_OFFSET (40 - LEVEL_HIGH/2)
23 #define CH1_OFFSET (CH0_OFFSET + 40 * 1)
24 #define CH2_OFFSET (CH0_OFFSET + 40 * 2)
25 #define CH3_OFFSET (CH0_OFFSET + 40 * 3)
26 
27 
28 NexWaveform s0 = NexWaveform(0, 1, "s0");
29 
30 static uint8_t ch0_data = LEVEL_LOW;
31 static uint8_t ch1_data = LEVEL_LOW;
32 static uint8_t ch2_data = LEVEL_LOW;
33 static uint8_t ch3_data = LEVEL_LOW;
34 
35 void setup(void)
36 {
37  nexInit();
38  dbSerialPrintln("setup done");
39 }
40 
41 void loop(void)
42 {
43  static uint32_t started = 0;
44  if (millis() - started >= 2000)
45  {
46  started = millis();
47  if (LEVEL_HIGH == ch0_data)
48  {
49  ch0_data = LEVEL_LOW;
50  }
51  else
52  {
53  ch0_data = LEVEL_HIGH;
54  }
55  }
56 
57  ch1_data = ch0_data + random(0, 2);
58  ch2_data = ch0_data + random(0, 5);
59  ch3_data = ch0_data + random(0, 8);
60 
61  s0.addValue(0, CH0_OFFSET + ch0_data);
62  s0.addValue(1, CH1_OFFSET + ch1_data);
63  s0.addValue(2, CH2_OFFSET + ch2_data);
64  s0.addValue(3, CH3_OFFSET + ch3_data);
65 
66 }
67 
bool nexInit(void)
Init Nextion.
bool addValue(uint8_t ch, uint8_t number)
Add value to show.
Definition: NexWaveform.cpp:22
The header file including all other header files provided by this library.
NexWaveform component.
Definition: NexWaveform.h:29