From ee7febe1ec1aea95d99ae3a299dd7354ab7c69de Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Thu, 14 Dec 2017 10:35:14 -0800 Subject: [PATCH] Refactor and store to EEPROM, restore on reboot Save the current URL to EEPROM on each change, and try and restart it after a power loss or reset --- examples/WebRadio/WebRadio.ino | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/WebRadio/WebRadio.ino b/examples/WebRadio/WebRadio.ino index 3f83618..626b390 100644 --- a/examples/WebRadio/WebRadio.ino +++ b/examples/WebRadio/WebRadio.ino @@ -169,9 +169,8 @@ void RedirectToIndex(WiFiClient *client) WebError(client, 301, PSTR("Location: /\r\n"), true); } -void HandleStop(WiFiClient *client) +void StopPlaying() { - Serial.printf_P(PSTR("HandleStop()\n")); if (decoder) { decoder->stop(); delete decoder; @@ -193,6 +192,13 @@ void HandleStop(WiFiClient *client) file = NULL; } strcpy_P(status, PSTR("Stopped")); + strcpy_P(title, PSTR("Stopped")); +} + +void HandleStop(WiFiClient *client) +{ + Serial.printf_P(PSTR("HandleStop()\n")); + StopPlaying(); RedirectToIndex(client); } @@ -321,7 +327,7 @@ void loop() if (!decoder->loop()) { Serial.printf_P(PSTR("Stopping decoder\n")); decoder->stop(); - strcpy_P(title, PSTR("Stopped")); + StopPlaying(); } } else { // Nothing here