docs: simplify pairing confirm, auto-detect sensor type and select suffix only
This commit is contained in:
@@ -79,74 +79,51 @@ void Key_Scan_Process(void) {
|
||||
}
|
||||
```
|
||||
|
||||
### 2.2 事件异步处理与分发 (Process_System_Event 示例)
|
||||
### 2.2 事件解调与微调分配分发 (Process_System_Event 示例)
|
||||
在主循环事件分发中,对各个状态下的事件进行处理:
|
||||
```c
|
||||
void Process_System_Event(KeyEvent evt) {
|
||||
switch (current_state) {
|
||||
case STATE_MENU:
|
||||
if (evt == KEY_UP_SHORT) {
|
||||
// 菜单滚动
|
||||
if (menu_index > 0) menu_index--;
|
||||
Redraw = 1;
|
||||
} else if (evt == KEY_DOWN_SHORT) {
|
||||
if (menu_index < 3) menu_index++;
|
||||
Redraw = 1;
|
||||
} else if (evt == KEY_CONFIRM_CLICK) {
|
||||
// 点击确认进入选中分支
|
||||
Enter_Menu_Branch(menu_index);
|
||||
} else if (evt == KEY_CONFIRM_LONG) {
|
||||
// 长按 3 秒退出菜单返回时钟待机
|
||||
current_state = STATE_CLOCK;
|
||||
Redraw = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_PAIR_CONFIRM:
|
||||
if (confirm_edit_focus == 0) {
|
||||
// 第一步:编辑传感器类型
|
||||
if (evt == KEY_UP_SHORT) {
|
||||
if (selected_type < 6) selected_type++;
|
||||
else selected_type = 0;
|
||||
Redraw = 1;
|
||||
} else if (evt == KEY_DOWN_SHORT) {
|
||||
if (selected_type > 0) selected_type--;
|
||||
else selected_type = 6;
|
||||
Redraw = 1;
|
||||
} else if (evt == KEY_CONFIRM_CLICK) {
|
||||
// 点击确认,锁定类型,跳入第二步选择序号
|
||||
confirm_edit_focus = 1;
|
||||
Redraw = 1;
|
||||
}
|
||||
} else if (confirm_edit_focus == 1) {
|
||||
// 第二步:编辑序号后缀
|
||||
if (evt == KEY_UP_SHORT) {
|
||||
if (selected_suffix < 99) selected_suffix++;
|
||||
Redraw = 1;
|
||||
} else if (evt == KEY_DOWN_SHORT) {
|
||||
if (selected_suffix > 1) selected_suffix--;
|
||||
Redraw = 1;
|
||||
} else if (evt == KEY_CONFIRM_CLICK) {
|
||||
// 点击确认,完成最终写入保存,返回时钟
|
||||
Add_Sensor(captured_addr, selected_type, selected_suffix);
|
||||
current_state = STATE_CLOCK;
|
||||
Redraw = 1;
|
||||
}
|
||||
}
|
||||
// 长按 CONFIRM 3 秒退出不保存
|
||||
if (evt == KEY_CONFIRM_LONG) {
|
||||
// 直接进行后缀序号微调 (传感器类型已由射频数据码自动识别并锁定)
|
||||
if (evt == KEY_UP_SHORT) {
|
||||
if (selected_suffix < 99) selected_suffix++;
|
||||
Redraw = 1;
|
||||
} else if (evt == KEY_DOWN_SHORT) {
|
||||
if (selected_suffix > 1) selected_suffix--;
|
||||
Redraw = 1;
|
||||
} else if (evt == KEY_CONFIRM_CLICK) {
|
||||
// 点击 CONFIRM,直接将自动解析的类型和调整好的序号写入数据库
|
||||
Add_Sensor(captured_addr, auto_detected_type, selected_suffix);
|
||||
current_state = STATE_CLOCK;
|
||||
Redraw = 1;
|
||||
} else if (evt == KEY_CONFIRM_LONG) {
|
||||
// 长按 3 秒放弃保存返回时钟
|
||||
current_state = STATE_CLOCK;
|
||||
Redraw = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case STATE_IPC_BIND:
|
||||
// IPC 绑定连发状态中支持物理长按退出
|
||||
if (evt == KEY_CONFIRM_LONG || evt == KEY_DOWN_LONG) {
|
||||
current_state = STATE_CLOCK;
|
||||
Redraw = 1;
|
||||
} else if (evt == KEY_CONFIRM_CLICK) {
|
||||
// 重发绑定信号
|
||||
EV1527_Transmit(bracelet_factory_id, 0x01);
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user