feat: 长按返回键2s开关机功能

- 开机: 长按返回键2s开机,显示左侧Logo+右侧'Starting...'开机画面2秒
- 关机: 主页未连接接收机时长按返回键2s关机
  - 关闭OLED/LED/PWM/NRF24L01/USB/外设时钟 → STOP休眠
  - 唤醒后自动复位重启
- 已连接接收机时屏蔽关机,防止飞行中误操作
- 添加 Input_IsKeyHeldFor() 指定时长按键检测
- 添加 OLED_Off() 关闭显示
- 更新 README.md 文档
This commit is contained in:
2026-06-25 23:19:31 +08:00
parent 89ca25c52d
commit f3df7276b2
8 changed files with 86 additions and 8 deletions

View File

@@ -147,6 +147,14 @@ uint8_t Input_IsKeyHeld(uint8_t key) {
return (key_state[key] == KEY_STATE_HOLD) ? 1 : 0;
}
uint8_t Input_IsKeyHeldFor(uint8_t key, uint32_t ms) {
if (key > 3) return 0;
/* 按键按下且按住时间 >= ms */
if (key_current[key] && (sys_tick_ms - key_press_time[key] >= ms))
return 1;
return 0;
}
uint8_t Input_IsKeyReleased(uint8_t key) {
if (key > 3) return 0;
if (key_state[key] == KEY_STATE_RELEASE) {