This is great.
I took the liberty of converting the code to a library and simplifying the API.
I’m hoping an update to the firmware will support C++ lambdas and allow multiple instances; I have this working locally:
#include "captouch.h"
CapTouch Touch(A0, A1);
CapTouch Touch2(D1, D4);
setup() {
Touch.setup();
Touch2.setup();
}
loop(){
CapTouch::Event touchEvent = Touch.getEvent();
if (touchEvent == CapTouch::TouchEvent) {
digitalWrite(D7, HIGH);
} else if (touchEvent == CapTouch::ReleaseEvent){
digitalWrite(D7, LOW);
}
touchEvent = Touch2.getEvent();
// more
}