|
@ -24,6 +24,9 @@ static const char *soundFile[3][3] = {{"/T0.wav", "/T1.wav", "/T2.wav"}, |
|
|
{"/T3.wav", "/T4.wav", "/T5.wav"}, |
|
|
{"/T3.wav", "/T4.wav", "/T5.wav"}, |
|
|
{"/T6.wav", "/T7.wav", "/T8.wav"}}; |
|
|
{"/T6.wav", "/T7.wav", "/T8.wav"}}; |
|
|
|
|
|
|
|
|
|
|
|
unsigned long lastDebounceTime = 0; // the last time the output pin was toggled
|
|
|
|
|
|
unsigned long debounceDelay = 100; // the debounce time
|
|
|
|
|
|
|
|
|
void setup() |
|
|
void setup() |
|
|
{ |
|
|
{ |
|
|
// initialize LED digital pin as an output.
|
|
|
// initialize LED digital pin as an output.
|
|
@ -42,23 +45,24 @@ void setup() |
|
|
|
|
|
|
|
|
static const char *bootSound = "/boot.wav"; |
|
|
static const char *bootSound = "/boot.wav"; |
|
|
|
|
|
|
|
|
//xTaskCreate(&(Sound::play_task), "play_task", 3072, (void*)bootSound, 5, &xTaskSound);
|
|
|
sound.play(bootSound); |
|
|
|
|
|
|
|
|
|
|
|
// keyboard.setCallback(0, [&soundFile]() {int i=0; sound.play(soundFile[i/3][i%3]);});
|
|
|
|
|
|
// keyboard.setCallback(1, []() {Serial.println("interrupt 1");});
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void loop() |
|
|
void loop() |
|
|
{ |
|
|
{ |
|
|
bool touched = false; |
|
|
bool touched = false; |
|
|
bool playing = false; |
|
|
|
|
|
for(int i=0; i<=9; i++) { |
|
|
for(int i=0; i<=9; i++) { |
|
|
if (keyboard.getTouchDetected(i) == true) { |
|
|
if (keyboard.getTouchDetected(i) == true) { |
|
|
touched = true; |
|
|
if ((millis() - lastDebounceTime) > debounceDelay) { |
|
|
Serial.print("touch "); |
|
|
lastDebounceTime = millis(); |
|
|
Serial.println(i, DEC); |
|
|
Serial.println("main loop touched==true: play new sound"); |
|
|
if (playing == false) { |
|
|
|
|
|
playing == true; |
|
|
|
|
|
Serial.println("main loop touched==true: new task"); |
|
|
|
|
|
sound.play(soundFile[i/3][i%3]); |
|
|
sound.play(soundFile[i/3][i%3]); |
|
|
} |
|
|
} |
|
|
|
|
|
Serial.print("touch "); |
|
|
|
|
|
Serial.println(i, DEC); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -71,6 +75,6 @@ void loop() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
wifi.loop(); |
|
|
wifi.loop(); |
|
|
// wait for a second
|
|
|
// wait for a moment
|
|
|
delay(50); |
|
|
delay(50); |
|
|
} |
|
|
} |
|
|