Flick is a range of add-on boards for the Raspberry Pi, bringing 3D tracking and gesture control in various form factors. These gestures can be associated with specific commands, offering an entire new way of controlling devices.
In this guide, we’ll cover the control of the JustBoom Player using gestures with Flick and REST.
- One Raspberry Pi with JustBoom pHAT or HAT, and the official JustBoom Player installed
- One Raspberry Pi with Flick board, and Flick software installed
Both Raspberry Pi should be connected to the same (wireless) network, and will interface via REST.
For more information on setting up the JustBoom Player or getting started with Flick, please refer to following guides:
The JustBoom Player, based on Volumio, can be controlled via its REST API. This API makes it possible for any device to control the player using specific URLs.
The full REST API is documented on the Volumio website.
Using Python, it is possible to combine the Flick library with this REST API, associating gestures with commands such as “play”, “pause”, etc …
Below is an example function of how to tackle REST calls in Python, with some checks for connection issues or unexpected responses:
With the REST calls available in a simple function, it’s a small task to combine it with the existing Flick demo code.
Below, is the full code for this project. The inline comments should help you understand the code.
Upload the code to your Pi using scp and give it the necessary permissions:
scp flick-justboom-rest.py firstname.lastname@example.org:Flick/bin/
sudo chmod +x /home/pi/Flick/bin/flick-justboom-rest.py
Run the script, you are ready to try it out!