初始提交卡包 USB 工程
纳入固件源码、屏幕组件、nand_xfer 工具和文档。忽略本机构建产物、sdkconfig,以及含本机路径的依赖锁。 Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -0,0 +1,182 @@
|
||||
#include "ui_nav.h"
|
||||
|
||||
#include "ui.h"
|
||||
#include "LVGL/lvgl_init.h"
|
||||
#include "LVGL/lvgl_lottie.h"
|
||||
#include "remapping.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
extern lv_obj_t *ui_Screen_Lottie;
|
||||
// 外部声明:正念状态标志和当前表情ID
|
||||
extern volatile bool g_mindfulness_active;
|
||||
extern uint16_t current_emoji_action_id;
|
||||
|
||||
static lv_obj_t **nav_get_page_by_idx(int idx)
|
||||
{
|
||||
static lv_obj_t *page_list[6];
|
||||
|
||||
page_list[0] = ui_Screen_Lottie;
|
||||
page_list[1] = guider_ui.screen_home_weather;
|
||||
page_list[2] = guider_ui.screen_time;
|
||||
page_list[3] = guider_ui.screen_pull_down;
|
||||
page_list[4] = guider_ui.screen_component;
|
||||
page_list[5] = guider_ui.screen_zodiacs;
|
||||
|
||||
if (idx < 0 || idx > 5) {
|
||||
return NULL;
|
||||
}
|
||||
return &page_list[idx];
|
||||
}
|
||||
|
||||
static void nav_load_screen_if_needed(lv_obj_t *target, lv_screen_load_anim_t anim_type)
|
||||
{
|
||||
if (target == NULL) {
|
||||
return;
|
||||
}
|
||||
if (lv_screen_active() == target) {
|
||||
return;
|
||||
}
|
||||
lv_screen_load_anim(target, anim_type, 150, 0, false);
|
||||
}
|
||||
|
||||
/** Same state as after ui_nav_go_by_index, without loading a screen. */
|
||||
static void nav_apply_index_chrome(int idx)
|
||||
{
|
||||
current_page_idx = idx;
|
||||
if (idx == 0) {
|
||||
is_ui_mode = false;
|
||||
if (current_lottie && lv_obj_is_valid(current_lottie)) {
|
||||
lv_obj_remove_flag(current_lottie, LV_OBJ_FLAG_HIDDEN);
|
||||
lv_anim_t *a = lv_lottie_get_anim(current_lottie);
|
||||
if (a) {
|
||||
lv_anim_resume(a);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
is_ui_mode = true;
|
||||
if (current_lottie && lv_obj_is_valid(current_lottie)) {
|
||||
lv_anim_t *a = lv_lottie_get_anim(current_lottie);
|
||||
if (a) {
|
||||
lv_anim_pause(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (idle_timer) {
|
||||
lv_timer_pause(idle_timer);
|
||||
}
|
||||
}
|
||||
|
||||
void ui_nav_interrupt_mindfulness_for_gesture(void)
|
||||
{
|
||||
if (!g_mindfulness_active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGI("ui_nav", "手势切页检测到正念状态,结束正念表情播放");
|
||||
|
||||
/* 仅在确认为正念播放态时,才发送切默认请求。 */
|
||||
if (current_emoji_action_id == emoji_event_mindfulness)
|
||||
{
|
||||
ESP_LOGI("ui_nav", "正在播放正念表情,通知切换到默认表情");
|
||||
reset_all_playback_state();
|
||||
extern char g_play_lottie_path[128];
|
||||
extern const char *default_emoji_path;
|
||||
strncpy(g_play_lottie_path, default_emoji_path, sizeof(g_play_lottie_path) - 1);
|
||||
g_play_lottie_path[sizeof(g_play_lottie_path) - 1] = '\0';
|
||||
if (change_task_handle != NULL)
|
||||
{
|
||||
xTaskNotify(change_task_handle, (uint32_t)NOTIFY_PLAY_BY_PATH, eSetValueWithOverwrite);
|
||||
}
|
||||
}
|
||||
|
||||
g_mindfulness_active = false;
|
||||
}
|
||||
|
||||
void ui_nav_go_by_index(int new_idx, lv_screen_load_anim_t anim_type)
|
||||
{
|
||||
lv_obj_t **target_ptr = nav_get_page_by_idx(new_idx);
|
||||
if (!target_ptr || (new_idx != 0 && *target_ptr == NULL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
nav_apply_index_chrome(new_idx);
|
||||
nav_load_screen_if_needed(*target_ptr, anim_type);
|
||||
}
|
||||
|
||||
void ui_nav_load_scr_animation(lv_ui *ui, lv_obj_t **new_scr, bool new_scr_del, bool *old_scr_del,
|
||||
ui_setup_scr_t setup_scr, lv_screen_load_anim_t anim_type,
|
||||
uint32_t time, uint32_t delay, bool is_clean, bool auto_del,
|
||||
int16_t page_idx_after)
|
||||
{
|
||||
ui_load_scr_animation(ui, new_scr, new_scr_del, old_scr_del, setup_scr, anim_type, time, delay, is_clean,
|
||||
auto_del);
|
||||
|
||||
if (page_idx_after < 0 || page_idx_after > 5) {
|
||||
return;
|
||||
}
|
||||
if (new_scr == NULL || *new_scr == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
nav_apply_index_chrome((int)page_idx_after);
|
||||
}
|
||||
|
||||
void ui_nav_apply_wake_to_lottie_home(void)
|
||||
{
|
||||
current_page_idx = 0;
|
||||
is_ui_mode = false;
|
||||
if (current_lottie && lv_obj_is_valid(current_lottie)) {
|
||||
lv_obj_remove_flag(current_lottie, LV_OBJ_FLAG_HIDDEN);
|
||||
lv_anim_t *a = lv_lottie_get_anim(current_lottie);
|
||||
if (a) {
|
||||
lv_anim_resume(a);
|
||||
}
|
||||
}
|
||||
if (idle_timer) {
|
||||
lv_timer_pause(idle_timer);
|
||||
}
|
||||
if (ui_Screen_Lottie && lv_obj_is_valid(ui_Screen_Lottie) && lv_screen_active() != ui_Screen_Lottie) {
|
||||
lv_screen_load(ui_Screen_Lottie);
|
||||
}
|
||||
}
|
||||
|
||||
void ui_nav_calendar_back_to_component(void)
|
||||
{
|
||||
if (guider_ui.screen_component == NULL) {
|
||||
return;
|
||||
}
|
||||
lv_screen_load_anim(guider_ui.screen_component, LV_SCR_LOAD_ANIM_MOVE_RIGHT, 150, 0, true);
|
||||
nav_apply_index_chrome(UI_IDX_COMPONENTS);
|
||||
}
|
||||
|
||||
void ui_nav_load_sortition_text_fade(void)
|
||||
{
|
||||
if (guider_ui.screen_sortition_text == NULL || !lv_obj_is_valid(guider_ui.screen_sortition_text)) {
|
||||
return;
|
||||
}
|
||||
lv_screen_load_anim(guider_ui.screen_sortition_text, LV_SCR_LOAD_ANIM_FADE_ON, 150, 0, false);
|
||||
}
|
||||
|
||||
void ui_nav_load_fortune_text_fade(void)
|
||||
{
|
||||
if (guider_ui.screen_fortune_text == NULL || !lv_obj_is_valid(guider_ui.screen_fortune_text)) {
|
||||
return;
|
||||
}
|
||||
lv_screen_load_anim(guider_ui.screen_fortune_text, LV_SCR_LOAD_ANIM_FADE_ON, 150, 0, false);
|
||||
}
|
||||
|
||||
void ui_nav_request_emoji_event(uint32_t emoji_event_bits)
|
||||
{
|
||||
if (change_task_handle == NULL) {
|
||||
return;
|
||||
}
|
||||
(void)xTaskNotify(change_task_handle, emoji_event_bits, eSetValueWithOverwrite);
|
||||
}
|
||||
|
||||
void ui_change_page(int new_idx, lv_screen_load_anim_t anim_type)
|
||||
{
|
||||
ui_nav_go_by_index(new_idx, anim_type);
|
||||
}
|
||||
Reference in New Issue
Block a user