From 53a28cda0cf7676e2197cc7ab0051301d1f0db37 Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak <dos@dosowisko.net> Date: Wed, 4 Oct 2023 02:09:23 +0200 Subject: [PATCH] py,st3m: overlays: Bring back damage tracking to BatteryIcon and ChargingIcon --- python_payload/st3m/ui/elements/overlays.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/python_payload/st3m/ui/elements/overlays.py b/python_payload/st3m/ui/elements/overlays.py index d3c0db4190..608ff3e9ea 100644 --- a/python_payload/st3m/ui/elements/overlays.py +++ b/python_payload/st3m/ui/elements/overlays.py @@ -561,7 +561,6 @@ class BatteryIcon(Icon): def __init__(self) -> None: super().__init__() self._percent = 100.0 - self._changed = True def visible(self) -> bool: return power.has_battery @@ -588,8 +587,13 @@ class BatteryIcon(Icon): ctx.font_size = 100 ctx.rgb(255, 255, 255).text(str(self._percent)) + self._changed = False + def think(self, ins: InputState, delta_ms: int) -> None: - self._percent = power.battery_percentage + percent = power.battery_percentage + if self._percent != percent: + self._changed = True + self._percent = percent class ChargingIcon(Icon): @@ -598,7 +602,6 @@ class ChargingIcon(Icon): def __init__(self) -> None: super().__init__() self._charging = power.battery_charging - self._changed = True def visible(self) -> bool: if not power.has_battery: @@ -620,8 +623,13 @@ class ChargingIcon(Icon): ctx.line_to(40, 35) ctx.stroke() + self._changed = False + def think(self, ins: InputState, delta_ms: int) -> None: - self._charging = power.battery_charging + charging = power.battery_charging + if self._charging != charging: + self._changed = True + self._charging = charging class IconTray(Overlay): -- GitLab