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

功能实现模块
- 可以手动配网+SmartConfig配网
1.8" tft_OLED采用TFT_eSPI库驱动,同时兼容合宙的0.96" 80X160屏幕(目前esp32C3带屏幕的开发板已经下架了)

- OTA升级功能根据需求,是否启用该函数
不足之处
设定的
SmartConfig配网保存wifi信息的代码失效,以及通过nvs保存wifi信息也不起作用,暂时没查到是什么原因引起的。导致的后果:如果不是将wifi信息代码中写入的话,每次重启都需要一次SmartConfig配网一次。
主程序代码
#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();OTA升级功能根据需求,是否启用该函数
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();//OTA升级功能根据需求,是否启用该函数
}
}
platformio.ini内容
由于VSCode PIO不带合宙ESP32C3,开发板型号是自己修改来的,需要根据自己的开发环境配置的修改型号.
- 参考文章《合宙ESP32C3基于VSCode PIO Arduino开发框架初探教程》有详细说明VSCode PIO环境下搭建和添加合宙ESP32C3开发内容。
[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
- 本项目参考来自github地址:https://github.com/zhuhai-esp/ESP32-C3-LuatOS
边栏推荐
- 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
- webrtc学习--webrtc桌面采集
- Promise原理及实现
- 法定代表人和股东是什么关系
- 盼他一切安好
- 2022G3 Boiler Water Treatment Exam Mock 100 Questions and Mock Exam
- leetcode每天5题-Day13
- Unity Shader 积雪效果
- 用 PySpark ML 构建机器学习模型
- 【无标题】
猜你喜欢

webrtc学习--websocket服务器(二) (web端播放h264)

2022年T电梯修理考试题及模拟考试

What is the relationship between legal representative and shareholders?

MySQL事务的保证机制

LeetCode·1413.逐步求和得到正数的最小值·贪心

什么是遗留代码:有效地处理遗留代码的8个小贴士

MySQL使用简单教程

mysql常用命令有什么

leetcode每天5题-Day10

2022 R2 transportable pressure vessel filling operation examination question bank simulation platform
随机推荐
【无标题】
flex 相关
I have a dream for Career .
[Web3 Series Development Tutorial - Create Your First NFT (7)] Create an NFT DApp and assign attributes to your NFT, such as pictures
oracle cdc时,设置并行度2插槽数1,最终任务只有一个tm,是不是因为oracle不支持并发
LeetCode 301. Remove Invalid Parentheses BFS
【无标题】
How does flinksql write that the value of redis has only the last field?
用 PySpark ML 构建机器学习模型
Thread.sleep, Thread.yield 作用解释
成为黑客不得不学的语言,看完觉得你们还可吗?
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
老博的往事
释放高通量算力价值潜能 JASMINER持续领跑 Web3 市场
如何在不同场景下选择合适的示波器探头
栈与队列 | 用栈实现队列 | 用队列实现栈 | 基础理论与代码原理
2022G3 Boiler Water Treatment Exam Mock 100 Questions and Mock Exam
flex related
EasyGBS连接mysql数据库提示“can’t connect to mysql server”,该如何解决?
深度学习之-01
