diff --git a/examples/EEPROM-Keymap/EEPROM-Keymap.ino b/examples/EEPROM-Keymap/EEPROM-Keymap.ino index 9bdd3656..f1127a23 100644 --- a/examples/EEPROM-Keymap/EEPROM-Keymap.ino +++ b/examples/EEPROM-Keymap/EEPROM-Keymap.ino @@ -48,11 +48,15 @@ void setup () { USE_PLUGINS (&EEPROMKeymap, &Focus); + Focus.addHook (FOCUS_HOOK_SETTINGS); Focus.addHook (FOCUS_HOOK_KEYMAP); Focus.addHook (FOCUS_HOOK_HELP); Focus.addHook (FOCUS_HOOK_VERSION); Layer.getKey = EEPROMKeymap.getKey; + + EEPROMKeymap.reserveSpace (2); + EEPROMSettings.seal (); } void loop () { diff --git a/src/Kaleidoscope/EEPROM-Keymap.cpp b/src/Kaleidoscope/EEPROM-Keymap.cpp index ea3536b4..91a42d49 100644 --- a/src/Kaleidoscope/EEPROM-Keymap.cpp +++ b/src/Kaleidoscope/EEPROM-Keymap.cpp @@ -29,10 +29,12 @@ namespace KaleidoscopePlugins { void EEPROMKeymap::begin (void) { USE_PLUGINS (&::EEPROMSettings); + } - uint16_t layerSize = ROWS * COLS * 2; - maxLayers = (E2END - ::EEPROMSettings.endOfSettings ()) / layerSize; - keymapBase = ::EEPROMSettings.endOfSettings () + 1; + void + EEPROMKeymap::reserveSpace (uint8_t layers) { + maxLayers = layers; + keymapBase = ::EEPROMSettings.requestSlice (maxLayers * ROWS * COLS * 2); } Key diff --git a/src/Kaleidoscope/EEPROM-Keymap.h b/src/Kaleidoscope/EEPROM-Keymap.h index 83809a89..14b5493c 100644 --- a/src/Kaleidoscope/EEPROM-Keymap.h +++ b/src/Kaleidoscope/EEPROM-Keymap.h @@ -28,8 +28,11 @@ namespace KaleidoscopePlugins { virtual void begin (void) final; - static Key getKey (uint8_t layer, byte row, byte col); + static void reserveSpace (uint8_t layers); static uint16_t base (void); + + static Key getKey (uint8_t layer, byte row, byte col); + static bool focusKeymap (const char *command); private: