Files
zhengxinandCursor 851e347cf5 初始提交卡包 USB 工程
纳入固件源码、屏幕组件、nand_xfer 工具和文档。忽略本机构建产物、sdkconfig,以及含本机路径的依赖锁。

Co-authored-by: Cursor <[email protected]>
2026-10-13 21:54:50 +08:00

103 lines
2.7 KiB
C

// main/ui/ui_events.c
#include "ui.h"
#include "ui_nav.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "lvgl.h"
lv_timer_t *idle_timer = NULL;
extern lv_obj_t *ui_Screen_Lottie;
bool is_ai_recording = false; // AI语音交互状态标志
bool is_ai_create_pcmfile = false; // AI语音交互生成pcm文件状态标志
bool is_ai_end_recording = false; // AI语音交互结束录音状态标志
static bool is_switching = false;
// 【解决方案二】正念练习状态标志(外部声明)
extern volatile bool g_mindfulness_active;
void ui_event_gesture_cb(lv_event_t *e)
{
if (lv_event_get_code(e) != LV_EVENT_GESTURE)
return;
if (is_switching)
return;
lv_dir_t dir = lv_indev_get_gesture_dir(lv_indev_get_act());
is_switching = true;
lv_indev_wait_release(lv_indev_get_act());
if (current_page_idx == UI_IDX_PULLDOWN)
{
if (dir == LV_DIR_TOP)
{
ui_nav_interrupt_mindfulness_for_gesture();
ui_nav_go_by_index(0, LV_SCR_LOAD_ANIM_OVER_TOP);
}
goto end;
}
if (current_page_idx == UI_IDX_COMPONENTS)
{
if (dir == LV_DIR_BOTTOM)
{
ui_nav_interrupt_mindfulness_for_gesture();
ui_nav_go_by_index(0, LV_SCR_LOAD_ANIM_OVER_BOTTOM);
}
goto end;
}
if (dir == LV_DIR_BOTTOM)
{
ESP_LOGE("手势","下划");
ui_nav_interrupt_mindfulness_for_gesture();
ui_nav_go_by_index(UI_IDX_PULLDOWN, LV_SCR_LOAD_ANIM_OVER_BOTTOM);
}
else if (dir == LV_DIR_TOP)
{
ESP_LOGE("手势","上划");
ui_nav_interrupt_mindfulness_for_gesture();
ui_nav_go_by_index(UI_IDX_COMPONENTS, LV_SCR_LOAD_ANIM_OVER_TOP);
}
else if (dir == LV_DIR_LEFT)
{
ESP_LOGE("手势","左划");
if (current_page_idx >= 0 && current_page_idx <= 2)
{
int next = (current_page_idx + 1) % 3;
ui_nav_interrupt_mindfulness_for_gesture();
ui_nav_go_by_index(next, LV_SCR_LOAD_ANIM_MOVE_LEFT);
}
}
else if (dir == LV_DIR_RIGHT)
{
ESP_LOGE("手势","右划");
if (current_page_idx >= 0 && current_page_idx <= 2)
{
int next = (current_page_idx - 1 + 3) % 3;
ui_nav_interrupt_mindfulness_for_gesture();
ui_nav_go_by_index(next, LV_SCR_LOAD_ANIM_MOVE_RIGHT);
}
}
end:
vTaskDelay(pdMS_TO_TICKS(100));
is_switching = false;
}
void idle_timer_cb(lv_timer_t *timer)
{
LV_UNUSED(timer);
ui_nav_go_by_index(0, LV_SCR_LOAD_ANIM_FADE_ON);
}
void ui_reset_idle_timer(void)
{
if (is_ui_mode && idle_timer != NULL)
{
lv_timer_reset(idle_timer);
lv_timer_resume(idle_timer);
}
}