mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-04-22 14:21:49 +00:00
indentation & added load & save persistent settings to sdcard
This commit is contained in:
parent
835bc49999
commit
17250304e0
@ -34,48 +34,54 @@
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include "file.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace portapack {
|
||||
namespace persistent_memory {
|
||||
namespace persistent_memory {
|
||||
|
||||
constexpr rf::Frequency tuned_frequency_reset_value { 100000000 };
|
||||
constexpr rf::Frequency tuned_frequency_reset_value { 100000000 };
|
||||
|
||||
using ppb_range_t = range_t<ppb_t>;
|
||||
constexpr ppb_range_t ppb_range { -99000, 99000 };
|
||||
constexpr ppb_t ppb_reset_value { 0 };
|
||||
using ppb_range_t = range_t<ppb_t>;
|
||||
constexpr ppb_range_t ppb_range { -99000, 99000 };
|
||||
constexpr ppb_t ppb_reset_value { 0 };
|
||||
|
||||
using tone_mix_range_t = range_t<int32_t>;
|
||||
constexpr tone_mix_range_t tone_mix_range { 10, 99 };
|
||||
constexpr int32_t tone_mix_reset_value { 20 };
|
||||
using tone_mix_range_t = range_t<int32_t>;
|
||||
constexpr tone_mix_range_t tone_mix_range { 10, 99 };
|
||||
constexpr int32_t tone_mix_reset_value { 20 };
|
||||
|
||||
using afsk_freq_range_t = range_t<int32_t>;
|
||||
constexpr afsk_freq_range_t afsk_freq_range { 1, 4000 };
|
||||
constexpr int32_t afsk_mark_reset_value { 1200 };
|
||||
constexpr int32_t afsk_space_reset_value { 2200 };
|
||||
using afsk_freq_range_t = range_t<int32_t>;
|
||||
constexpr afsk_freq_range_t afsk_freq_range { 1, 4000 };
|
||||
constexpr int32_t afsk_mark_reset_value { 1200 };
|
||||
constexpr int32_t afsk_space_reset_value { 2200 };
|
||||
|
||||
using modem_baudrate_range_t = range_t<int32_t>;
|
||||
constexpr modem_baudrate_range_t modem_baudrate_range { 50, 9600 };
|
||||
constexpr int32_t modem_baudrate_reset_value { 1200 };
|
||||
using modem_baudrate_range_t = range_t<int32_t>;
|
||||
constexpr modem_baudrate_range_t modem_baudrate_range { 50, 9600 };
|
||||
constexpr int32_t modem_baudrate_reset_value { 1200 };
|
||||
|
||||
/*using modem_bw_range_t = range_t<int32_t>;
|
||||
constexpr modem_bw_range_t modem_bw_range { 1000, 50000 };
|
||||
constexpr int32_t modem_bw_reset_value { 15000 };*/
|
||||
/*using modem_bw_range_t = range_t<int32_t>;
|
||||
constexpr modem_bw_range_t modem_bw_range { 1000, 50000 };
|
||||
constexpr int32_t modem_bw_reset_value { 15000 };*/
|
||||
|
||||
using modem_repeat_range_t = range_t<int32_t>;
|
||||
constexpr modem_repeat_range_t modem_repeat_range { 1, 99 };
|
||||
constexpr int32_t modem_repeat_reset_value { 5 };
|
||||
using modem_repeat_range_t = range_t<int32_t>;
|
||||
constexpr modem_repeat_range_t modem_repeat_range { 1, 99 };
|
||||
constexpr int32_t modem_repeat_reset_value { 5 };
|
||||
|
||||
using clkout_freq_range_t = range_t<uint32_t>;
|
||||
constexpr clkout_freq_range_t clkout_freq_range { 10, 60000 };
|
||||
constexpr uint32_t clkout_freq_reset_value { 10000 };
|
||||
using clkout_freq_range_t = range_t<uint32_t>;
|
||||
constexpr clkout_freq_range_t clkout_freq_range { 10, 60000 };
|
||||
constexpr uint32_t clkout_freq_reset_value { 10000 };
|
||||
|
||||
enum data_structure_version_enum : uint32_t {
|
||||
enum data_structure_version_enum : uint32_t {
|
||||
VERSION_CURRENT = 0x10000002,
|
||||
};
|
||||
};
|
||||
|
||||
static const uint32_t TOUCH_CALIBRATION_MAGIC = 0x074af82f;
|
||||
static const uint32_t TOUCH_CALIBRATION_MAGIC = 0x074af82f;
|
||||
|
||||
struct ui_config_t {
|
||||
private:
|
||||
struct ui_config_t {
|
||||
private:
|
||||
enum bits_t {
|
||||
BacklightTimeoutLSB = 0,
|
||||
BacklightTimeoutEnable = 3,
|
||||
@ -111,7 +117,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
backlight_config_t config_backlight_timer() {
|
||||
const auto timeout_enum = (backlight_timeout_t)((values & bits_mask_t::BacklightTimeoutMask) >> bits_t::BacklightTimeoutLSB);
|
||||
const bool timeout_enabled = bit_read(bits_t::BacklightTimeoutEnable);
|
||||
@ -250,10 +256,10 @@ public:
|
||||
)
|
||||
{
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/* struct must pack the same way on M4 and M0 cores. */
|
||||
struct data_t {
|
||||
/* struct must pack the same way on M4 and M0 cores. */
|
||||
struct data_t {
|
||||
data_structure_version_enum structure_version;
|
||||
int64_t tuned_frequency;
|
||||
int32_t correction_ppb;
|
||||
@ -331,10 +337,10 @@ struct data_t {
|
||||
converter_frequency_offset(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
struct backup_ram_t {
|
||||
private:
|
||||
struct backup_ram_t {
|
||||
private:
|
||||
uint32_t regfile[63];
|
||||
uint32_t check_value;
|
||||
|
||||
@ -369,7 +375,7 @@ private:
|
||||
return crc.checksum();
|
||||
}
|
||||
|
||||
public:
|
||||
public:
|
||||
/* default constructor */
|
||||
backup_ram_t() :
|
||||
check_value(0)
|
||||
@ -398,19 +404,19 @@ public:
|
||||
check_value = compute_check_value();
|
||||
copy(*this, dst);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
static_assert(sizeof(backup_ram_t) == memory::map::backup_ram.size());
|
||||
static_assert(sizeof(data_t) <= sizeof(backup_ram_t) - sizeof(uint32_t));
|
||||
static_assert(sizeof(backup_ram_t) == memory::map::backup_ram.size());
|
||||
static_assert(sizeof(data_t) <= sizeof(backup_ram_t) - sizeof(uint32_t));
|
||||
|
||||
static backup_ram_t* const backup_ram = reinterpret_cast<backup_ram_t*>(memory::map::backup_ram.base());
|
||||
static backup_ram_t* const backup_ram = reinterpret_cast<backup_ram_t*>(memory::map::backup_ram.base());
|
||||
|
||||
static backup_ram_t cached_backup_ram;
|
||||
static data_t* const data = reinterpret_cast<data_t*>(&cached_backup_ram);
|
||||
static backup_ram_t cached_backup_ram;
|
||||
static data_t* data = reinterpret_cast<data_t*>(&cached_backup_ram);
|
||||
|
||||
namespace cache {
|
||||
namespace cache {
|
||||
|
||||
void defaults() {
|
||||
void defaults() {
|
||||
cached_backup_ram = backup_ram_t();
|
||||
|
||||
// defaults values for recon app
|
||||
@ -423,9 +429,10 @@ void defaults() {
|
||||
set_recon_update_ranges_when_recon( true );
|
||||
set_recon_load_hamradios( true );
|
||||
set_recon_match_mode( 0 );
|
||||
}
|
||||
|
||||
void init() {
|
||||
}
|
||||
|
||||
void init() {
|
||||
if(backup_ram->is_valid()) {
|
||||
// Copy valid persistent data into cache.
|
||||
cached_backup_ram = *backup_ram;
|
||||
@ -441,338 +448,365 @@ void init() {
|
||||
// Copy defaults into cache.
|
||||
defaults();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void persist() {
|
||||
void persist() {
|
||||
cached_backup_ram.persist_to(*backup_ram);
|
||||
}
|
||||
}
|
||||
|
||||
} /* namespace cache */
|
||||
} /* namespace cache */
|
||||
|
||||
rf::Frequency tuned_frequency() {
|
||||
rf::Frequency tuned_frequency() {
|
||||
rf::tuning_range.reset_if_outside(data->tuned_frequency, tuned_frequency_reset_value);
|
||||
return data->tuned_frequency;
|
||||
}
|
||||
}
|
||||
|
||||
void set_tuned_frequency(const rf::Frequency new_value) {
|
||||
void set_tuned_frequency(const rf::Frequency new_value) {
|
||||
data->tuned_frequency = rf::tuning_range.clip(new_value);
|
||||
}
|
||||
}
|
||||
|
||||
ppb_t correction_ppb() {
|
||||
ppb_t correction_ppb() {
|
||||
ppb_range.reset_if_outside(data->correction_ppb, ppb_reset_value);
|
||||
return data->correction_ppb;
|
||||
}
|
||||
}
|
||||
|
||||
void set_correction_ppb(const ppb_t new_value) {
|
||||
void set_correction_ppb(const ppb_t new_value) {
|
||||
const auto clipped_value = ppb_range.clip(new_value);
|
||||
data->correction_ppb = clipped_value;
|
||||
portapack::clock_manager.set_reference_ppb(clipped_value);
|
||||
}
|
||||
}
|
||||
|
||||
void set_touch_calibration(const touch::Calibration& new_value) {
|
||||
void set_touch_calibration(const touch::Calibration& new_value) {
|
||||
data->touch_calibration = new_value;
|
||||
data->touch_calibration_magic = TOUCH_CALIBRATION_MAGIC;
|
||||
}
|
||||
}
|
||||
|
||||
const touch::Calibration& touch_calibration() {
|
||||
const touch::Calibration& touch_calibration() {
|
||||
if( data->touch_calibration_magic != TOUCH_CALIBRATION_MAGIC ) {
|
||||
set_touch_calibration(touch::Calibration());
|
||||
}
|
||||
return data->touch_calibration;
|
||||
}
|
||||
}
|
||||
|
||||
int32_t tone_mix() {
|
||||
int32_t tone_mix() {
|
||||
tone_mix_range.reset_if_outside(data->tone_mix, tone_mix_reset_value);
|
||||
return data->tone_mix;
|
||||
}
|
||||
}
|
||||
|
||||
void set_tone_mix(const int32_t new_value) {
|
||||
void set_tone_mix(const int32_t new_value) {
|
||||
data->tone_mix = tone_mix_range.clip(new_value);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t afsk_mark_freq() {
|
||||
int32_t afsk_mark_freq() {
|
||||
afsk_freq_range.reset_if_outside(data->afsk_mark_freq, afsk_mark_reset_value);
|
||||
return data->afsk_mark_freq;
|
||||
}
|
||||
}
|
||||
|
||||
void set_afsk_mark(const int32_t new_value) {
|
||||
void set_afsk_mark(const int32_t new_value) {
|
||||
data->afsk_mark_freq = afsk_freq_range.clip(new_value);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t afsk_space_freq() {
|
||||
int32_t afsk_space_freq() {
|
||||
afsk_freq_range.reset_if_outside(data->afsk_space_freq, afsk_space_reset_value);
|
||||
return data->afsk_space_freq;
|
||||
}
|
||||
}
|
||||
|
||||
void set_afsk_space(const int32_t new_value) {
|
||||
void set_afsk_space(const int32_t new_value) {
|
||||
data->afsk_space_freq = afsk_freq_range.clip(new_value);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t modem_baudrate() {
|
||||
int32_t modem_baudrate() {
|
||||
modem_baudrate_range.reset_if_outside(data->modem_baudrate, modem_baudrate_reset_value);
|
||||
return data->modem_baudrate;
|
||||
}
|
||||
}
|
||||
|
||||
void set_modem_baudrate(const int32_t new_value) {
|
||||
void set_modem_baudrate(const int32_t new_value) {
|
||||
data->modem_baudrate = modem_baudrate_range.clip(new_value);
|
||||
}
|
||||
}
|
||||
|
||||
/*int32_t modem_bw() {
|
||||
/*int32_t modem_bw() {
|
||||
modem_bw_range.reset_if_outside(data->modem_bw, modem_bw_reset_value);
|
||||
return data->modem_bw;
|
||||
}
|
||||
}
|
||||
|
||||
void set_modem_bw(const int32_t new_value) {
|
||||
void set_modem_bw(const int32_t new_value) {
|
||||
data->modem_bw = modem_bw_range.clip(new_value);
|
||||
}*/
|
||||
}*/
|
||||
|
||||
uint8_t modem_repeat() {
|
||||
uint8_t modem_repeat() {
|
||||
modem_repeat_range.reset_if_outside(data->modem_repeat, modem_repeat_reset_value);
|
||||
return data->modem_repeat;
|
||||
}
|
||||
}
|
||||
|
||||
void set_modem_repeat(const uint32_t new_value) {
|
||||
void set_modem_repeat(const uint32_t new_value) {
|
||||
data->modem_repeat = modem_repeat_range.clip(new_value);
|
||||
}
|
||||
}
|
||||
|
||||
serial_format_t serial_format() {
|
||||
serial_format_t serial_format() {
|
||||
return data->serial_format;
|
||||
}
|
||||
}
|
||||
|
||||
void set_serial_format(const serial_format_t new_value) {
|
||||
void set_serial_format(const serial_format_t new_value) {
|
||||
data->serial_format = new_value;
|
||||
}
|
||||
}
|
||||
|
||||
bool show_gui_return_icon() { // add return icon in touchscreen menue
|
||||
bool show_gui_return_icon() { // add return icon in touchscreen menue
|
||||
return data->ui_config.show_gui_return_icon();
|
||||
}
|
||||
}
|
||||
|
||||
bool load_app_settings() { // load (last saved) app settings on startup of app
|
||||
bool load_app_settings() { // load (last saved) app settings on startup of app
|
||||
return data->ui_config.load_app_settings();
|
||||
}
|
||||
}
|
||||
|
||||
bool save_app_settings() { // save app settings when closing app
|
||||
bool save_app_settings() { // save app settings when closing app
|
||||
return data->ui_config.save_app_settings();
|
||||
}
|
||||
}
|
||||
|
||||
bool show_bigger_qr_code() { // show bigger QR code
|
||||
bool show_bigger_qr_code() { // show bigger QR code
|
||||
return data->ui_config.show_bigger_qr_code();
|
||||
}
|
||||
}
|
||||
|
||||
bool disable_touchscreen() { // Option to disable touch screen
|
||||
bool disable_touchscreen() { // Option to disable touch screen
|
||||
return data->ui_config.disable_touchscreen();
|
||||
}
|
||||
}
|
||||
|
||||
bool hide_clock() { // clock hidden from main menu
|
||||
bool hide_clock() { // clock hidden from main menu
|
||||
return data->ui_config.hide_clock();
|
||||
}
|
||||
}
|
||||
|
||||
bool clock_with_date() { // show clock with date, if not hidden
|
||||
bool clock_with_date() { // show clock with date, if not hidden
|
||||
return data->ui_config.clock_with_date();
|
||||
}
|
||||
}
|
||||
|
||||
bool clkout_enabled() {
|
||||
bool clkout_enabled() {
|
||||
return data->ui_config.clkout_enabled();
|
||||
}
|
||||
}
|
||||
|
||||
bool config_speaker() {
|
||||
bool config_speaker() {
|
||||
return data->ui_config.config_speaker();
|
||||
}
|
||||
}
|
||||
|
||||
bool stealth_mode() {
|
||||
bool stealth_mode() {
|
||||
return data->ui_config.stealth_mode();
|
||||
}
|
||||
}
|
||||
|
||||
bool config_login() {
|
||||
bool config_login() {
|
||||
return data->ui_config.config_login();
|
||||
}
|
||||
}
|
||||
|
||||
bool config_splash() {
|
||||
bool config_splash() {
|
||||
return data->ui_config.config_splash();
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t config_cpld() {
|
||||
uint8_t config_cpld() {
|
||||
return data->hardware_config;
|
||||
}
|
||||
}
|
||||
|
||||
backlight_config_t config_backlight_timer() {
|
||||
backlight_config_t config_backlight_timer() {
|
||||
return data->ui_config.config_backlight_timer();
|
||||
}
|
||||
}
|
||||
|
||||
void set_gui_return_icon(bool v) {
|
||||
void set_gui_return_icon(bool v) {
|
||||
data->ui_config.set_gui_return_icon(v);
|
||||
}
|
||||
}
|
||||
|
||||
void set_load_app_settings(bool v) {
|
||||
void set_load_app_settings(bool v) {
|
||||
data->ui_config.set_load_app_settings(v);
|
||||
}
|
||||
}
|
||||
|
||||
void set_save_app_settings(bool v) {
|
||||
void set_save_app_settings(bool v) {
|
||||
data->ui_config.set_save_app_settings(v);
|
||||
}
|
||||
}
|
||||
|
||||
void set_show_bigger_qr_code(bool v) {
|
||||
void set_show_bigger_qr_code(bool v) {
|
||||
data->ui_config.set_show_bigger_qr_code(v);
|
||||
}
|
||||
}
|
||||
|
||||
void set_disable_touchscreen(bool v) {
|
||||
void set_disable_touchscreen(bool v) {
|
||||
data->ui_config.set_disable_touchscreen(v);
|
||||
}
|
||||
}
|
||||
|
||||
void set_clock_hidden(bool v) {
|
||||
void set_clock_hidden(bool v) {
|
||||
data->ui_config.set_clock_hidden(v);
|
||||
}
|
||||
}
|
||||
|
||||
void set_clock_with_date(bool v) {
|
||||
void set_clock_with_date(bool v) {
|
||||
data->ui_config.set_clock_with_date(v);
|
||||
}
|
||||
}
|
||||
|
||||
void set_clkout_enabled(bool v) {
|
||||
void set_clkout_enabled(bool v) {
|
||||
data->ui_config.set_clkout_enabled(v);
|
||||
}
|
||||
}
|
||||
|
||||
void set_config_speaker(bool v) {
|
||||
void set_config_speaker(bool v) {
|
||||
data->ui_config.set_config_speaker(v);
|
||||
}
|
||||
}
|
||||
|
||||
void set_stealth_mode(bool v) {
|
||||
void set_stealth_mode(bool v) {
|
||||
data->ui_config.set_stealth_mode(v);
|
||||
}
|
||||
}
|
||||
|
||||
void set_config_login(bool v) {
|
||||
void set_config_login(bool v) {
|
||||
data->ui_config.set_config_login(v);
|
||||
}
|
||||
}
|
||||
|
||||
void set_config_splash(bool v) {
|
||||
void set_config_splash(bool v) {
|
||||
data->ui_config.set_config_splash(v);
|
||||
}
|
||||
}
|
||||
|
||||
void set_config_cpld(uint8_t i) {
|
||||
void set_config_cpld(uint8_t i) {
|
||||
data->hardware_config = i;
|
||||
}
|
||||
}
|
||||
|
||||
void set_config_backlight_timer(const backlight_config_t& new_value) {
|
||||
void set_config_backlight_timer(const backlight_config_t& new_value) {
|
||||
data->ui_config.set_config_backlight_timer(new_value);
|
||||
}
|
||||
}
|
||||
|
||||
/*void set_config_textentry(uint8_t new_value) {
|
||||
/*void set_config_textentry(uint8_t new_value) {
|
||||
data->ui_config = (data->ui_config & ~0b100) | ((new_value & 1) << 2);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ui_config_textentry() {
|
||||
uint8_t ui_config_textentry() {
|
||||
return ((data->ui_config >> 2) & 1);
|
||||
}*/
|
||||
}*/
|
||||
|
||||
/*void set_ui_config(const uint32_t new_value) {
|
||||
/*void set_ui_config(const uint32_t new_value) {
|
||||
data->ui_config = new_value;
|
||||
}*/
|
||||
}*/
|
||||
|
||||
uint32_t pocsag_last_address() {
|
||||
uint32_t pocsag_last_address() {
|
||||
return data->pocsag_last_address;
|
||||
}
|
||||
}
|
||||
|
||||
void set_pocsag_last_address(uint32_t address) {
|
||||
void set_pocsag_last_address(uint32_t address) {
|
||||
data->pocsag_last_address = address;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t pocsag_ignore_address() {
|
||||
uint32_t pocsag_ignore_address() {
|
||||
return data->pocsag_ignore_address;
|
||||
}
|
||||
}
|
||||
|
||||
void set_pocsag_ignore_address(uint32_t address) {
|
||||
void set_pocsag_ignore_address(uint32_t address) {
|
||||
data->pocsag_ignore_address = address;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t clkout_freq() {
|
||||
uint32_t clkout_freq() {
|
||||
return data->ui_config.clkout_freq();
|
||||
}
|
||||
}
|
||||
|
||||
void set_clkout_freq(uint32_t freq) {
|
||||
void set_clkout_freq(uint32_t freq) {
|
||||
data->ui_config.set_clkout_freq(freq);
|
||||
}
|
||||
}
|
||||
|
||||
bool recon_autosave_freqs() {
|
||||
bool recon_autosave_freqs() {
|
||||
return (data->recon_config & 0x80000000UL) ? true : false;
|
||||
}
|
||||
bool recon_autostart_recon() {
|
||||
}
|
||||
bool recon_autostart_recon() {
|
||||
return (data->recon_config & 0x40000000UL) ? true : false;
|
||||
}
|
||||
bool recon_continuous() {
|
||||
}
|
||||
bool recon_continuous() {
|
||||
return (data->recon_config & 0x20000000UL) ? true : false;
|
||||
}
|
||||
bool recon_clear_output() {
|
||||
}
|
||||
bool recon_clear_output() {
|
||||
return (data->recon_config & 0x10000000UL) ? true : false;
|
||||
}
|
||||
bool recon_load_freqs() {
|
||||
}
|
||||
bool recon_load_freqs() {
|
||||
return (data->recon_config & 0x08000000UL) ? true : false;
|
||||
}
|
||||
bool recon_load_ranges() {
|
||||
}
|
||||
bool recon_load_ranges() {
|
||||
return (data->recon_config & 0x04000000UL) ? true : false;
|
||||
}
|
||||
bool recon_update_ranges_when_recon() {
|
||||
}
|
||||
bool recon_update_ranges_when_recon() {
|
||||
return (data->recon_config & 0x02000000UL) ? true : false;
|
||||
}
|
||||
bool recon_load_hamradios() {
|
||||
}
|
||||
bool recon_load_hamradios() {
|
||||
return (data->recon_config & 0x01000000UL) ? true : false;
|
||||
}
|
||||
bool recon_match_mode() {
|
||||
}
|
||||
bool recon_match_mode() {
|
||||
return (data->recon_config & 0x00800000UL) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
void set_recon_autosave_freqs(const bool v ){
|
||||
void set_recon_autosave_freqs(const bool v ){
|
||||
data->recon_config = (data->recon_config & ~0x80000000UL) | (v << 31);
|
||||
}
|
||||
void set_recon_autostart_recon(const bool v ){
|
||||
}
|
||||
void set_recon_autostart_recon(const bool v ){
|
||||
data->recon_config = (data->recon_config & ~0x40000000UL) | (v << 30);
|
||||
}
|
||||
void set_recon_continuous(const bool v ){
|
||||
}
|
||||
void set_recon_continuous(const bool v ){
|
||||
data->recon_config = (data->recon_config & ~0x20000000UL) | (v << 29);
|
||||
}
|
||||
void set_recon_clear_output(const bool v ){
|
||||
}
|
||||
void set_recon_clear_output(const bool v ){
|
||||
data->recon_config = (data->recon_config & ~0x10000000UL) | (v << 28);
|
||||
}
|
||||
void set_recon_load_freqs(const bool v ){
|
||||
}
|
||||
void set_recon_load_freqs(const bool v ){
|
||||
data->recon_config = (data->recon_config & ~0x08000000UL) | (v << 27);
|
||||
}
|
||||
void set_recon_load_ranges(const bool v ){
|
||||
}
|
||||
void set_recon_load_ranges(const bool v ){
|
||||
data->recon_config = (data->recon_config & ~0x04000000UL) | (v << 26);
|
||||
}
|
||||
void set_recon_update_ranges_when_recon(const bool v ){
|
||||
}
|
||||
void set_recon_update_ranges_when_recon(const bool v ){
|
||||
data->recon_config = (data->recon_config & ~0x02000000UL) | (v << 25);
|
||||
}
|
||||
void set_recon_load_hamradios(const bool v ){
|
||||
}
|
||||
void set_recon_load_hamradios(const bool v ){
|
||||
data->recon_config = (data->recon_config & ~0x01000000UL) | (v << 24);
|
||||
}
|
||||
void set_recon_match_mode(const bool v ) {
|
||||
}
|
||||
void set_recon_match_mode(const bool v ) {
|
||||
data->recon_config = (data->recon_config & ~0x00800000UL) | (v << 23);
|
||||
}
|
||||
bool config_hide_converter() {
|
||||
}
|
||||
bool config_hide_converter() {
|
||||
return data->hide_converter;
|
||||
}
|
||||
bool config_converter() {
|
||||
}
|
||||
bool config_converter() {
|
||||
return data->converter;
|
||||
}
|
||||
bool config_updown_converter() {
|
||||
}
|
||||
bool config_updown_converter() {
|
||||
return data->updown_converter;
|
||||
}
|
||||
int64_t config_converter_freq() {
|
||||
}
|
||||
int64_t config_converter_freq() {
|
||||
return data->converter_frequency_offset ;
|
||||
}
|
||||
void set_config_hide_converter(const bool v ){
|
||||
}
|
||||
void set_config_hide_converter(const bool v ){
|
||||
data-> hide_converter = v ;
|
||||
if( v )
|
||||
{
|
||||
data -> converter = false ;
|
||||
}
|
||||
}
|
||||
void set_config_converter(const bool v ){
|
||||
}
|
||||
void set_config_converter(const bool v ){
|
||||
data-> converter = v ;
|
||||
}
|
||||
void set_config_updown_converter(const bool v){
|
||||
}
|
||||
void set_config_updown_converter(const bool v){
|
||||
data-> updown_converter = v ;
|
||||
}
|
||||
void set_config_converter_freq(const int64_t v ){
|
||||
}
|
||||
void set_config_converter_freq(const int64_t v ){
|
||||
data-> converter_frequency_offset = v ;
|
||||
}
|
||||
} /* namespace persistent_memory */
|
||||
}
|
||||
|
||||
// sd persisting settings
|
||||
int save_persistent_settings_to_file( std::string filename )
|
||||
{
|
||||
delete_file( filename );
|
||||
File outfile ;
|
||||
auto result = outfile.create(filename);
|
||||
if( result.is_valid() )
|
||||
{
|
||||
return false ;
|
||||
}
|
||||
outfile.write( reinterpret_cast<char*>(&cached_backup_ram), sizeof(backup_ram_t) );
|
||||
return true ;
|
||||
}
|
||||
|
||||
int load_persistent_settings_from_file( std::string filename )
|
||||
{
|
||||
File infile ;
|
||||
auto result = infile.open(filename);
|
||||
if( !result.is_valid() )
|
||||
{
|
||||
infile.read( reinterpret_cast<char*>(&cached_backup_ram), sizeof(backup_ram_t) );
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
} /* namespace persistent_memory */
|
||||
} /* namespace portapack */
|
||||
|
@ -36,9 +36,10 @@ using namespace modems;
|
||||
using namespace serializer;
|
||||
|
||||
namespace portapack {
|
||||
namespace persistent_memory {
|
||||
|
||||
enum backlight_timeout_t {
|
||||
namespace persistent_memory {
|
||||
|
||||
enum backlight_timeout_t {
|
||||
Timeout5Sec = 0,
|
||||
Timeout15Sec = 1,
|
||||
Timeout30Sec = 2,
|
||||
@ -47,10 +48,10 @@ enum backlight_timeout_t {
|
||||
Timeout300Sec = 5,
|
||||
Timeout600Sec = 6,
|
||||
Timeout3600Sec = 7,
|
||||
};
|
||||
};
|
||||
|
||||
struct backlight_config_t {
|
||||
public:
|
||||
struct backlight_config_t {
|
||||
public:
|
||||
backlight_config_t() :
|
||||
_timeout_enum(backlight_timeout_t::Timeout600Sec),
|
||||
_timeout_enabled(false)
|
||||
@ -88,115 +89,115 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
backlight_timeout_t _timeout_enum;
|
||||
bool _timeout_enabled;
|
||||
};
|
||||
};
|
||||
|
||||
namespace cache {
|
||||
namespace cache {
|
||||
|
||||
/* Set values in cache to sensible defaults. */
|
||||
void defaults();
|
||||
/* Set values in cache to sensible defaults. */
|
||||
void defaults();
|
||||
|
||||
/* Load cached settings from values in persistent RAM, replacing with defaults
|
||||
/* Load cached settings from values in persistent RAM, replacing with defaults
|
||||
* if persistent RAM contents appear to be invalid. */
|
||||
void init();
|
||||
void init();
|
||||
|
||||
/* Calculate a check value for cached settings, and copy the check value and
|
||||
/* Calculate a check value for cached settings, and copy the check value and
|
||||
* settings into persistent RAM. Intended to be called periodically to update
|
||||
* persistent settings with current settings. */
|
||||
void persist();
|
||||
void persist();
|
||||
|
||||
} /* namespace cache */
|
||||
} /* namespace cache */
|
||||
|
||||
using ppb_t = int32_t;
|
||||
using ppb_t = int32_t;
|
||||
|
||||
rf::Frequency tuned_frequency();
|
||||
void set_tuned_frequency(const rf::Frequency new_value);
|
||||
rf::Frequency tuned_frequency();
|
||||
void set_tuned_frequency(const rf::Frequency new_value);
|
||||
|
||||
ppb_t correction_ppb();
|
||||
void set_correction_ppb(const ppb_t new_value);
|
||||
ppb_t correction_ppb();
|
||||
void set_correction_ppb(const ppb_t new_value);
|
||||
|
||||
void set_touch_calibration(const touch::Calibration& new_value);
|
||||
const touch::Calibration& touch_calibration();
|
||||
void set_touch_calibration(const touch::Calibration& new_value);
|
||||
const touch::Calibration& touch_calibration();
|
||||
|
||||
serial_format_t serial_format();
|
||||
void set_serial_format(const serial_format_t new_value);
|
||||
serial_format_t serial_format();
|
||||
void set_serial_format(const serial_format_t new_value);
|
||||
|
||||
int32_t tone_mix();
|
||||
void set_tone_mix(const int32_t new_value);
|
||||
int32_t tone_mix();
|
||||
void set_tone_mix(const int32_t new_value);
|
||||
|
||||
int32_t afsk_mark_freq();
|
||||
void set_afsk_mark(const int32_t new_value);
|
||||
int32_t afsk_mark_freq();
|
||||
void set_afsk_mark(const int32_t new_value);
|
||||
|
||||
int32_t afsk_space_freq();
|
||||
void set_afsk_space(const int32_t new_value);
|
||||
int32_t afsk_space_freq();
|
||||
void set_afsk_space(const int32_t new_value);
|
||||
|
||||
int32_t modem_baudrate();
|
||||
void set_modem_baudrate(const int32_t new_value);
|
||||
int32_t modem_baudrate();
|
||||
void set_modem_baudrate(const int32_t new_value);
|
||||
|
||||
uint8_t modem_repeat();
|
||||
void set_modem_repeat(const uint32_t new_value);
|
||||
uint8_t modem_repeat();
|
||||
void set_modem_repeat(const uint32_t new_value);
|
||||
|
||||
uint32_t playing_dead();
|
||||
void set_playing_dead(const uint32_t new_value);
|
||||
uint32_t playing_dead();
|
||||
void set_playing_dead(const uint32_t new_value);
|
||||
|
||||
uint32_t playdead_sequence();
|
||||
void set_playdead_sequence(const uint32_t new_value);
|
||||
uint32_t playdead_sequence();
|
||||
void set_playdead_sequence(const uint32_t new_value);
|
||||
|
||||
bool stealth_mode();
|
||||
void set_stealth_mode(const bool v);
|
||||
bool stealth_mode();
|
||||
void set_stealth_mode(const bool v);
|
||||
|
||||
uint8_t config_cpld();
|
||||
void set_config_cpld(uint8_t i);
|
||||
uint8_t config_cpld();
|
||||
void set_config_cpld(uint8_t i);
|
||||
|
||||
bool config_splash();
|
||||
bool config_hide_converter();
|
||||
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();
|
||||
bool config_login();
|
||||
bool config_speaker();
|
||||
backlight_config_t config_backlight_timer();
|
||||
bool disable_touchscreen();
|
||||
bool config_splash();
|
||||
bool config_hide_converter();
|
||||
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();
|
||||
bool config_login();
|
||||
bool config_speaker();
|
||||
backlight_config_t config_backlight_timer();
|
||||
bool disable_touchscreen();
|
||||
|
||||
void set_gui_return_icon(bool v);
|
||||
void set_load_app_settings(bool v);
|
||||
void set_save_app_settings(bool v);
|
||||
void set_show_bigger_qr_code(bool v);
|
||||
void set_config_splash(bool v);
|
||||
void set_config_hide_converter(bool v);
|
||||
void set_config_converter(bool v);
|
||||
void set_config_updown_converter(const bool v);
|
||||
void set_config_converter_freq(const int64_t v );
|
||||
void set_clock_hidden(bool v);
|
||||
void set_clock_with_date(bool v);
|
||||
void set_config_login(bool v);
|
||||
void set_config_speaker(bool v);
|
||||
void set_config_backlight_timer(const backlight_config_t& new_value);
|
||||
void set_disable_touchscreen(bool v);
|
||||
void set_gui_return_icon(bool v);
|
||||
void set_load_app_settings(bool v);
|
||||
void set_save_app_settings(bool v);
|
||||
void set_show_bigger_qr_code(bool v);
|
||||
void set_config_splash(bool v);
|
||||
void set_config_hide_converter(bool v);
|
||||
void set_config_converter(bool v);
|
||||
void set_config_updown_converter(const bool v);
|
||||
void set_config_converter_freq(const int64_t v );
|
||||
void set_clock_hidden(bool v);
|
||||
void set_clock_with_date(bool v);
|
||||
void set_config_login(bool v);
|
||||
void set_config_speaker(bool v);
|
||||
void set_config_backlight_timer(const backlight_config_t& new_value);
|
||||
void set_disable_touchscreen(bool v);
|
||||
|
||||
//uint8_t ui_config_textentry();
|
||||
//void set_config_textentry(uint8_t new_value);
|
||||
//uint8_t ui_config_textentry();
|
||||
//void set_config_textentry(uint8_t new_value);
|
||||
|
||||
uint32_t pocsag_last_address();
|
||||
void set_pocsag_last_address(uint32_t address);
|
||||
uint32_t pocsag_last_address();
|
||||
void set_pocsag_last_address(uint32_t address);
|
||||
|
||||
uint32_t pocsag_ignore_address();
|
||||
void set_pocsag_ignore_address(uint32_t address);
|
||||
uint32_t pocsag_ignore_address();
|
||||
void set_pocsag_ignore_address(uint32_t address);
|
||||
|
||||
bool clkout_enabled();
|
||||
void set_clkout_enabled(bool v);
|
||||
uint32_t clkout_freq();
|
||||
void set_clkout_freq(uint32_t freq);
|
||||
bool clkout_enabled();
|
||||
void set_clkout_enabled(bool v);
|
||||
uint32_t clkout_freq();
|
||||
void set_clkout_freq(uint32_t freq);
|
||||
|
||||
/* Recon app */
|
||||
/* Recon app */
|
||||
bool recon_autosave_freqs();
|
||||
bool recon_autostart_recon();
|
||||
bool recon_continuous();
|
||||
@ -216,7 +217,12 @@ void set_clkout_freq(uint32_t freq);
|
||||
void set_recon_load_hamradios(const bool v );
|
||||
void set_recon_match_mode( const bool v );
|
||||
|
||||
} /* namespace persistent_memory */
|
||||
// sd persisting settings
|
||||
int save_persistent_settings_to_file( std::string filename );
|
||||
int load_persistent_settings_from_file( std::string filename );
|
||||
|
||||
} /* namespace persistent_memory */
|
||||
|
||||
} /* namespace portapack */
|
||||
|
||||
#endif/*__PORTAPACK_PERSISTENT_MEMORY_H__*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user