2024年国庆期间,假期无聊写的程序
主界面
主程序
#include < Arduino.h >
#include "Backend_service.h"
#include "SMG_4.h"
void setup() {
Serial.begin(115200);
SMG_4_Init(); // 初始化数码管显示
connectToWiFi(); // 连接Wi-Fi
initOLED(); // 初始化 OLED
// 初始化 NTP 客户端
timeClient.begin();
// 等待时间同步
while(!timeClient.update()) {
Serial.println("Waiting for NTP time sync...");
delay(1000); // 每秒钟检查一次
}
// 处理网页请求
server.on("/", handleRoot); // 处理根路径
server.on("/setCity", handleSetCity); // 处理设置城市请求
server.on("/time", handleTime); // 处理时间请求
server.on("/weather", handleWeather)