refactor(app): App-per-screen navigation, remove menu_level entirely

Splits the ad-hoc menu_level state machine into standalone Apps with a
uniform parent/child exit convention (long-press CONFIRM -> parent):
clock_app renamed to home_app (boot-default), new set_clock_app
extracted from home_app's time-edit mode, new ipc_bind_app extracted
from menu_app's old level-2 screen, and the sensor-type selection step
merged into pair_app as its new initial state. menu_app now only holds
the 4-item top-level list (language toggle inline). Also makes both
menu_app and pair_app's up/down navigation cyclic (wraps at both ends).
This commit is contained in:
edisondeng
2026-07-31 18:05:23 +08:00
parent 655d29bbe1
commit 56b92a8ede
13 changed files with 462 additions and 393 deletions

View File

@@ -15,7 +15,7 @@
SystemState current_state = STATE_NORMAL; // 系统整体的当前运行状态,默认为正常时钟待机页
u8 menu_select = 0; // 主菜单当前选中的行高亮索引 (0~2)
u8 menu_select = 0; // 当前菜单高亮的选中项索引 (menu_app 0~3pair_app 传感器类型选择 0~4)
u32 captured_addr = 0; // 配对或报警时,捕获到的传感器 24 位 EV1527 射频物理地址
u8 captured_type = 0; // 正在对码或触发警报的传感器设备类型 (0:门磁, 1:PIR...)
u8 alarm_sensor_slot = 0; // 触发警报的传感器在 sensor_list 数组中的索引槽位号
@@ -162,21 +162,21 @@ void Debug_ProcessCommand(char cmd)
}
} else if (cmd == '1') {
// 模拟切换至 正常撤防 (NORMAL) 状态并刷新时钟
if (AppManager_GetActiveAppID() == APP_ID_CLOCK) {
if (AppManager_GetActiveAppID() == APP_ID_HOME) {
current_state = STATE_NORMAL;
UI_ShowClockPage(current_state, current_hour, current_min);
}
Uart_SendString("[UART] State: NORMAL\r\n");
} else if (cmd == '2') {
// 模拟切换至 已布防 (ARMED) 状态,普通门磁可触发警报
if (AppManager_GetActiveAppID() == APP_ID_CLOCK) {
if (AppManager_GetActiveAppID() == APP_ID_HOME) {
current_state = STATE_ARMED;
UI_ShowClockPage(current_state, current_hour, current_min);
}
Uart_SendString("[UART] State: ARMED\r\n");
} else if (cmd == '3') {
// 模拟切换至 已撤防 (DISARMED) 状态,忽略普通报警
if (AppManager_GetActiveAppID() == APP_ID_CLOCK) {
if (AppManager_GetActiveAppID() == APP_ID_HOME) {
current_state = STATE_DISARMED;
UI_ShowClockPage(current_state, current_hour, current_min);
}
@@ -267,7 +267,7 @@ void main(void)
/* 步骤 1: 初始化事件环形缓冲区队列 */
EventQueue_Init();
/* 步骤 2+5: 初始化应用管理器并登记所有前台应用,默认加载 ClockApp */
/* 步骤 2+5: 初始化应用管理器并登记所有前台应用,默认加载 HomeApp */
AppManager_Init();
/* 启动并挂载后台射频监控应用,开始侦听无线传感器信号 */
@@ -277,7 +277,7 @@ void main(void)
Timer1_Init();
/* 开机自动加载并运行待机时钟前台活跃应用 */
AppManager_StartApp(APP_ID_CLOCK);
AppManager_StartApp(APP_ID_HOME);
Uart_SendString("[SYS] Event-driven framework ready\r\n");
@@ -309,7 +309,7 @@ void main(void)
current_state = STATE_SLEEP; // 系统置为休眠状态
Enter_Low_Power_Sleep(); // 该函数是阻塞的MCU 将在此挂起。唤醒后将自动从其后继续执行
current_state = STATE_NORMAL; // 唤醒后重新置为正常待机状态
AppManager_StartApp(APP_ID_CLOCK); // 重新开启时钟应用以刷新画面和背光
AppManager_StartApp(APP_ID_HOME); // 重新开启时钟应用以刷新画面和背光
}
}
}