From 0184b12bbc743f2259a794a7889380f89b60e47e Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Wed, 4 Jan 2023 14:00:25 +0100 Subject: [PATCH] Remember volume after power loss --- src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 3bcef17..4baa46d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -163,6 +163,7 @@ void onChangeVolume(AsyncWebServerRequest *request) currentVolume = VOLUME_MAX; else if (currentVolume < VOLUME_MIN) currentVolume = VOLUME_MIN; + preferences.putUChar("currentVolume", currentVolume); audio.setVolume(currentVolume); Serial.print(currentVolume); clearMessageArea(); @@ -331,6 +332,7 @@ void setup() // Audio audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT); + currentVolume = preferences.getUChar("currentVolume", 12); audio.setVolume(currentVolume); // Setup is done, light up the LED