当前位置:网站首页>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
不足之处
设定的
SmartConfig
Distribution network preservationwifi
The 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 rebootSmartConfig
Network 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
边栏推荐
猜你喜欢
基于 EasyCV 复现 DETR 和 DAB-DETR,Object Query 的正确打开方式
法定代表人和股东是什么关系
JVM类加载机制
awk of the Three Musketeers of Shell Programming
基于BP神经网络的多因素房屋价格预测matlab仿真
线程(上篇):线程的创建
线性模型中的高级特征选择技术——基于R
Ueditor editor arbitrary file upload vulnerability
MySQL使用简单教程
栈与队列 | 有效的括号、删除字符串中的所有相邻元素、逆波兰表达式求值、滑动窗口的最大值、前K个高频元素 | leecode刷题笔记
随机推荐
开发智能硬件过程中需要掌握的方法之经典
ECMAScript6 Proxy和Reflect 对象操作拦截以及自定义
线性代数(四)
Unity Shader 积雪效果
Guys, the test in the idea uses FlinkCDC SQL to read Mysql data and write it into Kafka. The code creates
webrtc学习--webrtc源码获取
LeetCode 6138. 最长理想子序列 动态规划
华为交换机配置日志推送
众昂矿业:萤石下游需求强劲
元宇宙 | 你能通过图灵测试吗?
How to choose the right oscilloscope probe in different scenarios
FPGA工程师面试试题集锦31~40
大佬们,运行cdc后oracle归档日志20分钟增长3G是正常现象吗
2022年T电梯修理考试题及模拟考试
如何取得某月的最后一天
Flutter开发:报错The following assertion was thrown resolving an image codec:Unable to…的解决方法
Stacks and Queues | Implementing Queues with Stacks | Implementing Stacks with Queues | Basic Theory and Code Principles
SQL Server query optimization
十年架构五年生活-06 离职的冲动
redis基本数据类型