1838浏览
查看: 1838|回复: 1

7X71RGB柔性屏测评第二弹:电子时钟

[复制链接]
前记:
因为Arduino和柔性屏都没有时钟模块,所以为了获取时间和减少外设,准备选择带wifi功能的板子,

手头有Arduino UNO、掌控板、DF的FireBeetle可用,都是ESP32芯片的。可是测试的时候,这块柔性屏需要软串口?

再加上FireBeetle没有5V的输出电压,所以只好选择Arduino的板子。

还好手头有块常年不用的wifiduino(esp8266芯片)

一、时间同步

1. 安装 wifiduino的开发板库。

在Arduino的首选项里输入库地址:
http://arduino.esp8266.com/stable/package_esp8266com_index.json

7X71RGB柔性屏测评第二弹:电子时钟图1

待更新完成后,安装开发板



7X71RGB柔性屏测评第二弹:电子时钟图2

安装好扩展板后,因为是用NTP协议来更新时间,所以还需再安装一个NTP时间库,

打开工具→管理库→搜索 NTPClient 进行安装即可。

7X71RGB柔性屏测评第二弹:电子时钟图3

结合 DFRobot_SerialScreen771库和NTPClient库里的示例代码就可以愉快地撸好时间显示的代码了。[mw_shl_code=c,false]#include <NTPClient.h>
// change next line to use with another board/shield
#include <ESP8266WiFi.h>
//#include <WiFi.h> // for WiFi shield
//#include <WiFi101.h> // for WiFi 101 shield or MKR1000
#include <WiFiUdp.h>
#include <Arduino.h>
#include <HardwareSerial.h>
#include <SoftwareSerial.h>
#include "DFRobot_SerialScreen771.h"

#ifdef ARDUINO_AVR_UNO
SoftwareSerial Serial1(D2, D3); //RX, TX
#endif
DFRobot_SerialScreen771 screen;
const char *ssid     = "1404-2";
const char *password = "12345678";

WiFiUDP ntpUDP;

// You can specify the time server pool and the offset (in seconds, can be
// changed later with setTimeOffset() ). Additionaly you can specify the
// update interval (in milliseconds, can be changed using setUpdateInterval() ).
NTPClient timeClient(ntpUDP, "ntp1.aliyun.com", 8*60*60, 60000);
void setup(){
  Serial.begin(115200);

  WiFi.begin(ssid, password);

  while ( WiFi.status() != WL_CONNECTED ) {
    delay ( 500 );
    Serial.print ( "." );
  }
  timeClient.begin();
    /*Initialize communication interface (Serial1) and debug interface (Serial)*/
    Serial1.begin(19200);
    screen.begin(Serial1);
    screen.setDbgSerial(Serial);
    /*Display string "DFRobot"*/
    // screen.setMessage("DFRobot");

}

void loop() {
  timeClient.update();
  String str_time     = timeClient.getFormattedTime();
  char charBuf[str_time.length()+1];
  str_time.toCharArray(charBuf, str_time.length()+1);
  Serial.println(str_time);
  screen.setMessage(charBuf);
  delay(1000);
}[/mw_shl_code]
7X71RGB柔性屏测评第二弹:电子时钟图4

其他还好,就是有点闪。。。

7X71RGB柔性屏测评第二弹:电子时钟图5

几点卑微的说明:

1. 我是拿到实物才看功能函数的,瞟了一眼就感觉申请评测的时候立的flag有点不稳了。。。

2. 找到函数库源代码想改改,发现竟然只是API,底层的已经直接写到STC单片机芯片里了,

一阵凉凉。。。

3. 刷新率有点低,可以高点吗?电子时钟每秒闪一次,有点跳啊。

真用的话,只能选择时、分,不用秒了。。。

4. 底层API可以开放多点吗。。。







小助手  管理员

发表于 2020-5-13 10:16:35

我反馈给技术的同事~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail