diff --git a/README.md b/README.md index d2365de2..d6e86c33 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,9 @@ The plugin provides the `EEPROMSettings` object, which has the following methods > Seal the `EEPROM` layout, so no new slices can be requested. The CRC checksum > is considered final at this time, and the `isValid()`, `crc()`, `used()` and > `version()` methods can be used from this point onwards. +> +> If not called explicitly, the layout will be sealed automatically after +> `setup()` in the sketch finished. ### `update()` diff --git a/src/Kaleidoscope/EEPROM-Settings.cpp b/src/Kaleidoscope/EEPROM-Settings.cpp index 657fa89c..4e4fb247 100644 --- a/src/Kaleidoscope/EEPROM-Settings.cpp +++ b/src/Kaleidoscope/EEPROM-Settings.cpp @@ -30,6 +30,13 @@ EventHandlerResult EEPROMSettings::onSetup() { return EventHandlerResult::OK; } +EventHandlerResult EEPROMSettings::beforeEachCycle() { + if (!sealed_) + seal(); + + return EventHandlerResult::OK; +} + bool EEPROMSettings::isValid(void) { return is_valid_; } diff --git a/src/Kaleidoscope/EEPROM-Settings.h b/src/Kaleidoscope/EEPROM-Settings.h index 3fccd2ba..33cb0214 100644 --- a/src/Kaleidoscope/EEPROM-Settings.h +++ b/src/Kaleidoscope/EEPROM-Settings.h @@ -26,6 +26,7 @@ class EEPROMSettings : public kaleidoscope::Plugin { EEPROMSettings(void) {} EventHandlerResult onSetup(); + EventHandlerResult beforeEachCycle(); static void update(void); static bool isValid(void);