当前位置:网站首页>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
边栏推荐
- GP如何进行数据比对?
- 一篇文章掌握整个JVM,JVM超详细解析!!!
- awk of the Three Musketeers of Shell Programming
- LeetCode·301.删除无效的括号·BFS
- Kubernetes资源编排系列之一: Pod YAML篇
- Joomla漏洞复现
- Stacks and Queues | Implementing Queues with Stacks | Implementing Stacks with Queues | Basic Theory and Code Principles
- Pulsar中游标的工作原理
- 深入学习Synchronized各种使用方法
- An article to master the entire JVM, JVM ultra-detailed analysis!!!
猜你喜欢
随机推荐
leetcode每天5题-Day11
转型做产品,考NPDP靠谱吗?
MySQL事务的保证机制
西门子Step7和TIA软件“交叉引用”的使用
Nexus_仓库类型
告诉你如何从keil工程知道使用了多少RAM和ROM空间
RK3568处理器体验小记
#【软件STM32cubeIDE下F103配置uart3+DMA收发+简单数据解析-基础样例】
FPGA工程师面试试题集锦31~40
华为交换机配置日志推送
取消了这次
ECMAScript6 Proxy和Reflect 对象操作拦截以及自定义
栈与队列 | 有效的括号、删除字符串中的所有相邻元素、逆波兰表达式求值、滑动窗口的最大值、前K个高频元素 | leecode刷题笔记
【心理学·人物】第二期(学术X综艺)
2022G3锅炉水处理考试模拟100题及模拟考试
在vscode中屏蔽Alt热键
How cursors work in Pulsar
An article to master the entire JVM, JVM ultra-detailed analysis!!!
小影科技IPO被终止:年营收3.85亿 五岳与达晨是股东
安芯电子IPO过会:年营收4亿 汪良恩兄弟持股61.6%










