diff --git a/plugins/Kaleidoscope-EEPROM-Settings/src/kaleidoscope/plugin/EEPROM-Settings.cpp b/plugins/Kaleidoscope-EEPROM-Settings/src/kaleidoscope/plugin/EEPROM-Settings.cpp index 0854354058..a1c2173087 100644 --- a/plugins/Kaleidoscope-EEPROM-Settings/src/kaleidoscope/plugin/EEPROM-Settings.cpp +++ b/plugins/Kaleidoscope-EEPROM-Settings/src/kaleidoscope/plugin/EEPROM-Settings.cpp @@ -231,10 +231,8 @@ EventHandlerResult FocusEEPROMCommand::onFocusEvent(const char *input) { } else if (::Focus.inputMatchesCommand(input, cmd_free)) { ::Focus.send(Runtime.storage().length() - ::EEPROMSettings.used()); } else if (::Focus.inputMatchesCommand(input, cmd_erase)) { - for (uint16_t i = 0; i < Runtime.storage().length(); i++) { - Runtime.storage().update(i, EEPROMSettings::EEPROM_UNINITIALIZED_BYTE); - } - Runtime.storage().commit(); + + Runtime.storage().erase(); Runtime.device().rebootBootloader(); } else { return EventHandlerResult::OK; diff --git a/src/kaleidoscope/driver/storage/Base.h b/src/kaleidoscope/driver/storage/Base.h index 5f7c76d9c0..ec43026a21 100644 --- a/src/kaleidoscope/driver/storage/Base.h +++ b/src/kaleidoscope/driver/storage/Base.h @@ -59,6 +59,13 @@ class Base { void setup() {} void commit() {} + + void erase() { + for (uint16_t i = 0; i < length(); i++) { + update(i, _StorageProps::uninitialized_byte); + } + commit(); + } }; } // namespace storage diff --git a/src/kaleidoscope/driver/storage/GD32Flash.h b/src/kaleidoscope/driver/storage/GD32Flash.h index 216149052a..115b5f808e 100644 --- a/src/kaleidoscope/driver/storage/GD32Flash.h +++ b/src/kaleidoscope/driver/storage/GD32Flash.h @@ -46,6 +46,12 @@ class GD32Flash : public EEPROMClass<_StorageProps::length> { } return true; } + void erase() { + for (uint16_t i = 0; i < this->length(); i++) { + this->update(i, _StorageProps::uninitialized_byte); + } + this->commit(); + } }; } // namespace storage