Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lift storage reset into the storage base class in preparation for bei ng able to do something smarter on platforms with a filesystem #1455

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions src/kaleidoscope/driver/storage/Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/kaleidoscope/driver/storage/GD32Flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading