Pmem reset (#1115)

* reset config when holding down select durring boot

it still need to be tripple checked if adc or control init really doesnt use any pmem

* one less magic number :)

* dual key action left+right for pmem reset

---------

Co-authored-by: Eisenberger Tamas <e.tamas@iwstudio.hu>
This commit is contained in:
E.T 2023-06-08 00:52:29 +02:00 committed by GitHub
parent d3a7414e51
commit 3ddc753c88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 18 deletions

View File

@ -233,20 +233,23 @@ static PortaPackModel portapack_model() {
if (!model.is_valid()) {
const auto switches_state = get_switches_state();
if (switches_state[(size_t)ui::KeyEvent::Up]) {
save_config(1);
// model = PortaPackModel::R2_20170522; // Commented these out as they should be set down below anyway
} else if (switches_state[(size_t)ui::KeyEvent::Down]) {
save_config(2);
// model = PortaPackModel::R1_20150901;
} else if (switches_state[(size_t)ui::KeyEvent::Left]) {
save_config(3);
// model = PortaPackModel::R1_20150901;
} else if (switches_state[(size_t)ui::KeyEvent::Right]) {
save_config(4);
// model = PortaPackModel::R2_20170522;
} else if (switches_state[(size_t)ui::KeyEvent::Select]) {
save_config(0);
// Only save config if no other multi key boot action is triggered (like pmem reset)
if (switches_state.count() == 1) {
if (switches_state[(size_t)ui::KeyEvent::Up]) {
save_config(1);
// model = PortaPackModel::R2_20170522; // Commented these out as they should be set down below anyway
} else if (switches_state[(size_t)ui::KeyEvent::Down]) {
save_config(2);
// model = PortaPackModel::R1_20150901;
} else if (switches_state[(size_t)ui::KeyEvent::Left]) {
save_config(3);
// model = PortaPackModel::R1_20150901;
} else if (switches_state[(size_t)ui::KeyEvent::Right]) {
save_config(4);
// model = PortaPackModel::R2_20170522;
} else if (switches_state[(size_t)ui::KeyEvent::Select]) {
save_config(0);
}
}
if (load_config() == 1) {
@ -469,13 +472,13 @@ bool init() {
i2c0.start(i2c_config_fast_clock);
chThdSleepMilliseconds(10);
/* Cache some configuration data from persistent memory. */
persistent_memory::cache::init();
touch::adc::init();
controls_init();
chThdSleepMilliseconds(10);
/* Cache some configuration data from persistent memory. */
persistent_memory::cache::init();
clock_manager.set_reference_ppb(persistent_memory::correction_ppb());
clock_manager.enable_if_clocks();
clock_manager.enable_codec_clocks();

View File

@ -39,6 +39,8 @@
#include <fstream>
#include "file.hpp"
#include "irq_controls.hpp"
using namespace std;
namespace portapack {
@ -445,7 +447,8 @@ void defaults() {
}
void init() {
if (backup_ram->is_valid()) {
const auto switches_state = get_switches_state();
if (!(switches_state[(size_t)ui::KeyEvent::Left] && switches_state[(size_t)ui::KeyEvent::Right]) && backup_ram->is_valid()) {
// Copy valid persistent data into cache.
cached_backup_ram = *backup_ram;