Skip to content
Snippets Groups Projects
Commit b5e4f3d4 authored by q3k's avatar q3k
Browse files

py: add battery voltage to debug overlay

parent 23f45596
No related branches found
No related tags found
No related merge requests found
......@@ -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()
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment