Trill Print Raw Values
This example will work with all types of Trill sensor and will print the raw reading from each pad.
We are using the Trill library to read from the sensor. The first thing to do is make sure that the correct sensor type is given to touchSensor.setup(). If you have changed the address of the sensor then you will need to add the new address that to this function too.
The Trill sensor is scanned on an auxiliary task running parallel to the audio thread and is read in DIFF mode giving the differential reading of each pad on the sensor.
Once you run the project you will see the value of each capacitive pad on the sensor being printed. This is a good project to run to debug your sensors and make sure they are connected correctly.
#include <libraries/Trill/Trill.h>
int gPrintInterval = 500;
int gPrintIntervalSamples = 0;
unsigned int gTaskSleepTime = 12000;
void loop(void*)
{
touchSensor.readI2C();
usleep(gTaskSleepTime);
}
}
{
fprintf(stderr, "Unable to initialise Trill Craft\n");
return false;
}
touchSensor.printDetails();
return true;
}
{
static int readCount = 0;
for(
unsigned int n = 0; n < context->
audioFrames; n++) {
if(readCount >= gPrintIntervalSamples) {
readCount = 0;
for(unsigned int i = 0; i < touchSensor.getNumChannels(); i++)
rt_printf("%1.3f ", touchSensor.rawData[i]);
rt_printf("\n");
}
readCount++;
}
}
{
}
A class to use the Trill family of capacitive sensors. http://bela.io/trill.
Definition Trill.h:14
@ CRAFT
Trill Craft
Definition Trill.h:36
int setMode(Mode mode)
Definition Trill.cpp:504
@ DIFF
Definition Trill.h:25
AuxiliaryTask Bela_runAuxiliaryTask(void(*callback)(void *), int priority=0, void *arg=nullptr)
Create and start an AuxiliaryTask.
int Bela_stopRequested()
Check whether the program should stop.
void render(BelaContext *context, void *userData)
User-defined callback function to process audio and sensor data.
Definition render.cpp:68
bool setup(BelaContext *context, void *userData)
User-defined initialisation function which runs before audio rendering begins.
Definition render.cpp:51
void cleanup(BelaContext *context, void *userData)
User-defined cleanup function which runs when the program finishes.
Definition render.cpp:96
Structure holding audio and sensor settings and pointers to I/O data buffers.
Definition Bela.h:231
const uint32_t audioFrames
The number of audio frames per block.
Definition Bela.h:322
const float audioSampleRate
The audio sample rate in Hz (currently always 44100.0).
Definition Bela.h:328