Skip to content

Commit

Permalink
Use freq from AppSettings unless passed from another app (#2073)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotherNgineer committed Mar 30, 2024
1 parent d29172f commit 56303eb
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 16 deletions.
8 changes: 2 additions & 6 deletions firmware/application/app_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReceiverModel::Mode>(settings.modulation),
Expand Down
3 changes: 0 additions & 3 deletions firmware/application/app_settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
2 changes: 2 additions & 0 deletions firmware/application/apps/analog_audio_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
1 change: 0 additions & 1 deletion firmware/application/apps/analog_audio_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}};
Expand Down
8 changes: 8 additions & 0 deletions firmware/application/apps/capture_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions firmware/application/apps/capture_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()},
Expand Down
2 changes: 2 additions & 0 deletions firmware/application/apps/ui_mictx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion firmware/application/apps/ui_mictx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
4 changes: 2 additions & 2 deletions firmware/application/apps/ui_recon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CaptureAppView>();
nav_.replace<CaptureAppView>(settings);
else
nav_.replace<AnalogAudioView>(settings);
};
Expand Down Expand Up @@ -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<MicTXView>(receiver_model.settings());
};

Expand Down
2 changes: 1 addition & 1 deletion firmware/application/apps/ui_scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MicTXView>(receiver_model.settings());
};

Expand Down
1 change: 1 addition & 0 deletions firmware/application/receiver_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
1 change: 1 addition & 0 deletions firmware/application/receiver_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 56303eb

Please sign in to comment.