From be94c9fa9bf4ee74037ae46e953dfad838b7a166 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Fri, 16 Oct 2015 19:39:44 -0700 Subject: [PATCH] Switching between waterfall and console mode. Also remove an unused Console constructor. --- firmware/application/ui_console.hpp | 6 ------ firmware/application/ui_navigation.cpp | 3 ++- firmware/application/ui_receiver.cpp | 24 +++++++++++++++++++++++- firmware/application/ui_receiver.hpp | 3 +-- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/firmware/application/ui_console.hpp b/firmware/application/ui_console.hpp index 1675fe55..4f29486a 100644 --- a/firmware/application/ui_console.hpp +++ b/firmware/application/ui_console.hpp @@ -32,12 +32,6 @@ namespace ui { class Console : public Widget { public: - constexpr Console( - const Rect parent_rect - ) : Widget { parent_rect } - { - } - void clear(); void write(const std::string message); void writeln(const std::string message); diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 5a9e5b52..5b3bdb8c 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -21,6 +21,7 @@ #include "ui_navigation.hpp" +#include "portapack.hpp" #include "receiver_model.hpp" #include "ui_setup.hpp" @@ -93,7 +94,7 @@ void NavigationView::focus() { SystemMenuView::SystemMenuView(NavigationView& nav) { add_items<7>({ { - { "Receiver", [&nav](){ nav.push(new ReceiverView { nav, receiver_model }); } }, + { "Receiver", [&nav](){ nav.push(new ReceiverView { nav, portapack::receiver_model }); } }, { "Capture", [&nav](){ nav.push(new NotImplementedView { nav }); } }, { "Analyze", [&nav](){ nav.push(new NotImplementedView { nav }); } }, { "Setup", [&nav](){ nav.push(new SetupMenuView { nav }); } }, diff --git a/firmware/application/ui_receiver.cpp b/firmware/application/ui_receiver.cpp index 59721630..53ee5131 100644 --- a/firmware/application/ui_receiver.cpp +++ b/firmware/application/ui_receiver.cpp @@ -21,6 +21,9 @@ #include "ui_receiver.hpp" +#include "ui_spectrum.hpp" +#include "ui_console.hpp" + #include "portapack.hpp" using namespace portapack; @@ -402,7 +405,6 @@ ReceiverView::ReceiverView( &field_volume, &view_frequency_options, &view_rf_gain_options, - &waterfall, } }); button_done.on_select = [&nav](Button&){ @@ -562,6 +564,26 @@ void ReceiverView::on_modulation_changed(int32_t modulation) { break; } + remove_child(widget_content.get()); + widget_content.reset(); + + switch(modulation) { + case 3: + widget_content = std::make_unique(); + add_child(widget_content.get()); + break; + + default: + widget_content = std::make_unique(); + add_child(widget_content.get()); + break; + } + + if( widget_content ) { + const ui::Dim header_height = 3 * 16; + const ui::Rect rect { 0, header_height, parent_rect.width(), static_cast(parent_rect.height() - header_height) }; + widget_content->set_parent_rect(rect); + } } void ReceiverView::on_show_options_frequency() { diff --git a/firmware/application/ui_receiver.hpp b/firmware/application/ui_receiver.hpp index 99626981..7af05fee 100644 --- a/firmware/application/ui_receiver.hpp +++ b/firmware/application/ui_receiver.hpp @@ -27,7 +27,6 @@ #include "ui_navigation.hpp" #include "ui_painter.hpp" #include "ui_widget.hpp" -#include "ui_spectrum.hpp" #include "utility.hpp" @@ -456,7 +455,7 @@ private: &style_options_group }; - spectrum::WaterfallWidget waterfall; + std::unique_ptr widget_content; void on_tuning_frequency_changed(rf::Frequency f); void on_baseband_bandwidth_changed(uint32_t bandwidth_hz);