Reduce power consumption by reducing CPU frequency when not playing

This commit is contained in:
Gabriel Augendre 2023-01-07 14:30:02 +01:00
parent 638869824c
commit f3064fb535

View file

@ -13,6 +13,7 @@ long lastDebounceTime = 0;
void setup() void setup()
{ {
setCpuFrequencyMhz(240);
// Setup GPIO // Setup GPIO
pinMode(LED, OUTPUT); pinMode(LED, OUTPUT);
digitalWrite(LED, LOW); digitalWrite(LED, LOW);
@ -39,6 +40,7 @@ void setup()
// Setup is done, light up the LED // Setup is done, light up the LED
Serial.println("All setup & ready to go!"); Serial.println("All setup & ready to go!");
setCpuFrequencyMhz(80);
digitalWrite(LED, HIGH); digitalWrite(LED, HIGH);
} }
@ -53,3 +55,15 @@ void loop()
} }
audio.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);
}
}