diff --git a/python_payload/st3m/run.py b/python_payload/st3m/run.py index ae95af878e7c75c2230e780b6ba68307883dc988..8f7dfec2d7afc640e6788180fcac040d4afa8a56 100644 --- a/python_payload/st3m/run.py +++ b/python_payload/st3m/run.py @@ -75,6 +75,7 @@ def _make_compositor(reactor: Reactor, vm: ViewManager) -> overlays.Compositor: # Configure debug overlay fragments. debug = overlays.OverlayDebug() debug.add_fragment(overlays.DebugReactorStats(reactor)) + debug.add_fragment(overlays.DebugBattery()) compositor.add_overlay(debug) debug_touch = overlays.OverlayCaptouch() diff --git a/python_payload/st3m/ui/elements/overlays.py b/python_payload/st3m/ui/elements/overlays.py index 83f9780b1cbf356002ffde874f6bd0a3c6b0a733..41c30dbd9a26d978195d09db08a00eb0cd72a0a6 100644 --- a/python_payload/st3m/ui/elements/overlays.py +++ b/python_payload/st3m/ui/elements/overlays.py @@ -10,6 +10,7 @@ from st3m import Responder, InputState, Reactor from st3m.goose import Dict, Enum, List, ABCBase, abstractmethod, Optional from st3m.utils import tau from st3m.ui.view import ViewManager +from st3m.input import power from ctx import Context import math @@ -122,6 +123,17 @@ class DebugReactorStats(DebugFragment): return " ".join(res) +class DebugBattery(DebugFragment): + """ + DebugFragment which provides the OverlayDebug with information about the + battery voltage. + """ + + def text(self) -> str: + v = power.battery_voltage + return f"bat: {v:.2f}V" + + class OverlayDebug(Overlay): """ Overlay which renders a text bar at the bottom of the screen with random