This commit is contained in:
Stefan Ostermann 2023-09-24 21:22:44 +02:00
parent 75e6413693
commit af25c8af80
1 changed files with 25 additions and 2 deletions

View File

@ -26,7 +26,9 @@
#define I2S_BCLK 27 // connect to DAC pin BCK
#define I2S_LRC 25 // connect to DAC pin LCK
#define BTN_START_STOP 17 // Button on D3 and GND
#define BTN_START_STOP 17 // Button on XX and GND
#define BTN_NEXT 16
#define BTN_PREV 4
#define CS_SDCARD 22
@ -42,7 +44,7 @@ File mp3File;
Audio audio;
uint volume = 12;
uint volume = 8;
uint rfid_loop = RFID_LOOP_INTERVAL;
@ -64,6 +66,10 @@ bool asyncStart = false;
bool asyncTogglePlayPause = false;
bool asyncNext = false;
bool asyncPrev = false;
std::map<String, String> rfid_map{{"67 152 204 14", "01-The_Box_Tops-The_Letter.mp3"},
{"67 175 148 160","068-Der_Schatz_im_Bergsee"}};
@ -262,6 +268,8 @@ void setup()
Serial.begin(115200);
pinMode(BTN_START_STOP, INPUT_PULLUP);
pinMode(BTN_NEXT, INPUT_PULLUP);
pinMode(BTN_PREV, INPUT_PULLUP);
/* setup the IRQ pin*/
pinMode(IRQ_RFID, INPUT_PULLUP);
@ -436,6 +444,12 @@ void loop()
if (asyncTogglePlayPause) {
asyncTogglePlayPause = false;
togglePlayPause();
} else if (asyncNext) {
asyncNext = false;
next();
} else if (asyncPrev) {
asyncPrev = false;
Serial.println("Previous not yet implemented!");
}
rfid_loop--;
@ -461,18 +475,27 @@ void loop2(void *parameter)
if (buttonPressed(BTN_START_STOP))
{
asyncTogglePlayPause = true;
}
if (buttonPressed(BTN_NEXT)) {
asyncNext = true;
}
if (buttonPressed(BTN_PREV)) {
asyncPrev = true;
}
}
}
boolean buttonPressed(const uint8_t pin)
{
if (digitalRead(pin) == LOW)
{
unsigned long now = millis();
if (now - lastStart > startDelay)
{
lastStart = now;
Serial.println("button pressed.");
return true;
}
}