feat:重构空气温度处理并改进UI屏幕切换
- 从vars.c和vars.h中移除了空气温度整型变量及其相关的获取/设置函数 - 更新了FlowGlobalVariables枚举,移除了空气温度整型常量 - 修改了main.c中的UI任务,实现了每3秒切换屏幕的机制 - 清理了app_main函数,移除了空气温度整型的设置,仅保留字符串表示形式
This commit is contained in:
24
main/main.c
24
main/main.c
@@ -56,13 +56,30 @@ static void ui_task(void *arg)
|
||||
{
|
||||
(void)arg;
|
||||
|
||||
uint32_t elapsed_ms = 0;
|
||||
enum ScreensEnum current = SCREEN_ID_TEMPERATURE;
|
||||
const uint32_t switch_period_ms = 3000; // 每3秒切一次
|
||||
|
||||
for (;;)
|
||||
{
|
||||
lvgl_port_lock(0);
|
||||
ui_tick();
|
||||
lvgl_port_unlock();
|
||||
|
||||
// UI 刷新周期无需过高,20ms 兼顾流畅度与CPU占用。
|
||||
elapsed_ms += 20;
|
||||
if (elapsed_ms >= switch_period_ms) {
|
||||
elapsed_ms = 0;
|
||||
|
||||
// 下一个页面:1->2->3->4->1
|
||||
if (current >= _SCREEN_ID_LAST) {
|
||||
current = _SCREEN_ID_FIRST;
|
||||
} else {
|
||||
current = (enum ScreensEnum)(current + 1);
|
||||
}
|
||||
|
||||
loadScreen(current);
|
||||
}
|
||||
|
||||
lvgl_port_unlock();
|
||||
vTaskDelay(pdMS_TO_TICKS(20));
|
||||
}
|
||||
}
|
||||
@@ -192,8 +209,7 @@ void app_main(void)
|
||||
{
|
||||
snprintf(s_air_temp, sizeof(s_air_temp), "%.1f", sensor_data.aht30.temperature_c);
|
||||
set_var_air_temperature(s_air_temp);
|
||||
set_var_air_temperature_int((int32_t)(sensor_data.aht30.temperature_c * 100)); // 以 1°C 为单位的整数
|
||||
|
||||
|
||||
snprintf(s_air_hum, sizeof(s_air_hum), "%.1f", sensor_data.aht30.humidity_rh);
|
||||
set_var_air_humidity(s_air_hum);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user