class TrellisKeypadThread(GPIOThread): def __init__(self): from TrellisKeypad import TrellisKeypad self.component = TrellisKeypad(callback=self.on_button_press) super(TrellisKeypadThread, self).__init__() def state_parser(self): sleep(0.03) self.component.listen() def on_button_press(self, button): super(TrellisKeypadThread, self).send("mapping/%d" % button)
def __init__(self): from TrellisKeypad import TrellisKeypad self.component = TrellisKeypad(callback=self.on_button_press) super(TrellisKeypadThread, self).__init__()
from time import sleep from TrellisKeypad import TrellisKeypad def on_button_press(button): print "Button pressed: %d" % button if __name__ == "__main__": trellis = TrellisKeypad(callback=on_button_press) while True: sleep(0.03) trellis.listen()