From 90b2247465df5d8f38371ea8c33e1a775149d2f1 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Wed, 10 Oct 2018 09:43:47 +0200 Subject: [PATCH] Enable EEPROM storage unconditionally The plugin is much less useful without EEPROM storage, even confusing when using the Focus commands. As such, enable the storage unconditionally. This makes the `enableEEPROM` method obsolete, so we mark that as deprecated. Based on, and fixes #12 by Matt Venn . Signed-off-by: Gergely Nagy --- UPGRADING.md | 11 +++++++++++ src/Kaleidoscope/TypingBreaks.cpp | 3 ++- src/Kaleidoscope/TypingBreaks.h | 7 ++++++- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 UPGRADING.md diff --git a/UPGRADING.md b/UPGRADING.md new file mode 100644 index 00000000..9ccbf7ed --- /dev/null +++ b/UPGRADING.md @@ -0,0 +1,11 @@ +Important changes in TypingBreaks +================================= + +Older versions of the plugin used to provide EEPROM storage for the settings +only optionally, when it was explicitly enabled via the +`TypingBreaks.enableEEPROM()` method. Similarly, the Focus hooks were optional +too. + +Both of them are unconditionally enabled now, because they add so much to the +plugin. This means that any calls to `TypingBreaks.enableEEPROM()` can be safely +removed, the method is a no-op by now. diff --git a/src/Kaleidoscope/TypingBreaks.cpp b/src/Kaleidoscope/TypingBreaks.cpp index 2f1c52af..919b2f2f 100644 --- a/src/Kaleidoscope/TypingBreaks.cpp +++ b/src/Kaleidoscope/TypingBreaks.cpp @@ -109,7 +109,7 @@ EventHandlerResult TypingBreaks::onKeyswitchEvent(Key &mapped_key, byte row, byt return EventHandlerResult::OK; } -void TypingBreaks::enableEEPROM(void) { +EventHandlerResult TypingBreaks::onSetup() { settings_base_ = ::EEPROMSettings.requestSlice(sizeof(settings)); // If idleTime is max, assume that EEPROM is uninitialized, and store the @@ -121,6 +121,7 @@ void TypingBreaks::enableEEPROM(void) { } EEPROM.get(settings_base_, settings); + return EventHandlerResult::OK; } #define FOCUS_HOOK_TYPINGBREAKS FOCUS_HOOK(TypingBreaks.focusHook, \ diff --git a/src/Kaleidoscope/TypingBreaks.h b/src/Kaleidoscope/TypingBreaks.h index bfc39a98..fe128555 100644 --- a/src/Kaleidoscope/TypingBreaks.h +++ b/src/Kaleidoscope/TypingBreaks.h @@ -19,13 +19,17 @@ #include +#define _DEPRECATED_MESSAGE_ENABLE_EEPROM \ + "EEPROM is now enabled automatically, and the .enableEEPROM()\n" \ + "method is therefore obsolete. You can safely remove it." + namespace kaleidoscope { class TypingBreaks : public kaleidoscope::Plugin { public: TypingBreaks(void) {} - static void enableEEPROM(void); + static void enableEEPROM(void) DEPRECATED(ENABLE_EEPROM) {} typedef struct settings_t { uint16_t idle_time_limit; @@ -39,6 +43,7 @@ class TypingBreaks : public kaleidoscope::Plugin { EventHandlerResult onKeyswitchEvent(Key &mapped_key, byte row, byte col, uint8_t key_state); EventHandlerResult onFocusEvent(const char *command); + EventHandlerResult onSetup(); private: static uint32_t session_start_time_;