From 388e7bd8ff8a6ad6c6df5c23e01f19dfdd93fc2e Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak <dos@dosowisko.net> Date: Thu, 26 Oct 2023 19:43:06 +0200 Subject: [PATCH] py,st3m: about: Update space screen when entering the view Available space may have changed since the view has been instantiated. --- python_payload/st3m/about.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/python_payload/st3m/about.py b/python_payload/st3m/about.py index f152106798..23c6618902 100644 --- a/python_payload/st3m/about.py +++ b/python_payload/st3m/about.py @@ -33,6 +33,9 @@ class Screen(Responder): def think(self, ins: InputState, delta_ms: int) -> None: pass + def update(self) -> None: + pass + class HeroScreen(Screen): """ @@ -74,6 +77,9 @@ class SpaceScreen(Screen): """ def __init__(self) -> None: + pass + + def update(self) -> None: flash_statvfs = os.statvfs("/flash") flash_free = flash_statvfs[1] * flash_statvfs[3] flash_total = flash_statvfs[1] * flash_statvfs[2] @@ -203,6 +209,11 @@ class About(BaseView): self.screen_ix_anim = 0.0 super().__init__() + def on_enter(self, vm: Optional["ViewManager"]) -> None: + super().__init__(vm) + for screen in self.screens: + screen.update() + def think(self, ins: InputState, delta_ms: int) -> None: super().think(ins, delta_ms) self.ts += delta_ms / 1000 -- GitLab