当前位置:网站首页>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
边栏推荐
猜你喜欢
2022山东省安全员C证考试题及模拟考试
leetcode每天5题-Day11
Unity implements UI edge detection and drag-and-drop functions
万字总结:分布式系统的38个知识点
【无标题】
How cursors work in Pulsar
干货 | 查资料利器:线上图书馆
2022 R2 transportable pressure vessel filling operation examination question bank simulation platform
Ueditor editor arbitrary file upload vulnerability
线程(上篇):线程的创建
随机推荐
Ueditor编辑器任意文件上传漏洞
`id` bigint(20) unsigned NOT NULL COMMENT 'Database primary key',
Rpc接口压测
2022年A特种设备相关管理(电梯)考试模拟100题及答案
关于rust的mongodb驱动count方法无法与near条件一同使用的问题
Using the DatePicker date control, Prop being mutated: "placement" error occurs
LeetCode 2369. 检查数组是否存在有效划分 动态规划
老博的往事
【u-boot】u-boot驱动模型分析(02)
【LeetCode】41、 缺失的第一个正数
pytorch 学习
`id` bigint(20) unsigned NOT NULL COMMENT '数据库主键',
咨询cdc 2.0 for mysql不执行flush with read lock.怎么保证bin
Ueditor editor arbitrary file upload vulnerability
ORA-16018 异常处理记录
webrtc学习--一对一通话
安芯电子IPO过会:年营收4亿 汪良恩兄弟持股61.6%
Arduino框架下合宙ESP32C3 +1.8“tft 网络时钟
MySQL simple tutorial
awk of the Three Musketeers of Shell Programming