mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-23 03:07:40 +00:00
Hide implementation of MessageHandlerMap.
This commit is contained in:
@@ -184,10 +184,7 @@ private:
|
||||
while( !shared_memory.application_queue.is_empty() ) {
|
||||
auto message = shared_memory.application_queue.pop();
|
||||
|
||||
auto& fn = context.message_map[message->id];
|
||||
if( fn ) {
|
||||
fn(message);
|
||||
}
|
||||
context.message_map.send(message);
|
||||
|
||||
message->state = Message::State::Free;
|
||||
}
|
||||
|
@@ -26,13 +26,15 @@
|
||||
namespace ui {
|
||||
|
||||
void Audio::on_show() {
|
||||
context().message_map[Message::ID::AudioStatistics] = [this](const Message* const p) {
|
||||
this->on_statistics_update(static_cast<const AudioStatisticsMessage*>(p)->statistics);
|
||||
};
|
||||
context().message_map.register_handler(Message::ID::AudioStatistics,
|
||||
[this](const Message* const p) {
|
||||
this->on_statistics_update(static_cast<const AudioStatisticsMessage*>(p)->statistics);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void Audio::on_hide() {
|
||||
context().message_map[Message::ID::AudioStatistics] = nullptr;
|
||||
context().message_map.unregister_handler(Message::ID::AudioStatistics);
|
||||
}
|
||||
|
||||
void Audio::paint(Painter& painter) {
|
||||
|
@@ -26,13 +26,15 @@
|
||||
namespace ui {
|
||||
|
||||
void Channel::on_show() {
|
||||
context().message_map[Message::ID::ChannelStatistics] = [this](const Message* const p) {
|
||||
this->on_statistics_update(static_cast<const ChannelStatisticsMessage*>(p)->statistics);
|
||||
};
|
||||
context().message_map.register_handler(Message::ID::ChannelStatistics,
|
||||
[this](const Message* const p) {
|
||||
this->on_statistics_update(static_cast<const ChannelStatisticsMessage*>(p)->statistics);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void Channel::on_hide() {
|
||||
context().message_map[Message::ID::ChannelStatistics] = nullptr;
|
||||
context().message_map.unregister_handler(Message::ID::ChannelStatistics);
|
||||
}
|
||||
|
||||
void Channel::paint(Painter& painter) {
|
||||
|
@@ -40,13 +40,15 @@ BasebandStatsView::BasebandStatsView() {
|
||||
}
|
||||
|
||||
void BasebandStatsView::on_show() {
|
||||
context().message_map[Message::ID::BasebandStatistics] = [this](const Message* const p) {
|
||||
this->on_statistics_update(static_cast<const BasebandStatisticsMessage*>(p)->statistics);
|
||||
};
|
||||
context().message_map.register_handler(Message::ID::BasebandStatistics,
|
||||
[this](const Message* const p) {
|
||||
this->on_statistics_update(static_cast<const BasebandStatisticsMessage*>(p)->statistics);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void BasebandStatsView::on_hide() {
|
||||
context().message_map[Message::ID::BasebandStatistics] = nullptr;
|
||||
context().message_map.unregister_handler(Message::ID::BasebandStatistics);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -481,15 +481,17 @@ ReceiverView::ReceiverView(
|
||||
|
||||
receiver_model.enable();
|
||||
|
||||
context().message_map[Message::ID::FSKPacket] = [](const Message* const p) {
|
||||
const auto message = static_cast<const FSKPacketMessage*>(p);
|
||||
(void)message;
|
||||
};
|
||||
context().message_map.register_handler(Message::ID::FSKPacket,
|
||||
[](const Message* const p) {
|
||||
const auto message = static_cast<const FSKPacketMessage*>(p);
|
||||
(void)message;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
ReceiverView::~ReceiverView() {
|
||||
context().message_map[Message::ID::FSKPacket] = nullptr;
|
||||
|
||||
context().message_map.unregister_handler(Message::ID::FSKPacket);
|
||||
|
||||
// TODO: Manipulating audio codec here, and in ui_receiver.cpp. Good to do
|
||||
// both?
|
||||
audio_codec.headphone_mute();
|
||||
|
@@ -26,13 +26,15 @@
|
||||
namespace ui {
|
||||
|
||||
void RSSI::on_show() {
|
||||
context().message_map[Message::ID::RSSIStatistics] = [this](const Message* const p) {
|
||||
this->on_statistics_update(static_cast<const RSSIStatisticsMessage*>(p)->statistics);
|
||||
};
|
||||
context().message_map.register_handler(Message::ID::RSSIStatistics,
|
||||
[this](const Message* const p) {
|
||||
this->on_statistics_update(static_cast<const RSSIStatisticsMessage*>(p)->statistics);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void RSSI::on_hide() {
|
||||
context().message_map[Message::ID::RSSIStatistics] = nullptr;
|
||||
context().message_map.unregister_handler(Message::ID::RSSIStatistics);
|
||||
}
|
||||
|
||||
void RSSI::paint(Painter& painter) {
|
||||
|
@@ -233,13 +233,15 @@ public:
|
||||
}
|
||||
|
||||
void on_show() override {
|
||||
context().message_map[Message::ID::ChannelSpectrum] = [this](const Message* const p) {
|
||||
this->on_channel_spectrum(reinterpret_cast<const ChannelSpectrumMessage*>(p)->spectrum);
|
||||
};
|
||||
context().message_map.register_handler(Message::ID::ChannelSpectrum,
|
||||
[this](const Message* const p) {
|
||||
this->on_channel_spectrum(reinterpret_cast<const ChannelSpectrumMessage*>(p)->spectrum);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void on_hide() override {
|
||||
context().message_map[Message::ID::ChannelSpectrum] = nullptr;
|
||||
context().message_map.unregister_handler(Message::ID::ChannelSpectrum);
|
||||
}
|
||||
|
||||
void set_parent_rect(const Rect new_parent_rect) override {
|
||||
|
Reference in New Issue
Block a user