fix: confirm OLED alert count updates
This commit is contained in:
+14
-2
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user