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(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)
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 __init__(self, address, name, layer_config, loop): self.address = address self.name = name self.layer_config = layer_config self.layer_list = layer_config[2] # list of cmd layers on the other hand that can be accessed by this hand through prefixes self.other_hand_layers = layer_config[3] self.prefix_layer = self.layer_config[0] self.default_layer = self.layer_config[1] self.tap_sdk = TapSDK(address, loop)
from tapsdk import TapSDK tap_device = TapSDK() tap_device.set_input_mode(TapInputMode('raw', sensitivity=[2, 1, 4]))
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
if air_gesture_state: print("Entered air mouse mode") else: print("Left air mouse mode") 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) 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
from tapsdk import TapSDK, TapInputMode import pyautogui import statistics import time strap = TapSDK() connected = False IMU_A = [0, 0, 0] IMU_G = [0, 0, 0] DEV1 = [0, 0, 0] DEV2 = [0, 0, 0] UpA = 0 UpZero = 0 CALIBRATE_SAMPLE = 20 LIFTDOWN_THRESHOLD = 0 dCursor = [0, 0] MAIN_FREQ = 60 LIFT_FREQ = 12 def connection(identifier, name, firmware): strap.set_input_mode(TapInputMode("raw")) global connected connected = True def disconnection(identifier): global connected connected = False
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