This series of articles will explain how to use The Tactigon’s integrated sensors and communication interfaces to create a simple gesture controller.
In this article we’re going to learn how to use simple Tactigon’s functions to send accelerometer data and quaternions over Bluetooth Low Energy (BLE from now on).
We’ll look at, in details, to:
- Why Processing?
- Used Libraries
- UUID and Characteristic
- Connection To Device
- Get Data Stream
- Final Considerations
We choose processing because it’s a diffuse software sketchbook, simple and easy to start with. It offers Java and Android compatiblity, and usually it’s possible to port an application from Java to Android with little to no change in coding.
A lot of hobbyists use Processing, so it’s easy to find support, sketches and libraries, as well as in depth tutorials and communities.
This example uses few essential libraries:
We’ll focus on Blepdroid while other libraries are not the aim of this post.
Gesture controller with Blepdroid
This library is developed specifically for Processing, in Android environment.
Blepdroid is available at:
UUID and Characteristic
As we have seen in previous part, we send data from our Tactigon board with a specific UUID. We have to use the same Identifier in this code, to be able to intercept it and read associated Characteristic value.
This is the static String declaration:
public static String TACTIGON_QUAT_CHAR_STRING = “7ac71000-503d-4920-b000-acc000000001”;
Connection To Device
The onDeviceDiscovered() function verify if the BLE device discovered is The Tactigon board or another one.
To listen to the characteristic, we have to call for onServiceDiscovered(). This function scans for available Characteristic and, if available, set the listener to the one with TACTIGON_QUAT_UUID uuid.
Get The Data Stream
The onCharacteristicChanged() function will pull data out of the Characteristic byte data, reordering byte values to be able to plot them.
Once obtained the right data to plot, a shift in the plot arrays is executed, freeign a position for the last gathered value. This arrays are now ready to be plotted on the chards by the draw() function.
This Processing sketch is just a simple way to get data and print on an Android screen. By using more advanced algorithms and Processing functions, it’s possible to integrate a gesture controller with blepdroid!
Stay tuned for more Tactigon’s code!