esp32 soundboard project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.0 KiB

8 years ago
#include "Arduino.h"
#include "keyboard.h"
Keyboard::Keyboard() {
}
8 years ago
void Keyboard::init() {
8 years ago
this->thresholds = {40, 0, 0, 40, 40, 40, 40, 40, 20, 20};
this->touchDetected = {false, false, false, false, false, false, false, false, false, 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]);
}
8 years ago
void Keyboard::gotTouch0() {
8 years ago
delay(10);
if (touchRead(T0) < threshold[0])
this->touchDetected[0] = true;
}
8 years ago
void Keyboard::gotTouch1() {
8 years ago
delay(10);
if (touchRead(T1) < threshold[1])
this->touchDetected[1] = true;
}
8 years ago
void Keyboard::gotTouch2() {
8 years ago
delay(10);
if (touchRead(T2) < threshold[2])
this->touchDetected[2] = true;
}
8 years ago
void Keyboard::gotTouch3() {
8 years ago
delay(10);
if (touchRead(T3) < threshold[3])
this->touchDetected[3] = true;
}
8 years ago
void Keyboard::gotTouch4() {
8 years ago
delay(10);
if (touchRead(T4) < threshold[4])
this->touchDetected[4] = true;
}
8 years ago
void Keyboard::gotTouch5() {
8 years ago
delay(10);
if (touchRead(T5) < threshold[5])
this->touchDetected[5] = true;
}
8 years ago
void Keyboard::gotTouch6() {
8 years ago
delay(10);
if (touchRead(T6) < threshold[6])
this->touchDetected[6] = true;
}
8 years ago
void Keyboard::gotTouch7() {
8 years ago
delay(10);
if (touchRead(T7) < threshold[7])
this->touchDetected[7] = true;
}
8 years ago
void Keyboard::gotTouch8() {
8 years ago
delay(10);
if (touchRead(T8) < threshold[8])
this->touchDetected[8] = true;
}
8 years ago
void Keyboard::gotTouch9() {
8 years ago
delay(10);
if (touchRead(T9) < threshold[9])
this->touchDetected[9] = true;
}