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
# 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)

View File

@ -24,7 +24,7 @@ class KeypadListener:
- countdown timer to reset the input buffer after 30 seconds of inactivity
'''
def __init__(self, stateMachine, passwd):
ctrlKeys = { 69: 'NUML', 98: '/', 55: '*', 14: 'BS', 96: 'ENTER'}
volKeys = { 74: '-', 78: '+', 83: '.'}
@ -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':

View File

@ -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'),

View File

@ -167,7 +167,7 @@ class StateMachine:
# add signals to self to avoid calling partial every time
for sig in _SIGNALS:
setattr(self, sig.name, partial(self.selectState, sig))
secretTable = {
'dynamoHum': self.DISARM,
'zombyWoof': self.ARM,
@ -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']
)
]