初始提交卡包 USB 工程

纳入固件源码、屏幕组件、nand_xfer 工具和文档。忽略本机构建产物、sdkconfig,以及含本机路径的依赖锁。

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
zhengxin
2026-10-13 21:54:50 +08:00
co-authored by Cursor
commit 851e347cf5
260 changed files with 269349 additions and 0 deletions
File diff suppressed because it is too large Load Diff
+103
View File
@@ -0,0 +1,103 @@
#ifndef __LVGL_INIT_H__
#define __LVGL_INIT_H__
#include "config.h"
#define extraflash_flag (1 << 0)
#define NOTIFY_EXIT_ALL_MODES 0xFFFE
/* 下载成功后按路径播放:request_play_lottie_path 写入路径,change_task 收到 0xFFFF 时从此缓冲区取路径播放 */
#define NOTIFY_PLAY_BY_PATH 0xFFFF
/* 动画完成回调中不能持锁切换,由 change_task 延迟执行 */
#define NOTIFY_RESUME_MUSIC_LOOP 0xFFFC
#define NOTIFY_MUSIC_INTRO_DONE 0xFFFB
#define NOTIFY_SENTINEL_DO_SWITCH 0xFFFA
#define NOTIFY_SWITCH_BY_QUEUE 0xFFF9
#define NOTIFY_MUSIC_LISTEN_ANOTHER_PASS 0xFFF8
#define NOTIFY_MUSIC_REPLAY_INTRO 0xFFF7
#define NOTIFY_ACTION_QUEUE_READY 0xFFF6
#define NOTIFY_RESUME_CALLING_LOOP 0xFFF5
/* 通话中插播表情时收到挂断:等插播播完后由 completed_cb 通知,再回默认 */
#define NOTIFY_DEFERRED_HANGUP 0xFFF4
#define NOTIFY_START_AI_RESPOND_LOOP 0xFFF3
#define NOTIFY_RESUME_AI_RESPOND_LOOP 0xFFF2
#define LOTTIE_BUF_SIZE (LOTTIE_ANIM_WIDTH * LOTTIE_ANIM_HEIGHT * 4)
extern char *lottie_file_path;
extern int lottie_id;
extern int last_lottie_id;
/* 系统主初始化流程完成标志:true 后才允许处理 BLE 业务指令 */
extern volatile bool g_system_init_done;
/** BLE play_sticker 正在展示表情时置 true,回到默认等场景清 false;IMU 幸运表情需检查此标志 */
extern volatile bool g_ble_play_sticker_active;
/* BLE play_sticker 单槽覆盖队列:播放中收到新指令时,仅保留最后一条,待当前动画播完后切换 */
extern volatile bool g_ble_play_sticker_pending_valid;
extern volatile uint16_t g_ble_play_sticker_pending_action_id;
extern volatile uint8_t g_ble_play_sticker_pending_direction;
/* KTV 持续循环播放态标志(用于 BLE 直通插播判断) */
extern volatile bool g_is_ktv_playing;
extern bool back2default;
extern bool first_display;
extern StackType_t *main_task_stack;
extern StaticTask_t main_task_tcb;
extern _lock_t lvgl_api_lock;
extern esp_lcd_panel_handle_t panel_handle;
extern esp_lcd_panel_io_handle_t io_handle;
extern const qspi_amoled_lcd_init_cmd_t lcd_init_cmds[9];
extern volatile char g_target_path[32];
extern TaskHandle_t change_task_handle;
/** 当前任务是否为 LVGL port 任务(该任务上调用 LVGL API 时通常已持有 lvgl_api_lock) */
bool lvgl_port_task_is_current(void);
extern esp_lcd_panel_handle_t panel_handle;
extern const char *lottie_files[];
extern int64_t last_activity_timestamp;
extern bool block_auto_sleep;
/** 表情包下载流程进行中:收到新的下载指令时应忽略(避免并发) */
extern volatile bool g_emoji_download_in_progress;
/** 刷新自动休眠空闲时间戳(触摸、BLE 指令等) */
void system_keep_alive(void);
/** 设置是否阻止自动休眠(OTA / 配网等场景使用) */
void set_block_auto_sleep(bool block);
typedef struct
{
wakenet_state_t wakenet_mode;
esp_mn_state_t state;
int command_id;
} sr_result_t;
void set_lottie_id(int id);
void lottie_init(void);
esp_err_t app_sr_init(void);
esp_err_t app_lcd_init(void);
esp_err_t app_lvgl_init(void);
esp_err_t app_change_init(void);
esp_err_t BMI_init(void);
void switch_lottie_animation(int anim_index);
void load_brightness_from_nvs(void);
/** 将设置页亮度滑条与 get_system_brightness_percent() 对齐;可从任意任务调用,内部经 lv_async_call 投递到 LVGL 线程 */
void request_brightness_slider_sync(void);
esp_err_t app_touch_init(void);
void switch_lottie_animation_cross_path(const char *emoji_path);
void random_emoji(uint16_t n);
void request_play_lottie_path(const char *path);
void set_current_lottie_range_ratio(float start_ratio, float end_ratio);
void lvgl_deinit_for_wifi(void);
/* 向 change_task 投递 BLE 动作指令(队列化,避免与音乐内部通知互相覆盖) */
bool change_task_post_action(uint16_t action_id);
/** 获取当前正在展示的 Lottie 路径(升级快照等场景使用) */
const char *lvgl_get_current_lottie_path(void);
/** 清空当前路径缓存(用于强制重播同一路径) */
void lvgl_clear_current_lottie_path(void);
void lottie_anim_completed_cb(lv_anim_t *anim);
bool example_notify_lvgl_flush_ready(esp_lcd_panel_io_handle_t panel_io, esp_lcd_panel_io_event_data_t *edata, void *user_ctx);
#endif
File diff suppressed because it is too large Load Diff
+40
View File
@@ -0,0 +1,40 @@
#ifndef __LVGL_LOTTIE_H__
#define __LVGL_LOTTIE_H__
#include "config.h"
extern lv_obj_t *ui_Screen_Lottie;
extern lv_obj_t *g_music_preload_lottie;
extern uint8_t *g_music_preload_fb;
extern char g_music_preload_path[];
extern bool g_music_preload_ready;
extern bool resume_music_loop_after_oneshot; /* 持续播放音乐时收到其他指令,播完该指令一次后切回音乐段 */
extern bool resume_calling_loop_after_oneshot; /* 通话循环段被插播时,插播播完后恢复 20%-80% 循环 */
void handle_normal_sticker(uint16_t action_id, const char *path_to_play, int *last_active_page_ptr);
bool handle_play_music(uint16_t action_id, const char *path_to_play, int *last_active_page_ptr);
bool handle_sentinel_mode(uint16_t action_id, const char *path_to_play, int *last_active_page_ptr);
void reset_all_playback_state(void);
void switch_to_default_emoji(void);
bool handle_stop_music(uint16_t action_id, int *last_active_page_ptr);
bool handle_internal_commands(uint32_t bits, int *last_active_page_ptr);
void clear_music_preload(void);
void try_preload_music_listen_lottie(const char *path);
void set_current_lottie_range_time(float start_s, float end_s);
/** 通话接听后处于循环段时为 true;与 is_playing_music 类似,供 BLE 直通打断 pending */
bool lvgl_lottie_calling_active_for_ble(void);
/** AI 回复循环态(conversation.json)时为 true,供 BLE 持续态直通判断 */
bool lvgl_lottie_ai_respond_loop_active_for_ble(void);
/** play_sticker 是否跳过电机:仅 AI 循环内 0x0045、及 direction==0+resume/循环态(误回中);同向重复由 motor 层处理 */
bool lvgl_lottie_should_skip_play_sticker_motor(uint16_t action_id, uint8_t direction);
/** 正念 breath 两遍播放窗口内返回 true;BLE 侧据此丢弃所有指令 */
bool lvgl_lottie_mindfulness_block_ble_for_ble(void);
/** lottie_anim_completed_cb 内优先调用:若存在「插播中挂起的挂断」,则通知 change_task 回默认并返回 true */
bool lvgl_lottie_completed_try_deferred_hangup(void);
/** lottie_anim_completed_cb 内调用:若 AI 回复循环被插播,通知恢复并返回 true */
bool lvgl_lottie_completed_try_resume_ai_respond_loop(void);
/** lottie_anim_completed_cb 内调用:若 0x0020/21/2E/2F hearing 段已播完,通知启动 AI 回复循环并返回 true */
bool lvgl_lottie_completed_try_start_ai_respond_loop(void);
#endif
+6
View File
@@ -0,0 +1,6 @@
#include "lvgl_lottie_logic.h"
+6
View File
@@ -0,0 +1,6 @@
#ifndef __LVGL_LOTTIE_LOGIC_H__
#define __LVGL_LOTTIE_LOGIC_H__
#include "lvgl_init.h"
#include "config.h"
#endif
+82
View File
@@ -0,0 +1,82 @@
#include "LVGL/lvgl_src.h"
const char* lottie_files[] =
{
"/extflash/0/default.json", // 默认表情1 √
"/extflash/0/calling.json", // 拨打电话2 √
"/extflash/0/camping.json", // 露营模式3 √
"/extflash/0/charging.json", // 充电中4 √
"/extflash/0/charging-complete.json", // 充电完成5 √
"/extflash/0/cold.json", // 打开冷气6 √
"/extflash/0/guard.json", // 戴上墨镜?7 √
"/extflash/0/hearing.json", // 倾听中8 √
"/extflash/0/hello.json", // 打招呼9 √
"/extflash/0/hot.json", // 打开暖气10 √
"/extflash/0/music.json", // 打开音乐11 √
"/extflash/0/navigation.json", // 导航模式12 √
"/extflash/0/protect.json", // 哨兵模式13 √
"/extflash/0/saftybelt-no.json", // 安全带未系好14 √
"/extflash/0/saftybelt.json", // 安全带已系好15 √
"/extflash/0/snap.json", // 打瞌睡16 √
"/extflash/0/start.json", // 启动17 √
"/extflash/0/turnaround.json", // 左看右看18 √
"/extflash/0/washing.json", // 清洗中19 √
"/extflash/0/welcome.json", // 欢迎20 √
"/extflash/0/window-left.json", // 打开左窗21 √
"/extflash/0/window-right.json", // 打开右窗22 √
"/extflash/0/arrive.json", // 导航到达23 √
"/extflash/0/bless.json", // 抽签24 √
"/extflash/0/break.json", // 急刹车25 √
"/extflash/0/breath.json", // 冥想26 √
"/extflash/0/horoscope.json", // 星座运势27 √
"/extflash/0/money.json", // 颠簸28 √
"/extflash/0/sing.json", // 唱歌29 √
"/extflash/0/speedup.json", // 急加速30 √
"/extflash/0/turnright.json", // 右转弯31 √
"/extflash/0/turnleft.json", // 左转弯32 √
"/extflash/0/helloleft.json", // 打招呼左33 √
"/extflash/0/music-listen.json", // 持续播放音乐34 √
//待机随机表情包
"/extflash/0/tired.json", // 疲劳驾驶tired35 --- 新增12个表情;
"/extflash/0/trafficjam.json", // 堵车 36
"/extflash/0/holiday.json", //假期holiday 37 √
"/extflash/0/calmdown.json", //冷静 38 √
"/extflash/0/becool.json", // 装酷becool 39 --- 新增12个表情; √
"/extflash/0/boring.json", // 无聊boring 40 √
"/extflash/0/cheer.json", // 庆祝cheer 41 √
"/extflash/0/cry.json", // 哭cry 42 √
"/extflash/0/curious.json", // 好奇curious 43 √
"/extflash/0/eating.json", // 吃eating 44 √
"/extflash/0/happy.json", // 高兴happy 45 √
"/extflash/0/like.json", // 喜欢like 46 √
"/extflash/0/liuliuliu.json", // 666🤙🤙🤙 47 √
"/extflash/0/love.json", // 爱心 love 48 √
"/extflash/0/shy.json", // 害羞 shy 49 √
"/extflash/0/thinking.json", // 思考thinking 🤔 50 √
"/extflash/0/autodrive.json", //智能驾驶模式 51 √
"/extflash/0/backhome.json", //回家 52 √
"/extflash/0/outhome.json", //离家 53 √
"/extflash/0/card.json", //智付 刷卡 54 √
"/extflash/0/toofast.json", //超速120 55 √
"/extflash/0/2hours.json", //连续驾驶2小时 56 √
"/extflash/0/trafficlight.json", //交通灯 57 √
"/extflash/0/conversation.json", //AI 语音回答 58 √
"/extflash/0/parktronic.json", //自动泊车 59 √
"/extflash/0/backcar.json", //倒车 60 √
"/extflash/0/distract.json", //分心担忧紧张 61 √
"/extflash/0/deng.json", //大灯 62 √
"/extflash/0/windshield-wiper.json", //雨刮 63 √
"/extflash/0/birthday.json", //生日庆祝 64 √
"/extflash/0/child-lock.json", //儿童锁--上锁 65 √
"/extflash/0/child-unlock.json", //儿童锁--解锁 66 √
"/extflash/0/conversation1.json", //语音回复随机表情1 √
"/extflash/0/conversation2.json", //语音回复随机表情2 √
};
const uint32_t lottie_files_length = sizeof(lottie_files)/sizeof(lottie_files[0]);
+86
View File
@@ -0,0 +1,86 @@
#ifndef __LVGL_SRC_H__
#define __LVGL_SRC_H__
#include <stdint.h>
typedef enum
{
default_emojo = 0, //默认表情 默认表情 1
calling_emojo, //打电话 打电话2
camping_emojo, //露营模式 露营模式3
charging_emojo, //开始充电 开始充电4
charged_over_emojo, //充电完成 充电完成5
cold_air_emojo, //冷风 冷风6
guard_emojo, //墨镜😎哨兵模式 哨兵模式7
hearing_emojo, //聆听 聆听8
hello_emojo, //打招呼 打招呼9
warm_air_emojo, //暖风 暖风10
music_emojo, //播放音乐 播放音乐11
navigation_modle_emojo, //开始导航 开始导航12
protect_emojo, //保护--哨兵模式 左看右看表情13//保护
saftybelt_no_emojo, //未系好安全带 未系好安全带14
saftybelt_emojo, //系安全带 系安全带15
snap_emojo, //小憩模式 小憩模式16
start_emojo, //驾车出发 驾车出发17
turn_around_emojo, //左看右看表情 左看右18
washing_emojo, //洗车模式 洗车模式19
welcome_emojo, //迎宾模式 迎宾模式20
open_left_window_emojo, //主驾开窗 主驾开窗21
open_right_window_emojo, //副驾开窗 副驾开窗22
arrive_emojo, //到达目的地 到达目的地23
bless_emojo, //祈祷🙏 祈祷24
break_emojo, //刹车 刹车25
breath_emojo, //冥想 冥想26
horoscope_emojo, //星座运势 星座运势27
money_emojo, //金币 掉金币28
sing_emojo, //唱歌 唱歌29
speedup_emojo, //超速 超速30
turn_right_emojo, //右转向 右转向31
turn_left_emojo, //左转向 左转向32
hello_left_emojo, //打招呼左 打招呼左33
music_listen_emojo, //持续播放音乐 持续播放音乐34
tried_emojo, //疲劳驾驶 喝咖啡35
trafficjam_emojo, //堵车 🐌 堵车36
holiday_emojo, //假期 假期 庆祝🎉37
calm_down_emojo, //冷静 冷静38
becool_emojo, //装酷 39
boring_emojo, //无聊 40
cheer_emojo, //庆祝 41
cry_emojo, //哭 42
curious_emojo, //好奇 43
eating_emojo, //吃 44
happy_emojo, //高兴 45
like_emojo, //喜欢 46
liuliuliu_emojo, //666 47
love_emojo, //爱心 48
shy_emojo, //害羞 49
thinking_emojo, //思考 50
autodrive_emojo, //智能驾驶模式 智能驾驶模式51
backhome_emojo, //回家 52
outhome_emojo, //离家 53
card_emojo, //智付 刷卡 54
toofast_emojo, //超速120 55
_2h_emojo, //连续驾驶2小时 56
traffic_light_emojo, //红绿灯 57
AI_respond_emojo, //AI 回复 58
auto_parking_emojo, //自动泊车 59
back_car_emojo, //倒车 60
distract_emojo, //分心担忧紧张 61
deng_emojo, //大灯 62
windshield_wiper_emojo, //雨刮 63
birthday_emojo, //生日庆祝 64
child_lock_emojo, //儿童锁--上锁 65
child_unlock_emojo, //儿童锁--解锁 66
conversation1_emojo, //语音回复随机表情1 67
conversation2_emojo, //语音回复随机表情2 68
}LOTTIE_FILES;
extern const char* lottie_files[];
extern const uint32_t lottie_files_length;
#endif