feat: 重构项目结构以支持新的用户界面和功能

- 更新 CMakeLists.txt,添加新的源文件和依赖项以支持应用程序结构
- 移除旧的 main.c 和 lvgl_demo_ui.c 文件,整合应用逻辑至 app_main.c
- 新增 app/ui_handlers.c 和 app/ui_handlers.h,准备处理 UI 事件
- 引入 bsp/display.c 和 bsp/touch.c,配置显示和触摸功能
- 添加 services/wifi_manager.c,管理 Wi-Fi 连接
- 组织 UI 组件和资源,提升代码可维护性与可读性
- 更新相关头文件和配置,确保项目兼容性与功能完整性
This commit is contained in:
2026-06-30 19:12:40 +08:00
parent b0ba814625
commit 7dc20b37a8
27 changed files with 567 additions and 646 deletions
+40
View File
@@ -0,0 +1,40 @@
#include "esp_log.h"
#include "nvs_flash.h"
#include "board_config.h"
#include "display.h"
#include "lvgl_port.h"
#include "touch.h"
#include "ui.h"
#include "wifi_manager.h"
static const char *TAG = "app";
void app_main(void)
{
esp_log_level_set("*", ESP_LOG_INFO);
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK(ret);
esp_lcd_panel_io_handle_t io_handle = NULL;
esp_lcd_panel_handle_t panel_handle = NULL;
ESP_ERROR_CHECK(display_init(&io_handle, &panel_handle));
lv_display_t *display = lvgl_port_init(io_handle, panel_handle);
#if BOARD_TOUCH_ENABLED
ESP_ERROR_CHECK(touch_init(display));
#endif
lvgl_port_lock();
ui_init();
lvgl_port_unlock();
ESP_LOGI(TAG, "Starting WiFi");
wifi_manager_init();
}
+4
View File
@@ -0,0 +1,4 @@
#include "ui_handlers.h"
#include "ui_events.h"
/* Add callback implementations here when SquareLine Studio generates events. */
+3
View File
@@ -0,0 +1,3 @@
#pragma once
/* UI event callbacks declared in ui_events.h are implemented in ui_handlers.c */