From 39ca6fec6216a4a3ea1be7834e8ade1784577389 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sun, 3 Jan 2016 12:05:47 -0800 Subject: [PATCH] Transform update spectrum event into message. --- firmware/baseband/baseband_thread.cpp | 6 ------ firmware/baseband/baseband_thread.hpp | 1 - firmware/baseband/main.cpp | 4 ++-- firmware/baseband/proc_am_audio.cpp | 6 ++++++ firmware/baseband/proc_am_audio.hpp | 4 ++-- firmware/baseband/proc_nfm_audio.cpp | 6 ++++++ firmware/baseband/proc_nfm_audio.hpp | 2 +- firmware/baseband/proc_wideband_spectrum.cpp | 6 ++++++ firmware/baseband/proc_wideband_spectrum.hpp | 2 +- firmware/common/message.hpp | 9 +++++++++ 10 files changed, 33 insertions(+), 13 deletions(-) diff --git a/firmware/baseband/baseband_thread.cpp b/firmware/baseband/baseband_thread.cpp index 84b23bed6..223a762e5 100644 --- a/firmware/baseband/baseband_thread.cpp +++ b/firmware/baseband/baseband_thread.cpp @@ -78,12 +78,6 @@ void BasebandThread::on_message(const Message* const message) { } } -void BasebandThread::on_update_spectrum() { - if( baseband_processor ) { - baseband_processor->on_update_spectrum(); - } -} - void BasebandThread::run() { baseband::dma::init(); diff --git a/firmware/baseband/baseband_thread.hpp b/firmware/baseband/baseband_thread.hpp index c1c5d9041..81d35433a 100644 --- a/firmware/baseband/baseband_thread.hpp +++ b/firmware/baseband/baseband_thread.hpp @@ -38,7 +38,6 @@ public: Thread* start(const tprio_t priority); void on_message(const Message* const message); - void on_update_spectrum(); // This getter should die, it's just here to leak information to code that // isn't in the right place to begin with. diff --git a/firmware/baseband/main.cpp b/firmware/baseband/main.cpp index 3e18808a4..3814aa282 100755 --- a/firmware/baseband/main.cpp +++ b/firmware/baseband/main.cpp @@ -189,8 +189,8 @@ private: } void handle_spectrum() { - // TODO: Send this via another message?! - baseband_thread.on_update_spectrum(); + const UpdateSpectrumMessage message; + baseband_thread.on_message(&message); } }; diff --git a/firmware/baseband/proc_am_audio.cpp b/firmware/baseband/proc_am_audio.cpp index 518ad25f1..c2da853bb 100644 --- a/firmware/baseband/proc_am_audio.cpp +++ b/firmware/baseband/proc_am_audio.cpp @@ -71,3 +71,9 @@ void NarrowbandAMAudio::execute(const buffer_c8_t& buffer) { fill_audio_buffer(audio); } + +void NarrowbandAMAudio::on_message(const Message* const message) { + if( message->id == Message::ID::UpdateSpectrum ) { + channel_spectrum.update(); + } +} diff --git a/firmware/baseband/proc_am_audio.hpp b/firmware/baseband/proc_am_audio.hpp index 6acc2a27f..e664b0af8 100644 --- a/firmware/baseband/proc_am_audio.hpp +++ b/firmware/baseband/proc_am_audio.hpp @@ -41,8 +41,8 @@ public: NarrowbandAMAudio(); void execute(const buffer_c8_t& buffer) override; - - void on_update_spectrum() override { channel_spectrum.update(); } + + void on_message(const Message* const message) override; private: dsp::decimate::FIRC8xR16x24FS4Decim8 decim_0; diff --git a/firmware/baseband/proc_nfm_audio.cpp b/firmware/baseband/proc_nfm_audio.cpp index 4b8cb6c46..98c8f70c1 100644 --- a/firmware/baseband/proc_nfm_audio.cpp +++ b/firmware/baseband/proc_nfm_audio.cpp @@ -116,3 +116,9 @@ void NarrowbandFMAudio::execute(const buffer_c8_t& buffer) { fill_audio_buffer(audio); } + +void NarrowbandFMAudio::on_message(const Message* const message) { + if( message->id == Message::ID::UpdateSpectrum ) { + channel_spectrum.update(); + } +} diff --git a/firmware/baseband/proc_nfm_audio.hpp b/firmware/baseband/proc_nfm_audio.hpp index d0471d30f..4619a010f 100644 --- a/firmware/baseband/proc_nfm_audio.hpp +++ b/firmware/baseband/proc_nfm_audio.hpp @@ -48,7 +48,7 @@ public: void execute(const buffer_c8_t& buffer) override; - void on_update_spectrum() override { channel_spectrum.update(); } + void on_message(const Message* const message) override; private: dsp::decimate::FIRC8xR16x24FS4Decim8 decim_0; diff --git a/firmware/baseband/proc_wideband_spectrum.cpp b/firmware/baseband/proc_wideband_spectrum.cpp index 25ee7e48b..077342872 100644 --- a/firmware/baseband/proc_wideband_spectrum.cpp +++ b/firmware/baseband/proc_wideband_spectrum.cpp @@ -67,3 +67,9 @@ void WidebandSpectrum::execute(const buffer_c8_t& buffer) { i2s::i2s0::tx_mute(); } + +void WidebandSpectrum::on_message(const Message* const message) { + if( message->id == Message::ID::UpdateSpectrum ) { + channel_spectrum.update(); + } +} diff --git a/firmware/baseband/proc_wideband_spectrum.hpp b/firmware/baseband/proc_wideband_spectrum.hpp index b8311c694..24ac10b09 100644 --- a/firmware/baseband/proc_wideband_spectrum.hpp +++ b/firmware/baseband/proc_wideband_spectrum.hpp @@ -33,7 +33,7 @@ class WidebandSpectrum : public BasebandProcessor { public: void execute(const buffer_c8_t& buffer) override; - void on_update_spectrum() override { channel_spectrum.update(); } + void on_message(const Message* const message) override; private: size_t sample_count = 0; diff --git a/firmware/common/message.hpp b/firmware/common/message.hpp index cbd05969d..dc76459d6 100644 --- a/firmware/common/message.hpp +++ b/firmware/common/message.hpp @@ -50,6 +50,7 @@ public: Shutdown = 8, AISPacket = 7, ERTPacket = 9, + UpdateSpectrum = 10, MAX }; @@ -260,6 +261,14 @@ public: baseband::Packet packet; }; +class UpdateSpectrumMessage : public Message { +public: + constexpr UpdateSpectrumMessage( + ) : Message { ID::UpdateSpectrum } + { + } +}; + class MessageHandlerMap { public: using MessageHandler = std::function;