|
|
|
#include "Arduino.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
Keyboard::Keyboard() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void gotTouch0() {
|
|
|
|
touchDetected[0] = true;
|
|
|
|
}
|
|
|
|
void gotTouch1() {
|
|
|
|
touchDetected[1] = true;
|
|
|
|
}
|
|
|
|
void gotTouch2() {
|
|
|
|
touchDetected[2] = true;
|
|
|
|
}
|
|
|
|
void gotTouch3() {
|
|
|
|
touchDetected[3] = true;
|
|
|
|
}
|
|
|
|
void gotTouch4() {
|
|
|
|
touchDetected[4] = true;
|
|
|
|
}
|
|
|
|
void gotTouch5() {
|
|
|
|
touchDetected[5] = true;
|
|
|
|
}
|
|
|
|
void gotTouch6() {
|
|
|
|
touchDetected[6] = true;
|
|
|
|
}
|
|
|
|
void gotTouch7() {
|
|
|
|
touchDetected[7] = true;
|
|
|
|
}
|
|
|
|
void gotTouch8() {
|
|
|
|
touchDetected[8] = true;
|
|
|
|
}
|
|
|
|
void gotTouch9() {
|
|
|
|
touchDetected[9] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Keyboard::getTouchDetected(uint8_t pad) {
|
|
|
|
bool res = touchDetected[pad];
|
|
|
|
touchDetected[pad] = false;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Keyboard::init() {
|
|
|
|
threshold[0] = 40;
|
|
|
|
threshold[1] = 0;
|
|
|
|
threshold[2] = 0;
|
|
|
|
threshold[3] = 40;
|
|
|
|
threshold[4] = 40;
|
|
|
|
threshold[5] = 40;
|
|
|
|
threshold[6] = 40;
|
|
|
|
threshold[7] = 40;
|
|
|
|
threshold[8] = 20;
|
|
|
|
threshold[9] = 20;
|
|
|
|
for (int i=0; i<=9; i++) touchDetected[i] = false;
|
|
|
|
touchAttachInterrupt(T0, gotTouch0, threshold[0]);
|
|
|
|
// touchAttachInterrupt(T1, gotTouch1, threshold[1]); // GPIO_00 not usable on dev board
|
|
|
|
// touchAttachInterrupt(T2, gotTouch2, threshold[2]); // GPIO_02 not usable on dev board
|
|
|
|
touchAttachInterrupt(T3, gotTouch3, threshold[3]);
|
|
|
|
touchAttachInterrupt(T4, gotTouch4, threshold[4]);
|
|
|
|
touchAttachInterrupt(T5, gotTouch5, threshold[5]);
|
|
|
|
touchAttachInterrupt(T6, gotTouch6, threshold[6]);
|
|
|
|
touchAttachInterrupt(T7, gotTouch7, threshold[7]);
|
|
|
|
touchAttachInterrupt(T8, gotTouch8, threshold[8]);
|
|
|
|
touchAttachInterrupt(T9, gotTouch9, threshold[9]);
|
|
|
|
}
|
|
|
|
|