mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-18 04:04:33 -05:00
save/recall all receiver settings
This commit is contained in:
parent
a8885282cd
commit
a20a08c630
@ -52,6 +52,12 @@ int app_settings::load(std::string application, AppSettings* settings) {
|
|||||||
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->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;
|
||||||
@ -81,6 +87,11 @@ int app_settings::save(std::string application, AppSettings* settings) {
|
|||||||
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("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;
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,10 @@ public:
|
|||||||
uint8_t tx_gain;
|
uint8_t tx_gain;
|
||||||
uint8_t vga;
|
uint8_t vga;
|
||||||
uint32_t step;
|
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);
|
||||||
|
@ -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
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
@ -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 };
|
||||||
|
Loading…
Reference in New Issue
Block a user