From 9929376acf21d7db22109005f49946474e943c10 Mon Sep 17 00:00:00 2001 From: Mark Thompson <129641948+NotherNgineer@users.noreply.github.com> Date: Sat, 14 Oct 2023 11:33:52 -0500 Subject: [PATCH] Added Freq to Radio State, only update specified App Settings, always Load/Save Settings (#1498) * Add files via upload * Add files via upload * Add files via upload * Add files via upload * Add files via upload * Add files via upload * Add files via upload * Add files via upload --- firmware/application/app_settings.cpp | 74 +++++++++---------- firmware/application/app_settings.hpp | 3 - firmware/application/apps/acars_app.hpp | 3 +- firmware/application/apps/ais_app.cpp | 3 - firmware/application/apps/ais_app.hpp | 3 +- firmware/application/apps/ert_app.cpp | 3 - firmware/application/apps/ert_app.hpp | 3 +- firmware/application/apps/gps_sim_app.cpp | 7 -- firmware/application/apps/gps_sim_app.hpp | 12 +-- firmware/application/apps/lge_app.hpp | 1 + firmware/application/apps/pocsag_app.cpp | 3 - firmware/application/apps/pocsag_app.hpp | 7 +- firmware/application/apps/soundboard_app.cpp | 1 - firmware/application/apps/soundboard_app.hpp | 1 + firmware/application/apps/tpms_app.cpp | 3 - firmware/application/apps/tpms_app.hpp | 5 +- firmware/application/apps/ui_adsb_rx.cpp | 1 - firmware/application/apps/ui_adsb_rx.hpp | 1 + firmware/application/apps/ui_adsb_tx.cpp | 1 - firmware/application/apps/ui_adsb_tx.hpp | 3 +- firmware/application/apps/ui_aprs_rx.hpp | 6 +- firmware/application/apps/ui_aprs_tx.cpp | 1 - firmware/application/apps/ui_aprs_tx.hpp | 1 + firmware/application/apps/ui_btle_rx.cpp | 1 - firmware/application/apps/ui_btle_rx.hpp | 1 + firmware/application/apps/ui_coasterp.cpp | 1 - firmware/application/apps/ui_coasterp.hpp | 1 + firmware/application/apps/ui_encoders.cpp | 1 - firmware/application/apps/ui_encoders.hpp | 1 + firmware/application/apps/ui_jammer.hpp | 1 + firmware/application/apps/ui_keyfob.cpp | 2 - firmware/application/apps/ui_keyfob.hpp | 1 + firmware/application/apps/ui_lcr.hpp | 1 + firmware/application/apps/ui_mictx.hpp | 1 + firmware/application/apps/ui_morse.hpp | 1 + firmware/application/apps/ui_nrf_rx.cpp | 1 - firmware/application/apps/ui_nrf_rx.hpp | 1 + firmware/application/apps/ui_numbers.hpp | 1 + firmware/application/apps/ui_nuoptix.hpp | 1 + firmware/application/apps/ui_pocsag_tx.hpp | 1 + firmware/application/apps/ui_rds.cpp | 1 - firmware/application/apps/ui_rds.hpp | 1 + firmware/application/apps/ui_search.hpp | 1 + firmware/application/apps/ui_settings.cpp | 29 -------- firmware/application/apps/ui_settings.hpp | 35 --------- firmware/application/apps/ui_siggen.hpp | 1 + firmware/application/apps/ui_sonde.cpp | 3 - firmware/application/apps/ui_sonde.hpp | 2 +- firmware/application/apps/ui_test.hpp | 1 + firmware/application/apps/ui_touchtunes.cpp | 4 - firmware/application/apps/ui_touchtunes.hpp | 6 +- firmware/application/radio_state.hpp | 7 +- .../common/portapack_persistent_memory.cpp | 8 -- .../common/portapack_persistent_memory.hpp | 2 - 54 files changed, 88 insertions(+), 177 deletions(-) diff --git a/firmware/application/app_settings.cpp b/firmware/application/app_settings.cpp index 3d9d5f7b..3e2b133c 100644 --- a/firmware/application/app_settings.cpp +++ b/firmware/application/app_settings.cpp @@ -244,8 +244,7 @@ SettingsManager::SettingsManager( : app_name_{app_name}, settings_{}, bindings_{}, - loaded_{false}, - radio_loaded_{false} { + loaded_{false} { settings_.mode = mode; settings_.options = options; @@ -253,53 +252,50 @@ SettingsManager::SettingsManager( additional_settings.reserve(17 + additional_settings.size()); bindings_ = std::move(additional_settings); - // Additional settings should always be loaded because apps now rely - // on being able to store UI settings, config, etc. The radio settings - // are only loaded if the global option has been enabled. - // Add the radio setting bindings if either load or save are enabled. - if (portapack::persistent_memory::load_app_settings() || - portapack::persistent_memory::save_app_settings()) { - // Transmitter model settings. - if (flags_enabled(mode, Mode::TX)) { - bindings_.emplace_back("tx_frequency"sv, &settings_.tx_frequency); - bindings_.emplace_back("tx_amp"sv, &settings_.tx_amp); - bindings_.emplace_back("tx_gain"sv, &settings_.tx_gain); - bindings_.emplace_back("channel_bandwidth"sv, &settings_.channel_bandwidth); - } + // Settings should always be loaded because apps now rely + // on being able to store UI settings, config, etc. - // Receiver model settings. - if (flags_enabled(mode, Mode::RX)) { - bindings_.emplace_back("rx_frequency"sv, &settings_.rx_frequency); - bindings_.emplace_back("lna"sv, &settings_.lna); - bindings_.emplace_back("vga"sv, &settings_.vga); - bindings_.emplace_back("rx_amp"sv, &settings_.rx_amp); - bindings_.emplace_back("modulation"sv, &settings_.modulation); - bindings_.emplace_back("am_config_index"sv, &settings_.am_config_index); - bindings_.emplace_back("nbfm_config_index"sv, &settings_.nbfm_config_index); - bindings_.emplace_back("wfm_config_index"sv, &settings_.wfm_config_index); - bindings_.emplace_back("squelch"sv, &settings_.squelch); - } - - // Common model settings. - bindings_.emplace_back("baseband_bandwidth"sv, &settings_.baseband_bandwidth); - bindings_.emplace_back("sampling_rate"sv, &settings_.sampling_rate); - bindings_.emplace_back("step"sv, &settings_.step); - bindings_.emplace_back("volume"sv, &settings_.volume); + // Transmitter model settings. + if (flags_enabled(mode, Mode::TX)) { + bindings_.emplace_back("tx_frequency"sv, &settings_.tx_frequency); + bindings_.emplace_back("tx_amp"sv, &settings_.tx_amp); + bindings_.emplace_back("tx_gain"sv, &settings_.tx_gain); + bindings_.emplace_back("channel_bandwidth"sv, &settings_.channel_bandwidth); } + // Receiver model settings. + if (flags_enabled(mode, Mode::RX)) { + bindings_.emplace_back("rx_frequency"sv, &settings_.rx_frequency); + bindings_.emplace_back("lna"sv, &settings_.lna); + bindings_.emplace_back("vga"sv, &settings_.vga); + bindings_.emplace_back("rx_amp"sv, &settings_.rx_amp); + bindings_.emplace_back("modulation"sv, &settings_.modulation); + bindings_.emplace_back("am_config_index"sv, &settings_.am_config_index); + bindings_.emplace_back("nbfm_config_index"sv, &settings_.nbfm_config_index); + bindings_.emplace_back("wfm_config_index"sv, &settings_.wfm_config_index); + bindings_.emplace_back("squelch"sv, &settings_.squelch); + } + + // Common model settings. + bindings_.emplace_back("baseband_bandwidth"sv, &settings_.baseband_bandwidth); + bindings_.emplace_back("sampling_rate"sv, &settings_.sampling_rate); + bindings_.emplace_back("step"sv, &settings_.step); + bindings_.emplace_back("volume"sv, &settings_.volume); + + // RadioState should have initialized default radio parameters before this function; + // copy them to settings_ before checking settings .ini file (in case the file doesn't exist + // or doesn't include all parameters). Settings in the file can overwrite all, or a subset of parameters. + copy_from_radio_model(settings_); + loaded_ = load_settings(app_name_, bindings_); // Only copy to the radio if load was successful. - if (loaded_ && portapack::persistent_memory::load_app_settings()) { - radio_loaded_ = true; + if (loaded_) copy_to_radio_model(settings_); - } } SettingsManager::~SettingsManager() { - // Only save radio settings when the option is enabled. - if (portapack::persistent_memory::save_app_settings()) - copy_from_radio_model(settings_); + copy_from_radio_model(settings_); save_settings(app_name_, bindings_); } diff --git a/firmware/application/app_settings.hpp b/firmware/application/app_settings.hpp index 9ce4f6c2..967f83bd 100644 --- a/firmware/application/app_settings.hpp +++ b/firmware/application/app_settings.hpp @@ -170,8 +170,6 @@ class SettingsManager { /* True if settings were successfully loaded from file. */ bool loaded() const { return loaded_; } - /* True if radio settings were successfully loaded from file. */ - bool radio_loaded() const { return radio_loaded_; } Mode mode() const { return settings_.mode; } AppSettings& raw() { return settings_; } @@ -181,7 +179,6 @@ class SettingsManager { AppSettings settings_; SettingBindings bindings_; bool loaded_; - bool radio_loaded_; }; } // namespace app_settings diff --git a/firmware/application/apps/acars_app.hpp b/firmware/application/apps/acars_app.hpp index 72097403..75d11f6b 100644 --- a/firmware/application/apps/acars_app.hpp +++ b/firmware/application/apps/acars_app.hpp @@ -60,11 +60,12 @@ class ACARSAppView : public View { private: NavigationView& nav_; RxRadioState radio_state_{ + 131550000 /* frequency */, 1750000 /* bandwidth */, 2457600 /* sampling rate */ }; app_settings::SettingsManager settings_{ - "rx_acars.hpp", app_settings::Mode::RX}; + "rx_acars", app_settings::Mode::RX}; bool logging{false}; uint32_t packet_counter{0}; diff --git a/firmware/application/apps/ais_app.cpp b/firmware/application/apps/ais_app.cpp index 578ed808..d8dc4637 100644 --- a/firmware/application/apps/ais_app.cpp +++ b/firmware/application/apps/ais_app.cpp @@ -382,9 +382,6 @@ AISAppView::AISAppView(NavigationView& nav) recent_entry_detail_view.hidden(true); - if (!settings_.radio_loaded()) - receiver_model.set_target_frequency(initial_target_frequency); - receiver_model.enable(); options_channel.on_change = [this](size_t, OptionsField::value_t v) { diff --git a/firmware/application/apps/ais_app.hpp b/firmware/application/apps/ais_app.hpp index 5960b399..175ef463 100644 --- a/firmware/application/apps/ais_app.hpp +++ b/firmware/application/apps/ais_app.hpp @@ -162,9 +162,8 @@ class AISAppView : public View { std::string title() const override { return "AIS RX"; }; private: - static constexpr uint32_t initial_target_frequency = 162025000; - RxRadioState radio_state_{ + 162025000 /* frequency*/, 1750000 /* bandwidth */, 2457600 /* sampling rate */ }; diff --git a/firmware/application/apps/ert_app.cpp b/firmware/application/apps/ert_app.cpp index 688eed47..e476c966 100644 --- a/firmware/application/apps/ert_app.cpp +++ b/firmware/application/apps/ert_app.cpp @@ -110,9 +110,6 @@ ERTAppView::ERTAppView(NavigationView&) { &recent_entries_view, }); - if (!settings_.radio_loaded()) - receiver_model.set_target_frequency(initial_target_frequency); - receiver_model.enable(); logger = std::make_unique(); diff --git a/firmware/application/apps/ert_app.hpp b/firmware/application/apps/ert_app.hpp index ec80098e..ab22bf4f 100644 --- a/firmware/application/apps/ert_app.hpp +++ b/firmware/application/apps/ert_app.hpp @@ -123,12 +123,11 @@ class ERTAppView : public View { std::string title() const override { return "ERT RX"; }; private: - static constexpr uint32_t initial_target_frequency = 911600000; - ERTRecentEntries recent{}; std::unique_ptr logger{}; RxRadioState radio_state_{ + 911600000 /* frequency */, 2500000 /* bandwidth */, 4194304 /* sampling rate */}; app_settings::SettingsManager settings_{ diff --git a/firmware/application/apps/gps_sim_app.cpp b/firmware/application/apps/gps_sim_app.cpp index 1cd43530..27b9a236 100644 --- a/firmware/application/apps/gps_sim_app.cpp +++ b/firmware/application/apps/gps_sim_app.cpp @@ -176,13 +176,6 @@ GpsSimAppView::GpsSimAppView( &waterfall, }); - transmitter_model.set_baseband_bandwidth(15'000'000); // GPS L1 signal use to have wide band spectrum, still with lobule energy -30dB's at + - 15 Mhz - - if (!settings_.radio_loaded()) { - field_frequency.set_value(initial_target_frequency); - transmitter_model.set_sampling_rate(2600000); - } - field_frequency.set_step(5000); button_play.on_select = [this](ImageButton&) { diff --git a/firmware/application/apps/gps_sim_app.hpp b/firmware/application/apps/gps_sim_app.hpp index c99c2548..7d48d5eb 100644 --- a/firmware/application/apps/gps_sim_app.hpp +++ b/firmware/application/apps/gps_sim_app.hpp @@ -51,21 +51,17 @@ class GpsSimAppView : public View { std::string title() const override { return "GPS Sim TX"; }; private: - static constexpr uint32_t initial_target_frequency = 1575420000; - NavigationView& nav_; - RxRadioState radio_state_{ - 3000000 /* bandwidth */, - 500000 /* sampling rate */ + TxRadioState radio_state_{ + 1575420000 /* frequency */, + 15000000 /* bandwidth */, + 2600000 /* sampling rate */ }; app_settings::SettingsManager settings_{ "tx_gps", app_settings::Mode::TX}; static constexpr ui::Dim header_height = 3 * 16; - int32_t tx_gain{47}; - bool rf_amp{true}; // aux private var to store temporal, same as Replay App rf_amp user selection. - static constexpr uint32_t baseband_bandwidth = 3000000; // filter bandwidth const size_t read_size{16384}; const size_t buffer_count{3}; diff --git a/firmware/application/apps/lge_app.hpp b/firmware/application/apps/lge_app.hpp index fb2c6d70..4eac2b1a 100644 --- a/firmware/application/apps/lge_app.hpp +++ b/firmware/application/apps/lge_app.hpp @@ -51,6 +51,7 @@ class LGEView : public View { }; TxRadioState radio_state_{ + 868067000 /* frequency */, 1750000 /* bandwidth */, 2280000 /* sampling rate */ }; diff --git a/firmware/application/apps/pocsag_app.cpp b/firmware/application/apps/pocsag_app.cpp index e710f242..88d4a647 100644 --- a/firmware/application/apps/pocsag_app.cpp +++ b/firmware/application/apps/pocsag_app.cpp @@ -114,9 +114,6 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav) ? FILTER_NONE : FILTER_DROP; } - if (!app_settings_.radio_loaded()) { - field_frequency.set_value(initial_target_frequency); - } logger.append(LOG_ROOT_DIR "/POCSAG.TXT"); diff --git a/firmware/application/apps/pocsag_app.hpp b/firmware/application/apps/pocsag_app.hpp index 1bf9ba71..ea97ef61 100644 --- a/firmware/application/apps/pocsag_app.hpp +++ b/firmware/application/apps/pocsag_app.hpp @@ -197,14 +197,17 @@ class POCSAGAppView : public View { void focus() override; private: - static constexpr uint32_t initial_target_frequency = 466'175'000; bool logging() const { return settings_.enable_logging; }; bool logging_raw() const { return settings_.enable_raw_log; }; bool hide_bad_data() const { return settings_.hide_bad_data; }; bool hide_addr_only() const { return settings_.hide_addr_only; }; NavigationView& nav_; - RxRadioState radio_state_{}; + RxRadioState radio_state_{ + 466175000 /* frequency*/, + max283x::filter::bandwidth_minimum /* bandwidth */, + 3072000 /* sampling rate */ + }; // Settings POCSAGSettings settings_{}; diff --git a/firmware/application/apps/soundboard_app.cpp b/firmware/application/apps/soundboard_app.cpp index 90f52155..2431e6c7 100644 --- a/firmware/application/apps/soundboard_app.cpp +++ b/firmware/application/apps/soundboard_app.cpp @@ -120,7 +120,6 @@ void SoundBoardView::start_tx(const uint32_t id) { ); baseband::set_sample_rate(sample_rate); - transmitter_model.set_baseband_bandwidth(1'750'000); // the Minimum TX LPF 1M75 is fine. transmitter_model.enable(); tx_view.set_transmitting(true); diff --git a/firmware/application/apps/soundboard_app.hpp b/firmware/application/apps/soundboard_app.hpp index 08708f5b..7a439151 100644 --- a/firmware/application/apps/soundboard_app.hpp +++ b/firmware/application/apps/soundboard_app.hpp @@ -50,6 +50,7 @@ class SoundBoardView : public View { private: TxRadioState radio_state_{ + 0 /* frequency */, 1750000 /* bandwidth */, 1536000 /* sampling rate */ }; diff --git a/firmware/application/apps/tpms_app.cpp b/firmware/application/apps/tpms_app.cpp index 3bf25d2a..41c95eaa 100644 --- a/firmware/application/apps/tpms_app.cpp +++ b/firmware/application/apps/tpms_app.cpp @@ -157,9 +157,6 @@ TPMSAppView::TPMSAppView(NavigationView&) { &field_vga, &recent_entries_view}); - if (!settings_.radio_loaded()) - receiver_model.set_target_frequency(initial_target_frequency); - receiver_model.enable(); options_band.on_change = [this](size_t, OptionsField::value_t v) { diff --git a/firmware/application/apps/tpms_app.hpp b/firmware/application/apps/tpms_app.hpp index 788a4add..fb0745f3 100644 --- a/firmware/application/apps/tpms_app.hpp +++ b/firmware/application/apps/tpms_app.hpp @@ -102,9 +102,8 @@ class TPMSAppView : public View { std::string title() const override { return "TPMS RX"; }; private: - static constexpr uint32_t initial_target_frequency = 315000000; - RxRadioState radio_state_{ + 315000000 /* frequency*/, 1750000 /* bandwidth */, 2457600 /* sampling rate */}; app_settings::SettingsManager settings_{ @@ -135,7 +134,7 @@ class TPMSAppView : public View { 3, { {"315", 315000000}, - {"433", 433920000}, + {"434", 433920000}, }}; OptionsField options_pressure{ diff --git a/firmware/application/apps/ui_adsb_rx.cpp b/firmware/application/apps/ui_adsb_rx.cpp index 7fa5f9a5..3c5f1820 100644 --- a/firmware/application/apps/ui_adsb_rx.cpp +++ b/firmware/application/apps/ui_adsb_rx.cpp @@ -521,7 +521,6 @@ ADSBRxView::ADSBRxView(NavigationView& nav) { baseband::set_adsb(); - receiver_model.set_target_frequency(1'090'000'000); receiver_model.enable(); } diff --git a/firmware/application/apps/ui_adsb_rx.hpp b/firmware/application/apps/ui_adsb_rx.hpp index 57d8fa64..2cf66c4f 100644 --- a/firmware/application/apps/ui_adsb_rx.hpp +++ b/firmware/application/apps/ui_adsb_rx.hpp @@ -342,6 +342,7 @@ class ADSBRxView : public View { private: RxRadioState radio_state_{ + 1090000000 /* frequency */, 2500000 /* bandwidth */, 2000000 /* sampling rate */, ReceiverModel::Mode::SpectrumAnalysis}; diff --git a/firmware/application/apps/ui_adsb_tx.cpp b/firmware/application/apps/ui_adsb_tx.cpp index 79581bdb..4104bbf0 100644 --- a/firmware/application/apps/ui_adsb_tx.cpp +++ b/firmware/application/apps/ui_adsb_tx.cpp @@ -299,7 +299,6 @@ void ADSBTxView::start_tx() { /* Already tested , with SDR Angel + another Hackrf RX and dump1090 + SDR RLT. Final conclusion is TX LPF 6 Mhz is * the best settings to fulfill ADSB transponder spectrum mask requirements (<=-20 dB's at +-7Mhz , <=-40 dB's at +-23Mhz ) * and not showing any ADSB data decoding degradation.*/ - transmitter_model.set_baseband_bandwidth(6'000'000); // best settings for ADSB TX. transmitter_model.enable(); baseband::set_adsb(); diff --git a/firmware/application/apps/ui_adsb_tx.hpp b/firmware/application/apps/ui_adsb_tx.hpp index 507d9da1..18e72537 100644 --- a/firmware/application/apps/ui_adsb_tx.hpp +++ b/firmware/application/apps/ui_adsb_tx.hpp @@ -203,7 +203,8 @@ class ADSBTxView : public View { };*/ TxRadioState radio_state_{ - 10000000 /* bandwidth */, + 1090000000 /* frequency */, + 6000000 /* bandwidth */, 4000000 /* sampling rate */ }; app_settings::SettingsManager settings_{ diff --git a/firmware/application/apps/ui_aprs_rx.hpp b/firmware/application/apps/ui_aprs_rx.hpp index 267f959e..e7c27b4e 100644 --- a/firmware/application/apps/ui_aprs_rx.hpp +++ b/firmware/application/apps/ui_aprs_rx.hpp @@ -190,7 +190,11 @@ class APRSRxView : public View { bool reset_console = false; NavigationView& nav_; - RxRadioState radio_state_{}; + RxRadioState radio_state_{ + 144390000 /* frequency */, + 1750000 /* bandwidth */, + 3072000 /* sampling rate */ + }; app_settings::SettingsManager settings_{ "rx_aprs", app_settings::Mode::RX}; diff --git a/firmware/application/apps/ui_aprs_tx.cpp b/firmware/application/apps/ui_aprs_tx.cpp index a9f0ea4d..e5c6c79e 100644 --- a/firmware/application/apps/ui_aprs_tx.cpp +++ b/firmware/application/apps/ui_aprs_tx.cpp @@ -57,7 +57,6 @@ void APRSTXView::start_tx() { // uint8_t * bb_data_ptr = shared_memory.bb_data.data; // text_payload.set(to_string_hex_array(bb_data_ptr + 56, 15)); - transmitter_model.set_baseband_bandwidth(1'750'000); // APRS Automatic Packet Reporting System (APRS).AFSK with NBFM , max BW= 12k5 , then TX LPF min 1M75 transmitter_model.enable(); baseband::set_afsk_data( diff --git a/firmware/application/apps/ui_aprs_tx.hpp b/firmware/application/apps/ui_aprs_tx.hpp index e94a7536..9524cc50 100644 --- a/firmware/application/apps/ui_aprs_tx.hpp +++ b/firmware/application/apps/ui_aprs_tx.hpp @@ -46,6 +46,7 @@ class APRSTXView : public View { private: TxRadioState radio_state_{ + 144390000 /* frequency */, 1750000 /* bandwidth */, AFSK_TX_SAMPLERATE /* sampling rate */ }; diff --git a/firmware/application/apps/ui_btle_rx.cpp b/firmware/application/apps/ui_btle_rx.cpp index b9954dc3..1db2c225 100644 --- a/firmware/application/apps/ui_btle_rx.cpp +++ b/firmware/application/apps/ui_btle_rx.cpp @@ -54,7 +54,6 @@ BTLERxView::BTLERxView(NavigationView& nav) &console}); // Auto-configure modem for LCR RX (TODO: remove later) - field_frequency.set_value(2426000000); auto def_bell202 = &modem_defs[0]; persistent_memory::set_modem_baudrate(def_bell202->baudrate); serial_format_t serial_format; diff --git a/firmware/application/apps/ui_btle_rx.hpp b/firmware/application/apps/ui_btle_rx.hpp index 4bdb993e..f071779d 100644 --- a/firmware/application/apps/ui_btle_rx.hpp +++ b/firmware/application/apps/ui_btle_rx.hpp @@ -50,6 +50,7 @@ class BTLERxView : public View { NavigationView& nav_; RxRadioState radio_state_{ + 2426000000 /* frequency */, 4000000 /* bandwidth */, 4000000 /* sampling rate */, ReceiverModel::Mode::WidebandFMAudio}; diff --git a/firmware/application/apps/ui_coasterp.cpp b/firmware/application/apps/ui_coasterp.cpp index 78431201..9849b3d9 100644 --- a/firmware/application/apps/ui_coasterp.cpp +++ b/firmware/application/apps/ui_coasterp.cpp @@ -67,7 +67,6 @@ void CoasterPagerView::generate_frame() { void CoasterPagerView::start_tx() { generate_frame(); - transmitter_model.set_baseband_bandwidth(1'750'000); // AFSK narrowband ,low baud, max FM dev 150khz , std 10khz. TX LPF=1M75 the min. transmitter_model.enable(); baseband::set_fsk_data(19 * 8, 2280000 / 1000, 5000, 32); diff --git a/firmware/application/apps/ui_coasterp.hpp b/firmware/application/apps/ui_coasterp.hpp index e6cfcf18..9906cff9 100644 --- a/firmware/application/apps/ui_coasterp.hpp +++ b/firmware/application/apps/ui_coasterp.hpp @@ -52,6 +52,7 @@ class CoasterPagerView : public View { tx_modes tx_mode = IDLE; TxRadioState radio_state_{ + 433920000, /* frequency */ 1750000 /* bandwidth */, 2280000 /* sampling rate */ }; diff --git a/firmware/application/apps/ui_encoders.cpp b/firmware/application/apps/ui_encoders.cpp index 3e71a505..60d386a0 100644 --- a/firmware/application/apps/ui_encoders.cpp +++ b/firmware/application/apps/ui_encoders.cpp @@ -272,7 +272,6 @@ void EncodersView::start_tx(const bool scan) { /* Setting TX LPF 1M75 in this TX OOK App , We got same results as fw 1.7.4 * Looking max BW of this app, we tested , Selecting OOK type 145026 with CLK 455K and max DEV. 150k, * and we got BW +-2Mhz , with that TX LPF 1M75, it is fine.*/ - transmitter_model.set_baseband_bandwidth(1'750'000); // Min. TX LPF value. transmitter_model.enable(); baseband::set_ook_data( diff --git a/firmware/application/apps/ui_encoders.hpp b/firmware/application/apps/ui_encoders.hpp index b392e80f..021f4746 100644 --- a/firmware/application/apps/ui_encoders.hpp +++ b/firmware/application/apps/ui_encoders.hpp @@ -185,6 +185,7 @@ class EncodersView : public View { }; TxRadioState radio_state_{ + 433920000 /* frequency */, 1750000 /* bandwidth */, OOK_SAMPLERATE /* sampling rate */ }; diff --git a/firmware/application/apps/ui_jammer.hpp b/firmware/application/apps/ui_jammer.hpp index 74ebba93..41a8c85c 100644 --- a/firmware/application/apps/ui_jammer.hpp +++ b/firmware/application/apps/ui_jammer.hpp @@ -101,6 +101,7 @@ class JammerView : public View { private: NavigationView& nav_; TxRadioState radio_state_{ + 0 /* frequency */, 3500000 /* bandwidth */, 3072000 /* sampling rate */ }; diff --git a/firmware/application/apps/ui_keyfob.cpp b/firmware/application/apps/ui_keyfob.cpp index da4da14b..f907cfdf 100644 --- a/firmware/application/apps/ui_keyfob.cpp +++ b/firmware/application/apps/ui_keyfob.cpp @@ -222,8 +222,6 @@ KeyfobView::KeyfobView( options_make.set_selected_index(0); - transmitter_model.set_target_frequency(433920000); // Fixed 433.92MHz - tx_view.on_edit_frequency = [this, &nav]() { auto new_view = nav.push(transmitter_model.target_frequency()); new_view->on_changed = [this](rf::Frequency f) { diff --git a/firmware/application/apps/ui_keyfob.hpp b/firmware/application/apps/ui_keyfob.hpp index f02e7e8b..bda7c112 100644 --- a/firmware/application/apps/ui_keyfob.hpp +++ b/firmware/application/apps/ui_keyfob.hpp @@ -44,6 +44,7 @@ class KeyfobView : public View { NavigationView& nav_; TxRadioState radio_state_{ + 433920000 /* frequency */, 1750000 /* bandwidth */, OOK_SAMPLERATE /* sampling rate */ }; diff --git a/firmware/application/apps/ui_lcr.hpp b/firmware/application/apps/ui_lcr.hpp index 329f1744..06c92387 100644 --- a/firmware/application/apps/ui_lcr.hpp +++ b/firmware/application/apps/ui_lcr.hpp @@ -82,6 +82,7 @@ class LCRView : public View { }; TxRadioState radio_state_{ + 0 /* frequency */, 1750000 /* bandwidth */, AFSK_TX_SAMPLERATE /* sampling rate */ }; diff --git a/firmware/application/apps/ui_mictx.hpp b/firmware/application/apps/ui_mictx.hpp index aa4d967b..c479155e 100644 --- a/firmware/application/apps/ui_mictx.hpp +++ b/firmware/application/apps/ui_mictx.hpp @@ -82,6 +82,7 @@ class MicTXView : public View { RxRadioState rx_radio_state_{}; TxRadioState tx_radio_state_{ + 0 /* frequency */, 1750000 /* bandwidth */, sampling_rate /* sampling rate */ }; diff --git a/firmware/application/apps/ui_morse.hpp b/firmware/application/apps/ui_morse.hpp index 0a8afe26..c9fdcd98 100644 --- a/firmware/application/apps/ui_morse.hpp +++ b/firmware/application/apps/ui_morse.hpp @@ -70,6 +70,7 @@ class MorseView : public View { uint32_t time_units{0}; TxRadioState radio_state_{ + 0 /* frequency */, 1750000 /* bandwidth */, 1536000 /* sampling rate */ }; diff --git a/firmware/application/apps/ui_nrf_rx.cpp b/firmware/application/apps/ui_nrf_rx.cpp index eeba3e20..179d8ac2 100644 --- a/firmware/application/apps/ui_nrf_rx.cpp +++ b/firmware/application/apps/ui_nrf_rx.cpp @@ -54,7 +54,6 @@ NRFRxView::NRFRxView(NavigationView& nav) &console}); // Auto-configure modem for LCR RX (will be removed later) - field_frequency.set_value(2480000000); auto def_bell202 = &modem_defs[0]; persistent_memory::set_modem_baudrate(def_bell202->baudrate); serial_format_t serial_format; diff --git a/firmware/application/apps/ui_nrf_rx.hpp b/firmware/application/apps/ui_nrf_rx.hpp index a265d240..efb46cb5 100644 --- a/firmware/application/apps/ui_nrf_rx.hpp +++ b/firmware/application/apps/ui_nrf_rx.hpp @@ -50,6 +50,7 @@ class NRFRxView : public View { NavigationView& nav_; RxRadioState radio_state_{ + 2480000000 /* frequency */, 4000000 /* bandwidth */, 4000000 /* sampling rate */, ReceiverModel::Mode::WidebandFMAudio}; diff --git a/firmware/application/apps/ui_numbers.hpp b/firmware/application/apps/ui_numbers.hpp index 40afedf0..4615d8b7 100644 --- a/firmware/application/apps/ui_numbers.hpp +++ b/firmware/application/apps/ui_numbers.hpp @@ -56,6 +56,7 @@ class NumbersStationView : public View { NavigationView& nav_; TxRadioState radio_state_{ + 0 /* frequency */, 1750000 /* bandwidth */, 1536000 /* sampling rate */ }; diff --git a/firmware/application/apps/ui_nuoptix.hpp b/firmware/application/apps/ui_nuoptix.hpp index c9af6330..bc7564ca 100644 --- a/firmware/application/apps/ui_nuoptix.hpp +++ b/firmware/application/apps/ui_nuoptix.hpp @@ -56,6 +56,7 @@ class NuoptixView : public View { }; TxRadioState radio_state_{ + 0 /* frequency */, 1750000 /* bandwidth */, 1536000 /* sampling rate */ }; diff --git a/firmware/application/apps/ui_pocsag_tx.hpp b/firmware/application/apps/ui_pocsag_tx.hpp index 649e233f..29f7201c 100644 --- a/firmware/application/apps/ui_pocsag_tx.hpp +++ b/firmware/application/apps/ui_pocsag_tx.hpp @@ -60,6 +60,7 @@ class POCSAGTXView : public View { NavigationView& nav_; TxRadioState radio_state_{ + 0 /* frequency */, 1750000 /* bandwidth */, 2280000 /* sampling rate */ }; diff --git a/firmware/application/apps/ui_rds.cpp b/firmware/application/apps/ui_rds.cpp index 387d5b0e..a17e7a59 100644 --- a/firmware/application/apps/ui_rds.cpp +++ b/firmware/application/apps/ui_rds.cpp @@ -187,7 +187,6 @@ void RDSView::start_tx() { else frame_datetime.clear(); - transmitter_model.set_baseband_bandwidth(1'750'000); // Big Spectrum harmonics reduction, and now quicker decoding time. transmitter_model.enable(); tx_thread = std::make_unique(frames); diff --git a/firmware/application/apps/ui_rds.hpp b/firmware/application/apps/ui_rds.hpp index 87f52926..017d5611 100644 --- a/firmware/application/apps/ui_rds.hpp +++ b/firmware/application/apps/ui_rds.hpp @@ -142,6 +142,7 @@ class RDSView : public View { RDS_flags rds_flags{}; TxRadioState radio_state_{ + 0 /* frequency */, 1750000 /* bandwidth */, 2280000 /* sampling rate */ }; diff --git a/firmware/application/apps/ui_search.hpp b/firmware/application/apps/ui_search.hpp index f4551632..9342422b 100644 --- a/firmware/application/apps/ui_search.hpp +++ b/firmware/application/apps/ui_search.hpp @@ -90,6 +90,7 @@ class SearchView : public View { private: NavigationView& nav_; RxRadioState radio_state_{ + 100'000'000 /* frequency */, 2500000 /* bandwidth */, SEARCH_SLICE_WIDTH /* sampling rate */, ReceiverModel::Mode::SpectrumAnalysis}; diff --git a/firmware/application/apps/ui_settings.cpp b/firmware/application/apps/ui_settings.cpp index 361e8bbb..6facf199 100644 --- a/firmware/application/apps/ui_settings.cpp +++ b/firmware/application/apps/ui_settings.cpp @@ -343,34 +343,6 @@ void SetUIView::focus() { button_save.focus(); } -/* SetAppSettingsView ************************************/ - -SetAppSettingsView::SetAppSettingsView(NavigationView& nav) { - add_children({ - &labels, - &checkbox_load_app_settings, - &checkbox_save_app_settings, - &button_save, - &button_cancel, - }); - - checkbox_load_app_settings.set_value(pmem::load_app_settings()); - checkbox_save_app_settings.set_value(pmem::save_app_settings()); - - button_save.on_select = [&nav, this](Button&) { - pmem::set_load_app_settings(checkbox_load_app_settings.value()); - pmem::set_save_app_settings(checkbox_save_app_settings.value()); - nav.pop(); - }; - button_cancel.on_select = [&nav, this](Button&) { - nav.pop(); - }; -} - -void SetAppSettingsView::focus() { - button_save.focus(); -} - /* SetConverterSettingsView ******************************/ SetConverterSettingsView::SetConverterSettingsView(NavigationView& nav) { @@ -654,7 +626,6 @@ SettingsMenuView::SettingsMenuView(NavigationView& nav) { add_items({{"..", ui::Color::light_grey(), &bitmap_icon_previous, [&nav]() { nav.pop(); }}}); } add_items({ - {"App Settings", ui::Color::dark_cyan(), &bitmap_icon_setup, [&nav]() { nav.push(); }}, {"Audio", ui::Color::dark_cyan(), &bitmap_icon_speaker, [&nav]() { nav.push(); }}, {"Calibration", ui::Color::dark_cyan(), &bitmap_icon_options_touch, [&nav]() { nav.push(); }}, {"Converter", ui::Color::dark_cyan(), &bitmap_icon_options_radio, [&nav]() { nav.push(); }}, diff --git a/firmware/application/apps/ui_settings.hpp b/firmware/application/apps/ui_settings.hpp index 61c69375..899ec877 100644 --- a/firmware/application/apps/ui_settings.hpp +++ b/firmware/application/apps/ui_settings.hpp @@ -310,41 +310,6 @@ class SetUIView : public View { }; }; -class SetAppSettingsView : public View { - public: - SetAppSettingsView(NavigationView& nav); - - void focus() override; - std::string title() const override { return "App Settings"; }; - - private: - Labels labels{ - {{1 * 8, 1 * 16}, "App settings are saved to", Color::light_grey()}, - {{1 * 8, 2 * 16}, "the SD card in /SETTINGS.", Color::light_grey()}, - {{1 * 8, 3 * 16}, "Radio settings may also be", Color::light_grey()}, - {{1 * 8, 4 * 16}, "loaded or saved per app.", Color::light_grey()}, - }; - - Checkbox checkbox_load_app_settings{ - {3 * 8, 6 * 16}, - 25, - "Load radio settings"}; - - Checkbox checkbox_save_app_settings{ - {3 * 8, 8 * 16}, - 25, - "Save radio settings"}; - - Button button_save{ - {2 * 8, 16 * 16, 12 * 8, 32}, - "Save"}; - - Button button_cancel{ - {16 * 8, 16 * 16, 12 * 8, 32}, - "Cancel", - }; -}; - class SetConverterSettingsView : public View { public: SetConverterSettingsView(NavigationView& nav); diff --git a/firmware/application/apps/ui_siggen.hpp b/firmware/application/apps/ui_siggen.hpp index f9e2f44f..6d6d6b99 100644 --- a/firmware/application/apps/ui_siggen.hpp +++ b/firmware/application/apps/ui_siggen.hpp @@ -51,6 +51,7 @@ class SigGenView : public View { void on_tx_progress(const uint32_t progress, const bool done); TxRadioState radio_state_{ + 0 /* frequency */, 1750000 /* bandwidth */, 1536000 /* sampling rate */ }; diff --git a/firmware/application/apps/ui_sonde.cpp b/firmware/application/apps/ui_sonde.cpp index ddb2d99d..b6e975c7 100644 --- a/firmware/application/apps/ui_sonde.cpp +++ b/firmware/application/apps/ui_sonde.cpp @@ -66,9 +66,6 @@ SondeView::SondeView(NavigationView& nav) &button_see_qr, &button_see_map}); - if (!settings_.radio_loaded()) - field_frequency.set_value(initial_target_frequency); - field_frequency.set_step(500); // euquiq: was 10000, but we are using this for fine-tunning geopos.set_read_only(true); diff --git a/firmware/application/apps/ui_sonde.hpp b/firmware/application/apps/ui_sonde.hpp index 4053067e..d3992fd4 100644 --- a/firmware/application/apps/ui_sonde.hpp +++ b/firmware/application/apps/ui_sonde.hpp @@ -68,6 +68,7 @@ class SondeView : public View { private: NavigationView& nav_; RxRadioState radio_state_{ + 402700000 /* frequency */, 1750000 /* bandwidth */, 2457600 /* sampling rate */ }; @@ -75,7 +76,6 @@ class SondeView : public View { "rx_sonde", app_settings::Mode::RX}; std::unique_ptr logger{}; - uint32_t target_frequency_{402700000}; bool logging{false}; bool use_crc{false}; bool beep{false}; diff --git a/firmware/application/apps/ui_test.hpp b/firmware/application/apps/ui_test.hpp index ec439f18..9bf69506 100644 --- a/firmware/application/apps/ui_test.hpp +++ b/firmware/application/apps/ui_test.hpp @@ -62,6 +62,7 @@ class TestView : public View { private: NavigationView& nav_; RxRadioState radio_state_{ + 0 /* frequency */, 1750000 /* bandwidth */, 2457600 * 2 /* sampling rate */ }; diff --git a/firmware/application/apps/ui_touchtunes.cpp b/firmware/application/apps/ui_touchtunes.cpp index 16cf8ebe..bdab1df1 100644 --- a/firmware/application/apps/ui_touchtunes.cpp +++ b/firmware/application/apps/ui_touchtunes.cpp @@ -85,7 +85,6 @@ void TouchTunesView::on_tx_progress(const uint32_t progress, const bool done) { // transmission events. void TouchTunesView::start_ew() { // Radio - transmitter_model.set_target_frequency(433920000); transmitter_model.set_rf_amp(true); transmitter_model.set_tx_gain(47); transmitter_model.enable(); @@ -151,10 +150,7 @@ void TouchTunesView::start_tx(const uint32_t button_index) { size_t bitstream_length = make_bitstream(fragments); - transmitter_model.set_target_frequency(433920000); - transmitter_model.set_sampling_rate(OOK_SAMPLERATE); transmitter_model.set_rf_amp(true); - transmitter_model.set_baseband_bandwidth(1750000); transmitter_model.enable(); baseband::set_ook_data( diff --git a/firmware/application/apps/ui_touchtunes.hpp b/firmware/application/apps/ui_touchtunes.hpp index c8fc5795..49a3537f 100644 --- a/firmware/application/apps/ui_touchtunes.hpp +++ b/firmware/application/apps/ui_touchtunes.hpp @@ -25,6 +25,7 @@ #include "ui_transmitter.hpp" #include "transmitter_model.hpp" #include "radio_state.hpp" +#include "encoders.hpp" // The coding in notpike's script is quite complex, using multiple LUTs to form the data sent to the YSO. // The format is actually very simple if it is rather seen as short and long gaps between pulses (as seen in many OOK remotes). @@ -115,8 +116,9 @@ class TouchTunesView : public View { private: TxRadioState radio_state_{ - 3500000 /* bandwidth */, - 3072000 /* sampling rate */ + 433920000 /* frequency */, + 1750000 /* bandwidth */, + OOK_SAMPLERATE /* sampling rate */ }; uint32_t scan_button_index{}; diff --git a/firmware/application/radio_state.hpp b/firmware/application/radio_state.hpp index 7145a1c5..923ca0e5 100644 --- a/firmware/application/radio_state.hpp +++ b/firmware/application/radio_state.hpp @@ -41,8 +41,10 @@ class RadioState { model->initialize(); } - RadioState(uint32_t new_bandwidth, uint32_t new_sampling_rate) { + RadioState(uint32_t new_frequency, uint32_t new_bandwidth, uint32_t new_sampling_rate) { model->initialize(); + if (new_frequency != 0) + model->set_target_frequency(new_frequency); model->set_sampling_rate(new_sampling_rate); model->set_baseband_bandwidth(new_bandwidth); } @@ -61,10 +63,13 @@ class RadioState { typename U = TModel, typename Mode = std::enable_if_t > RadioState( + uint32_t new_frequency, uint32_t new_bandwidth, uint32_t new_sampling_rate, Mode new_mode) { model->initialize(); + if (new_frequency != 0) + model->set_target_frequency(new_frequency); model->set_sampling_rate(new_sampling_rate); model->set_baseband_bandwidth(new_bandwidth); model->settings().mode = new_mode; diff --git a/firmware/common/portapack_persistent_memory.cpp b/firmware/common/portapack_persistent_memory.cpp index 98e1e83a..9271d336 100644 --- a/firmware/common/portapack_persistent_memory.cpp +++ b/firmware/common/portapack_persistent_memory.cpp @@ -524,14 +524,6 @@ bool show_gui_return_icon() { // add return icon in touchscreen menu return data->ui_config.show_gui_return_icon != 0; } -bool load_app_settings() { // load (last saved) app settings on startup of app - return data->ui_config.load_app_settings != 0; -} - -bool save_app_settings() { // save app settings when closing app - return data->ui_config.save_app_settings != 0; -} - bool show_bigger_qr_code() { // show bigger QR code return data->ui_config.show_large_qr_code != 0; } diff --git a/firmware/common/portapack_persistent_memory.hpp b/firmware/common/portapack_persistent_memory.hpp index c430533f..33030847 100644 --- a/firmware/common/portapack_persistent_memory.hpp +++ b/firmware/common/portapack_persistent_memory.hpp @@ -179,8 +179,6 @@ bool config_converter(); bool config_updown_converter(); int64_t config_converter_freq(); bool show_gui_return_icon(); -bool load_app_settings(); -bool save_app_settings(); bool show_bigger_qr_code(); bool hide_clock(); bool clock_with_date();