当前位置:网站首页>Hezhou ESP32C3 +1.8"tft network clock under Arduino framework
Hezhou ESP32C3 +1.8"tft network clock under Arduino framework
2022-08-10 05:04:00 【perseverance52】
Arduino框架下合宙ESP32C3 +1.8"tft 网络时钟
本项目是在
VSCode PIO平台开发,基于Arduino框架.

功能实现模块
- The network can be manually configured+SmartConfig配网
1.8" tft_OLED采用TFT_eSPI库驱动,At the same time compatible with the universe0.96" 80X160屏幕(目前esp32C3Development boards with screens have been discontinued)

- OTAUpgrade function according to demand,Whether to enable this function
不足之处
设定的
SmartConfigDistribution network preservationwifiThe code for the message is invalid,以及通过nvs保存wifiInformation doesn't work either,No reason has yet been found.导致的后果:如果不是将wifiwords written in the information code,It needs to be done once every rebootSmartConfigNetwork once.
主程序代码
#include "LuatOS_C3.h"
#include <Arduino.h>
Preferences prefs; // 声明Preferences对象
TFT_eSPI tft = TFT_eSPI();
char buf[32] = {
0};
unsigned long lastMs = 0;
long check1s = 0;
TFT_eSprite drawBuf(&tft);
void setup() {
disableCore0WDT();
Serial.begin(115200);
delay(500);
Serial.println("Hello ESP32C3!!");
prefs.begin("wifi");// use "wifi" namespace,
if(prefs.isKey("ssid")) {
// 如果当前命名空间中有键名为"name"的元素
Serial.printf("ssid: %s\n\n", prefs.getString("ssid").c_str());
}
if(prefs.isKey("password")) {
// 如果当前命名空间中有键名为"name"的元素
Serial.printf("ssid: %s\n\n", prefs.getString("password").c_str());
}
if(prefs.isKey("ssid") && prefs.isKey("password") ) WiFi.begin(prefs.getString("ssid").c_str(),prefs.getString("password").c_str());
initTFT();
initLEDs();
tft.println("Start Config WiFi!");
if (!AutoConfig())
{
autoConfigWifi();
}
tft.println("Wifi Connected!");
sprintf(buf, "IP: %s", WiFi.localIP().toString().c_str());
tft.println(buf);
configTime(TZ_SEC, DST_SEC, "ntp.ntsc.ac.cn", "ntp1.aliyun.com");
delay(2000);
drawBuf.createSprite(TFT_HEIGHT, TFT_WIDTH);
// setupOTAConfig();OTAUpgrade function according to demand,Whether to enable this function
tft.fillScreen(TFT_BLACK);
}
inline void showCurrentTime() {
struct tm info;
getLocalTime(&info);
strftime(buf, 32, "%T", &info);
drawBuf.fillRect(0, 0, TFT_HEIGHT, TFT_WIDTH, TFT_BLACK);
drawBuf.setTextColor(TFT_ORANGE);//TFT_CYAN
drawBuf.setFreeFont(&FreeSerifBold18pt7b);
drawBuf.drawCentreString(buf, 80, 10, 1);
strftime(buf, 32, "%F", &info);
drawBuf.setTextColor(TFT_GREEN);
digitalWrite(PIN_LED1, HIGH);
drawBuf.setFreeFont(&FreeSerifBold12pt7b);
drawBuf.drawCentreString(buf, 80, 50, 1);
digitalWrite(PIN_LED1, LOW);
drawBuf.pushSprite(0, 0);
}
void loop() {
auto ms = millis();
if (ms - check1s > 1000) {
check1s = ms;
showCurrentTime();
// ArduinoOTA.handle();//OTAUpgrade function according to demand,Whether to enable this function
}
}
platformio.ini内容
由于VSCode PIOWithout the universeESP32C3,The model of the development board is modified by myself,You need to modify the model according to your own development environment configuration.
- 参考文章《合宙ESP32C3基于VSCode PIO ArduinoA preliminary tutorial on developing frameworks》有详细说明VSCode PIOBuild and add a universe in the environmentESP32C3开发内容.
[env:esp32-c3-luat]
platform = espressif32
board = esp32-c3-luat
; esp32-c3-devkitm-1
framework = arduino
upload_speed = 921600
monitor_speed = 115200
;board_build.partitions = partitions_16m.csv
; set frequency to 80MHz
board_build.f_flash = 80000000L
; set frequency to 160MHz
board_build.f_cpu = 160000000L
board_build.flash_mode =dio
;upload_port = /dev/cu.SLAB_USBtoUART
;monitor_port = /dev/cu.SLAB_USBtoUART
; upload_protocol = espota
; upload_port = 192.168.50.122
工程源码
链接:https://pan.baidu.com/s/1Q14rif9yRlXknzjKNGS9sA
提取码:qcse
- This project is referenced fromgithub地址:https://github.com/zhuhai-esp/ESP32-C3-LuatOS
边栏推荐
猜你喜欢

openvino 安装(01)

2022 R2 transportable pressure vessel filling operation examination question bank simulation platform

LeetCode 6138. 最长理想子序列 动态规划

二进制中负数为何要用补码形式来表示——二进制加减法

LeetCode 301. Remove Invalid Parentheses BFS

canvas 画布绘制时钟

2022年A特种设备相关管理(电梯)考试模拟100题及答案

Ueditor编辑器任意文件上传漏洞

告诉你如何从keil工程知道使用了多少RAM和ROM空间

tensorflow分词深度学习——影评预测
随机推荐
【无标题】
LeetCode·124.二叉树中的最大路径和·递归
Unity Shader 积雪效果
众昂矿业:萤石下游需求强劲
RadiAnt DICOM Viewer 2022.1 Crack
LeetCode 2369. 检查数组是否存在有效划分 动态规划
How does flinksql write that the value of redis has only the last field?
【裴蜀定理】CF1055C Lucky Days
Shell编程三剑客之awk
B+树与B树的区别、Hash索引与B+树索引的区别
使用 DatePicker 日期控件,发生 Prop being mutated: “placement“ 报错问题
什么是SRM?有什么作用?在企业管理中能实现哪些功能?
awk of the Three Musketeers of Shell Programming
2022山东省安全员C证考试题及模拟考试
When oracle cdc, set the parallelism to 2 and the number of slots to 1, and the final task has only one tm. Is it because oracle does not support concurrency
解决“File has been changed outside the editor, reload?”提示
Pulsar中游标的工作原理
LeetCode 6138. 最长理想子序列 动态规划
webrtc学习--webrtc桌面采集
leetcode每天5题-Day13
