From 31e471462d5d76ed399d348a9d991c7e96783228 Mon Sep 17 00:00:00 2001 From: dequis <dx@dxzone.com.ar> Date: Sat, 12 Aug 2023 02:24:59 +0200 Subject: [PATCH] Revert "py: use InputController in simple_drums" This reverts commit 36d14db574d575525391e38b9e2d99e7b3676ff1. --- python_payload/apps/simple_drums/__init__.py | 32 ++++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/python_payload/apps/simple_drums/__init__.py b/python_payload/apps/simple_drums/__init__.py index b17027a918..30099f75b8 100644 --- a/python_payload/apps/simple_drums/__init__.py +++ b/python_payload/apps/simple_drums/__init__.py @@ -57,6 +57,7 @@ class SimpleDrums(Application): self.seq.signals.bpm.value = 80 self.track_names = ["kick", "hihat", "snare"] + self.ct_prev = captouch.read() self.track = 0 self.blm.background_mute_override = True self.tap_tempo_press_counter = 0 @@ -64,14 +65,6 @@ class SimpleDrums(Application): self.stopped = False self.bpm = self.seq.signals.bpm.value - # True if a given group should be highlighted, when a corresponding - # petal is pressed. - self._group_highlight = [False for _ in range(4)] - - # Disable repeat functionality as we want to detect long holds. - for i in range(10): - self.input.captouch.petals[i].whole.repeat_disable() - def _highlight_petal(self, num: int, r: int, g: int, b: int) -> None: for i in range(5): leds.set_rgb((4 * num - i + 2) % 40, r, g, b) @@ -90,7 +83,7 @@ class SimpleDrums(Application): dots = [] groupgap = 4 for i in range(4): - if self._group_highlight[i]: + if self.ct_prev.petals[4 - i].pressed: dots.append( Dot( 48 + groupgap, @@ -173,19 +166,17 @@ class SimpleDrums(Application): self._highlight_petal(10 - (4 - (st // 4)), *rgb) self._highlight_petal(10 - (6 + (st % 4)), *rgb) leds.update() - - petals = self.input.captouch.petals - - self._group_highlight = [False for _ in range(4)] + ct = captouch.read() for i in range(4): - if petals[4 - i].whole.down: - self._group_highlight[i] = True + if ct.petals[4 - i].pressed: for j in range(4): - if petals[6 + j].whole.pressed: + if ct.petals[6 + j].pressed and not ( + self.ct_prev.petals[6 + j].pressed + ): self.seq.trigger_toggle(self.track, i * 4 + j) - if petals[5].whole.pressed: - self.track = (self.track - 1) % 3 - if petals[0].whole.pressed: + if ct.petals[5].pressed and not (self.ct_prev.petals[5].pressed): + self.track = (self.track + 1) % 3 + if ct.petals[0].pressed and not (self.ct_prev.petals[0].pressed): if self.stopped: self.seq.signals.bpm = self.bpm self.blm.background_mute_override = True @@ -197,7 +188,7 @@ class SimpleDrums(Application): self.bpm = bpm self.delta_acc = 0 - if petals[0].whole.down: + if ct.petals[0].pressed: if self.tap_tempo_press_counter > 500: self.seq.signals.bpm = 0 self.stopped = True @@ -209,3 +200,4 @@ class SimpleDrums(Application): if self.delta_acc < 3000: self.delta_acc += delta_ms + self.ct_prev = ct -- GitLab