auzn 发表于 2020-5-17 16:18:22

7X71RGB柔性屏试用——ESP32驱动显示时间

本帖最后由 auzn 于 2020-5-17 16:20 编辑



系列试用文章:
一、开箱贴

# 硬件连接
!(https://wiki.dfrobot.com.cn/images/7/77/771%E8%BD%AF%E5%B1%8F.png)
![掌控板IO](https://wiki.dfrobot.com.cn/images/8/83/MBT0014%E5%B9%B3%E9%9D%A2%E5%9B%BE.png)
**查看柔性屏及掌控板IO定义,红线连正极、黑线连负极、蓝线连13、绿线连14**
!(data/attachment/album/202005/17/160331ls4c5msfasbwmjzj.jpg)
查看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);
}
```





https://www.bilibili.com/video/BV1hf4y1U7LS/
页: [1]
查看完整版本: 7X71RGB柔性屏试用——ESP32驱动显示时间