fix: confirm OLED alert count updates

This commit is contained in:
way
2026-09-27 23:52:27 +08:00
parent b5314f944d
commit 7b3b5907c7
3 changed files with 17 additions and 5 deletions
+14 -2
View File
@@ -167,10 +167,11 @@ class Controller:
self.stop_event.wait(1)
def oled_loop(self):
last=None;last_time=0
last=None;last_time=0;last_alert_ids=None
while not self.stop_event.is_set():
try:
v=self.view();page=v['page'];system=v['system'];network=v['network'];home=False
alert_ids=tuple(a['id'] for a in v['alerts'])
if page=='NORMAL_HOME':
home=True
ip=network.get('ip','NO IP');label=network.get('ip_label','IP4')
@@ -189,7 +190,18 @@ class Controller:
lines=[(a['title'],f"{index}/{len(v['alerts'])}"),(a['l2'],''),(a['l3'],''),(a['l4'],'')]
state=(lines,home)
if state!=last or self.clock()-last_time>=v['config']['oled']['refresh_seconds']:
self.driver.oled(lines,home);last=state;last_time=self.clock()
self.driver.oled(lines,home)
# Alert recovery changes only a few header pixels (for
# example 1/2 -> 1/1). Confirm that rare topology change
# with a second complete frame: during undervoltage an
# OLED transfer can be only partly applied without an
# I2C exception being reported by the controller.
if last_alert_ids is not None and alert_ids!=last_alert_ids:
self.stop_event.wait(.05)
if not self.stop_event.is_set():self.driver.oled(lines,home)
last=state
last_time=self.clock()
last_alert_ids=alert_ids
self.recovered('oled')
except Exception as exc:self.error('oled',exc)
self.stop_event.wait(.1)
+1 -1
View File
@@ -3,7 +3,7 @@ import configparser
import math
from pathlib import Path
VERSION = "1.0.0"
VERSION = "1.0.1"
PLUGIN_ID = "yahboom-cooling-hat"
COLORS = {"red":0,"green":1,"blue":2,"yellow":3,"purple":4,"cyan":5,"white":6}
EFFECTS = {"flow":0,"breathe":1,"marquee":2,"rainbow":3,"colorful":4}