Semester assignments for the course "Microprocessors and Peripherals" of THMMY in AUTH university.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

25 lines
770 B

#!/usr/bin/python
from redBlocks import *
def keyPadCallback(sc, interface,value):
if value:
key = ord(interface.getName()[6]) - 0x30
print( "Key " + interface.getName()[6] + " pressed." )
sc.CC("Keypad").sendMessage( bytearray([key]) )
scf = SimulatorConnectionFactory()
scf.registerCC("Keypad")
scf.registerSBO("KeyPad0", keyPadCallback)
scf.registerSBO("KeyPad1", keyPadCallback)
scf.registerSBO("KeyPad2", keyPadCallback)
scf.registerSBO("KeyPad3", keyPadCallback)
scf.registerSBO("KeyPad4", keyPadCallback)
scf.registerSBO("KeyPad5", keyPadCallback)
scf.registerSBO("KeyPad6", keyPadCallback)
scf.registerSBO("KeyPad7", keyPadCallback)
scf.registerSBO("KeyPad8", keyPadCallback)
scf.registerSBO("KeyPad9", keyPadCallback)
sc = scf.create()
loopForever()