/** * ESP32 Soundboard * * Hendriks Projekt * * https://dev.xd0.de/hendrik/soundboard */ #include "Arduino.h" #include "hardware.h" #include "keyboard.h" #include "sdcard.h" #include "sound.h" #define VERSION "0.0" #define WIFI_SSID "ssid" #define WIFI_PASSWORD "password" Keyboard keyboard; SDCard sdcard; Sound sound; TaskHandle_t xTaskSound = NULL; bool playing = false; static const char *soundFile[3][3] = {{"/T0.wav", "/T1.wav", "/T2.wav"}, {"/T3.wav", "/T4.wav", "/T5.wav"}, {"/T6.wav", "/T7.wav", "/T8.wav"}}; void setup() { // initialize LED digital pin as an output. pinMode(LED_PIN, OUTPUT); Serial.begin(115200); Serial.println("-------------------------------------"); Serial.print("Soundboard v."); Serial.println(VERSION); Serial.println("https://dev.xd0.de/hendrik/soundboard"); Serial.println("-------------------------------------"); keyboard.init(); sdcard.mount(); sound.init(); static const char *bootSound = "/boot.wav"; xTaskCreate(&(Sound::buffer_refill_task), "buffer_refill_task", 4096, (void*)bootSound, 5, &xTaskSound); } void loop() { bool touched = false; for(int i=0; i<=9; i++) { if (keyboard.getTouchDetected(i) == true) { touched = true; Serial.print("touch "); Serial.println(i, DEC); if (sound.playing == false) { Serial.println("new task"); xTaskCreate(&(Sound::buffer_refill_task), "buffer_refill_task", 4096, (void*)soundFile[i/3][i%3], 5, &xTaskSound); } } } if (touched == true) { // turn the LED on (HIGH is the voltage level) digitalWrite(LED_PIN, HIGH); } else { // turn the LED off by making the voltage LOW digitalWrite(LED_PIN, LOW); } // wait for a second delay(50); }