This series of articles will explain how to use The Tactigon’s integrated sensors and communication interfaces to create a simple wearable 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:
- Used Libraries
- UUID and Characteristic
- Final Considerations
This example uses few essential libraries:
First three libraries, have been analyzed on first part of this series, we now discover tactigon_BLE.h library.
This library is dedicated to integrated BLE module. It provides few types needed to create a communication between two devices.
T_BLE is BLE Manager (bleManager instance in this example), it handles UUID, Characteristics and their buffer. In next examples we’ll see other methods of this class, handling connection and its status.
UUID is the universally unique identification, which, associated with a characteristic, allows to identify it by external devices.
T_BLE_Characteristic is the characteristic class. It needs an UUID and length in bytes of the payload it will transmit.
UUID and Characteristic
In the setup function we created an uuid with the uuid.set() method.
The UUID needs to be unique at application level.
The String “7ac71000-503d-4920-b000-acc000000001″ used is unique since we use only this in our sketch.
We set the Characteristic (bleChar instance) with the bleManager.addNewChar() method, which instantiate a new Characteristic object by providing an UUID and the data length in byte (14 in this example).
Sampling and transmission frequency
With the condition:
if(GetCurrentMilli() >= (ticks +(1000 / 50)))
ticks = GetCurrentMilli();
we let sensors acquisition, buffering and transmission happen at 50Hz.
An unsigned char array (also 14 bytes size) is used as buffer for the characteristic.
With memcpy we prepare this buffer, filling with sensors data.
memcpy(&buffData, &qData.q0, 2);
This execution of memcpy copies the memory area pointed by qData.q0, 2 bytes long, in the memory area pointed by buffData. It’a a binary operation, so data type is not relevant.
Same applies for other Quaternions and Accelerometer data in this example.
Once the buffer has been prepared with all needed informations, bleChar.update(buffData) function is called.
This function notify bleChar that a buffer is ready for transmission.
The library will transmit it as soon as possible.
Final Considerations – Wearable Gesture Controller
This sketch is another step towards the creation of a wearable gesture controller with The Tactigon. In next article we’ll look at how to receive and use data sent by this sketch in a processing environment.
Stay tuned for more Tactigon’s code!