当前位置:网站首页>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
边栏推荐
- How Current Probes Set Oscilloscope Parameters
- 2022山东省安全员C证考试题及模拟考试
- Consulting cdc 2.0 for mysql does not execute flush with read lock. How to ensure bin
- 众昂矿业:萤石下游需求强劲
- 老博的往事
- webrtc学习--websocket服务器(二) (web端播放h264)
- Guys, the test in the idea uses FlinkCDC SQL to read Mysql data and write it into Kafka. The code creates
- 今天月亮很美
- PHPCMS仿站从入门到精通,小白看这一套课程就够了
- JS gets the year, month, day, time, etc. of the simple current time
猜你喜欢

What is the relationship between legal representative and shareholders?

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

How cursors work in Pulsar

【无标题】

深度学习之-01

线程(下):读写者模型\环形队列\线程池

Using the DatePicker date control, Prop being mutated: "placement" error occurs

2022年R2移动式压力容器充装考试题库模拟考试平台操作

webrtc学习--webrtc源码获取

什么是遗留代码:有效地处理遗留代码的8个小贴士
随机推荐
【论文笔记】Prototypical Contrast Adaptation for Domain Adaptive Semantic Segmentation
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
LeetCode 2369. 检查数组是否存在有效划分 动态规划
十年架构五年生活-07 年轻气盛的蜕变
cmake
MySQL使用简单教程
在vscode中屏蔽Alt热键
`id` bigint(20) unsigned NOT NULL COMMENT 'Database primary key',
pytorch 学习
Thread.sleep, Thread.yield 作用解释
【Web3 系列开发教程——创建你的第一个 NFT(7)】创建一个 NFT DApp,给你的 NFT 赋予属性,例如图片
About the problem that the mongodb driver count method of rust cannot be used with the near condition
ORA-16018 异常处理记录
各位大佬,idea中测试使用FlinkCDC SQL 读取Mysql 数据写入Kafka中,代码中创
告诉你如何从keil工程知道使用了多少RAM和ROM空间
如何从代码层提高产品质量
SQL数据库字段追加到主表
栈与队列 | 有效的括号、删除字符串中的所有相邻元素、逆波兰表达式求值、滑动窗口的最大值、前K个高频元素 | leecode刷题笔记
阿笑家的黄桃
【u-boot】u-boot驱动模型分析(02)
