From 631f60b31fff4e025e8c4baff1fb3bee45e6fb94 Mon Sep 17 00:00:00 2001 From: Torsten Stauder Date: Thu, 17 Jun 2021 22:12:47 +0200 Subject: [PATCH] Adding some delays/stuff to avoid ugly noises when powering off/on --- src/AudioPlayer.cpp | 6 ++++++ src/System.cpp | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/src/AudioPlayer.cpp b/src/AudioPlayer.cpp index 450d7ba..7f204d7 100644 --- a/src/AudioPlayer.cpp +++ b/src/AudioPlayer.cpp @@ -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 { diff --git a/src/System.cpp b/src/System.cpp index 285c72b..e173fcc 100644 --- a/src/System.cpp +++ b/src/System.cpp @@ -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 @@ -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);