fix sounds in stateMachine

This commit is contained in:
petrucci4prez 2017-06-18 15:00:01 -04:00
parent 4ff3f27c7c
commit 4b922a126b
4 changed files with 18 additions and 19 deletions

View File

@ -19,7 +19,7 @@ class Blinkenlights(ExceptionThread):
# because we spend first half of period decreasing duty cycle and the # because we spend first half of period decreasing duty cycle and the
# second half increasing (between 0 and 100) # second half increasing (between 0 and 100)
self._steps = 40 self._steps = 40
self._stepsize = 100/(self._steps/2) self._stepsize = int(100/(self._steps/2))
self._pin = pin self._pin = pin
@ -47,7 +47,7 @@ class Blinkenlights(ExceptionThread):
if not blinkSet: if not blinkSet:
continue continue
elif not linearSet: elif not linearSet:
t = self._sleeptime*self._stepsize t = self._sleeptime*self._steps/2
pwm.ChangeDutyCycle(100) pwm.ChangeDutyCycle(100)
self._linear.wait(timeout=t) self._linear.wait(timeout=t)

View File

@ -24,7 +24,7 @@ class KeypadListener:
- countdown timer to reset the input buffer after 30 seconds of inactivity - countdown timer to reset the input buffer after 30 seconds of inactivity
''' '''
def __init__(self, stateMachine, passwd): def __init__(self, stateMachine, passwd):
ctrlKeys = { 69: 'NUML', 98: '/', 55: '*', 14: 'BS', 96: 'ENTER'} ctrlKeys = { 69: 'NUML', 98: '/', 55: '*', 14: 'BS', 96: 'ENTER'}
volKeys = { 74: '-', 78: '+', 83: '.'} volKeys = { 74: '-', 78: '+', 83: '.'}
@ -69,7 +69,7 @@ class KeypadListener:
ctrlKeySound.play() ctrlKeySound.play()
elif self._buf == passwd: elif self._buf == passwd:
self.resetBuffer() self.resetBuffer()
stateMachine.DISARM stateMachine.DISARM()
else: else:
self.resetBuffer() self.resetBuffer()
wrongPassSound.play() wrongPassSound.play()
@ -77,20 +77,17 @@ class KeypadListener:
# lock # lock
elif val == 'NUML': elif val == 'NUML':
self.resetBuffer() self.resetBuffer()
stateMachine.LOCK stateMachine.LOCK()
ctrlKeySound.play()
# instant lock # instant lock
elif val == '/': elif val == '/':
self.resetBuffer() self.resetBuffer()
stateMachine.INSTANT_LOCK stateMachine.INSTANT_LOCK()
ctrlKeySound.play()
# arm # arm
elif val == '*': elif val == '*':
self.resetBuffer() self.resetBuffer()
stateMachine.ARM stateMachine.ARM()
ctrlKeySound.play()
# delete last char in buffer # delete last char in buffer
elif val == 'BS': elif val == 'BS':

View File

@ -95,10 +95,12 @@ class SoundLib:
mixer.init() mixer.init()
self.soundEffects = { self.soundEffects = {
'disarmedCountdown': SoundEffect(path='soundfx/smb_coin.wav'), 'disarmedCountdown': SoundEffect(path='soundfx/smb_kick.wav'),
'disarmed': SoundEffect(path='soundfx/smb_pause.wav'), 'disarmed': SoundEffect(path='soundfx/smb_pause.wav'),
'armed': SoundEffect(path='soundfx/smb_powerup.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), 'triggered': SoundEffect(path='soundfx/alarms/burgler_alarm.ogg', volume=1.0, loops=-1),
'door': SoundEffect(path='soundfx/smb_pipe.wav'), 'door': SoundEffect(path='soundfx/smb_pipe.wav'),
'numKey': SoundEffect(path='soundfx/smb_bump.wav'), 'numKey': SoundEffect(path='soundfx/smb_bump.wav'),

View File

@ -167,7 +167,7 @@ class StateMachine:
# add signals to self to avoid calling partial every time # add signals to self to avoid calling partial every time
for sig in _SIGNALS: for sig in _SIGNALS:
setattr(self, sig.name, partial(self.selectState, sig)) setattr(self, sig.name, partial(self.selectState, sig))
secretTable = { secretTable = {
'dynamoHum': self.DISARM, 'dynamoHum': self.DISARM,
'zombyWoof': self.ARM, 'zombyWoof': self.ARM,
@ -223,19 +223,19 @@ class StateMachine:
), ),
_State( _State(
name = 'armed', name = 'armed',
entryCallbacks = [partial(linearBlink, 2)], entryCallbacks = [partial(linearBlink, 1)],
sound = sfx['armed'] sound = sfx['armed']
), ),
_State( _State(
name = 'lockedCountdown', name = 'lockedCountdown',
entryCallbacks = [partial(squareBlink, 1), partial(startTimer, 30, sfx['disarmedCountdown'])], entryCallbacks = [partial(squareBlink, 1), partial(startTimer, 30, sfx['lockedCountdown'])],
exitCallbacks = [stopTimer], exitCallbacks = [stopTimer],
sound = sfx['disarmedCountdown'] sound = sfx['lockedCountdown']
), ),
_State( _State(
name = 'locked', name = 'locked',
entryCallbacks = [partial(linearBlink, 3)], entryCallbacks = [partial(squareBlink, 2)],
sound = sfx['armed'] sound = sfx['locked']
), ),
_State( _State(
name = 'armedCountdown', name = 'armedCountdown',
@ -245,7 +245,7 @@ class StateMachine:
), ),
_State( _State(
name = 'triggered', name = 'triggered',
entryCallbacks = [partial(linearBlink, 1), intruderAlert], entryCallbacks = [partial(linearBlink, 0.5), intruderAlert],
sound = sfx['triggered'] sound = sfx['triggered']
) )
] ]