From f3064fb535a442112d0c79d0a25af1cea4bd9f08 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sat, 7 Jan 2023 14:30:02 +0100 Subject: [PATCH] Reduce power consumption by reducing CPU frequency when not playing --- src/main.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 0e2308f..856db1c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,6 +13,7 @@ long lastDebounceTime = 0; void setup() { + setCpuFrequencyMhz(240); // Setup GPIO pinMode(LED, OUTPUT); digitalWrite(LED, LOW); @@ -39,6 +40,7 @@ void setup() // Setup is done, light up the LED Serial.println("All setup & ready to go!"); + setCpuFrequencyMhz(80); digitalWrite(LED, HIGH); } @@ -53,3 +55,15 @@ void loop() } audio.loop(); } + +void audio_info(const char *info){ + String s_info = info; + s_info.toLowerCase(); + s_info.trim(); + if (s_info == "closing audio file") { + setCpuFrequencyMhz(80); + } + else if (s_info == "stream ready") { + setCpuFrequencyMhz(240); + } +}