add passwd lock for all keypad controls

This commit is contained in:
petrucci4prez 2017-06-18 15:09:40 -04:00
parent 4b922a126b
commit 4b180efe19
1 changed files with 16 additions and 17 deletions

View File

@ -43,6 +43,16 @@ class KeypadListener:
wrongPassSound = soundLib.soundEffects['wrongPass'] wrongPassSound = soundLib.soundEffects['wrongPass']
backspaceSound = soundLib.soundEffects['backspace'] backspaceSound = soundLib.soundEffects['backspace']
def checkPasswd(action):
if self._buf == '':
ctrlKeySound.play()
elif self._buf == passwd:
self.resetBuffer()
action()
else:
self.resetBuffer()
wrongPassSound.play()
def getInput(): def getInput():
while 1: while 1:
select([self._dev], [], []) select([self._dev], [], [])
@ -51,7 +61,6 @@ class KeypadListener:
# numeral input # numeral input
if event.code in numKeys: if event.code in numKeys:
if stateMachine.currentState != stateMachine.states.disarmed:
self._buf = self._buf + numKeys[event.code] self._buf = self._buf + numKeys[event.code]
self._startResetTimer() self._startResetTimer()
numKeySound.play() numKeySound.play()
@ -65,29 +74,19 @@ class KeypadListener:
if stateMachine.currentState == stateMachine.states.disarmed: if stateMachine.currentState == stateMachine.states.disarmed:
ctrlKeySound.play() ctrlKeySound.play()
else: else:
if self._buf == '': checkPasswd(stateMachine.DISARM)
ctrlKeySound.play()
elif self._buf == passwd:
self.resetBuffer()
stateMachine.DISARM()
else:
self.resetBuffer()
wrongPassSound.play()
# lock # lock
elif val == 'NUML': elif val == 'NUML':
self.resetBuffer() checkPasswd(stateMachine.LOCK)
stateMachine.LOCK()
# instant lock # instant lock
elif val == '/': elif val == '/':
self.resetBuffer() checkPasswd(stateMachine.INSTANT_LOCK)
stateMachine.INSTANT_LOCK()
# arm # arm
elif val == '*': elif val == '*':
self.resetBuffer() checkPasswd(stateMachine.ARM)
stateMachine.ARM()
# delete last char in buffer # delete last char in buffer
elif val == 'BS': elif val == 'BS':