async def run(loop, debug=False): if debug: import sys # loop.set_debug(True) l = logging.getLogger("asyncio") l.setLevel(logging.DEBUG) h = logging.StreamHandler(sys.stdout) h.setLevel(logging.INFO) l.addHandler(h) logger.addHandler(h) client = TapSDK(address="D7:6D:0F:56:6A:F0", loop=loop) # devices = await client.list_connected_taps() x = await client.manager.connect_retrieved() x = await client.manager.is_connected() logger.info("Connected: {0}".format(x)) await client.set_input_mode(TapInputMode("controller")) await client.register_air_gesture_events(OnGesture) await client.register_tap_events(OnTapped) await client.register_raw_data_events(OnRawData) await client.register_mouse_events(OnMoused) await client.register_air_gesture_state_events(OnMouseModeChange) await asyncio.sleep(3) await client.set_input_mode(TapInputMode("raw", sensitivity=[0, 0, 0])) await asyncio.sleep(3) await client.set_input_mode(TapInputMode("text")) await asyncio.sleep(3) await client.set_input_mode(TapInputMode("raw", sensitivity=[2, 2, 2])) await client.send_vibration_sequence([100, 200, 300, 400, 500]) await asyncio.sleep(50.0, loop=loop)
async def run(loop=None, debug=False): if debug: import sys loop.set_debug(True) h = logging.StreamHandler(sys.stdout) h.setLevel(logging.WARNING) logger.addHandler(h) client = TapSDK(None, loop) if not await client.client.connect_retrieved(): logger.error("Failed to connect the the Device.") return logger.info("Connected to {}".format(client.client.address)) await client.set_input_mode(TapInputMode("controller")) await client.register_air_gesture_events(OnGesture) await client.register_tap_events(OnTapped) await client.register_raw_data_events(OnRawData) await client.register_mouse_events(OnMoused) await client.register_air_gesture_state_events(OnMouseModeChange) # logger.info("Changing to text mode") await client.set_input_mode(TapInputMode("text")) # await asyncio.sleep(30)) logger.info("Changing to raw mode") await client.set_input_mode(TapInputMode("raw")) # await client.send_vibration_sequence([100, 200, 300, 400, 500]) await asyncio.sleep(50.0, loop=loop)
def on_air_gesture_event(identifier, air_gesture): print(" Air gesture: " + AirGestures(air_gesture).name) if air_gesture == AirGestures.UP_ONE_FINGER.value: tap_instance.set_input_mode(TapInputMode("raw"), identifier) if air_gesture == AirGestures.DOWN_ONE_FINGER.value: tap_instance.set_input_mode(TapInputMode("text"), identifier) if air_gesture == AirGestures.LEFT_ONE_FINGER.value: tap_instance.set_input_mode(TapInputMode("controller"), identifier)
async def run(loop): client = TapSDK(loop) x = await client.manager.connect_retrieved() await client.register_raw_data_events(OnRawData) await client.set_input_mode(TapInputMode("raw", sensitivity=[2, 2, 2])) await asyncio.sleep(500.0, loop=loop)
def main(): global tap_instance tap_instance = TapSDK() tap_instance.run() tap_instance.register_connection_events(on_connect) tap_instance.register_disconnection_events(on_disconnect) tap_instance.register_tap_events(on_tap_event) tap_instance.register_raw_data_events(on_raw_sensor_data) tap_instance.set_input_mode(TapInputMode("controller")) while True: pass
def main(): global tap_instance tap_instance = TapSDK() tap_instance.run() tap_instance.register_connection_events(on_connect) tap_instance.register_disconnection_events(on_disconnect) tap_instance.register_mouse_events(on_mouse_event) tap_instance.register_tap_events(on_tap_event) tap_instance.register_raw_data_events(on_raw_sensor_data) tap_instance.register_air_gesture_events(on_air_gesture_event) tap_instance.register_air_gesture_state_events(on_air_gesture_state_event) tap_instance.set_input_mode(TapInputMode("controller")) # tap_instance.set_input_mode(TapInputMode("raw", sensitivity=[2,1,4])) # tap_instance.set_input_mode(TapInputMode("text")) # tap_instance.set_default_input_mode(TapInputMode("raw", sensitivity=[2,1,4])) # sleep(3.0) while True: pass
def on_raw_sensor_data(identifier, raw_sensor_data): # print(raw_sensor_data) if raw_sensor_data.GetPoint(1).z > 2000 and raw_sensor_data.GetPoint( 2).z > 2000 and raw_sensor_data.GetPoint( 3).z > 2000 and raw_sensor_data.GetPoint(4).z > 2000: tap_instance.set_input_mode(TapInputMode("controller"), identifier)
# print(raw_sensor_data) if raw_sensor_data.GetPoint(1).z > 2000 and raw_sensor_data.GetPoint( 2).z > 2000 and raw_sensor_data.GetPoint( 3).z > 2000 and raw_sensor_data.GetPoint(4).z > 2000: tap_instance.set_input_mode(TapInputMode("controller"), identifier) tap_instance tap_instance = TapSDK() tap_instance.run() tap_instance.register_connection_events(on_connect) tap_instance.register_disconnection_events(on_disconnect) tap_instance.register_mouse_events(on_mouse_event) tap_instance.register_tap_events(on_tap_event) tap_instance.register_raw_data_events(on_raw_sensor_data) tap_instance.register_air_gesture_events(on_air_gesture_event) tap_instance.register_air_gesture_state_events(on_air_gesture_state_event) tap_instance.set_input_mode(TapInputMode("controller")) @app.route('/') def hello_world(): global data temp = data data = [] return str(temp) if __name__ == "__main__": main()
async def connect(self): if not await self.tap_sdk.client.connect_retrieved(): print("Error connecting to {}".format(self.address)) return None print("Connected to {}".format(self.tap_sdk.client.address)) await self.tap_sdk.set_input_mode(TapInputMode("controller"))
def connection(identifier, name, firmware): strap.set_input_mode(TapInputMode("raw")) global connected connected = True