在主应用中更新显示驱动和 MQTT 主题
- 将显示驱动从 lvgl_st7735s_use 改为 lvgl_st7789_use,在 CMakeLists.txt 和 main.c 中。 - 将 MQTT 警报主题从“topic/alert/esp32_iothome_001”更新为“topic/alert/esp32_iothome_002”。 - 重构 UI 任务,去除周期性屏幕切换逻辑,专注于界面刷新。 - 调整错误处理,使新的显示驱动程序用于错误信息。
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
idf_component_register(SRCS "main.c" "auto_ctrl_thresholds.c" "auto_alerts.c" "status_web.c"
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES wifi-connect mqtt_control esp_lvgl_port lvgl_st7735s_use i2c_master_messager io_device_control console_simple_init console console_user_cmds capactive_soil_moisture_sensor_V2.0 ui esp_app_format
|
||||
REQUIRES wifi-connect mqtt_control esp_lvgl_port lvgl_st7789_use i2c_master_messager io_device_control console_simple_init console console_user_cmds capactive_soil_moisture_sensor_V2.0 ui esp_app_format
|
||||
)
|
||||
|
||||
26
main/main.c
26
main/main.c
@@ -6,7 +6,7 @@
|
||||
#include "esp_check.h"
|
||||
#include "esp_log.h"
|
||||
#include "wifi-connect.h"
|
||||
#include "lvgl_st7735s_use.h"
|
||||
#include "lvgl_st7789_use.h"
|
||||
#include "i2c_master_messager.h"
|
||||
#include "io_device_control.h"
|
||||
#include "console_simple_init.h" // 提供 console_cmd_user_register 和 console_cmd_all_register
|
||||
@@ -62,7 +62,7 @@
|
||||
// I2C 内部上拉使能
|
||||
#define BOTANY_I2C_INTERNAL_PULLUP CONFIG_I2C_MASTER_MESSAGER_ENABLE_INTERNAL_PULLUP
|
||||
// MQTT 告警主题
|
||||
#define BOTANY_MQTT_ALERT_TOPIC "topic/alert/esp32_iothome_001"
|
||||
#define BOTANY_MQTT_ALERT_TOPIC "topic/alert/esp32_iothome_002"
|
||||
// MQTT 遥测数据上报周期(毫秒)
|
||||
#define BOTANY_MQTT_TELEMETRY_PERIOD_MS 5000
|
||||
#define BOTANY_STATUS_WEB_PORT 8080
|
||||
@@ -415,7 +415,7 @@ static void auto_control_update(bool soil_valid,
|
||||
/**
|
||||
* @brief UI 任务函数
|
||||
*
|
||||
* 负责定期切换显示页面(每3秒切换一次)。
|
||||
* 负责定期驱动 UI 刷新。
|
||||
*
|
||||
* @param arg 任务参数(未使用)
|
||||
*/
|
||||
@@ -423,29 +423,11 @@ 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();
|
||||
|
||||
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));
|
||||
}
|
||||
@@ -532,7 +514,7 @@ void app_main(void)
|
||||
{
|
||||
ESP_LOGE(TAG, "I2C 传感器管理启动失败: %s", esp_err_to_name(ret));
|
||||
ESP_LOGW(TAG, "请检查 I2C 引脚/上拉电阻/端口占用情况,系统将继续运行但不采集传感器");
|
||||
ESP_ERROR_CHECK(lvgl_st7735s_set_center_text("I2C init failed"));
|
||||
ESP_ERROR_CHECK(lvgl_st7789_set_center_text("I2C init failed"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user