41 lines
1.8 KiB
Markdown
41 lines
1.8 KiB
Markdown
# flow3r-openhab
|
|
|
|
An app for the CCCamp 2023 [flow3r][flow3r] badge that submits detected touch gestures to an MQTT broker.
|
|
|
|
I wrote this so that the flow3r can be used as a remote control for
|
|
OpenHAB (which subscribes to the MQTT broker), but it should be usable
|
|
with other subscribers as well.
|
|
|
|
## Installation
|
|
|
|
1. Copy `flow3r_openhab/config.example.json` to `flow3r_openhab/config.json` and enter your configuration details.
|
|
1. Copy the `flow3r_openhab` directory to `/sys/apps/flow3r_openhab` on the flow3r's flash filesystem.
|
|
1. Reboot the flow3r and start the `OpenHAB` app
|
|
|
|
## Events
|
|
|
|
The touch events detected by the flow3r are published to the topic `flow3r-<macaddress>/event`.
|
|
|
|
Each event is a JSON string that looks like this:
|
|
|
|
```json
|
|
{"petal":"2","event":"touch_tip","dx":8083,"dy":6960,"duration":150}
|
|
```
|
|
|
|
The keys and their values are defined as follows:
|
|
|
|
| Key | Value |
|
|
|:---|:---|
|
|
| `petal` | The petal the event was detected on. Uses the numbers printed on the PCB (1-10), rather than the `captouch` indexes (0-9). |
|
|
| `event` | The type of gesture that was detected. One of `touch_tip`, `touch_base`, `swipe_up`, `swipe_right`, `swipe_down`, `swipe_left`, whereas `swipe_up` always means a swipe towards the tip of the petal, and `swipe_down` towards its base. |
|
|
| `dx` | The distance between start and end of the touch event in `x` (base-to-tip) direction. Unitless number, as returned by [captouch's `position()` function][captouch]. |
|
|
| `dy` | The distance between start and end of the touch event in `y` (side-to-side) direction. |
|
|
| `duration` | The duration between start and end of the touch event in `ms`. |
|
|
|
|
|
|
## License
|
|
|
|
MIT License
|
|
|
|
[flow3r]: https://flow3r.garden/
|
|
[captouch]: https://docs.flow3r.garden/api/captouch.html#captouch.CaptouchPetalState.position
|