Developers / API reference / Python library
Python library
The HaptGlovePython library builds BLE payloads that drive the glove. Reference for the parts you'll use most.
Haptics
Create a Haptics instance for a hand, then build payloads to write to the glove's BLE characteristic.
python
from Haptics import Haptics
haptics = Haptics("right") # or "left"hexr_pressure_multiple(fingers, states, intensities, speeds)
Returns the bytes to write for pressure across several fingers at once.
| Argument | Type | Description |
|---|---|---|
| fingers | list[Haptics.Finger] | Thumb, Index, Middle, Ring, Pinky, Palm — enum members, not strings |
| states | list[bool] | True applies pressure, False releases it |
| intensities | list[float] | 0.1–1.0 per channel, mapped to 15–50 kPa |
| speeds | list[float] | 0.1–1.0 per channel — the ramp rate, not the strength |
Fingers are enum members
Passing a string raises AttributeError. Use Haptics.Finger.Index, not "Index".
python
from Haptics import Haptics
F = Haptics.Finger
# Drive all six channels
data = haptics.hexr_pressure_multiple(
[F.Thumb, F.Index, F.Middle, F.Ring, F.Pinky, F.Palm],
[True]*6, [0.8]*6, [1.0]*6)
await client.write_gatt_char(CHAR_UUID, data)
# Release them again
data = haptics.hexr_pressure_multiple(
[F.Thumb, F.Index, F.Middle, F.Ring, F.Pinky, F.Palm],
[False]*6, [0]*6, [1.0]*6)
await client.write_gatt_char(CHAR_UUID, data)Helper scripts
AddressDiscovery.py— find your glove's BLE addressCharacteristicDiscovery.py— list the glove's BLE characteristicsExampleHaptics.py— a ready-to-run example
Soon
The full method list (other actuation modes and parameters) is being documented. Read the source in the HaptGlovePython repo in the meantime.