Transform update spectrum event into message.

This commit is contained in:
Jared Boone 2016-01-03 12:05:47 -08:00
parent c9f9d97d07
commit 39ca6fec62
10 changed files with 33 additions and 13 deletions

View File

@ -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();

View File

@ -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.

View File

@ -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);
}
};

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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<void(Message* const p)>;