From 24f939300ec6f56d1667b02a5b99cc3380dae1f6 Mon Sep 17 00:00:00 2001 From: moon2 <moon2protonmail@protonmail.com> Date: Wed, 20 Sep 2023 15:20:32 +0000 Subject: [PATCH] fix up some system applications and move LEDs to on_exit_done() --- python_payload/apps/demo_harmonic/__init__.py | 7 ++++--- python_payload/apps/gay_drums/__init__.py | 2 ++ python_payload/apps/mandelbrot/__init__.py | 1 + python_payload/apps/shoegaze/__init__.py | 6 ++++-- python_payload/st3m/application.py | 13 ++++++++++--- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/python_payload/apps/demo_harmonic/__init__.py b/python_payload/apps/demo_harmonic/__init__.py index ec52fc126b..5f3a4f0aa1 100644 --- a/python_payload/apps/demo_harmonic/__init__.py +++ b/python_payload/apps/demo_harmonic/__init__.py @@ -261,7 +261,7 @@ class HarmonicApp(Application): self.prev_captouch = [0] * 10 self.fade = [0] * 5 self.mode = 0 - self._set_chord(3) + self._set_chord(3, force_update=True) self._num_modes = 3 self._file_settings = None @@ -370,9 +370,9 @@ class HarmonicApp(Application): self.lp.signals.reso = 2000 self.lp.signals.gain.dB = +3 - def _set_chord(self, i: int) -> None: + def _set_chord(self, i, force_update=False): hue = int(72 * (i + 0.5)) % 360 - if i != self.chord_index: + if i != self.chord_index or force_update: self.chord_index = i leds.set_all_rgb(*bottom_petal_to_rgb(self.chord_index, soft=0)) leds.update() @@ -611,6 +611,7 @@ class HarmonicApp(Application): self._build_synth() self.blm.foreground = True self._load_settings() + self._set_chord(self.chord_index, force_update=True) def on_exit(self): if self.blm is not None: diff --git a/python_payload/apps/gay_drums/__init__.py b/python_payload/apps/gay_drums/__init__.py index a169b59b37..aafd616ff9 100644 --- a/python_payload/apps/gay_drums/__init__.py +++ b/python_payload/apps/gay_drums/__init__.py @@ -725,6 +725,7 @@ class GayDrums(Application): self.ct_prev = None def on_enter_done(self) -> None: + super().on_enter_done() # schedule one more redraw so draw_track_step_marker draws the real state self._render_list += [(self.draw_background, None)] @@ -743,6 +744,7 @@ class GayDrums(Application): self.load_iter = self.iterate_loading() else: self.blm.background_mute_override = True + super().on_exit_done() # For running with `mpremote run`: diff --git a/python_payload/apps/mandelbrot/__init__.py b/python_payload/apps/mandelbrot/__init__.py index 0de97fb48b..68e6df8cb8 100644 --- a/python_payload/apps/mandelbrot/__init__.py +++ b/python_payload/apps/mandelbrot/__init__.py @@ -15,6 +15,7 @@ class App(Application): self.yb = 1.0 def on_enter_done(self): + super().on_enter_done() sys_display.set_mode(sys_display.cool | sys_display.x2) def draw(self, ctx: Context): diff --git a/python_payload/apps/shoegaze/__init__.py b/python_payload/apps/shoegaze/__init__.py index 718f250433..b50e39cb55 100644 --- a/python_payload/apps/shoegaze/__init__.py +++ b/python_payload/apps/shoegaze/__init__.py @@ -45,7 +45,7 @@ class ShoegazeApp(Application): self._rand_rot = 0.0 self.delay_on = True self.organ_on = False - self._set_chord(3) + self._set_chord(3, force_update=True) def _build_synth(self) -> None: if self.blm is None: @@ -255,16 +255,18 @@ class ShoegazeApp(Application): self.bass_string.signals.trigger.start() def on_enter_done(self) -> None: + super().on_enter_done() if self.blm is None: self._build_synth() self.blm.foreground = True + self._set_chord(self.chord_index, force_update=True) def on_exit(self) -> None: - super().on_exit() if self.blm is not None: self.blm.clear() self.blm.free = True self.blm = None + super().on_exit() # For running with `mpremote run`: diff --git a/python_payload/st3m/application.py b/python_payload/st3m/application.py index 3a5354fb61..4d1dc47431 100644 --- a/python_payload/st3m/application.py +++ b/python_payload/st3m/application.py @@ -78,14 +78,21 @@ class Application(BaseView): if fully_exiting and self._wifi_preference is not None: st3m.wifi._onoff_wifi_update() super().on_exit() + # set the default graphics mode, this is a no-op if + # it is already set if fully_exiting: - # set the default graphics mode, this is a no-op if - # it is already set sys_display.set_mode(0) - # read menu led config from flash and set it + if fully_exiting: + leds.set_slew_rate(10) + leds.set_auto_update(1) led_patterns.set_menu_colors() + + def on_exit_done(self): + fully_exiting = self.vm.direction == ViewTransitionDirection.BACKWARD + if fully_exiting: leds.set_slew_rate(10) leds.set_auto_update(1) + led_patterns.set_menu_colors() def think(self, ins: InputState, delta_ms: int) -> None: super().think(ins, delta_ms) -- GitLab