add gpio and rtc example

This commit is contained in:
huangxiaoming
2016-12-08 11:11:43 +08:00
parent 1b3afa949d
commit bf370dbc51
197 changed files with 18655 additions and 0 deletions

BIN
examples/CompGpio/CompGpio.HMI Executable file

Binary file not shown.

48
examples/CompGpio/CompGpio.ino Executable file
View 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

Binary file not shown.

BIN
examples/CompRtc/CompRtc.HMI Executable file

Binary file not shown.

19
examples/CompRtc/CompRtc.ino Executable file
View 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

Binary file not shown.