#### # configuration ## enc0A = connector.gpio1p5 enc0B = connector.gpio1p7 enc0 = "/enc0" #### # initialisation ## gpio.init() gpio.setcfg(enc0A, gpio.INPUT) gpio.setcfg(enc0B, gpio.INPUT) gpio.pullup(enc0A, gpio.PULLUP) gpio.pullup(enc0B, gpio.PULLUP) #def read_config (path) : def osc_send (value,channel) : msg = osc_message_builder.OscMessageBuilder(address = channel) msg.add_arg(value, "i") msg = msg.build() client.send(msg) def send (value) : msg = osc_message_builder.OscMessageBuilder(address = "/test") msg.add_arg(value, "i")
__credits__ = ["Stefan Mavrodiev"] __license__ = "GPL" __version__ = "2.0" __maintainer__ = __author__ __email__ = "*****@*****.**" led = connector.gpio0p0 # This is the same as port.PH2 button = connector.gpio3p40 """Init gpio module""" gpio.init() """Set directions""" gpio.setcfg(led, gpio.OUTPUT) gpio.setcfg(button, gpio.INPUT) """Enable pullup resistor""" gpio.pullup(button, gpio.PULLUP) #gpio.pullup(button, gpio.PULLDOWN) # Optionally you can use pull-down resistor try: print ("Press CTRL+C to exit") while True: state = gpio.input(button) # Read button state """Since we use pull-up the logic will be inverted""" gpio.output(led, not state) except KeyboardInterrupt: print ("Goodbye.")
#### # configuration ## enc0A = connector.gpio1p5 enc0B = connector.gpio1p7 enc0 = "/enc0" #### # initialisation ## gpio.init() gpio.setcfg(enc0A, gpio.INPUT) gpio.setcfg(enc0B, gpio.INPUT) gpio.pullup(enc0A, gpio.PULLUP) gpio.pullup(enc0B, gpio.PULLUP) #def read_config (path) : def osc_send(value, channel): msg = osc_message_builder.OscMessageBuilder(address=channel) msg.add_arg(value, "i") msg = msg.build() client.send(msg) def send(value): msg = osc_message_builder.OscMessageBuilder(address="/test") msg.add_arg(value, "i")