From 212861173cb9d8b20f9a6a857e5b27e040e6dac2 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 26 Feb 2017 10:14:30 +0100 Subject: [PATCH] Add a version to the settings struct Signed-off-by: Gergely Nagy --- src/Kaleidoscope/EEPROM-Settings.cpp | 17 +++++++++++++++++ src/Kaleidoscope/EEPROM-Settings.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/src/Kaleidoscope/EEPROM-Settings.cpp b/src/Kaleidoscope/EEPROM-Settings.cpp index 213e6b64..bf221395 100644 --- a/src/Kaleidoscope/EEPROM-Settings.cpp +++ b/src/Kaleidoscope/EEPROM-Settings.cpp @@ -54,9 +54,26 @@ namespace KaleidoscopePlugins { return _isValid; } + void + EEPROMSettings::invalidate (void) { + _isValid = false; + } + void EEPROMSettings::update (void) { EEPROM.put (0, settings); + _isValid = true; + } + + uint8_t + EEPROMSettings::version (void) { + return settings.version; + } + + void + EEPROMSettings::version (uint8_t ver) { + settings.version = ver; + update (); } }; diff --git a/src/Kaleidoscope/EEPROM-Settings.h b/src/Kaleidoscope/EEPROM-Settings.h index 184bc1f7..cdaf9a7a 100644 --- a/src/Kaleidoscope/EEPROM-Settings.h +++ b/src/Kaleidoscope/EEPROM-Settings.h @@ -35,11 +35,15 @@ namespace KaleidoscopePlugins { static uint16_t endOfSettings (void); static void update (void); static bool isValid (void); + static void invalidate (void); + static uint8_t version (void); + static void version (uint8_t ver); private: static bool _isValid; static struct settings { char magic[2]; + uint8_t version; uint16_t endOfSettings; } settings; };