mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-01 13:04:43 -04:00
Move app-level config to new AISAppView class.
This commit is contained in:
parent
1f2b28b2b8
commit
6e0aa79d44
2 changed files with 41 additions and 38 deletions
|
@ -163,36 +163,11 @@ void AISRecentEntries::truncate_entries() {
|
|||
|
||||
namespace ui {
|
||||
|
||||
AISRecentEntriesView::AISRecentEntriesView() {
|
||||
AISRecentEntriesView::AISRecentEntriesView(
|
||||
AISRecentEntries& recent
|
||||
) : recent { recent }
|
||||
{
|
||||
flags.focusable = true;
|
||||
|
||||
EventDispatcher::message_map().register_handler(Message::ID::AISPacket,
|
||||
[this](Message* const p) {
|
||||
const auto message = static_cast<const AISPacketMessage*>(p);
|
||||
const ais::Packet packet { message->packet };
|
||||
if( packet.is_valid() ) {
|
||||
this->logger.on_packet(packet);
|
||||
this->on_packet(packet);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
receiver_model.set_baseband_configuration({
|
||||
.mode = 3,
|
||||
.sampling_rate = 2457600,
|
||||
.decimation_factor = 1,
|
||||
});
|
||||
receiver_model.set_baseband_bandwidth(1750000);
|
||||
}
|
||||
|
||||
AISRecentEntriesView::~AISRecentEntriesView() {
|
||||
EventDispatcher::message_map().unregister_handler(Message::ID::AISPacket);
|
||||
}
|
||||
|
||||
void AISRecentEntriesView::on_packet(const ais::Packet& packet) {
|
||||
recent.on_packet(packet);
|
||||
|
||||
set_dirty();
|
||||
}
|
||||
|
||||
void AISRecentEntriesView::on_focus() {
|
||||
|
@ -296,6 +271,27 @@ AISAppView::AISAppView() {
|
|||
add_children({ {
|
||||
&recent_entries_view,
|
||||
} });
|
||||
|
||||
EventDispatcher::message_map().register_handler(Message::ID::AISPacket,
|
||||
[this](Message* const p) {
|
||||
const auto message = static_cast<const AISPacketMessage*>(p);
|
||||
const ais::Packet packet { message->packet };
|
||||
if( packet.is_valid() ) {
|
||||
this->on_packet(packet);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
receiver_model.set_baseband_configuration({
|
||||
.mode = 3,
|
||||
.sampling_rate = 2457600,
|
||||
.decimation_factor = 1,
|
||||
});
|
||||
receiver_model.set_baseband_bandwidth(1750000);
|
||||
}
|
||||
|
||||
AISAppView::~AISAppView() {
|
||||
EventDispatcher::message_map().unregister_handler(Message::ID::AISPacket);
|
||||
}
|
||||
|
||||
void AISAppView::set_parent_rect(const Rect new_parent_rect) {
|
||||
|
@ -303,4 +299,10 @@ void AISAppView::set_parent_rect(const Rect new_parent_rect) {
|
|||
recent_entries_view.set_parent_rect({ 0, 0, new_parent_rect.width(), new_parent_rect.height() });
|
||||
}
|
||||
|
||||
void AISAppView::on_packet(const ais::Packet& packet) {
|
||||
logger.on_packet(packet);
|
||||
recent.on_packet(packet);
|
||||
recent_entries_view.set_dirty();
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue