1. 按键驱动重构:GPIO中断+手动去抖 → iot_button组件(单击/双击/长按) 2. 新增key_nav按键导航管理器:上下文状态机 + Set界面焦点蓝色边框高亮 3. 移除所有触摸手势/点击事件(ScreenHome/ScreenImg/ScreenSet) 4. 应援灯颜色切换优化:DISPOFF→直接写GRAM→DISPON,消除分band刷新 5. 亮度调节按键化:BOOT +10% / KEY -10% / KEY长按退出 6. 休眠管理适配:按键唤醒统一由key_nav处理 7. 新增迁移总结文档 docs/touch-to-button-migration.md Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
147 lines
5.4 KiB
C
147 lines
5.4 KiB
C
// This file was generated by SquareLine Studio
|
||
// SquareLine Studio version: SquareLine Studio 1.6.0
|
||
// LVGL version: 8.3.11
|
||
// Project name: Lcd_Pro
|
||
|
||
#include "../ui.h"
|
||
#include "../../pages/include/pages.h" // 引入图片管理函数
|
||
#include "esp_log.h"
|
||
|
||
extern void init_spiffs_image_list(void);
|
||
extern void update_ui_ImgBle(const char *img_name);
|
||
extern void free_spiffs_image_list(void);
|
||
extern const char* get_next_image(void);
|
||
extern const char* get_prev_image(void);
|
||
|
||
lv_obj_t *ui_ScreenImg = NULL;
|
||
lv_obj_t *ui_ImgBle = NULL;
|
||
lv_obj_t *ui_ContainerDle = NULL;
|
||
lv_obj_t *ui_ImageDel = NULL;
|
||
lv_obj_t *ui_ImageReturn = NULL;
|
||
|
||
// 标志:是否首次加载
|
||
static bool first_load = true;
|
||
// 标志:是否需要显示 ContainerDle(只有从 ScreenSet 点击 ImgDelete 时才为 true)
|
||
static bool should_show_container = false;
|
||
|
||
// 显示 ContainerDle
|
||
void ui_ScreenImg_show_delete_container(void) {
|
||
should_show_container = true; // 设置标志,表示需要显示
|
||
if (ui_ContainerDle) {
|
||
lv_obj_clear_flag(ui_ContainerDle, LV_OBJ_FLAG_HIDDEN);
|
||
}
|
||
}
|
||
|
||
// 隐藏 ContainerDle
|
||
void ui_ScreenImg_hide_delete_container(void) {
|
||
should_show_container = false; // 清除标志
|
||
if (ui_ContainerDle) {
|
||
lv_obj_add_flag(ui_ContainerDle, LV_OBJ_FLAG_HIDDEN);
|
||
}
|
||
}
|
||
|
||
// 触摸点击事件已移除,删除/返回操作由key_nav按键模块统一管理
|
||
|
||
// 界面加载事件:首次进入时初始化图片列表
|
||
void ui_event_ScreenImg( lv_event_t * e) {
|
||
lv_event_code_t event_code = lv_event_get_code(e);
|
||
|
||
if ( event_code == LV_EVENT_SCREEN_LOADED ) {
|
||
if (first_load) {
|
||
first_load = false;
|
||
init_spiffs_image_list();
|
||
const char *first_img = get_current_image();
|
||
if (first_img) {
|
||
update_ui_ImgBle(first_img);
|
||
} else {
|
||
ESP_LOGI("ScreenImg", "SPIFFS无可用图片,显示默认UI图片");
|
||
}
|
||
}
|
||
|
||
// 检查是否需要显示 ContainerDle(从Set删除图标进入时)
|
||
if (should_show_container) {
|
||
should_show_container = false;
|
||
} else {
|
||
ui_ScreenImg_hide_delete_container();
|
||
}
|
||
}
|
||
|
||
// 手势事件已移除,界面导航由key_nav按键模块统一管理
|
||
}
|
||
|
||
// build funtions
|
||
|
||
void ui_ScreenImg_screen_init(void)
|
||
{
|
||
ui_ScreenImg = lv_obj_create(NULL);
|
||
lv_obj_clear_flag( ui_ScreenImg, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
|
||
|
||
ui_ImgBle = lv_img_create(ui_ScreenImg);
|
||
lv_img_set_src(ui_ImgBle, &ui_img_s1_png);
|
||
lv_obj_set_width( ui_ImgBle, 360);
|
||
lv_obj_set_height( ui_ImgBle, 360);
|
||
lv_obj_set_align( ui_ImgBle, LV_ALIGN_CENTER );
|
||
lv_obj_set_flex_flow(ui_ImgBle,LV_FLEX_FLOW_ROW);
|
||
lv_obj_set_flex_align(ui_ImgBle, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START);
|
||
lv_obj_add_flag( ui_ImgBle, LV_OBJ_FLAG_ADV_HITTEST ); /// Flags
|
||
lv_obj_clear_flag( ui_ImgBle, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
|
||
|
||
ui_ContainerDle = lv_obj_create(ui_ScreenImg);
|
||
lv_obj_remove_style_all(ui_ContainerDle);
|
||
lv_obj_set_width( ui_ContainerDle, 360);
|
||
lv_obj_set_height( ui_ContainerDle, 360); // 圆形容器
|
||
lv_obj_set_x( ui_ContainerDle, 0 );
|
||
lv_obj_set_y( ui_ContainerDle, 240 ); // 向下偏移 240px(显示顶部 1/3)
|
||
lv_obj_set_align( ui_ContainerDle, LV_ALIGN_CENTER );
|
||
lv_obj_clear_flag( ui_ContainerDle, LV_OBJ_FLAG_CLICKABLE | LV_OBJ_FLAG_SCROLLABLE );
|
||
// 设置圆形和裁剪
|
||
lv_obj_set_style_radius(ui_ContainerDle, 180, LV_PART_MAIN); // 圆角半径 180
|
||
lv_obj_set_style_clip_corner(ui_ContainerDle, true, LV_PART_MAIN); // 裁剪圆角外内容
|
||
lv_obj_set_style_bg_color(ui_ContainerDle, lv_color_hex(0x000000), LV_PART_MAIN);
|
||
lv_obj_set_style_bg_opa(ui_ContainerDle, 180, LV_PART_MAIN); // 半透明(180/255 约 70%)
|
||
lv_obj_add_flag( ui_ContainerDle, LV_OBJ_FLAG_HIDDEN ); // 默认隐藏
|
||
|
||
ui_ImageDel = lv_img_create(ui_ContainerDle);
|
||
lv_img_set_src(ui_ImageDel, &ui_img_s13_png);
|
||
lv_obj_set_width( ui_ImageDel, LV_SIZE_CONTENT);
|
||
lv_obj_set_height( ui_ImageDel, LV_SIZE_CONTENT);
|
||
lv_obj_set_x( ui_ImageDel, -60 ); // 左侧位置
|
||
lv_obj_set_y( ui_ImageDel, -120 ); // 容器顶部区域(屏幕底部可见区域)
|
||
lv_obj_set_align( ui_ImageDel, LV_ALIGN_CENTER );
|
||
lv_obj_add_flag( ui_ImageDel, LV_OBJ_FLAG_CLICKABLE ); // 可点击
|
||
lv_obj_clear_flag( ui_ImageDel, LV_OBJ_FLAG_SCROLLABLE );
|
||
|
||
ui_ImageReturn = lv_img_create(ui_ContainerDle);
|
||
lv_img_set_src(ui_ImageReturn, &ui_img_s14_png);
|
||
lv_obj_set_width( ui_ImageReturn, LV_SIZE_CONTENT);
|
||
lv_obj_set_height( ui_ImageReturn, LV_SIZE_CONTENT);
|
||
lv_obj_set_x( ui_ImageReturn, 60 ); // 右侧位置
|
||
lv_obj_set_y( ui_ImageReturn, -120 ); // 容器顶部区域(屏幕底部可见区域)
|
||
lv_obj_set_align( ui_ImageReturn, LV_ALIGN_CENTER );
|
||
lv_obj_add_flag( ui_ImageReturn, LV_OBJ_FLAG_CLICKABLE ); // 可点击
|
||
lv_obj_clear_flag( ui_ImageReturn, LV_OBJ_FLAG_SCROLLABLE );
|
||
|
||
// 触摸点击回调已移除,仅保留界面加载事件用于首次图片初始化
|
||
lv_obj_add_event_cb(ui_ScreenImg, ui_event_ScreenImg, LV_EVENT_ALL, NULL);
|
||
|
||
// 注意:不在此处加载图片,延迟到 LV_EVENT_SCREEN_LOADED 事件中加载
|
||
// 这样避免ui_init()时触发渲染导致开机闪烁
|
||
}
|
||
|
||
void ui_ScreenImg_screen_destroy(void)
|
||
{
|
||
if (ui_ScreenImg) lv_obj_del(ui_ScreenImg);
|
||
|
||
// NULL screen variables
|
||
ui_ScreenImg= NULL;
|
||
ui_ImgBle= NULL;
|
||
ui_ContainerDle= NULL;
|
||
ui_ImageDel= NULL;
|
||
ui_ImageReturn= NULL;
|
||
|
||
// 重置首次加载标志,下次进入时重新初始化
|
||
first_load = true;
|
||
|
||
free_spiffs_image_list();
|
||
}
|