Ok, back to Pure Data and knowing how that works :-)
Two questions::
---> I'm trying to find out what pure Data gets from the MPR121 via render.cpp
I managed to print this
rt_printf("%d ", sensorValue[i]);
:-D
--> so the MPR121 gives values from 0 (state of not touched) to 110 approximately
I need an object in pd that does not send bangs (like [route] does) but a construction that works with a threshold (when the value is higher than 30, button is pressed, play sound)
Any ideas? - I think I know about an object, but I don't know how it deals with the array of 12 numbers..
---> Render.cpp does not want to print rt_printf("%d ", sensorIndex); (commented out in the following code snippet)
Is this because sensorIndex is just a very local variable?
is it ignored?
Is it a problem (seems not to be the case..)
// Auxiliary task to read the I2C board
void readMPR121(void*)
{
for(int i = 0; i < NUM_TOUCH_PINS; i++) {
sensorValue[i] = -(mpr121.filteredData(i) - mpr121.baselineData(i));
sensorValue[i] -= threshold;
if(sensorValue[i] < 0)
sensorValue[i] = 0;
libpd_float("sensorIndex", (float)i);
//rt_printf("%d ", sensorIndex[i]); //error: use of undeclared identifier 'sensorIndex'
libpd_float("sensorValue", (float)sensorValue[i]);
#ifdef DEBUG_MPR121
rt_printf("%d ", sensorValue[i]); //prints the values of the sensor when DEBUG_MPR121 is define at beginning of programme
#endif
}
#ifdef DEBUG_MPR121
rt_printf("\n");
#endif
// You can use this to read binary on/off touch state more easily
//rt_printf("Touched: %x\n", mpr121.touched());
}
Full render.cpp file is here:
https://framabin.org/p/?6facff6f6e1a593b#XZ1pyi4ED24QQQ+dUT9aEfZh+IzhXY58XUYzLIHQw8E=
And, thanks - you made my day!
greetz,
dywen