diff --git a/Buzzer.py b/Buzzer.py index 73ff9b8..cfa0949 100644 --- a/Buzzer.py +++ b/Buzzer.py @@ -52,7 +52,7 @@ class Buzzer(): else: self._pwm.duty(0) await asyncio.sleep_ms(s[0]) - if self.newSound: + if self.newSound or self.sound == None: break if (not self.newSound): self.sound = None diff --git a/Screens.py b/Screens.py index 3b8349f..15512ca 100644 --- a/Screens.py +++ b/Screens.py @@ -63,6 +63,8 @@ class SettingsScreen(): self.stepperhour.rotateTo(direction=-1) def onButtonReleased(self,button): + if not self.running: + return self.leds[button].off(overwriteFlashing=False) if button == 0:#left if self.mode == 0 or self.mode == 1: @@ -118,4 +120,6 @@ class SettingsScreen(): self.housingLEDs.clear() self.stepperhour.reset() self.stepperminu.reset() + self.buzzer.stop() + Settings.save() __iter__ = __await__ # https://github.com/micropython/micropython/issues/2678 \ No newline at end of file diff --git a/Settings.py b/Settings.py index 9d0ebef..49ead57 100644 --- a/Settings.py +++ b/Settings.py @@ -1,2 +1,25 @@ +selectedSound=0 +alarmTime=((1,2,3,4),(8,),(0,)) -selectedSound = 0 \ No newline at end of file + +def printState(): + print("selectedSound=",selectedSound) + print("alarmTime=",alarmTime) + +def save(): + global selectedSound + lines = [] + with open("Settings.py",'r') as rf: + for l in rf: + lines.append(l) + + with open("Settings.py",'w') as wf: + for l in lines: + if l.startswith("selectedSound"): + wf.write("selectedSound="+str(selectedSound)+"\n") + elif l.startswith("alarmTime"): + wf.write("alarmTime="+str(alarmTime)+"\n") + else: + wf.write(l) + #printState() +#printState() \ No newline at end of file