feat: 添加 GPIO 电平检测触发亮屏/息屏
新增 GPIOEventDetector 后台线程,以 50ms 间隔轮询 GPIO 引脚。 检测到电平变化时唤醒屏幕并启动 60 秒倒计时,到期无新变化则息屏。 - 添加 GPIOEventDetector 类,支持 RPi.GPIO 硬读取和 Mock 回退 - 集成到 PadSleepApp 主循环,GPIO 触发优先级高于定时亮屏时段 - TUI 状态面板新增 GPIO 行,显示引脚号和倒计时 - 支持通过配置文件调整引脚号(gpio_pin)和倒计时长度 - install.sh 修复:补装 rpi-lgpio 依赖 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
da8ad4d17d
commit
9940db451f
@@ -434,6 +434,24 @@ class TuiApp:
|
||||
self.stdscr.addstr(f"{s.get('config_path', '?')}", curses.A_DIM)
|
||||
except curses.error:
|
||||
pass
|
||||
|
||||
# ── GPIO 状态 ──
|
||||
gpio_avail = s.get("gpio_available", False)
|
||||
if gpio_avail:
|
||||
y += 1
|
||||
gpio_trig = s.get("gpio_triggered", False)
|
||||
gpio_cnt = s.get("gpio_countdown", 0)
|
||||
trig_text = f"触发中 ⏱ {gpio_cnt}s" if gpio_trig else "等待中"
|
||||
trig_color = 3 if gpio_trig else 2
|
||||
gpio_pin = s.get("gpio_pin", "?")
|
||||
if y < h:
|
||||
self._clear_line(y)
|
||||
try:
|
||||
self.stdscr.addstr(y, 4, "GPIO: ")
|
||||
self.stdscr.addstr(f"BCM {gpio_pin} ", curses.A_DIM)
|
||||
self.stdscr.addstr(f"{trig_text}", curses.color_pair(trig_color) | curses.A_BOLD)
|
||||
except curses.error:
|
||||
pass
|
||||
else:
|
||||
if y < h:
|
||||
self._clear_line(y)
|
||||
|
||||
Reference in New Issue
Block a user