Add Pico dashboard main entrypoint
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
from app import PicoDashboardApp
|
||||
from state.app_state import AppState
|
||||
from comms.uart_client import UartClient
|
||||
from comms.communication_service import CommunicationService
|
||||
from hardware.display import Display
|
||||
from hardware.buzzer import Buzzer
|
||||
from ui.screen_manager import ScreenManager
|
||||
from ui.touch_router import TouchRouter
|
||||
from ui.renderers import DashboardRenderer
|
||||
|
||||
|
||||
class NullUart:
|
||||
def write(self, data):
|
||||
pass
|
||||
|
||||
def any(self):
|
||||
return False
|
||||
|
||||
def read(self):
|
||||
return b""
|
||||
|
||||
|
||||
def build_app():
|
||||
state = AppState()
|
||||
uart_client = UartClient(NullUart())
|
||||
comms = CommunicationService(uart_client, state)
|
||||
|
||||
screens = ScreenManager()
|
||||
display = Display()
|
||||
buzzer = Buzzer()
|
||||
touch_router = TouchRouter(screens)
|
||||
dashboard_renderer = DashboardRenderer(display)
|
||||
|
||||
return PicoDashboardApp(
|
||||
app_state=state,
|
||||
communication_service=comms,
|
||||
screen_manager=screens,
|
||||
touch_router=touch_router,
|
||||
display=display,
|
||||
dashboard_renderer=dashboard_renderer,
|
||||
buzzer=buzzer,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
app = build_app()
|
||||
app.tick()
|
||||
return app
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -817,3 +817,21 @@ def test_pico_dashboard_app_tick_updates_alarms_and_buzzer():
|
||||
assert "fridge_zone_1_high" in app.alarms
|
||||
assert buzzer.enabled is True
|
||||
assert display.commands
|
||||
|
||||
|
||||
def test_pico_main_builds_app():
|
||||
import main
|
||||
|
||||
app = main.build_app()
|
||||
|
||||
assert app.state is not None
|
||||
assert app.comms is not None
|
||||
assert app.screen_manager.current_screen == "dashboard"
|
||||
|
||||
|
||||
def test_pico_main_runs_one_tick():
|
||||
import main
|
||||
|
||||
app = main.main()
|
||||
|
||||
assert app is not None
|
||||
|
||||
Reference in New Issue
Block a user