fix: separate monitor pause and stabilize RGB edges

This commit is contained in:
way
2026-09-27 13:49:09 +08:00
parent 08c00aa370
commit cd9bdd5970
6 changed files with 42 additions and 18 deletions
+12 -6
View File
@@ -210,7 +210,9 @@ def load_cfg():
if c.has_section("services"):
for label,target in c["services"].items():
target=target.strip()
if target and not target.startswith("#"): watches.append(("service",label.upper(),target))
paused=c.getboolean("service_monitor_disabled",label,fallback=False)
if target and not target.startswith("#") and not paused:
watches.append(("service",label.upper(),target))
if c.has_section("processes"):
for label,target in c["processes"].items():
target=target.strip()
@@ -666,7 +668,8 @@ class DisplayController:
}
def _rgb_worker(self):
previous_error=None; applied_mode="OFF"; applied_flash=False; animation_started=time.monotonic()
previous_error=None; applied_mode="OFF"; applied_flash=False
flash_on=None; animation_started=time.monotonic()
while not self.stop_event.is_set():
try:
with self.lock: wanted_mode=self.current_rgb_mode
@@ -683,6 +686,7 @@ class DisplayController:
else: raise ValueError(f"unsupported RGB mode: {wanted_mode}")
log("INFO","RGB_MODE",old=applied_mode,new=wanted_mode)
applied_mode=wanted_mode; animation_started=time.monotonic()
flash_on=True if wanted_mode.endswith("_FLASH") else None
applied_flash=applied_mode.endswith("_FLASH")
if applied_flash:
elapsed_ms=(time.monotonic()-animation_started)*1000.0
@@ -691,10 +695,12 @@ class DisplayController:
elif "_CRITICAL_" in applied_mode: on_ms,off_ms=CRITICAL_FLASH
else: on_ms,off_ms=WARNING_FLASH
on=elapsed_ms%(on_ms+off_ms)<on_ms
with bus_lock:
if applied_mode=="NORMAL_FLASH":
rgb_static(NORMAL_COLOR,"normal_flash_on") if on else rgb_off()
else: rgb_flash(applied_mode,on)
if on!=flash_on:
with bus_lock:
if applied_mode=="NORMAL_FLASH":
rgb_static(NORMAL_COLOR,"normal_flash_on") if on else rgb_off()
else: rgb_flash(applied_mode,on)
flash_on=on
if previous_error is not None: log("INFO","RGB_RECOVERED")
previous_error=None
except Exception as e: