fix sounds in stateMachine
This commit is contained in:
parent
4ff3f27c7c
commit
4b922a126b
|
@ -19,7 +19,7 @@ class Blinkenlights(ExceptionThread):
|
|||
# because we spend first half of period decreasing duty cycle and the
|
||||
# second half increasing (between 0 and 100)
|
||||
self._steps = 40
|
||||
self._stepsize = 100/(self._steps/2)
|
||||
self._stepsize = int(100/(self._steps/2))
|
||||
|
||||
self._pin = pin
|
||||
|
||||
|
@ -47,7 +47,7 @@ class Blinkenlights(ExceptionThread):
|
|||
if not blinkSet:
|
||||
continue
|
||||
elif not linearSet:
|
||||
t = self._sleeptime*self._stepsize
|
||||
t = self._sleeptime*self._steps/2
|
||||
|
||||
pwm.ChangeDutyCycle(100)
|
||||
self._linear.wait(timeout=t)
|
||||
|
|
11
listeners.py
11
listeners.py
|
@ -69,7 +69,7 @@ class KeypadListener:
|
|||
ctrlKeySound.play()
|
||||
elif self._buf == passwd:
|
||||
self.resetBuffer()
|
||||
stateMachine.DISARM
|
||||
stateMachine.DISARM()
|
||||
else:
|
||||
self.resetBuffer()
|
||||
wrongPassSound.play()
|
||||
|
@ -77,20 +77,17 @@ class KeypadListener:
|
|||
# lock
|
||||
elif val == 'NUML':
|
||||
self.resetBuffer()
|
||||
stateMachine.LOCK
|
||||
ctrlKeySound.play()
|
||||
stateMachine.LOCK()
|
||||
|
||||
# instant lock
|
||||
elif val == '/':
|
||||
self.resetBuffer()
|
||||
stateMachine.INSTANT_LOCK
|
||||
ctrlKeySound.play()
|
||||
stateMachine.INSTANT_LOCK()
|
||||
|
||||
# arm
|
||||
elif val == '*':
|
||||
self.resetBuffer()
|
||||
stateMachine.ARM
|
||||
ctrlKeySound.play()
|
||||
stateMachine.ARM()
|
||||
|
||||
# delete last char in buffer
|
||||
elif val == 'BS':
|
||||
|
|
|
@ -95,10 +95,12 @@ class SoundLib:
|
|||
mixer.init()
|
||||
|
||||
self.soundEffects = {
|
||||
'disarmedCountdown': SoundEffect(path='soundfx/smb_coin.wav'),
|
||||
'disarmedCountdown': SoundEffect(path='soundfx/smb_kick.wav'),
|
||||
'disarmed': SoundEffect(path='soundfx/smb_pause.wav'),
|
||||
'armed': SoundEffect(path='soundfx/smb_powerup.wav'),
|
||||
'armedCountdown': SoundEffect(path='soundfx/smb_jump-small.wav'),
|
||||
'armedCountdown': SoundEffect(path='soundfx/smb2_door_appears.wav'),
|
||||
'locked': SoundEffect(path='soundfx/smb_1-up.wav'),
|
||||
'lockedCountdown': SoundEffect(path='soundfx/smb_stomp.wav'),
|
||||
'triggered': SoundEffect(path='soundfx/alarms/burgler_alarm.ogg', volume=1.0, loops=-1),
|
||||
'door': SoundEffect(path='soundfx/smb_pipe.wav'),
|
||||
'numKey': SoundEffect(path='soundfx/smb_bump.wav'),
|
||||
|
|
|
@ -223,19 +223,19 @@ class StateMachine:
|
|||
),
|
||||
_State(
|
||||
name = 'armed',
|
||||
entryCallbacks = [partial(linearBlink, 2)],
|
||||
entryCallbacks = [partial(linearBlink, 1)],
|
||||
sound = sfx['armed']
|
||||
),
|
||||
_State(
|
||||
name = 'lockedCountdown',
|
||||
entryCallbacks = [partial(squareBlink, 1), partial(startTimer, 30, sfx['disarmedCountdown'])],
|
||||
entryCallbacks = [partial(squareBlink, 1), partial(startTimer, 30, sfx['lockedCountdown'])],
|
||||
exitCallbacks = [stopTimer],
|
||||
sound = sfx['disarmedCountdown']
|
||||
sound = sfx['lockedCountdown']
|
||||
),
|
||||
_State(
|
||||
name = 'locked',
|
||||
entryCallbacks = [partial(linearBlink, 3)],
|
||||
sound = sfx['armed']
|
||||
entryCallbacks = [partial(squareBlink, 2)],
|
||||
sound = sfx['locked']
|
||||
),
|
||||
_State(
|
||||
name = 'armedCountdown',
|
||||
|
@ -245,7 +245,7 @@ class StateMachine:
|
|||
),
|
||||
_State(
|
||||
name = 'triggered',
|
||||
entryCallbacks = [partial(linearBlink, 1), intruderAlert],
|
||||
entryCallbacks = [partial(linearBlink, 0.5), intruderAlert],
|
||||
sound = sfx['triggered']
|
||||
)
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue