本帖最后由 auzn 于 2020-5-17 16:20 编辑
系列试用文章:
一、开箱贴
硬件连接
查看柔性屏及掌控板IO定义,红线连正极、黑线连负极、蓝线连13、绿线连14
查看ESP32引脚定义对应IO18 19,初始化屏幕
SoftwareSerial SoftwareSerial1(19, 18);
DFRobot_SerialScreen771 screen;
screen.begin(&SoftwareSerial1);
程序
引用NTPClient库 、ESP32 SoftwareSerial库,更新并显示时间,loop设置200ms,如果和上次时间一样不更新显示,不一样就更新显示
#include <Arduino.h>
#include <SoftwareSerial.h>
#include <DFRobot_SerialScreen771.h>
#include <WiFi.h>
#include <WiFiUdp.h>
#include <NTPClient.h>
SoftwareSerial SoftwareSerial1(19, 18);
DFRobot_SerialScreen771 screen;
const char* ssid = "ChinaNet-HM1316";
const char* password = "";
String before = "";
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP,"ntp1.aliyun.com",60*60*8, 30*60*1000);
void setup() {
Serial.begin(115200);
delay(10);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
timeClient.begin();
screen.begin(&SoftwareSerial1);
//screen.setDispalyColor(eColor_white, eColor_blue);
//screen.setMoveSpeed(eSpeedLevel_3);
}
void loop() {
timeClient.update();
String now = timeClient.getFormattedTime();
if(now != before){
before = now;
//入参不是String 要转换
screen.setMessage(now.c_str());
}
delay(200);
}
|