From 0f6f095be207106a50d759ea3322838ccd32eab7 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Wed, 15 Mar 2017 10:37:54 +0100 Subject: [PATCH] Use the EEPROM-Settings plugin Use the EEPROM-Settings plugin to figure out where to store the EEPROM settings. Fixes #2. Signed-off-by: Gergely Nagy --- src/Kaleidoscope/HostOS.cpp | 9 +++++---- src/Kaleidoscope/HostOS.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Kaleidoscope/HostOS.cpp b/src/Kaleidoscope/HostOS.cpp index b68366df..eca19df1 100644 --- a/src/Kaleidoscope/HostOS.cpp +++ b/src/Kaleidoscope/HostOS.cpp @@ -17,11 +17,10 @@ */ #include +#include #include -#define EEPROM_HOSTOS_TYPE_LOCATION 2 - namespace KaleidoscopePlugins { namespace HostOS { void @@ -29,13 +28,15 @@ namespace KaleidoscopePlugins { if (isConfigured) return; + eepromSlice = ::EEPROMSettings.requestSlice (sizeof (osType)); + isConfigured = true; if (osType != AUTO) { return; } - if ((osType = (Type)EEPROM.read (EEPROM_HOSTOS_TYPE_LOCATION)) != AUTO) + if ((osType = (Type)EEPROM.read (eepromSlice)) != AUTO) return; autoDetect (); @@ -52,7 +53,7 @@ namespace KaleidoscopePlugins { void Base::os (HostOS::Type osType_) { osType = osType_; - EEPROM.update (EEPROM_HOSTOS_TYPE_LOCATION, osType); + EEPROM.update (eepromSlice, osType); } }; }; diff --git a/src/Kaleidoscope/HostOS.h b/src/Kaleidoscope/HostOS.h index 9ebb8c82..1ac9e721 100644 --- a/src/Kaleidoscope/HostOS.h +++ b/src/Kaleidoscope/HostOS.h @@ -43,6 +43,7 @@ namespace KaleidoscopePlugins { Type osType; private: + uint16_t eepromSlice; bool isConfigured = false; }; };