Add AIS channel control.

This commit is contained in:
Jared Boone 2016-01-25 11:47:59 -08:00
parent 8b0e6e65c8
commit c1f7f23367
2 changed files with 38 additions and 3 deletions

View File

@ -299,6 +299,8 @@ void AISRecentEntryDetailView::set_entry(const AISRecentEntry& entry) {
AISAppView::AISAppView(NavigationView&) { AISAppView::AISAppView(NavigationView&) {
add_children({ { add_children({ {
&label_channel,
&options_channel,
&recent_entries_view, &recent_entries_view,
&recent_entry_detail_view, &recent_entry_detail_view,
} }); } });
@ -315,6 +317,11 @@ AISAppView::AISAppView(NavigationView&) {
} }
); );
options_channel.on_change = [this](size_t, OptionsField::value_t v) {
this->on_frequency_changed(v);
};
options_channel.set_by_value(162025000);
receiver_model.set_baseband_configuration({ receiver_model.set_baseband_configuration({
.mode = 3, .mode = 3,
.sampling_rate = 2457600, .sampling_rate = 2457600,
@ -324,7 +331,6 @@ AISAppView::AISAppView(NavigationView&) {
receiver_model.set_rf_amp(false); receiver_model.set_rf_amp(false);
receiver_model.set_lna(32); receiver_model.set_lna(32);
receiver_model.set_vga(32); receiver_model.set_vga(32);
receiver_model.set_tuning_frequency(162025000);
receiver_model.enable(); receiver_model.enable();
recent_entries_view.on_select = [this](const AISRecentEntry& entry) { recent_entries_view.on_select = [this](const AISRecentEntry& entry) {
@ -340,10 +346,15 @@ AISAppView::~AISAppView() {
EventDispatcher::message_map().unregister_handler(Message::ID::AISPacket); EventDispatcher::message_map().unregister_handler(Message::ID::AISPacket);
} }
void AISAppView::focus() {
options_channel.focus();
}
void AISAppView::set_parent_rect(const Rect new_parent_rect) { void AISAppView::set_parent_rect(const Rect new_parent_rect) {
View::set_parent_rect(new_parent_rect); View::set_parent_rect(new_parent_rect);
recent_entries_view.set_parent_rect({ 0, 0, new_parent_rect.width(), new_parent_rect.height() }); const Rect content_rect { 0, header_height, new_parent_rect.width(), new_parent_rect.height() - header_height };
recent_entry_detail_view.set_parent_rect({ 0, 0, new_parent_rect.width(), new_parent_rect.height() }); recent_entries_view.set_parent_rect(content_rect);
recent_entry_detail_view.set_parent_rect(content_rect);
} }
void AISAppView::on_packet(const ais::Packet& packet) { void AISAppView::on_packet(const ais::Packet& packet) {
@ -370,4 +381,8 @@ void AISAppView::on_show_detail(const AISRecentEntry& entry) {
recent_entry_detail_view.focus(); recent_entry_detail_view.focus();
} }
void AISAppView::on_frequency_changed(const uint32_t new_frequency) {
receiver_model.set_tuning_frequency(new_frequency);
}
} /* namespace ui */ } /* namespace ui */

View File

@ -140,6 +140,8 @@ public:
// TODO: Add flag to View that specifies view does not need to be cleared before painting. // TODO: Add flag to View that specifies view does not need to be cleared before painting.
void paint(Painter&) override { }; void paint(Painter&) override { };
void focus() override;
private: private:
AISRecentEntries recent; AISRecentEntries recent;
AISLogger logger; AISLogger logger;
@ -147,9 +149,27 @@ private:
AISRecentEntriesView recent_entries_view { recent }; AISRecentEntriesView recent_entries_view { recent };
AISRecentEntryDetailView recent_entry_detail_view; AISRecentEntryDetailView recent_entry_detail_view;
static constexpr auto header_height = 1 * 16;
Text label_channel {
{ 0 * 8, 0 * 16, 2 * 8, 1 * 16 },
"Ch"
};
OptionsField options_channel {
{ 3 * 8, 0 * 16 },
3,
{
{ "87B", 161975000 },
{ "88B", 162025000 },
}
};
void on_packet(const ais::Packet& packet); void on_packet(const ais::Packet& packet);
void on_show_list(); void on_show_list();
void on_show_detail(const AISRecentEntry& entry); void on_show_detail(const AISRecentEntry& entry);
void on_frequency_changed(const uint32_t new_frequency);
}; };
} /* namespace ui */ } /* namespace ui */