Skip to content

Commit

Permalink
Adding some delays/stuff to avoid ugly noises when powering off/on
Browse files Browse the repository at this point in the history
  • Loading branch information
biologist79 committed Jun 17, 2021
1 parent 8405e27 commit 631f60b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/AudioPlayer.cpp
Expand Up @@ -168,9 +168,15 @@ void AudioPlayer_SetupVolume(void) {
#endif

#ifdef GPIO_PA_EN
while (millis() < 500) {
delay(10); // Wait a bit in order to avoid ugly noises when enabling amp
}
Port_Write(GPIO_PA_EN, true, true);
#endif
#ifdef GPIO_HP_EN
while (millis() < 500) {
delay(10); // Wait a bit in order to avoid ugly noises when enabling amp
}
Port_Write(GPIO_HP_EN, false, true);
#endif
} else {
Expand Down
9 changes: 9 additions & 0 deletions src/System.cpp
Expand Up @@ -7,6 +7,7 @@
#include "Log.h"
#include "Mqtt.h"
#include "SdCard.h"
#include "Port.h"

constexpr const char prefsRfidNamespace[] PROGMEM = "rfidTags"; // Namespace used to save IDs of rfid-tags
constexpr const char prefsSettingsNamespace[] PROGMEM = "settings"; // Namespace used for generic settings
Expand Down Expand Up @@ -186,6 +187,14 @@ void System_DeepSleepManager(void) {
return;
}

// Disable amps in order to avoid ugly noises when powering off
#ifdef GPIO_PA_EN
Port_Write(GPIO_PA_EN, false);
#endif
#ifdef GPIO_HP_EN
Port_Write(GPIO_HP_EN, false);
#endif

System_Sleeping = true;
Log_Println((char *) FPSTR(goToSleepNow), LOGLEVEL_NOTICE);

Expand Down

0 comments on commit 631f60b

Please sign in to comment.