```
feat(BSP): 添加WiFi模块MQTT连接优化和SNTP配置改进 - 添加SNTP配置标志位,确保只在首次连接时配置SNTP,避免重复重启模块 - 实现MQTT断线重连机制,支持持续运行和自动重连 - 增加SNTP时间查询频率控制,避免频繁查询导致性能问题 - 添加连接状态检测和心跳机制,超时自动重连 - 优化LCD时间显示界面,分别显示时分和年月日信息 - 调整LCD页面刷新策略,时间页面30秒刷新一次以节省资源 ```
This commit is contained in:
@@ -256,14 +256,21 @@ void LCD_Task(void *argument)
|
||||
WIFI_Get_SNTP_Time();
|
||||
now = WIFI_Get_Current_Time();
|
||||
if (now.valid) {
|
||||
snprintf(display_str, sizeof(display_str), "%02d:%02d:%02d", now.hour,
|
||||
now.minute, now.second);
|
||||
// 显示时间(大字体,只显示时:分,不显示秒)
|
||||
snprintf(display_str, sizeof(display_str), "%02d:%02d", now.hour, now.minute);
|
||||
ST7735_WriteString(25, 20, display_str, &Font_16x26, text_color, bg_color);
|
||||
|
||||
// 显示年月日(小字体,向下移动并居中)
|
||||
snprintf(display_str, sizeof(display_str), "%04d-%02d-%02d", now.year,
|
||||
now.month, now.day);
|
||||
ST7735_WriteString(20, 60, display_str, &Font_7x10, ST7735_CYAN, bg_color);
|
||||
} else {
|
||||
snprintf(display_str, sizeof(display_str), "--:--:--");
|
||||
ST7735_WriteString(25, 20, "--:--", &Font_16x26, text_color, bg_color);
|
||||
ST7735_WriteString(20, 60, "----/--/--", &Font_7x10, ST7735_CYAN, bg_color);
|
||||
}
|
||||
ST7735_WriteString(10, 20, display_str, &Font_16x26, text_color, bg_color);
|
||||
} else {
|
||||
ST7735_WriteString(10, 20, "--:--:--", &Font_16x26, text_color, bg_color);
|
||||
ST7735_WriteString(25, 20, "--:--", &Font_16x26, text_color, bg_color);
|
||||
ST7735_WriteString(20, 60, "----/--/--", &Font_7x10, ST7735_CYAN, bg_color);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -336,7 +343,22 @@ void LCD_Task(void *argument)
|
||||
break;
|
||||
}
|
||||
|
||||
osDelay(1000);
|
||||
// 记录当前页面
|
||||
LCD_Page_t displayed_page = current_page;
|
||||
|
||||
// 根据当前页面设置不同的刷新间隔
|
||||
if (current_page == LCD_PAGE_TIME || current_page == LCD_PAGE_SYSTEM_STATUS) {
|
||||
// 时间页面和系统状态页面:30秒刷新一次,但每100ms检查一次是否需要切换页面
|
||||
for (int i = 0; i < 300; i++) {
|
||||
if (current_page != displayed_page) {
|
||||
break; // 检测到页面切换,立即跳出
|
||||
}
|
||||
osDelay(100); // 每100ms检查一次,总共30秒
|
||||
}
|
||||
} else {
|
||||
// 其他页面:1秒刷新一次
|
||||
osDelay(1000);
|
||||
}
|
||||
}
|
||||
/* USER CODE END LCD_Task */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user