Merge pull request #789 from formtapez/settings

Save and recall all receiver settings of the Audio RX app
This commit is contained in:
gullradriel 2023-01-21 13:04:52 +01:00 committed by GitHub
commit e02e58b366
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 11 deletions

View File

@ -51,6 +51,13 @@ int app_settings::load(std::string application, AppSettings* settings) {
settings->tx_amp=std::app_settings::read_long_long(file_content, "tx_amp="); settings->tx_amp=std::app_settings::read_long_long(file_content, "tx_amp=");
settings->tx_frequency=std::app_settings::read_long_long(file_content, "tx_frequency="); settings->tx_frequency=std::app_settings::read_long_long(file_content, "tx_frequency=");
settings->tx_gain=std::app_settings::read_long_long(file_content, "tx_gain="); settings->tx_gain=std::app_settings::read_long_long(file_content, "tx_gain=");
settings->step=std::app_settings::read_long_long(file_content, "step=");
settings->modulation=std::app_settings::read_long_long(file_content, "modulation=");
settings->am_config_index=std::app_settings::read_long_long(file_content, "am_config_index=");
settings->nbfm_config_index=std::app_settings::read_long_long(file_content, "nbfm_config_index=");
settings->wfm_config_index=std::app_settings::read_long_long(file_content, "wfm_config_index=");
settings->squelch=std::app_settings::read_long_long(file_content, "squelch=");
rc = SETTINGS_OK; rc = SETTINGS_OK;
} }
else rc = SETTINGS_UNABLE_TO_LOAD; else rc = SETTINGS_UNABLE_TO_LOAD;
@ -79,6 +86,12 @@ int app_settings::save(std::string application, AppSettings* settings) {
// Save other settings from struct // Save other settings from struct
settings_file.write_line("rx_frequency="+to_string_dec_uint(settings->rx_frequency)); settings_file.write_line("rx_frequency="+to_string_dec_uint(settings->rx_frequency));
settings_file.write_line("tx_frequency="+to_string_dec_uint(settings->tx_frequency)); settings_file.write_line("tx_frequency="+to_string_dec_uint(settings->tx_frequency));
settings_file.write_line("step="+to_string_dec_uint(settings->step));
settings_file.write_line("modulation="+to_string_dec_uint(settings->modulation));
settings_file.write_line("am_config_index="+to_string_dec_uint(settings->am_config_index));
settings_file.write_line("nbfm_config_index="+to_string_dec_uint(settings->nbfm_config_index));
settings_file.write_line("wfm_config_index="+to_string_dec_uint(settings->wfm_config_index));
settings_file.write_line("squelch="+to_string_dec_uint(settings->squelch));
rc = SETTINGS_OK; rc = SETTINGS_OK;
} }

View File

@ -59,6 +59,11 @@ public:
uint32_t tx_frequency; uint32_t tx_frequency;
uint8_t tx_gain; uint8_t tx_gain;
uint8_t vga; uint8_t vga;
uint32_t step;
uint8_t am_config_index;
uint8_t nbfm_config_index;
uint8_t wfm_config_index;
uint8_t squelch;
}; };
int load(std::string application, AppSettings* settings); int load(std::string application, AppSettings* settings);

View File

@ -136,6 +136,7 @@ AnalogAudioView::AnalogAudioView(
field_vga.set_value(app_settings.vga); field_vga.set_value(app_settings.vga);
receiver_model.set_rf_amp(app_settings.rx_amp); receiver_model.set_rf_amp(app_settings.rx_amp);
field_frequency.set_value(app_settings.rx_frequency); field_frequency.set_value(app_settings.rx_frequency);
receiver_model.set_configuration_without_init(static_cast<ReceiverModel::Mode>(app_settings.modulation), app_settings.step, app_settings.am_config_index, app_settings.nbfm_config_index, app_settings.wfm_config_index, app_settings.squelch);
} }
else field_frequency.set_value(receiver_model.tuning_frequency()); else field_frequency.set_value(receiver_model.tuning_frequency());
@ -223,6 +224,15 @@ AnalogAudioView::~AnalogAudioView() {
// save app settings // save app settings
app_settings.rx_frequency = field_frequency.value(); app_settings.rx_frequency = field_frequency.value();
app_settings.lna = receiver_model.lna();
app_settings.vga = receiver_model.vga();
app_settings.rx_amp = receiver_model.rf_amp();
app_settings.step = receiver_model.frequency_step();
app_settings.modulation = (uint8_t)receiver_model.modulation();
app_settings.am_config_index = receiver_model.am_configuration();
app_settings.nbfm_config_index = receiver_model.nbfm_configuration();
app_settings.wfm_config_index = receiver_model.wfm_configuration();
app_settings.squelch = receiver_model.squelch_level();
settings.save("rx_audio", &app_settings); settings.save("rx_audio", &app_settings);
// TODO: Manipulating audio codec here, and in ui_receiver.cpp. Good to do // TODO: Manipulating audio codec here, and in ui_receiver.cpp. Good to do

View File

@ -313,3 +313,12 @@ size_t ReceiverModel::wfm_configuration() const {
void ReceiverModel::update_wfm_configuration() { void ReceiverModel::update_wfm_configuration() {
wfm_configs[wfm_config_index].apply(); wfm_configs[wfm_config_index].apply();
} }
void ReceiverModel::set_configuration_without_init(const Mode new_mode, const rf::Frequency new_frequency_step, const size_t new_am_config_index, const size_t new_nbfm_config_index, const size_t new_wfm_config_index, uint8_t new_squelch_level) {
mode_ = new_mode;
frequency_step_ = new_frequency_step;
am_config_index = new_am_config_index;
nbfm_config_index = new_nbfm_config_index;
wfm_config_index = new_wfm_config_index;
squelch_level_ = new_squelch_level;
}

View File

@ -87,6 +87,8 @@ public:
size_t wfm_configuration() const; size_t wfm_configuration() const;
void set_wfm_configuration(const size_t n); void set_wfm_configuration(const size_t n);
void set_configuration_without_init(const Mode new_mode, const rf::Frequency new_frequency_step, const size_t new_am_config_index, const size_t new_nbfm_config_index, const size_t new_wfm_config_index, uint8_t new_squelch_level);
private: private:
rf::Frequency frequency_step_ { 25000 }; rf::Frequency frequency_step_ { 25000 };
bool enabled_ { false }; bool enabled_ { false };