#include <libraries/Trill/Trill.h>
#include <cmath>
#define NUM_TOUCH 5 // Number of touches on Trill sensor
#define NUM_LED 12 // Number of LEDs used for visualisation
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 };
int gNumActiveTouches = 0;
unsigned int gTaskSleepTime = 12000;
float gTimePeriod = 0.01;
unsigned int gLedPins[NUM_LED] = { 0, 1, 2, 3, 4, 5, 8, 9, 11, 12, 13, 14 };
bool gLedStatus[NUM_LED] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
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 Bar\n");
return false;
}
for(unsigned int l = 0; l < NUM_LED; l++)
pinMode(context, 0, gLedPins[l], OUTPUT);
return true;
}
{
bool activeSections[NUM_LED] = { false };
static unsigned int count = 0;
for(
unsigned int n = 0; n < context->
audioFrames; n++) {
for(unsigned int t = 0; t < gNumActiveTouches; t++) {
int section = floor( NUM_LED * gTouchLocation[t] );
activeSections[section] = activeSections[section] || 1;
}
for(unsigned int l = 0; l < NUM_LED; l++) {
gLedStatus[l] = activeSections[l];
}
{
for(unsigned int l = 0; l < NUM_LED; l++)
rt_printf("%d ",gLedStatus[l]);
rt_printf("\n");
count = 0;
}
count++;
}
}
{}