From 56303eb385dd7b466eff8b09ea0d0d30a2aa462d Mon Sep 17 00:00:00 2001 From: Mark Thompson <129641948+NotherNgineer@users.noreply.github.com> Date: Sat, 30 Mar 2024 12:57:43 -0500 Subject: [PATCH] Use freq from AppSettings unless passed from another app (#2073) --- firmware/application/app_settings.cpp | 8 ++------ firmware/application/app_settings.hpp | 3 --- firmware/application/apps/analog_audio_app.cpp | 2 ++ firmware/application/apps/analog_audio_app.hpp | 1 - firmware/application/apps/capture_app.cpp | 8 ++++++++ firmware/application/apps/capture_app.hpp | 4 ++-- firmware/application/apps/ui_mictx.cpp | 2 ++ firmware/application/apps/ui_mictx.hpp | 1 - firmware/application/apps/ui_recon.cpp | 4 ++-- firmware/application/apps/ui_scanner.cpp | 2 +- firmware/application/receiver_model.cpp | 1 + firmware/application/receiver_model.hpp | 1 + 12 files changed, 21 insertions(+), 16 deletions(-) diff --git a/firmware/application/app_settings.cpp b/firmware/application/app_settings.cpp index ce067e4c..505ed456 100644 --- a/firmware/application/app_settings.cpp +++ b/firmware/application/app_settings.cpp @@ -175,16 +175,12 @@ void copy_to_radio_model(const AppSettings& settings) { // Specifically 'modulation' which requires a running baseband. if (flags_enabled(settings.mode, Mode::TX)) { - if (!flags_enabled(settings.options, Options::UseGlobalTargetFrequency)) - persistent_memory::set_target_frequency(settings.tx_frequency); - + persistent_memory::set_target_frequency(settings.tx_frequency); transmitter_model.configure_from_app_settings(settings); } if (flags_enabled(settings.mode, Mode::RX)) { - if (!flags_enabled(settings.options, Options::UseGlobalTargetFrequency)) - persistent_memory::set_target_frequency(settings.rx_frequency); - + persistent_memory::set_target_frequency(settings.rx_frequency); receiver_model.configure_from_app_settings(settings); receiver_model.set_configuration_without_update( static_cast(settings.modulation), diff --git a/firmware/application/app_settings.hpp b/firmware/application/app_settings.hpp index 422daaa3..dd83c405 100644 --- a/firmware/application/app_settings.hpp +++ b/firmware/application/app_settings.hpp @@ -118,9 +118,6 @@ enum class Mode : uint8_t { enum class Options { None = 0x0000, - - /* Don't use target frequency from app settings. */ - UseGlobalTargetFrequency = 0x0001, }; /* NB: See RX/TX model headers for default values. */ diff --git a/firmware/application/apps/analog_audio_app.cpp b/firmware/application/apps/analog_audio_app.cpp index 2be1ccd4..c055539a 100644 --- a/firmware/application/apps/analog_audio_app.cpp +++ b/firmware/application/apps/analog_audio_app.cpp @@ -208,7 +208,9 @@ AnalogAudioView::AnalogAudioView( NavigationView& nav, ReceiverModel::settings_t override) : AnalogAudioView(nav) { + // Settings to override when launched from another app (versus from AppSettings .ini file) // TODO: Which other settings make sense to override? + field_frequency.set_value(override.frequency_app_override); on_frequency_step_changed(override.frequency_step); options_modulation.set_by_value(toUType(override.mode)); } diff --git a/firmware/application/apps/analog_audio_app.hpp b/firmware/application/apps/analog_audio_app.hpp index 56da8540..efe154c7 100644 --- a/firmware/application/apps/analog_audio_app.hpp +++ b/firmware/application/apps/analog_audio_app.hpp @@ -174,7 +174,6 @@ class AnalogAudioView : public View { app_settings::SettingsManager settings_{ "rx_audio", app_settings::Mode::RX, - app_settings::Options::UseGlobalTargetFrequency, { {"iq_phase_calibration"sv, &iq_phase_calibration_value}, // we are saving and restoring that CAL from Settings. }}; diff --git a/firmware/application/apps/capture_app.cpp b/firmware/application/apps/capture_app.cpp index 999d4176..a774a2c1 100644 --- a/firmware/application/apps/capture_app.cpp +++ b/firmware/application/apps/capture_app.cpp @@ -104,6 +104,14 @@ CaptureAppView::CaptureAppView(NavigationView& nav) }; } +CaptureAppView::CaptureAppView( + NavigationView& nav, + ReceiverModel::settings_t override) + : CaptureAppView(nav) { + // Settings to override when launched from another app (versus from AppSettings .ini file) + field_frequency.set_value(override.frequency_app_override); +} + CaptureAppView::~CaptureAppView() { receiver_model.disable(); baseband::shutdown(); diff --git a/firmware/application/apps/capture_app.hpp b/firmware/application/apps/capture_app.hpp index 07a162b4..bec009ac 100644 --- a/firmware/application/apps/capture_app.hpp +++ b/firmware/application/apps/capture_app.hpp @@ -38,6 +38,7 @@ namespace ui { class CaptureAppView : public View { public: CaptureAppView(NavigationView& nav); + CaptureAppView(NavigationView& nav, ReceiverModel::settings_t override); ~CaptureAppView(); void focus() override; @@ -52,8 +53,7 @@ class CaptureAppView : public View { NavigationView& nav_; RxRadioState radio_state_{ReceiverModel::Mode::Capture}; app_settings::SettingsManager settings_{ - "rx_capture", app_settings::Mode::RX, - app_settings::Options::UseGlobalTargetFrequency}; + "rx_capture", app_settings::Mode::RX}; Labels labels{ {{0 * 8, 1 * 16}, "Rate:", Color::light_grey()}, diff --git a/firmware/application/apps/ui_mictx.cpp b/firmware/application/apps/ui_mictx.cpp index e72e63a0..005303dc 100644 --- a/firmware/application/apps/ui_mictx.cpp +++ b/firmware/application/apps/ui_mictx.cpp @@ -596,6 +596,7 @@ MicTXView::MicTXView( NavigationView& nav, ReceiverModel::settings_t override) : MicTXView(nav) { + // Settings to override when launched from another app (versus from AppSettings .ini file) // Try to use the modulation/bandwidth from RX settings. // TODO: These concepts should be merged so there's only one. switch (override.mode) { @@ -616,6 +617,7 @@ MicTXView::MicTXView( break; } + field_frequency.set_value(override.frequency_app_override); check_common_freq_tx_rx.set_value(true); // freq passed from other app is in tx_frequency, so set rx_frequency=tx_frequency // TODO: bandwidth selection is tied too tightly to the UI diff --git a/firmware/application/apps/ui_mictx.hpp b/firmware/application/apps/ui_mictx.hpp index 8a0c18c8..9b599b2b 100644 --- a/firmware/application/apps/ui_mictx.hpp +++ b/firmware/application/apps/ui_mictx.hpp @@ -118,7 +118,6 @@ class MicTXView : public View { app_settings::SettingsManager settings_{ "tx_mic", app_settings::Mode::RX_TX, - app_settings::Options::UseGlobalTargetFrequency, { {"mic_mod_index"sv, &mic_mod_index}, {"rxbw_index"sv, &rxbw_index}, diff --git a/firmware/application/apps/ui_recon.cpp b/firmware/application/apps/ui_recon.cpp index afa3782f..d3531b85 100644 --- a/firmware/application/apps/ui_recon.cpp +++ b/firmware/application/apps/ui_recon.cpp @@ -508,7 +508,7 @@ ReconView::ReconView(NavigationView& nav) auto settings = receiver_model.settings(); settings.frequency_step = step_mode.selected_index_value(); if (field_mode.selected_index_value() == SPEC_MODULATION) - nav_.replace(); + nav_.replace(settings); else nav_.replace(settings); }; @@ -539,7 +539,7 @@ ReconView::ReconView(NavigationView& nav) } } - // MicTX wants Modulation and Bandwidth overrides, but that's only stored on the RX model. + // MicTX wants Frequency, Modulation and Bandwidth overrides, but that's only stored on the RX model. nav_.replace(receiver_model.settings()); }; diff --git a/firmware/application/apps/ui_scanner.cpp b/firmware/application/apps/ui_scanner.cpp index 8f7d4495..fc49f664 100644 --- a/firmware/application/apps/ui_scanner.cpp +++ b/firmware/application/apps/ui_scanner.cpp @@ -413,7 +413,7 @@ ScannerView::ScannerView( button_mic_app.on_select = [this](Button&) { if (scan_thread) scan_thread->stop(); - // MicTX wants Modulation and Bandwidth overrides, but that's only stored on the RX model. + // MicTX wants Frequency, Modulation and Bandwidth overrides, but that's only stored on the RX model. nav_.replace(receiver_model.settings()); }; diff --git a/firmware/application/receiver_model.cpp b/firmware/application/receiver_model.cpp index 0c0044a2..f7c79555 100644 --- a/firmware/application/receiver_model.cpp +++ b/firmware/application/receiver_model.cpp @@ -68,6 +68,7 @@ rf::Frequency ReceiverModel::target_frequency() const { void ReceiverModel::set_target_frequency(rf::Frequency f) { persistent_memory::set_target_frequency(f); + settings_.frequency_app_override = f; update_tuning_frequency(); } diff --git a/firmware/application/receiver_model.hpp b/firmware/application/receiver_model.hpp index 7b5263d3..ecdb3223 100644 --- a/firmware/application/receiver_model.hpp +++ b/firmware/application/receiver_model.hpp @@ -48,6 +48,7 @@ class ReceiverModel { uint32_t baseband_bandwidth = max283x::filter::bandwidth_minimum; uint32_t sampling_rate = 3'072'000; rf::Frequency frequency_step = 25'000; + rf::Frequency frequency_app_override = 0; uint8_t lna_gain_db = 32; uint8_t vga_gain_db = 32; bool rf_amp = false;