mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-07-01 01:57:11 -04:00
Save most common settings for TX apps. And translated some French apps along the way.
This commit is contained in:
parent
c9db1aab30
commit
cccc92cc34
30 changed files with 309 additions and 96 deletions
|
@ -27,56 +27,30 @@
|
|||
#include "portapack.hpp"
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
|
||||
namespace std {
|
||||
|
||||
int app_settings::load(std::string application, AppSettings* settings){
|
||||
int app_settings::load(std::string application, AppSettings* settings) {
|
||||
|
||||
if (portapack::persistent_memory::load_app_settings()) {
|
||||
file_path = folder+"/"+application+".ini";
|
||||
|
||||
auto error = settings_file.open(file_path);
|
||||
if (!error.is_valid()) {
|
||||
auto error = settings_file.read(file_content, 256);
|
||||
|
||||
// Retrieve settings
|
||||
auto position1 = strstr(file_content, "baseband_bandwidth=");
|
||||
if (position1) {
|
||||
position1 += 19;
|
||||
settings->baseband_bandwidth=strtoll(position1, nullptr, 10);
|
||||
}
|
||||
|
||||
auto position2 = strstr(file_content, "rx_frequency=");
|
||||
if (position2) {
|
||||
position2 += 13;
|
||||
settings->rx_frequency=strtoll(position2, nullptr, 10);
|
||||
}
|
||||
|
||||
auto position3 = strstr(file_content, "lna=");
|
||||
if (position3) {
|
||||
position3 += 4;
|
||||
settings->lna=strtoll(position3, nullptr, 10);
|
||||
}
|
||||
|
||||
auto position4 = strstr(file_content, "rx_amp=");
|
||||
if (position4) {
|
||||
position4 += 7;
|
||||
settings->rx_amp=strtoll(position4, nullptr, 10);
|
||||
}
|
||||
|
||||
auto position5 = strstr(file_content, "sampling_rate=");
|
||||
if (position5) {
|
||||
position5 += 13;
|
||||
settings->sampling_rate=strtoll(position5, nullptr, 10);
|
||||
}
|
||||
|
||||
|
||||
auto position6 = strstr(file_content, "vga=");
|
||||
if (position6) {
|
||||
position6 += 4;
|
||||
settings->vga=strtoll(position6, nullptr, 10);
|
||||
}
|
||||
auto error = settings_file.read(file_content, std::min((int)settings_file.size(), MAX_FILE_CONTENT_SIZE));
|
||||
|
||||
settings->baseband_bandwidth=std::app_settings::read_long_long(file_content, "baseband_bandwidth=");
|
||||
settings->channel_bandwidth=std::app_settings::read_long_long(file_content, "channel_bandwidth=");
|
||||
settings->lna=std::app_settings::read_long_long(file_content, "lna=");
|
||||
settings->modulation=std::app_settings::read_long_long(file_content, "modulation=");
|
||||
settings->rx_amp=std::app_settings::read_long_long(file_content, "rx_amp=");
|
||||
settings->rx_frequency=std::app_settings::read_long_long(file_content, "rx_frequency=");
|
||||
settings->sampling_rate=std::app_settings::read_long_long(file_content, "sampling_rate=");
|
||||
settings->vga=std::app_settings::read_long_long(file_content, "vga=");
|
||||
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_gain=std::app_settings::read_long_long(file_content, "tx_gain=");
|
||||
rc = SETTINGS_OK;
|
||||
}
|
||||
else rc = SETTINGS_UNABLE_TO_LOAD;
|
||||
|
@ -85,7 +59,7 @@ int app_settings::load(std::string application, AppSettings* settings){
|
|||
return(rc);
|
||||
}
|
||||
|
||||
int app_settings::save(std::string application, AppSettings* settings){
|
||||
int app_settings::save(std::string application, AppSettings* settings) {
|
||||
|
||||
if (portapack::persistent_memory::save_app_settings()) {
|
||||
file_path = folder+"/"+application+".ini";
|
||||
|
@ -95,12 +69,16 @@ int app_settings::save(std::string application, AppSettings* settings){
|
|||
if (!error.is_valid()) {
|
||||
// Save common setting
|
||||
settings_file.write_line("baseband_bandwidth="+to_string_dec_uint(portapack::receiver_model.baseband_bandwidth()));
|
||||
settings_file.write_line("channel_bandwidth="+to_string_dec_uint(portapack::transmitter_model.channel_bandwidth()));
|
||||
settings_file.write_line("lna="+to_string_dec_uint(portapack::receiver_model.lna()));
|
||||
settings_file.write_line("rx_amp="+to_string_dec_uint(portapack::receiver_model.rf_amp()));
|
||||
settings_file.write_line("sampling_rate="+to_string_dec_uint(portapack::receiver_model.sampling_rate()));
|
||||
settings_file.write_line("tx_amp="+to_string_dec_uint(portapack::transmitter_model.rf_amp()));
|
||||
settings_file.write_line("tx_gain="+to_string_dec_uint(portapack::transmitter_model.tx_gain()));
|
||||
settings_file.write_line("vga="+to_string_dec_uint(portapack::receiver_model.vga()));
|
||||
// Save other settings from struct
|
||||
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));
|
||||
|
||||
rc = SETTINGS_OK;
|
||||
}
|
||||
|
@ -110,4 +88,15 @@ int app_settings::save(std::string application, AppSettings* settings){
|
|||
return(rc);
|
||||
}
|
||||
|
||||
|
||||
long long int app_settings::read_long_long(char* file_content, const char* setting_text) {
|
||||
auto position = strstr(file_content, (char *)setting_text);
|
||||
if (position) {
|
||||
position += strlen((char *)setting_text);
|
||||
setting_value = strtoll(position, nullptr, 10);
|
||||
}
|
||||
return(setting_value);
|
||||
}
|
||||
|
||||
|
||||
} /* namespace std */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue