From 9190fe7e4f7a711a6fbba7b68299dfa1b4d0af99 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Mon, 6 Jun 2016 10:27:33 -0700 Subject: [PATCH] Move common code to LNA/VGA field widgets. --- firmware/application/analog_audio_app.cpp | 17 ----------------- firmware/application/analog_audio_app.hpp | 2 -- firmware/application/capture_app.cpp | 18 ------------------ firmware/application/capture_app.hpp | 2 -- firmware/application/tpms_app.cpp | 10 ---------- firmware/application/ui_receiver.cpp | 10 ++++++++++ 6 files changed, 10 insertions(+), 49 deletions(-) diff --git a/firmware/application/analog_audio_app.cpp b/firmware/application/analog_audio_app.cpp index 9edf96a6..4145d2c4 100644 --- a/firmware/application/analog_audio_app.cpp +++ b/firmware/application/analog_audio_app.cpp @@ -108,19 +108,10 @@ AnalogAudioView::AnalogAudioView( this->on_show_options_frequency(); }; - field_lna.set_value(receiver_model.lna()); - field_lna.on_change = [this](int32_t v) { - this->on_lna_changed(v); - }; - field_lna.on_show_options = [this]() { this->on_show_options_rf_gain(); }; - field_vga.set_value(receiver_model.vga()); - field_vga.on_change = [this](int32_t v_db) { - this->on_vga_changed(v_db); - }; field_vga.on_show_options = [this]() { this->on_show_options_rf_gain(); }; @@ -182,14 +173,6 @@ void AnalogAudioView::on_baseband_bandwidth_changed(uint32_t bandwidth_hz) { receiver_model.set_baseband_bandwidth(bandwidth_hz); } -void AnalogAudioView::on_lna_changed(int32_t v_db) { - receiver_model.set_lna(v_db); -} - -void AnalogAudioView::on_vga_changed(int32_t v_db) { - receiver_model.set_vga(v_db); -} - void AnalogAudioView::on_modulation_changed(const ReceiverModel::Mode modulation) { // TODO: Terrible kludge because widget system doesn't notify Waterfall that // it's being shown or hidden. diff --git a/firmware/application/analog_audio_app.hpp b/firmware/application/analog_audio_app.hpp index db9b9f28..a91e8059 100644 --- a/firmware/application/analog_audio_app.hpp +++ b/firmware/application/analog_audio_app.hpp @@ -150,8 +150,6 @@ private: void on_tuning_frequency_changed(rf::Frequency f); void on_baseband_bandwidth_changed(uint32_t bandwidth_hz); - void on_lna_changed(int32_t v_db); - void on_vga_changed(int32_t v_db); void on_modulation_changed(const ReceiverModel::Mode modulation); void on_show_options_frequency(); void on_show_options_rf_gain(); diff --git a/firmware/application/capture_app.cpp b/firmware/application/capture_app.cpp index cff3bf0b..4ad9d823 100644 --- a/firmware/application/capture_app.cpp +++ b/firmware/application/capture_app.cpp @@ -51,16 +51,6 @@ CaptureAppView::CaptureAppView(NavigationView& nav) { }; }; - field_lna.set_value(receiver_model.lna()); - field_lna.on_change = [this](int32_t v) { - this->on_lna_changed(v); - }; - - field_vga.set_value(receiver_model.vga()); - field_vga.on_change = [this](int32_t v_db) { - this->on_vga_changed(v_db); - }; - receiver_model.set_baseband_configuration({ .mode = toUType(ReceiverModel::Mode::Capture), .sampling_rate = sampling_rate, @@ -101,12 +91,4 @@ void CaptureAppView::on_tuning_frequency_changed(rf::Frequency f) { receiver_model.set_tuning_frequency(f); } -void CaptureAppView::on_lna_changed(int32_t v_db) { - receiver_model.set_lna(v_db); -} - -void CaptureAppView::on_vga_changed(int32_t v_db) { - receiver_model.set_vga(v_db); -} - } /* namespace ui */ diff --git a/firmware/application/capture_app.hpp b/firmware/application/capture_app.hpp index 6ece4b89..14d48434 100644 --- a/firmware/application/capture_app.hpp +++ b/firmware/application/capture_app.hpp @@ -53,8 +53,6 @@ private: static constexpr uint32_t baseband_bandwidth = 2500000; void on_tuning_frequency_changed(rf::Frequency f); - void on_lna_changed(int32_t v_db); - void on_vga_changed(int32_t v_db); RSSI rssi { { 21 * 8, 0, 6 * 8, 4 }, diff --git a/firmware/application/tpms_app.cpp b/firmware/application/tpms_app.cpp index 795a3ad0..5462db6e 100644 --- a/firmware/application/tpms_app.cpp +++ b/firmware/application/tpms_app.cpp @@ -172,16 +172,6 @@ TPMSAppView::TPMSAppView(NavigationView&) { &recent_entries_view, } }); - field_lna.set_value(receiver_model.lna()); - field_lna.on_change = [this](int32_t v_db) { - receiver_model.set_lna(v_db); - }; - - field_vga.set_value(receiver_model.vga()); - field_vga.on_change = [this](int32_t v_db) { - receiver_model.set_vga(v_db); - }; - radio::enable({ tuning_frequency(), sampling_rate, diff --git a/firmware/application/ui_receiver.cpp b/firmware/application/ui_receiver.cpp index 0198a171..479d4468 100644 --- a/firmware/application/ui_receiver.cpp +++ b/firmware/application/ui_receiver.cpp @@ -314,6 +314,11 @@ LNAGainField::LNAGainField( ' ', } { + set_value(receiver_model.lna()); + + on_change = [](int32_t v) { + receiver_model.set_lna(v); + }; } void LNAGainField::on_focus() { @@ -334,6 +339,11 @@ VGAGainField::VGAGainField( ' ', } { + set_value(receiver_model.vga()); + + on_change = [](int32_t v) { + receiver_model.set_vga(v); + }; } void VGAGainField::on_focus() {