#include /* * CopyLeft 2022-2023 Pascal Engélibert * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/. */ // Radio Jukebox #define PIN_TX PIN_PA6 #define PIN_RX PIN_PA7 bool playing = false; class Mp3Notify; typedef DFMiniMp3 DfMp3; DfMp3 dfmp3(Serial); class Mp3Notify { public: static void PrintlnSourceAction(DfMp3_PlaySources source, const char* action) { } static void OnError([[maybe_unused]] DfMp3& mp3, uint16_t errorCode) { } static void OnPlayFinished([[maybe_unused]] DfMp3& mp3, [[maybe_unused]] DfMp3_PlaySources source, uint16_t track) { playing = false; } static void OnPlaySourceOnline([[maybe_unused]] DfMp3& mp3, DfMp3_PlaySources source) {} static void OnPlaySourceInserted([[maybe_unused]] DfMp3& mp3, DfMp3_PlaySources source) {} static void OnPlaySourceRemoved([[maybe_unused]] DfMp3& mp3, DfMp3_PlaySources source) {} }; void wait_ms(uint16_t msWait) { uint32_t start = millis(); while((millis() - start) < msWait) { // if you have loops with delays, its important to // call dfmp3.loop() periodically so it allows for notifications // to be handled without interrupts dfmp3.loop(); delay(1); } } void setup() { delay(1000); //Serial.begin(9600, SERIAL_8N1); dfmp3.begin(); dfmp3.setVolume(24); //dfmp3.setPlaybackSource(DfMp3_PlaySource_Sd); wait_ms(1000); //dfmp3.playMp3FolderTrack(0); dfmp3.setRepeatPlayAllInRoot(true); wait_ms(1000); } void loop() { wait_ms(10); }