Merge remote-tracking branch 'origin/next' into ssd_to_usb

This commit is contained in:
Bernd Herzog 2023-04-01 19:24:53 +02:00
commit db5fcaba44
5 changed files with 1435 additions and 1240 deletions

View File

@ -42,9 +42,9 @@ using namespace portapack;
namespace ui {
SetDateTimeView::SetDateTimeView(
SetDateTimeView::SetDateTimeView(
NavigationView& nav
) {
) {
button_save.on_select = [&nav, this](Button&){
const auto model = this->form_collect();
const rtc::RTC new_datetime {
@ -83,22 +83,22 @@ SetDateTimeView::SetDateTimeView(
};
form_init(model);
}
}
void SetDateTimeView::focus() {
void SetDateTimeView::focus() {
button_cancel.focus();
}
}
void SetDateTimeView::form_init(const SetDateTimeModel& model) {
void SetDateTimeView::form_init(const SetDateTimeModel& model) {
field_year.set_value(model.year);
field_month.set_value(model.month);
field_day.set_value(model.day);
field_hour.set_value(model.hour);
field_minute.set_value(model.minute);
field_second.set_value(model.second);
}
}
SetDateTimeModel SetDateTimeView::form_collect() {
SetDateTimeModel SetDateTimeView::form_collect() {
return {
.year = static_cast<uint16_t>(field_year.value()),
.month = static_cast<uint8_t>(field_month.value()),
@ -107,11 +107,11 @@ SetDateTimeModel SetDateTimeView::form_collect() {
.minute = static_cast<uint8_t>(field_minute.value()),
.second = static_cast<uint8_t>(field_second.value())
};
}
}
SetRadioView::SetRadioView(
SetRadioView::SetRadioView(
NavigationView& nav
) {
) {
button_cancel.on_select = [&nav](Button&){
nav.pop();
};
@ -209,25 +209,25 @@ SetRadioView::SetRadioView(
clock_manager.enable_clock_output(portapack::persistent_memory::clkout_enabled());
nav.pop();
};
}
}
void SetRadioView::focus() {
void SetRadioView::focus() {
button_save.focus();
}
}
void SetRadioView::form_init(const SetFrequencyCorrectionModel& model) {
void SetRadioView::form_init(const SetFrequencyCorrectionModel& model) {
field_ppm.set_value(model.ppm);
}
}
SetFrequencyCorrectionModel SetRadioView::form_collect() {
SetFrequencyCorrectionModel SetRadioView::form_collect() {
return {
.ppm = static_cast<int8_t>(field_ppm.value()),
.freq = static_cast<uint32_t>(field_clkout_freq.value()),
};
}
}
SetUIView::SetUIView(NavigationView& nav) {
SetUIView::SetUIView(NavigationView& nav) {
add_children({
&checkbox_disable_touchscreen,
&checkbox_speaker,
@ -285,17 +285,17 @@ SetUIView::SetUIView(NavigationView& nav) {
button_cancel.on_select = [&nav, this](Button&) {
nav.pop();
};
}
}
void SetUIView::focus() {
void SetUIView::focus() {
button_save.focus();
}
}
// ---------------------------------------------------------
// Appl. Settings
// ---------------------------------------------------------
SetAppSettingsView::SetAppSettingsView(NavigationView& nav) {
// ---------------------------------------------------------
// Appl. Settings
// ---------------------------------------------------------
SetAppSettingsView::SetAppSettingsView(NavigationView& nav) {
add_children({
&checkbox_load_app_settings,
&checkbox_save_app_settings,
@ -315,16 +315,16 @@ SetAppSettingsView::SetAppSettingsView(NavigationView& nav) {
button_cancel.on_select = [&nav, this](Button&) {
nav.pop();
};
}
}
void SetAppSettingsView::focus() {
void SetAppSettingsView::focus() {
button_save.focus();
}
}
// ---------------------------------------------------------
// Converter Settings
// ---------------------------------------------------------
SetConverterSettingsView::SetConverterSettingsView(NavigationView& nav) {
// ---------------------------------------------------------
// Converter Settings
// ---------------------------------------------------------
SetConverterSettingsView::SetConverterSettingsView(NavigationView& nav) {
add_children({
&check_show_converter,
&check_converter,
@ -388,13 +388,111 @@ SetConverterSettingsView::SetConverterSettingsView(NavigationView& nav) {
button_cancel.on_select = [&nav, this](Button&) {
nav.pop();
};
}
}
void SetConverterSettingsView::focus() {
void SetConverterSettingsView::focus() {
button_save.focus();
}
}
SetAudioView::SetAudioView(NavigationView& nav) {
// ---------------------------------------------------------
// Persistent Memory Settings
// ---------------------------------------------------------
SetPersistentMemoryView::SetPersistentMemoryView(NavigationView& nav) {
add_children({
&text_pmem_about,
&text_pmem_informations,
&text_pmem_status,
&check_load_mem_at_startup,
&button_save_mem_to_file,
&button_load_mem_from_file,
&button_return
});
bool load_mem_at_startup = false ;
File pmem_flag_file_handle ;
std::string pmem_flag_file = "/SETTINGS/PMEM_FILEFLAG" ;
auto result = pmem_flag_file_handle.open(pmem_flag_file);
if(!result.is_valid())
{
load_mem_at_startup = true ;
}
check_load_mem_at_startup.set_value(load_mem_at_startup);
check_load_mem_at_startup.on_select = [this](Checkbox&, bool v) {
File pmem_flag_file_handle ;
std::string pmem_flag_file = "/SETTINGS/PMEM_FILEFLAG" ;
if( v )
{
auto result = pmem_flag_file_handle.open(pmem_flag_file);
if(result.is_valid())
{
auto result = pmem_flag_file_handle.create(pmem_flag_file); //third: create if it is not there
if( !result.is_valid() )
{
text_pmem_status.set("pmem flag file created");
}
else
{
text_pmem_status.set("!err. creating pmem flagfile!");
}
}
else
{
text_pmem_status.set("pmem flag already present");
}
}
else
{
auto result = delete_file( pmem_flag_file );
if( result != 0 )
{
text_pmem_status.set("!err. deleting pmem flagfile!");
}
else
{
text_pmem_status.set("pmem flag file deleted");
}
}
};
button_save_mem_to_file.on_select = [&nav, this](Button&) {
if( !portapack::persistent_memory::save_persistent_settings_to_file("SETTINGS/pmem_settings") )
{
text_pmem_status.set("!problem saving settings!");
}
else
{
text_pmem_status.set("settings saved");
}
};
button_load_mem_from_file.on_select = [&nav, this](Button&) {
if( !portapack::persistent_memory::load_persistent_settings_from_file("SETTINGS/pmem_settings") )
{
text_pmem_status.set("!problem loading settings!");
}
else
{
text_pmem_status.set("settings loaded");
//Refresh status bar with icon up or down
StatusRefreshMessage message { };
EventDispatcher::send_message(message);
}
};
button_return.on_select = [&nav, this](Button&) {
nav.pop();
};
}
void SetPersistentMemoryView::focus() {
button_return.focus();
}
//
// Audio settings
//
SetAudioView::SetAudioView(NavigationView& nav) {
add_children({
&labels,
&field_tone_mix,
@ -412,13 +510,13 @@ SetAudioView::SetAudioView(NavigationView& nav) {
button_cancel.on_select = [&nav, this](Button&) {
nav.pop();
};
}
}
void SetAudioView::focus() {
void SetAudioView::focus() {
button_save.focus();
}
}
SetQRCodeView::SetQRCodeView(NavigationView& nav) {
SetQRCodeView::SetQRCodeView(NavigationView& nav) {
add_children({
&checkbox_bigger_qr,
&button_save,
@ -436,16 +534,16 @@ SetQRCodeView::SetQRCodeView(NavigationView& nav) {
nav.pop();
};
}
}
void SetQRCodeView::focus() {
void SetQRCodeView::focus() {
button_save.focus();
}
}
// ---------------------------------------------------------
// Settings main menu
// ---------------------------------------------------------
SettingsMenuView::SettingsMenuView(NavigationView& nav) {
// ---------------------------------------------------------
// Settings main menu
// ---------------------------------------------------------
SettingsMenuView::SettingsMenuView(NavigationView& nav) {
if( portapack::persistent_memory::show_gui_return_icon() )
{
add_items( { { "..", ui::Color::light_grey(),&bitmap_icon_previous, [&nav](){ nav.pop(); } } } );
@ -458,9 +556,10 @@ SettingsMenuView::SettingsMenuView(NavigationView& nav) {
{ "Calibration", ui::Color::dark_cyan(), &bitmap_icon_options_touch, [&nav](){ nav.push<TouchCalibrationView>(); } },
{ "App Settings", ui::Color::dark_cyan(), &bitmap_icon_setup, [&nav](){ nav.push<SetAppSettingsView>(); } },
{ "Converter", ui::Color::dark_cyan(), &bitmap_icon_options_radio, [&nav](){ nav.push<SetConverterSettingsView>(); } },
{ "QR Code", ui::Color::dark_cyan(), &bitmap_icon_qr_code, [&nav](){ nav.push<SetQRCodeView>(); } }
{ "QR Code", ui::Color::dark_cyan(), &bitmap_icon_qr_code, [&nav](){ nav.push<SetQRCodeView>(); } },
{ "P.Memory Mgmt", ui::Color::dark_cyan(), &bitmap_icon_memory, [&nav](){ nav.push<SetPersistentMemoryView>(); } },
});
set_max_rows(2); // allow wider buttons
}
}
} /* namespace ui */

View File

@ -432,6 +432,54 @@ private:
};
};
class SetPersistentMemoryView : public View {
public:
SetPersistentMemoryView(NavigationView& nav);
void focus() override;
std::string title() const override { return "P.Mem Mgmt"; };
private:
Text text_pmem_about {
{ 0, 1 * 16, 240 , 16 },
"PersistentMemory from/to SD"
};
Text text_pmem_informations {
{ 0, 2 * 16, 240 , 16 },
"use: when no/dead coin bat."
};
Text text_pmem_status {
{ 0, 3 * 16, 240 , 16 },
""
};
Checkbox check_load_mem_at_startup {
{ 18, 6 * 16},
19,
"load from sd at startup"
};
Button button_save_mem_to_file {
{ 0, 9 * 16, 240, 32 },
"save p.mem to sdcard"
};
Button button_load_mem_from_file {
{ 0, 12 * 16, 240, 32 },
"load p.mem from sdcard"
};
Button button_return {
{ 16 * 8, 16 * 16, 12 * 8, 32 },
"Return",
};
};
class SettingsMenuView : public BtnGridView {
public:
SettingsMenuView(NavigationView& nav);

View File

@ -723,6 +723,14 @@ SystemView::SystemView(
navigation_view.push<SystemMenuView>();
File pmem_flag_file_handle ;
std::string pmem_flag_file = "/SETTINGS/PMEM_FILEFLAG" ;
auto result = pmem_flag_file_handle.open(pmem_flag_file);
if(!result.is_valid())
{
portapack::persistent_memory::load_persistent_settings_from_file("SETTINGS/pmem_settings");
}
if (portapack::persistent_memory::config_splash())
{
navigation_view.push<BMPView>();

View File

@ -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 */

View File

@ -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__*/