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.
 
 

82 lines
2.0 KiB

/**
* ESP32 Soundboard
*
* Hendriks Projekt
*
* https://dev.xd0.de/hendrik/soundboard
*/
#include "Arduino.h"
#include "hardware.h"
#include "soundboard.h"
#include "keyboard.h"
#include "sdcard.h"
#include "sound.h"
#include "wifi.h"
#define VERSION "0.0"
Keyboard keyboard;
SDCard sdcard;
Sound sound;
Wifi wifi;
Bluetooth bluetooth;
static const char *soundFile[3][3] = {{"/T0.wav", "/T1.wav", "/T2.wav"},
{"/T3.wav", "/T4.wav", "/T5.wav"},
{"/T6.wav", "/T7.wav", "/T8.wav"}};
unsigned long lastDebounceTime = 0; // the last time the output pin was toggled
unsigned long debounceDelay = 250; // the debounce time
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();
wifi.init();
static const char *bootSound = "/boot.wav";
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()
{
bool touched = false;
for(int i=0; i<=9; i++) {
if (keyboard.getTouchDetected(i) == true) {
if ((millis() - lastDebounceTime) > debounceDelay) {
lastDebounceTime = millis();
Serial.println("main loop touched==true: play new sound");
sound.play(soundFile[i/3][i%3]);
}
Serial.print("touch ");
Serial.println(i, DEC);
}
}
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);
}
wifi.loop();
// wait for a moment
delay(50);
}