well, with this code:
/*
____ _____ _ _
| __ )| ____| | / \
| _ \| _| | | / _ \
| |_) | |___| |___ / ___ \
|____/|_____|_____/_/ \_\
http://bela.io
\example craft-print
Trill Craft Print
=================
This is an example of how to communicate with the Trill Craft
sensor using the Trill Arduino library.
The sensor is set to Differential mode and readings from each of the
capacitive connections on the sensor ar eprinted to the serial port.
*/
#include <Trill.h>
byte notes[8] = {60,63,65,67,68,71,72,74};
byte pattern[30] = {notes[0],notes[1], notes[2], notes[3], notes[4], notes[5], notes[6], notes[7],
notes[3] +12,notes[0] +12, notes[2] +12, notes[1] +12, notes[4] +12, notes[5] +12, notes[6] +12, notes[7] +12,
notes[0] +24,notes[1] +24, notes[2] +24, notes[3] +24, notes[4] +24, notes[5] +24, notes[6] +24, notes[7] +24,
notes[0] +36,notes[1] +36, notes[2], notes[3]+36, notes[4], notes[5] +36
};
int touch_val[30];
byte pin_order[30] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29};
bool pin_touched[30];
Trill trillSensor; // for Trill Craft
elapsedMillis readTime;
void setup() {
pinMode(2, INPUT);
// put your setup code here, to run once:
Serial.begin(115200);
int ret = trillSensor.setup(Trill::TRILL_CRAFT);
if(ret != 0) {
Serial.println("failed to initialise trillSensor");
Serial.print("Error code: ");
Serial.println(ret);
}
trillSensor.setScanSettings(0, 9);
delay(Trill::interCommandDelay);
// trillSensor.setPrescaler(1);
// delay(Trill::interCommandDelay);
trillSensor.setMode(Trill::DIFF);
delay(Trill::interCommandDelay);
trillSensor.setNoiseThreshold(40);
delay(Trill::interCommandDelay);
trillSensor.setAutoScanInterval(1);
delay(Trill::interCommandDelay);
Serial.println("Setup Complete");
}
void loop() {
// put your main code here, to run repeatedly:
// delay(1);
if (digitalRead(2)) {
readTime = 0;
// trillSensor.requestRawData();
}
if (readTime < 150) {
trillSensor.requestRawData();
}
//}
while(trillSensor.rawDataAvailable() > 0) {
for (int i = 0; i < 30; i++) {
touch_val[i] = trillSensor.rawDataRead();
if (!pin_touched[i] && (touch_val[i] > 50)) {
pin_touched[i] = 1;
usbMIDI.sendNoteOn(pattern[i],127,1);
// Serial.println(i);
// Serial.println(touch_val[i]);
// Serial.println();
}
if (pin_touched[i] && (touch_val[i] < 40)) {
pin_touched[i] = 0;
usbMIDI.sendNoteOff(pattern[i],0,1);
}
}
}
}
it all works as expected, i can retrigger the same sensor as fast as my finger goes, while with this part:
if (digitalRead(2)) {
readTime = 0;
// trillSensor.requestRawData();
}
if (readTime < 150) {
trillSensor.requestRawData();
}
changed to:
if (digitalRead(2)) {
trillSensor.requestRawData();
}
retriggers of the same note do not happen very consistently.
probably my example is not coded in the best way possible, but i still think it is a reasonable approach for a sensor board to output all zeroes when not touched. if that would happen before the EVT pin goes low, this would solve my "problem" i guess, yes.
nobody uses the EVT pin? i think it will be crucial for my design, since i plan to incorporate this into a teensy 3.6 project and want to avoid polling the sensor all the time (so i can do other things in between faster)