mirror of
https://github.com/itead/ITEADLIB_Arduino_Nextion.git
synced 2026-03-06 18:16:49 +01:00
add gpio and rtc example
This commit is contained in:
BIN
examples/CompGpio/CompGpio.HMI
Executable file
BIN
examples/CompGpio/CompGpio.HMI
Executable file
Binary file not shown.
48
examples/CompGpio/CompGpio.ino
Executable file
48
examples/CompGpio/CompGpio.ino
Executable file
@@ -0,0 +1,48 @@
|
||||
#include "Nextion.h"
|
||||
|
||||
NexGpio gpio;
|
||||
NexNumber n0 = NexNumber(0,1,"n0");
|
||||
NexNumber n1 = NexNumber(0,3,"n1");
|
||||
|
||||
#define GPIO_PUSH_PORT 1
|
||||
#define GPIO_PWM_PORT 2
|
||||
#define GPIO_PUSH_OUTPUT_MODE 2
|
||||
#define GPIO_PWM_OUT_MODE 3
|
||||
#define CONTROLS_ID 0 //when the modeel is 1 to be valid
|
||||
|
||||
uint32_t pwm_value = 0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
nexSerial.begin(115200);
|
||||
gpio.pin_mode(GPIO_PUSH_PORT,GPIO_PUSH_OUTPUT_MODE,CONTROLS_ID);
|
||||
gpio.pin_mode(GPIO_PWM_PORT,GPIO_PWM_OUT_MODE,CONTROLS_ID);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
if(gpio.digital_read(1) == 0)
|
||||
{
|
||||
gpio.digital_write(GPIO_PUSH_PORT,HIGH);
|
||||
n0.setValue(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
gpio.digital_write(GPIO_PUSH_PORT,LOW);
|
||||
n0.setValue(0);
|
||||
}
|
||||
|
||||
|
||||
gpio.analog_write(GPIO_PWM_PORT,pwm_value);
|
||||
n1.setValue(pwm_value);
|
||||
if(pwm_value == 100)
|
||||
{
|
||||
pwm_value = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
pwm_value += 20;
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
BIN
examples/CompGpio/font.zi
Executable file
BIN
examples/CompGpio/font.zi
Executable file
Binary file not shown.
BIN
examples/CompRtc/CompRtc.HMI
Executable file
BIN
examples/CompRtc/CompRtc.HMI
Executable file
Binary file not shown.
19
examples/CompRtc/CompRtc.ino
Executable file
19
examples/CompRtc/CompRtc.ino
Executable file
@@ -0,0 +1,19 @@
|
||||
#include "Nextion.h"
|
||||
|
||||
NexText t0 = NexText(0,1,"t0");
|
||||
NexRtc rtc;
|
||||
uint32_t time[7] = {2016,11,25,12,34,50};
|
||||
uint8_t time_buf[30] = {0};
|
||||
|
||||
void setup()
|
||||
{
|
||||
nexSerial.begin(115200);
|
||||
rtc.write_rtc_time(time);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
rtc.read_rtc_time(time_buf,30);
|
||||
t0.setText(time_buf);
|
||||
delay(1000);
|
||||
}
|
||||
BIN
examples/CompRtc/font.zi
Executable file
BIN
examples/CompRtc/font.zi
Executable file
Binary file not shown.
Reference in New Issue
Block a user