Port 6 Touch SDK
Project description
Touch SDK py
Connects to Port 6 Touch SDK compatible Bluetooth devices – like this Wear OS app.
There is also a web SDK and a Unity SDK.
See port6.io/sdk for more info.
Installation
pip install touch-sdk
Example usage
from touch_sdk import Watch
class MyWatch(Watch):
def on_tap(self):
print('Tap')
watch = MyWatch()
watch.start()
Usage
All callback functions should be methods in the class that inherits Watch
, like in the example above.
An optional name string in the constructor will search only for devices with that name (case insensitive).
watch = MyWatch('fvaf')
Tap gesture
def on_tap(self):
print('tap')
Sensors
def on_sensors(self, sensors):
print(sensors.acceleration) # (x, y, z)
print(sensors.gravity) # (x, y, z)
print(sensors.angular_velocity) # (x, y, z)
print(sensors.orientation) # (x, y, z, w)
print(sensors.magnetic_field) # (x, y, z), or None if unavailable
print(sensors.magnetic_field_calibration) # (x, y, z), or None if unavailable
Touch screen
def on_touch_down(self, x, y):
print('touch down', x, y)
def on_touch_up(self, x, y):
print('touch up', x, y)
def on_touch_move(self, x, y):
print('touch move', x, y)
def on_touch_cancel(self, x, y):
print('touch cancel', x, y)
Rotary dial
def on_rotary(self, direction):
print('rotary', direction)
Outputs +1 for clockwise and -1 for counter-clockwise.
Back button
def on_back_button(self):
print('back button')
Called when the back button is pressed and released. Wear OS does not support separate button down and button up events for the back button.
Haptics
The trigger_haptics(intensity, length)
method can be used to initiate one-shot haptic effects on the watch. For example, to drive the haptics motor for 300 ms at 100% intensity on watch
, call watch.trigger_haptics(1.0, 300)
.
Unexplainable bugs
Sometimes turning your device's Bluetooth off and on again fixes problems – this has been observed on Linux, Mac and Windows. This is unideal, but those error states are hard to reproduce and thus hard to fix.
Pylint
python3 -m pylint src --rcfile=.pylintrc
Adding pylint to pre-commit
echo 'python3 -m pylint src --rcfile=.pylintrc -sn' > .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for touch_sdk-0.5.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89627699beec2cad7be40202fbb3d8dd44d29122e47f0835f99df3cb69e9668c |
|
MD5 | c4f826c784e205749426003073c72b75 |
|
BLAKE2b-256 | 399950eba9670972eb244adb2e75cf797e560fb0e252f2ae6b895d1b30a3bd8c |