Merge pull request #948 from gullradriel/pmem-defaults

Pmem defaults
This commit is contained in:
gullradriel 2023-05-03 19:48:05 +02:00 committed by GitHub
commit bec70b4ee5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 6 deletions

View File

@ -41,7 +41,6 @@ using namespace portapack;
#include "freqman.hpp" #include "freqman.hpp"
namespace ui { namespace ui {
SetDateTimeView::SetDateTimeView( SetDateTimeView::SetDateTimeView(
NavigationView& nav NavigationView& nav
) { ) {
@ -306,7 +305,6 @@ namespace ui {
checkbox_load_app_settings.set_value(persistent_memory::load_app_settings()); checkbox_load_app_settings.set_value(persistent_memory::load_app_settings());
checkbox_save_app_settings.set_value(persistent_memory::save_app_settings()); checkbox_save_app_settings.set_value(persistent_memory::save_app_settings());
button_save.on_select = [&nav, this](Button&) { button_save.on_select = [&nav, this](Button&) {
persistent_memory::set_load_app_settings(checkbox_load_app_settings.value()); persistent_memory::set_load_app_settings(checkbox_load_app_settings.value());
persistent_memory::set_save_app_settings(checkbox_save_app_settings.value()); persistent_memory::set_save_app_settings(checkbox_save_app_settings.value());
@ -405,6 +403,7 @@ namespace ui {
&check_load_mem_at_startup, &check_load_mem_at_startup,
&button_save_mem_to_file, &button_save_mem_to_file,
&button_load_mem_from_file, &button_load_mem_from_file,
&button_load_mem_defaults,
&button_return &button_return
}); });
@ -483,6 +482,17 @@ namespace ui {
} }
}; };
button_load_mem_defaults.on_select = [&nav, this](Button&) {
nav.push<ModalMessageView>(
"Warning!",
"This will reset the persistent_memory\nand set the default settings",
YESNO,
[this](bool choice) {
if (choice) {
portapack::persistent_memory::cache::defaults();
}
} );
};
button_return.on_select = [&nav, this](Button&) { button_return.on_select = [&nav, this](Button&) {
nav.pop(); nav.pop();

View File

@ -314,7 +314,7 @@ private:
25, 25,
"Save app settings" "Save app settings"
}; };
Button button_save { Button button_save {
{ 2 * 8, 16 * 16, 12 * 8, 32 }, { 2 * 8, 16 * 16, 12 * 8, 32 },
"Save" "Save"
@ -464,15 +464,20 @@ private:
}; };
Button button_save_mem_to_file { Button button_save_mem_to_file {
{ 0, 9 * 16, 240, 32 }, { 0, 8 * 16, 240, 32 },
"save p.mem to sdcard" "save p.mem to sdcard"
}; };
Button button_load_mem_from_file { Button button_load_mem_from_file {
{ 0, 12 * 16, 240, 32 }, { 0, 10 * 16 + 4 , 240, 32 },
"load p.mem from sdcard" "load p.mem from sdcard"
}; };
Button button_load_mem_defaults {
{ 0, 12 * 16 + 8 , 240, 32 },
"!! reset p.mem, load defaults !!"
};
Button button_return { Button button_return {
{ 16 * 8, 16 * 16, 12 * 8, 32 }, { 16 * 8, 16 * 16, 12 * 8, 32 },
"Return", "Return",