mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-24 23:00:34 -04:00
Working pmem load flag checkbox
This commit is contained in:
parent
9540776afd
commit
835bc49999
2 changed files with 504 additions and 382 deletions
|
@ -394,6 +394,79 @@ void SetConverterSettingsView::focus() {
|
|||
button_save.focus();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
// 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 flag file");
|
||||
}
|
||||
}
|
||||
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 flag file");
|
||||
}
|
||||
else
|
||||
{
|
||||
text_pmem_status.set("pmem flag file deleted!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
button_return.on_select = [&nav, this](Button&) {
|
||||
nav.pop();
|
||||
};
|
||||
}
|
||||
|
||||
void SetPersistentMemoryView::focus() {
|
||||
button_return.focus();
|
||||
}
|
||||
|
||||
//
|
||||
// Audio settings
|
||||
//
|
||||
|
||||
SetAudioView::SetAudioView(NavigationView& nav) {
|
||||
add_children({
|
||||
&labels,
|
||||
|
@ -458,7 +531,8 @@ 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
|
||||
}
|
||||
|
|
|
@ -432,6 +432,54 @@ private:
|
|||
};
|
||||
};
|
||||
|
||||
class SetPersistentMemoryView : public View {
|
||||
public:
|
||||
SetPersistentMemoryView(NavigationView& nav);
|
||||
|
||||
void focus() override;
|
||||
|
||||
std::string title() const override { return "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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue