diff --git a/examples/WebRadio/WebRadio.ino b/examples/WebRadio/WebRadio.ino index 626b390..8904ce3 100644 --- a/examples/WebRadio/WebRadio.ino +++ b/examples/WebRadio/WebRadio.ino @@ -25,6 +25,7 @@ #include "AudioGeneratorMP3.h" #include "AudioGeneratorAAC.h" #include "AudioOutputI2SDAC.h" +#include // Custom web server that doesn't need much RAM #include "web.h" @@ -49,6 +50,11 @@ char status[64]; bool newUrl = false; bool isAAC = false; +typedef struct { + char url[64]; + int16_t checksum; +} Settings; + // C++11 multiline string constants are neato... static const char HEAD[] PROGMEM = R"KEWL( @@ -262,6 +268,23 @@ void setup() buff = NULL; out = NULL; decoder = NULL; + + // Restore from EEPROM, check the checksum matches + Settings s; + uint8_t *ptr = reinterpret_cast(&s); + EEPROM.begin(sizeof(s)); + for (size_t i=0; istop(); - delete decoder; - } - if (buff) { - buff->close(); - delete buff; - } - if (out) { - out->stop(); - delete out; - } - if (file) { - file->close(); - delete file; - } + StopPlaying(); + // Store in "EEPROM" to restart automatically + Settings s; + strcpy(s.url, url); + s.checksum = 0x1234; + for (size_t i=0; i(&s); + EEPROM.begin(sizeof(s)); + for (size_t i=0; iRegisterMetadataCB(MDCallback, NULL); buff = new AudioFileSourceBuffer(file, 1500);