G1sms/shell/tools/matrixKeypad.py

42 lines
758 B
Python
Executable File

#! /usr/bin/python
import fourletterphat
from matrixKeypad_RPi_GPIO import keypad
from time import sleep
# Initialize the keypad class
kp = keypad()
fourletterphat.print_str(" G1?")
fourletterphat.show()
def digit():
# Loop while waiting for a keypress
r = None
while r == None:
r = kp.getKey()
return r
#print ("Please enter a 4 digit code: ")
# Getting digit 1, printing it, then sleep to allow the next digit press.
d1 = digit()
#print (d1)
sleep(0.25)
d2 = digit()
#print (d2)
sleep(0.25)
d3 = digit()
#print (d3)
sleep(0.25)
d4 = digit()
#print (d4)
# printing out the assembled 4 digit code.
print "%s%s%s%s"%(d1,d2,d3,d4)
fourletterphat.clear()
fourletterphat.scroll_print("OK %s%s%s%s"%(d1,d2,d3,d4))
sleep(2)