diff --git a/python_payload/apps/gr33nhouse/__init__.py b/python_payload/apps/gr33nhouse/__init__.py index 46a98a3f4a3b35ddbf6b828d9d96e0bf792379d4..327fc68fa07b7de41dedf6cf991a9ae83cf3ffa4 100644 --- a/python_payload/apps/gr33nhouse/__init__.py +++ b/python_payload/apps/gr33nhouse/__init__.py @@ -1,6 +1,6 @@ from st3m.goose import Enum from st3m.application import Application, ApplicationContext -from st3m.input import InputController, InputState +from st3m.input import InputState from st3m.ui.interactions import ScrollController from st3m.ui import colours from st3m.ui.view import ViewManager @@ -20,14 +20,12 @@ class ViewState(Enum): class Gr33nhouseApp(Application): items = ["Browse apps", "Record flow3r seed", "Enter flow3r seed"] - input: InputController background: Flow3rView state: ViewState def __init__(self, app_ctx: ApplicationContext) -> None: super().__init__(app_ctx=app_ctx) - self.input = InputController() self.background = Flow3rView() self._sc = ScrollController() self._sc.set_item_count(3) @@ -105,7 +103,7 @@ class Gr33nhouseApp(Application): ctx.restore() def think(self, ins: InputState, delta_ms: int) -> None: - self.input.think(ins, delta_ms) + super().think(ins, delta_ms) self._sc.think(ins, delta_ms) if self.vm is None: diff --git a/python_payload/apps/gr33nhouse/applist.py b/python_payload/apps/gr33nhouse/applist.py index e755a6a340f788cc99b05114951f1515b94851a9..475c3025aeb82a9aa61107c1d1f23b2bf05fb9d2 100644 --- a/python_payload/apps/gr33nhouse/applist.py +++ b/python_payload/apps/gr33nhouse/applist.py @@ -1,5 +1,5 @@ from st3m.goose import Optional, Enum, Any -from st3m.input import InputController, InputState +from st3m.input import InputState from st3m.ui import colours from st3m.ui.view import BaseView, ViewManager from st3m.ui.interactions import ScrollController @@ -25,12 +25,10 @@ class AppList(BaseView): apps: list[Any] = [] - input: InputController background: Flow3rView def __init__(self) -> None: - self.input = InputController() - self.vm = None + super().__init__() self.background = Flow3rView() self._sc = ScrollController() @@ -122,12 +120,11 @@ class AppList(BaseView): raise RuntimeError(f"Invalid view state {self._state}") def think(self, ins: InputState, delta_ms: int) -> None: + super().think(ins, delta_ms) self._sc.think(ins, delta_ms) if self.initial_ticks == 0 or time.ticks_ms() < self.initial_ticks + 300: return - self.input.think(ins, delta_ms) - if self._state == ViewState.INITIAL: try: self._state = ViewState.LOADING diff --git a/python_payload/apps/gr33nhouse/background.py b/python_payload/apps/gr33nhouse/background.py index 18f4e1378c4c2caf6f529cb63fa131fe2bc023e8..f3a58605ca63e73f344f9f1a0302af96caa1ded7 100644 --- a/python_payload/apps/gr33nhouse/background.py +++ b/python_payload/apps/gr33nhouse/background.py @@ -1,16 +1,13 @@ import random -from st3m.input import InputController, InputState +from st3m.input import InputState from st3m.ui.view import BaseView from ctx import Context class Flow3rView(BaseView): - input: InputController - def __init__(self) -> None: - self.vm = None - self.input = InputController() + super().__init__() self.flowers = [] for i in range(8): diff --git a/python_payload/apps/gr33nhouse/confirmation.py b/python_payload/apps/gr33nhouse/confirmation.py index f7702815fdf5c6e23ae3a708b1b77cfeb03a9371..fbf18457287ac325aeca6b43688a752ea049e2e3 100644 --- a/python_payload/apps/gr33nhouse/confirmation.py +++ b/python_payload/apps/gr33nhouse/confirmation.py @@ -1,4 +1,4 @@ -from st3m.input import InputController, InputState +from st3m.input import InputState from st3m.ui import colours from st3m.ui.view import BaseView, ViewManager from ctx import Context @@ -8,15 +8,13 @@ from .download import DownloadView class ConfirmationView(BaseView): background: Flow3rView - input: InputController url: str name: str author: str def __init__(self, url: str, name: str, author: str) -> None: - self.input = InputController() - self.vm = None + super().__init__() self.background = Flow3rView() self.url = url @@ -71,7 +69,7 @@ class ConfirmationView(BaseView): ctx.restore() def think(self, ins: InputState, delta_ms: int) -> None: - self.input.think(ins, delta_ms) + super().think(ins, delta_ms) self.background.think(ins, delta_ms) if self.vm is None: diff --git a/python_payload/apps/gr33nhouse/download.py b/python_payload/apps/gr33nhouse/download.py index 64cc91b26b82517dc9a9acc1c7cd032fafe2d1bc..ca85f9a0498813c4309ed1035b67955f2965e1e0 100644 --- a/python_payload/apps/gr33nhouse/download.py +++ b/python_payload/apps/gr33nhouse/download.py @@ -1,4 +1,4 @@ -from st3m.input import InputController, InputState +from st3m.input import InputState from st3m.goose import Optional, List from st3m.ui import colours import urequests @@ -28,8 +28,6 @@ class DownloadView(BaseView): """ _state: int - input: InputController - def __init__(self, url: str) -> None: super().__init__() self._state = 1 @@ -38,8 +36,6 @@ class DownloadView(BaseView): self.response = b"" self._download_instance = None - self.input = InputController() - def draw(self, ctx: Context) -> None: ctx.rgb(0, 0, 0).rectangle(-120, -120, 240, 240).fill() @@ -97,8 +93,7 @@ class DownloadView(BaseView): req.close() def think(self, ins: InputState, delta_ms: int) -> None: - # super().think(ins, delta_ms) # Let BaseView do its thing - self.input.think(ins, delta_ms) + super().think(ins, delta_ms) # Let BaseView do its thing if self.input.buttons.app.middle.pressed: if self.vm is None: diff --git a/python_payload/apps/gr33nhouse/manual.py b/python_payload/apps/gr33nhouse/manual.py index 34c4232ce9f164049661ac33594a37e5d581613a..0d112ae7733aeee4b18e78b2cb9f48b5b31c7a30 100644 --- a/python_payload/apps/gr33nhouse/manual.py +++ b/python_payload/apps/gr33nhouse/manual.py @@ -1,5 +1,5 @@ from st3m.goose import Optional, Enum -from st3m.input import InputController, InputState +from st3m.input import InputState from st3m.ui import colours from st3m.ui.view import BaseView, ViewManager from ctx import Context @@ -34,8 +34,7 @@ class ManualInputView(BaseView): wait_timer: Optional[int] def __init__(self) -> None: - self.input = InputController() - self.vm = None + super().__init__() self.background = Flow3rView() self.flow3r_seed = "" @@ -109,7 +108,7 @@ class ManualInputView(BaseView): ctx.text(f"not found!") def think(self, ins: InputState, delta_ms: int) -> None: - self.input.think(ins, delta_ms) + super().think(ins, delta_ms) self.background.think(ins, delta_ms) if self.state == ViewState.ENTER_SEED: diff --git a/python_payload/apps/gr33nhouse/record.py b/python_payload/apps/gr33nhouse/record.py index be2e969e33e2f5af7e16b2f7c3494c2ea91557ae..6fb6d6abcfb242739eed68f8c7e01c1186641438 100644 --- a/python_payload/apps/gr33nhouse/record.py +++ b/python_payload/apps/gr33nhouse/record.py @@ -1,4 +1,4 @@ -from st3m.input import InputController, InputState +from st3m.input import InputState from st3m.ui import colours from st3m.ui.view import BaseView, ViewManager from ctx import Context @@ -6,11 +6,8 @@ from .background import Flow3rView class RecordView(BaseView): - input: InputController - def __init__(self) -> None: - self.input = InputController() - self.vm = None + super().__init__() self.background = Flow3rView() def on_enter(self, vm: ViewManager | None) -> None: @@ -37,6 +34,3 @@ class RecordView(BaseView): ctx.text_baseline = ctx.MIDDLE ctx.text("Coming soon") ctx.restore() - - def think(self, ins: InputState, delta_ms: int) -> None: - self.input.think(ins, delta_ms)