mirror of
https://github.com/Crocmagnon/buzzer.git
synced 2024-12-26 16:01:49 +01:00
Reduce power consumption by reducing CPU frequency when not playing
This commit is contained in:
parent
638869824c
commit
f3064fb535
1 changed files with 14 additions and 0 deletions
14
src/main.cpp
14
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue