View ControllerServer8.py
charNum = 0 | |
for char, prevChar in zip(packet[1], PrevPacket['K']): | |
if (char == '0') and (prevChar == '1'): | |
controller.device.emit(controller.devKeys[(controllerNum*Controller.NumButtons) + charNum], 1) | |
elif (char == '1') and (prevChar == '0'): | |
controller.device.emit(controller.devKeys[(controllerNum*Controller.NumButtons) + charNum], 0) | |
charNum = charNum + 1 | |
PrevPacket['K'] = packet[1] |
View ControllerServer7.py
if packet[0] == 'K': | |
#... | |
elif packet[0] == 'A': | |
#... | |
elif packet[0] == 'B': | |
#... |
View ControllerServer6.py
line = controller.serial.readline() | |
print line | |
packet = line.split(':') |
View ControllerServer5.py
while True: | |
controllerNum = 0 | |
for controller in Controllers: | |
#... | |
controllerNum = controllerNum + 1 |
View ControllerServer4.py
PrevPacket = {} | |
PrevPacket['K'] = '1' * Controller.NumButtons |
View ControllerServer3.py
Controllers = [] | |
controllerNum = 0 | |
for controllerName in ControllerNames: | |
Controllers.append(Controller(controllerName, ValidKeys[controllerNum:((controllerNum*Controller.NumButtons) - 1)])) | |
Controllers[controllerNum].serial.reset_input_buffer() | |
controllerNum = controllerNum + 1 |
View ControllerServer2.py
ControllerNames = ["rfcomm0"] |
View ControllerServer1.py
ValidKeys = [ KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G, KEY_H, KEY_I, KEY_J, | |
KEY_K, KEY_L, KEY_M, KEY_N, KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, | |
KEY_U, KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z,] |
View ControllerServer0.py
class Controller: | |
"""docstring for Controller""" | |
NumButtons = 8 | |
def __init__(self, devName, devKeys): | |
self.devPath = "/dev/" + devName | |
try: | |
print "Connecting to " + self.devPath | |
self.serial = serial.Serial(self.devPath, 9600, timeout=10) |
View ControllerTestFirmware3.ino
delay(10); |
NewerOlder