This example shows how to communicate with the Trill Ring sensor using the Trill library. It visualises the touch position and size of up to five touches in real time on the GUI.
In this file Trill sensor is scanned in an AuxiliaryTask running in parallel with the audio thread and the horizontal and vertical position and size are stored in global variables.
Click the GUI button to see the visualisation. Touch position and size are displayed in the sketch.
#include <cmath>
#include <libraries/Trill/Trill.h>
#include <libraries/Gui/Gui.h>
#define NUM_TOUCH 5 // Number of touches on Trill sensor
float gTouchLocation[NUM_TOUCH] = { 0.0, 0.0, 0.0, 0.0, 0.0 };
float gTouchSize[NUM_TOUCH] = { 0.0, 0.0, 0.0, 0.0, 0.0 };
unsigned int gNumActiveTouches = 0;
unsigned int gTaskSleepTime = 12000;
float gTimePeriod = 0.015;
void loop(void*)
{
{
for(unsigned int i = 0; i < gNumActiveTouches; i++) {
}
for(unsigned int i = gNumActiveTouches; i < NUM_TOUCH; i++) {
gTouchLocation[i] = 0.0;
gTouchSize[i] = 0.0;
}
usleep(gTaskSleepTime);
}
}
{
fprintf(stderr, "Unable to initialise Trill Ring\n");
return false;
}
return true;
}
{
static unsigned int count = 0;
for(
unsigned int n = 0; n < context->
audioFrames; n++) {
{
count = 0;
}
count++;
}
}
{}