Skip to content
Snippets Groups Projects
Commit d4dfaa1d authored by ave's avatar ave
Browse files

default python apps: use super.on_enter/on_exit reliably

fix shoegaze

fix tiny_sampler
parent 5b3163f5
Branches
Tags
1 merge request!248default python apps: use super.on_enter/on_exit reliably
Pipeline #7483 passed
...@@ -27,6 +27,7 @@ class AudioPassthrough(Application): ...@@ -27,6 +27,7 @@ class AudioPassthrough(Application):
self._force_mode: str = "AUTO" self._force_mode: str = "AUTO"
def on_enter(self, vm: Optional[ViewManager]) -> None: def on_enter(self, vm: Optional[ViewManager]) -> None:
super().on_enter(vm)
self._force_mode = "AUTO" self._force_mode = "AUTO"
def draw(self, ctx: Context) -> None: def draw(self, ctx: Context) -> None:
...@@ -96,6 +97,7 @@ class AudioPassthrough(Application): ...@@ -96,6 +97,7 @@ class AudioPassthrough(Application):
ctx.text("force line in/out") ctx.text("force line in/out")
def on_exit(self) -> None: def on_exit(self) -> None:
super().on_exit()
# Mic passthrough has a loopback risk # Mic passthrough has a loopback risk
if self._force_mode == "FORCE_MIC": if self._force_mode == "FORCE_MIC":
self._force_mode = "FORCE_NONE" self._force_mode = "FORCE_NONE"
......
...@@ -562,5 +562,6 @@ class GayDrums(Application): ...@@ -562,5 +562,6 @@ class GayDrums(Application):
self.ct_prev = ct self.ct_prev = ct
def on_enter(self, vm: Optional[ViewManager]) -> None: def on_enter(self, vm: Optional[ViewManager]) -> None:
super().on_enter(vm)
self.ct_prev = None self.ct_prev = None
self.draw_background_counter = 2 self.draw_background_counter = 2
...@@ -5,6 +5,8 @@ import leds ...@@ -5,6 +5,8 @@ import leds
from st3m.goose import List from st3m.goose import List
from st3m.input import InputState from st3m.input import InputState
from st3m.goose import Optional
from st3m.ui.view import ViewManager
from ctx import Context from ctx import Context
import cmath import cmath
import math import math
...@@ -129,7 +131,7 @@ class HarmonicApp(Application): ...@@ -129,7 +131,7 @@ class HarmonicApp(Application):
self.cp_prev = cp self.cp_prev = cp
def on_enter(self, vm: Optional[ViewManager]) -> None: def on_enter(self, vm: Optional[ViewManager]) -> None:
# super().on_enter(vm) idk not using it in shoegaze, works fine? super().on_enter(vm)
if self.blm is None: if self.blm is None:
self._build_synth() self._build_synth()
self.blm.foreground = True self.blm.foreground = True
......
...@@ -124,13 +124,14 @@ class MelodicApp(Application): ...@@ -124,13 +124,14 @@ class MelodicApp(Application):
leds.update() leds.update()
def on_enter(self, vm: Optional[ViewManager]) -> None: def on_enter(self, vm: Optional[ViewManager]) -> None:
# super().on_enter(vm) idk not using it in shoegaze, works fine? super().on_enter(vm)
if self.blm is None: if self.blm is None:
self._build_synth() self._build_synth()
self.blm.foreground = True self.blm.foreground = True
self.make_scale() self.make_scale()
def on_exit(self): def on_exit(self):
super().on_exit()
if self.blm is not None: if self.blm is not None:
self.blm.free = True self.blm.free = True
self.blm = None self.blm = None
......
...@@ -163,6 +163,7 @@ class NickApp(Application): ...@@ -163,6 +163,7 @@ class NickApp(Application):
# ctx.fill() # ctx.fill()
def on_exit(self) -> None: def on_exit(self) -> None:
super().on_exit()
if not self._config.config_errors: if not self._config.config_errors:
self._config.save(self._filename) self._config.save(self._filename)
......
...@@ -116,6 +116,7 @@ class Otamatone(Application): ...@@ -116,6 +116,7 @@ class Otamatone(Application):
self._lp.signals.freq = 4000 self._lp.signals.freq = 4000
def on_exit(self): def on_exit(self):
super().on_exit()
if self._blm is not None: if self._blm is not None:
self._blm.free = True self._blm.free = True
self._blm = None self._blm = None
......
...@@ -231,12 +231,14 @@ class ShoegazeApp(Application): ...@@ -231,12 +231,14 @@ class ShoegazeApp(Application):
self.bass_string.signals.trigger.start() self.bass_string.signals.trigger.start()
def on_enter(self, vm: Optional[ViewManager]) -> None: def on_enter(self, vm: Optional[ViewManager]) -> None:
super().on_enter(vm)
if self.blm is None: if self.blm is None:
self._build_synth() self._build_synth()
if self.blm is not None: # silly mypy if self.blm is not None: # silly mypy
self.blm.foreground = True self.blm.foreground = True
def on_exit(self) -> None: def on_exit(self) -> None:
super().on_exit()
if self.blm is not None: if self.blm is not None:
self.blm.free = True # yeeting the channel in the backend self.blm.free = True # yeeting the channel in the backend
self.blm = None self.blm = None
......
...@@ -90,6 +90,7 @@ class TinySampler(Application): ...@@ -90,6 +90,7 @@ class TinySampler(Application):
self.ct_prev = ct self.ct_prev = ct
def on_exit(self) -> None: def on_exit(self) -> None:
super().on_exit()
for i in range(5): for i in range(5):
if self.is_recording[i]: if self.is_recording[i]:
self.samplers[i].signals.rec_trigger.stop() self.samplers[i].signals.rec_trigger.stop()
......
...@@ -129,6 +129,7 @@ class WifiApp(Application): ...@@ -129,6 +129,7 @@ class WifiApp(Application):
leds.set_rgb((direction * 4) + 1, r, g, b) leds.set_rgb((direction * 4) + 1, r, g, b)
def on_exit(self) -> None: def on_exit(self) -> None:
super().on_exit()
leds.set_all_rgb(0, 0, 0) leds.set_all_rgb(0, 0, 0)
leds.update() leds.update()
......
...@@ -55,6 +55,7 @@ class JukeBox(Application): ...@@ -55,6 +55,7 @@ class JukeBox(Application):
self.load_stream() self.load_stream()
def on_exit(self): def on_exit(self):
super().on_exit()
media.stop() media.stop()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment