Add Pico display rendering abstraction
This commit is contained in:
@@ -722,3 +722,59 @@ def test_touch_router_ignores_unpressed_event():
|
||||
|
||||
assert handled is False
|
||||
assert screens.current_screen == "dashboard"
|
||||
|
||||
|
||||
def test_display_records_commands():
|
||||
from hardware.display import Display
|
||||
|
||||
display = Display()
|
||||
|
||||
display.clear()
|
||||
display.text(1, 2, "hello", size=2)
|
||||
display.rect(3, 4, 5, 6, filled=True)
|
||||
|
||||
assert display.commands == [
|
||||
("clear",),
|
||||
("text", 1, 2, "hello", 2),
|
||||
("rect", 3, 4, 5, 6, True),
|
||||
]
|
||||
|
||||
|
||||
def test_dashboard_renderer_creates_draw_commands():
|
||||
from hardware.display import Display
|
||||
from ui.dashboard_view_model import DashboardViewModel
|
||||
from ui.renderers import DashboardRenderer
|
||||
|
||||
state = AppState()
|
||||
state.update_from_status({
|
||||
"battery": {
|
||||
"soc": 82,
|
||||
"voltage": 13.2,
|
||||
"current": -6.4,
|
||||
"runtime_hours": 12.0,
|
||||
},
|
||||
"temps": {
|
||||
"fridge_zone_1": 34.5,
|
||||
"fridge_zone_2": 36.0,
|
||||
},
|
||||
"relays": {
|
||||
"starlink": False,
|
||||
"fridge": True,
|
||||
},
|
||||
"network": {
|
||||
"uart_connected": True,
|
||||
},
|
||||
})
|
||||
|
||||
display = Display()
|
||||
renderer = DashboardRenderer(display)
|
||||
|
||||
renderer.render(DashboardViewModel(state))
|
||||
|
||||
assert display.commands[0] == ("clear",)
|
||||
assert ("text", 0, 0, "SOC 82%", 1) in display.commands
|
||||
assert ("text", 120, 0, "UART OK", 1) in display.commands
|
||||
assert ("text", 0, 48, "Battery", 1) in display.commands
|
||||
assert ("text", 0, 128, "Fridge", 1) in display.commands
|
||||
assert ("text", 0, 232, "Power", 1) in display.commands
|
||||
assert ("text", 0, 440, "[Dash]", 1) in display.commands
|
||||
|
||||
Reference in New Issue
Block a user