requests.get(VELUX + 'toggle/3/', timeout=2).content if state & (1 << 5): # Toggle Blinds #"Toggle Blinds" requests.get(VELUX + 'toggle/2/', timeout=2).content requests.get(VELUX + 'toggle/4/', timeout=2).content except: pass if __name__ == "__main__": ipcon = IPConnection() mt = BrickletMultiTouch(UID, ipcon) ipcon.connect(HOST, PORT) time.sleep(1) mt.recalibrate() mt.register_callback(mt.CALLBACK_TOUCH_STATE, cb_touch_state) #previos_state = "" #while True: # state = mt.get_touch_state() # if state != previous_state: # cb_touch_state(state) # previous_state = state # time.sleep(0.5) raw_input("Press key to exit\n") # Use input() in Python 3 ipcon.disconnect()
s = "" if state & (1 << 12): s += "In proximity, " if (state & 0xfff) == 0: s += "No electrodes touched" else: s += "Electrodes " for i in range(12): if state & (1 << i): s += str(i) + " " s += "touched" print(s) ipcon = IPConnection() # Verbindung mit dem Master herstellen mt = BrickletMultiTouch(UID, ipcon) # Verbindung zum Touchpad anlegen ipcon.connect(HOST, PORT) # Verbinden mt.recalibrate( ) # Rekalibrieren, sonst wird das Touchpad nicht sauber ausgewertet # Callback funktion anmelden mt.register_callback(mt.CALLBACK_TOUCH_STATE, cb_touch_state) input("Drücke ENTER zum beenden\n" ) # Auf irgendetwas warten, sonst habt Ihr keine Zeit etwas zu tun ipcon.disconnect() # Die Verbindung wieder abbauen