mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-06 06:10:15 -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 {
|
namespace ui {
|
||||||
|
|
||||||
AISRecentEntriesView::AISRecentEntriesView() {
|
AISRecentEntriesView::AISRecentEntriesView(
|
||||||
|
AISRecentEntries& recent
|
||||||
|
) : recent { recent }
|
||||||
|
{
|
||||||
flags.focusable = true;
|
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() {
|
void AISRecentEntriesView::on_focus() {
|
||||||
|
@ -296,6 +271,27 @@ AISAppView::AISAppView() {
|
||||||
add_children({ {
|
add_children({ {
|
||||||
&recent_entries_view,
|
&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) {
|
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() });
|
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 */
|
} /* namespace ui */
|
||||||
|
|
|
@ -108,8 +108,7 @@ namespace ui {
|
||||||
|
|
||||||
class AISRecentEntriesView : public View {
|
class AISRecentEntriesView : public View {
|
||||||
public:
|
public:
|
||||||
AISRecentEntriesView();
|
AISRecentEntriesView(AISRecentEntries& recent);
|
||||||
~AISRecentEntriesView();
|
|
||||||
|
|
||||||
void paint(Painter& painter) override;
|
void paint(Painter& painter) override;
|
||||||
|
|
||||||
|
@ -119,29 +118,31 @@ public:
|
||||||
bool on_encoder(const EncoderEvent event) override;
|
bool on_encoder(const EncoderEvent event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AISLogger logger;
|
AISRecentEntries& recent;
|
||||||
|
|
||||||
using EntryKey = ais::MMSI;
|
using EntryKey = ais::MMSI;
|
||||||
EntryKey selected_key;
|
EntryKey selected_key;
|
||||||
const EntryKey invalid_key = 0xffffffff;
|
const EntryKey invalid_key = 0xffffffff;
|
||||||
|
|
||||||
bool has_focus = false;
|
bool has_focus = false;
|
||||||
|
|
||||||
AISRecentEntries recent;
|
|
||||||
|
|
||||||
void on_packet(const ais::Packet& packet);
|
|
||||||
|
|
||||||
void advance(const int32_t amount);
|
void advance(const int32_t amount);
|
||||||
};
|
};
|
||||||
|
|
||||||
class AISAppView : public View {
|
class AISAppView : public View {
|
||||||
public:
|
public:
|
||||||
AISAppView();
|
AISAppView();
|
||||||
|
~AISAppView();
|
||||||
|
|
||||||
void set_parent_rect(const Rect new_parent_rect) override;
|
void set_parent_rect(const Rect new_parent_rect) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AISRecentEntriesView recent_entries_view;
|
AISRecentEntries recent;
|
||||||
|
AISLogger logger;
|
||||||
|
|
||||||
|
AISRecentEntriesView recent_entries_view { recent };
|
||||||
|
|
||||||
|
void on_packet(const ais::Packet& packet);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace ui */
|
} /* namespace ui */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue