From 5a7601bb300a1e6edde869447a67bef443a2c32b Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Wed, 15 Mar 2017 10:17:00 +0100 Subject: [PATCH] Update to use the new EEPROM-Settings library Signed-off-by: Gergely Nagy --- examples/EEPROM-Keymap/EEPROM-Keymap.ino | 4 ++++ src/Kaleidoscope/EEPROM-Keymap.cpp | 8 +++++--- src/Kaleidoscope/EEPROM-Keymap.h | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-) 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: