From 3c304b9fe3c39ddb2bb7ed79b003d43f48828218 Mon Sep 17 00:00:00 2001 From: eried <1091420+eried@users.noreply.github.com> Date: Mon, 8 Jun 2020 01:22:58 +0200 Subject: [PATCH] Mute and unmute audio --- firmware/application/audio.cpp | 11 +++++++++++ firmware/application/audio.hpp | 14 ++++++++++++++ firmware/common/wm8731.hpp | 4 ++++ 3 files changed, 29 insertions(+) diff --git a/firmware/application/audio.cpp b/firmware/application/audio.cpp index 958daad2..4ba23acc 100644 --- a/firmware/application/audio.cpp +++ b/firmware/application/audio.cpp @@ -26,6 +26,7 @@ using portapack::clock_manager; #include "portapack_hal.hpp" +#include "portapack_persistent_memory.hpp" #include "i2s.hpp" using namespace lpc43xx; @@ -153,6 +154,16 @@ void unmute() { audio_codec->headphone_enable(); } +void speaker_mute() { + i2s::i2s0::tx_mute(); + audio_codec->speaker_disable(); + } + + void speaker_unmute() { + i2s::i2s0::tx_unmute(); + audio_codec->speaker_enable(); + } + } /* namespace output */ namespace input { diff --git a/firmware/application/audio.hpp b/firmware/application/audio.hpp index 06e7c92a..b02e42aa 100644 --- a/firmware/application/audio.hpp +++ b/firmware/application/audio.hpp @@ -41,6 +41,9 @@ public: virtual bool reset() = 0; virtual void init() = 0; + virtual void speaker_enable() = 0; + virtual void speaker_disable() = 0; + virtual void headphone_enable() = 0; virtual void headphone_disable() = 0; virtual volume_range_t headphone_gain_range() const = 0; @@ -62,6 +65,9 @@ void stop(); void mute(); void unmute(); +void speaker_mute(); +void speaker_unmute(); + } /* namespace output */ namespace input { @@ -79,6 +85,14 @@ void set_volume(const volume_t volume); } /* namespace headphone */ +namespace speaker { + +volume_range_t volume_range(); + +void set_volume(const volume_t volume); + +} /* namespace speaker */ + namespace debug { size_t reg_count(); diff --git a/firmware/common/wm8731.hpp b/firmware/common/wm8731.hpp index 0d1b15b7..a5c8908b 100644 --- a/firmware/common/wm8731.hpp +++ b/firmware/common/wm8731.hpp @@ -341,6 +341,10 @@ public: headphone_mute(); } + void speaker_enable() {}; + void speaker_disable() {}; + + void microphone_enable() override { // TODO: Implement }