| Documentation For Arduino users

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

- File List
- File Members

CompGpio.ino
1
18 #include "Nextion.h"
19
20 NexGpio gpio;
21 NexNumber n0 = NexNumber(0,1,"n0");
22 NexNumber n1 = NexNumber(0,3,"n1");
23
24 #define GPIO_PUSH_PORT 1
25 #define GPIO_PWM_PORT 2
26 #define GPIO_PUSH_OUTPUT_MODE 2
27 #define GPIO_PWM_OUT_MODE 3
28 #define CONTROLS_ID 0 //when the modeel is 1 to be valid
29
30 uint32_t pwm_value = 0;
31
32 void setup()
33 {
34 nexSerial.begin(115200);
35 gpio.pin_mode(GPIO_PUSH_PORT,GPIO_PUSH_OUTPUT_MODE,CONTROLS_ID);
36 gpio.pin_mode(GPIO_PWM_PORT,GPIO_PWM_OUT_MODE,CONTROLS_ID);
37 }
38
39 void loop()
40 {
41 if(gpio.digital_read(1) == 0)
42 {
43 gpio.digital_write(GPIO_PUSH_PORT,HIGH);
44 n0.setValue(1);
45 }
46 else
47 {
48 gpio.digital_write(GPIO_PUSH_PORT,LOW);
49 n0.setValue(0);
50 }
51
52
53 gpio.analog_write(GPIO_PWM_PORT,pwm_value);
54 n1.setValue(pwm_value);
55 if(pwm_value == 100)
56 {
57 pwm_value = 0;
58 }
59 else
60 {
61 pwm_value += 20;
62 }
63
64 delay(1000);
65 }
NexNumber
NexNumber component.
Definition: NexNumber.h:30
nexSerial
#define nexSerial
Define nexSerial for communicate with Nextion touch panel.
Definition: NexConfig.h:37
NexGpio::digital_write
bool digital_write(uint32_t port, uint32_t value)
write a HIGH or a LOW value to a digital pin
Definition: NexGpio.cpp:37
NexGpio::pin_mode
bool pin_mode(uint32_t port, uint32_t mode, uint32_t control_id)
Set gpio mode.
Definition: NexGpio.cpp:17
Nextion.h
The header file including all other header files provided by this library.
NexGpio
NexGpio component.
Definition: NexGpio.h:31
NexNumber::setValue
bool setValue(uint32_t number)
Set number attribute of component.
Definition: NexNumber.cpp:31
NexGpio::analog_write
bool analog_write(uint32_t port, uint32_t value)
writes an analog value (PWM wave) to a pin
Definition: NexGpio.cpp:68
NexGpio::digital_read
uint32_t digital_read(uint32_t port)
read a HIGH or a LOW value to a digital pin
Definition: NexGpio.cpp:53