Merge branch 'master' into ledPWM
This commit is contained in:
commit
6713e6278a
21
Buzzer.py
21
Buzzer.py
@ -20,14 +20,14 @@ BEEPBEEP = ((700,1100),(100,None),(600,1100))
|
||||
|
||||
# 0: BEEEEP BEEEEP BEEEEEP
|
||||
# 1: Alle Meine Entchen
|
||||
ALARMTONES = (((300,1200),(100,None),(200,1200),(300,None),(None,10)),
|
||||
((400,c),(100,None),(400,d),(100,None),(400,e),(100,None),(400,f),(100,None),\
|
||||
(900,g),(100,None),(900,g),(100,None),(400,a),(100,None),(400,a),(100,None),\
|
||||
(400,a),(100,None),(400,a),(100,None),(1900,g),(100,None),(400,a),(100,None),\
|
||||
(400,a),(100,None),(400,a),(100,None),(400,a),(100,None),(1600,g),(100,None),\
|
||||
(400,f),(100,None),(400,f),(100,None),(400,f),(100,None),(400,f),(100,None),\
|
||||
(900,e),(100,None),(900,e),(100,None),(400,d),(100,None),(400,d),(100,None),\
|
||||
(400,d),(100,None),(400,d),(100,None),(1600,c)),)
|
||||
ALARMTONES = (((300,1200),(80,None),(200,1200),(300,None),(None,10)),
|
||||
((400,c),(80,None),(400,d),(80,None),(400,e),(80,None),(400,f),(80,None),\
|
||||
(900,g),(80,None),(900,g),(80,None),(400,a),(80,None),(400,a),(80,None),\
|
||||
(400,a),(80,None),(400,a),(80,None),(1900,g),(80,None),(400,a),(80,None),\
|
||||
(400,a),(80,None),(400,a),(80,None),(400,a),(80,None),(1600,g),(80,None),\
|
||||
(400,f),(80,None),(400,f),(80,None),(400,f),(80,None),(400,f),(80,None),\
|
||||
(900,e),(80,None),(900,e),(80,None),(400,d),(80,None),(400,d),(80,None),\
|
||||
(400,d),(80,None),(400,d),(80,None),(1600,c)),)
|
||||
|
||||
class Buzzer():
|
||||
def __init__(self,pin,duty = 1000):
|
||||
@ -47,7 +47,8 @@ class Buzzer():
|
||||
self.newSound = False
|
||||
timesPlayed = 0
|
||||
#print("Play sound!")
|
||||
for i in range(len(self.sound)):
|
||||
i = 0
|
||||
while i < len(self.sound):
|
||||
s = self.sound[i]
|
||||
if s[0] == None:
|
||||
if s[1]-timesPlayed == 0:
|
||||
@ -55,6 +56,7 @@ class Buzzer():
|
||||
else:
|
||||
i = 0
|
||||
timesPlayed += 1
|
||||
continue
|
||||
if (s[1] != None):
|
||||
self._pwm.freq(s[1])
|
||||
self._pwm.duty(self.duty)
|
||||
@ -64,6 +66,7 @@ class Buzzer():
|
||||
await asyncio.sleep_ms(s[0])
|
||||
if self.newSound or self.sound == None:
|
||||
break
|
||||
i+=1
|
||||
if (not self.newSound):
|
||||
self.sound = None
|
||||
self.newSound = False
|
||||
|
@ -98,6 +98,7 @@ class RingtoneSettingsScreen():
|
||||
onNumberChange=self.playAndSetSound,\
|
||||
onPicked=lambda _:Settings.save())
|
||||
await numberScreen
|
||||
HW.buzzer.stop()
|
||||
|
||||
class ShowIpScreen():
|
||||
def __init__(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user