mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-25 07:10:43 -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
|
@ -42,9 +42,9 @@ using namespace portapack;
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
|
|
||||||
SetDateTimeView::SetDateTimeView(
|
SetDateTimeView::SetDateTimeView(
|
||||||
NavigationView& nav
|
NavigationView& nav
|
||||||
) {
|
) {
|
||||||
button_save.on_select = [&nav, this](Button&){
|
button_save.on_select = [&nav, this](Button&){
|
||||||
const auto model = this->form_collect();
|
const auto model = this->form_collect();
|
||||||
const rtc::RTC new_datetime {
|
const rtc::RTC new_datetime {
|
||||||
|
@ -83,22 +83,22 @@ SetDateTimeView::SetDateTimeView(
|
||||||
};
|
};
|
||||||
|
|
||||||
form_init(model);
|
form_init(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDateTimeView::focus() {
|
void SetDateTimeView::focus() {
|
||||||
button_cancel.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_year.set_value(model.year);
|
||||||
field_month.set_value(model.month);
|
field_month.set_value(model.month);
|
||||||
field_day.set_value(model.day);
|
field_day.set_value(model.day);
|
||||||
field_hour.set_value(model.hour);
|
field_hour.set_value(model.hour);
|
||||||
field_minute.set_value(model.minute);
|
field_minute.set_value(model.minute);
|
||||||
field_second.set_value(model.second);
|
field_second.set_value(model.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDateTimeModel SetDateTimeView::form_collect() {
|
SetDateTimeModel SetDateTimeView::form_collect() {
|
||||||
return {
|
return {
|
||||||
.year = static_cast<uint16_t>(field_year.value()),
|
.year = static_cast<uint16_t>(field_year.value()),
|
||||||
.month = static_cast<uint8_t>(field_month.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()),
|
.minute = static_cast<uint8_t>(field_minute.value()),
|
||||||
.second = static_cast<uint8_t>(field_second.value())
|
.second = static_cast<uint8_t>(field_second.value())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
SetRadioView::SetRadioView(
|
SetRadioView::SetRadioView(
|
||||||
NavigationView& nav
|
NavigationView& nav
|
||||||
) {
|
) {
|
||||||
button_cancel.on_select = [&nav](Button&){
|
button_cancel.on_select = [&nav](Button&){
|
||||||
nav.pop();
|
nav.pop();
|
||||||
};
|
};
|
||||||
|
@ -209,25 +209,25 @@ SetRadioView::SetRadioView(
|
||||||
clock_manager.enable_clock_output(portapack::persistent_memory::clkout_enabled());
|
clock_manager.enable_clock_output(portapack::persistent_memory::clkout_enabled());
|
||||||
nav.pop();
|
nav.pop();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetRadioView::focus() {
|
void SetRadioView::focus() {
|
||||||
button_save.focus();
|
button_save.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetRadioView::form_init(const SetFrequencyCorrectionModel& model) {
|
void SetRadioView::form_init(const SetFrequencyCorrectionModel& model) {
|
||||||
field_ppm.set_value(model.ppm);
|
field_ppm.set_value(model.ppm);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetFrequencyCorrectionModel SetRadioView::form_collect() {
|
SetFrequencyCorrectionModel SetRadioView::form_collect() {
|
||||||
return {
|
return {
|
||||||
.ppm = static_cast<int8_t>(field_ppm.value()),
|
.ppm = static_cast<int8_t>(field_ppm.value()),
|
||||||
.freq = static_cast<uint32_t>(field_clkout_freq.value()),
|
.freq = static_cast<uint32_t>(field_clkout_freq.value()),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SetUIView::SetUIView(NavigationView& nav) {
|
SetUIView::SetUIView(NavigationView& nav) {
|
||||||
add_children({
|
add_children({
|
||||||
&checkbox_disable_touchscreen,
|
&checkbox_disable_touchscreen,
|
||||||
&checkbox_speaker,
|
&checkbox_speaker,
|
||||||
|
@ -285,17 +285,17 @@ SetUIView::SetUIView(NavigationView& nav) {
|
||||||
button_cancel.on_select = [&nav, this](Button&) {
|
button_cancel.on_select = [&nav, this](Button&) {
|
||||||
nav.pop();
|
nav.pop();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetUIView::focus() {
|
void SetUIView::focus() {
|
||||||
button_save.focus();
|
button_save.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// Appl. Settings
|
// Appl. Settings
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
SetAppSettingsView::SetAppSettingsView(NavigationView& nav) {
|
SetAppSettingsView::SetAppSettingsView(NavigationView& nav) {
|
||||||
add_children({
|
add_children({
|
||||||
&checkbox_load_app_settings,
|
&checkbox_load_app_settings,
|
||||||
&checkbox_save_app_settings,
|
&checkbox_save_app_settings,
|
||||||
|
@ -315,16 +315,16 @@ SetAppSettingsView::SetAppSettingsView(NavigationView& nav) {
|
||||||
button_cancel.on_select = [&nav, this](Button&) {
|
button_cancel.on_select = [&nav, this](Button&) {
|
||||||
nav.pop();
|
nav.pop();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetAppSettingsView::focus() {
|
void SetAppSettingsView::focus() {
|
||||||
button_save.focus();
|
button_save.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// Converter Settings
|
// Converter Settings
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
SetConverterSettingsView::SetConverterSettingsView(NavigationView& nav) {
|
SetConverterSettingsView::SetConverterSettingsView(NavigationView& nav) {
|
||||||
add_children({
|
add_children({
|
||||||
&check_show_converter,
|
&check_show_converter,
|
||||||
&check_converter,
|
&check_converter,
|
||||||
|
@ -388,13 +388,86 @@ SetConverterSettingsView::SetConverterSettingsView(NavigationView& nav) {
|
||||||
button_cancel.on_select = [&nav, this](Button&) {
|
button_cancel.on_select = [&nav, this](Button&) {
|
||||||
nav.pop();
|
nav.pop();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetConverterSettingsView::focus() {
|
void SetConverterSettingsView::focus() {
|
||||||
button_save.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 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({
|
add_children({
|
||||||
&labels,
|
&labels,
|
||||||
&field_tone_mix,
|
&field_tone_mix,
|
||||||
|
@ -412,13 +485,13 @@ SetAudioView::SetAudioView(NavigationView& nav) {
|
||||||
button_cancel.on_select = [&nav, this](Button&) {
|
button_cancel.on_select = [&nav, this](Button&) {
|
||||||
nav.pop();
|
nav.pop();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetAudioView::focus() {
|
void SetAudioView::focus() {
|
||||||
button_save.focus();
|
button_save.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetQRCodeView::SetQRCodeView(NavigationView& nav) {
|
SetQRCodeView::SetQRCodeView(NavigationView& nav) {
|
||||||
add_children({
|
add_children({
|
||||||
&checkbox_bigger_qr,
|
&checkbox_bigger_qr,
|
||||||
&button_save,
|
&button_save,
|
||||||
|
@ -436,16 +509,16 @@ SetQRCodeView::SetQRCodeView(NavigationView& nav) {
|
||||||
nav.pop();
|
nav.pop();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetQRCodeView::focus() {
|
void SetQRCodeView::focus() {
|
||||||
button_save.focus();
|
button_save.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// Settings main menu
|
// Settings main menu
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
SettingsMenuView::SettingsMenuView(NavigationView& nav) {
|
SettingsMenuView::SettingsMenuView(NavigationView& nav) {
|
||||||
if( portapack::persistent_memory::show_gui_return_icon() )
|
if( portapack::persistent_memory::show_gui_return_icon() )
|
||||||
{
|
{
|
||||||
add_items( { { "..", ui::Color::light_grey(),&bitmap_icon_previous, [&nav](){ nav.pop(); } } } );
|
add_items( { { "..", ui::Color::light_grey(),&bitmap_icon_previous, [&nav](){ nav.pop(); } } } );
|
||||||
|
@ -458,9 +531,10 @@ SettingsMenuView::SettingsMenuView(NavigationView& nav) {
|
||||||
{ "Calibration", ui::Color::dark_cyan(), &bitmap_icon_options_touch, [&nav](){ nav.push<TouchCalibrationView>(); } },
|
{ "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>(); } },
|
{ "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>(); } },
|
{ "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
|
set_max_rows(2); // allow wider buttons
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace ui */
|
} /* namespace ui */
|
||||||
|
|
|
@ -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 {
|
class SettingsMenuView : public BtnGridView {
|
||||||
public:
|
public:
|
||||||
SettingsMenuView(NavigationView& nav);
|
SettingsMenuView(NavigationView& nav);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue