diff --git a/python_payload/apps/demo_cap_touch/__init__.py b/python_payload/apps/demo_cap_touch/__init__.py index d50b1b8d52d44f202770632db556c93b8b0e4621..e2ae20edf0e844034f3eb7e66c5ebfeaca10dab4 100644 --- a/python_payload/apps/demo_cap_touch/__init__.py +++ b/python_payload/apps/demo_cap_touch/__init__.py @@ -39,11 +39,14 @@ class CapTouchDemo(Application): self.last_calib = None self.state = 0 self.timer = 0 - self.button = 0 + self.button = None def think(self, ins: InputState, delta_ms: int) -> None: super().think(ins, delta_ms) - press_event = (self.button != ins.buttons.app) and ins.buttons.app + if self.button is not None: + press_event = (self.button != ins.buttons.app) and ins.buttons.app + else: + press_event = False self.button = int(ins.buttons.app) if press_event: print(self.button) @@ -116,6 +119,10 @@ class CapTouchDemo(Application): ctx.rgb(1.0, 0.5, 0.2) ctx.text("calibrating...") + def on_enter(self, vm: Optional[ViewManager]) -> None: + super().on_enter(vm) + self.button = None + # For running with `mpremote run`: if __name__ == "__main__": diff --git a/python_payload/apps/demo_cap_touch/flow3r.toml b/python_payload/apps/demo_cap_touch/flow3r.toml index ed6f8f183837cb97804f934420abd0f378135187..debf2412d3f84866568a5ae994a4ff0735ebb85d 100644 --- a/python_payload/apps/demo_cap_touch/flow3r.toml +++ b/python_payload/apps/demo_cap_touch/flow3r.toml @@ -3,7 +3,7 @@ name = "captouch demo" category = "Apps" [entry] -class = "App" +class = "CapTouchDemo" [metadata] author = "Flow3r Badge Authors"