Merge pull request #13 from keyboardio/f/auto-settings

Automatically pull in EEPROMSettings, and set up defaults
pull/365/head
Jesse Vincent 6 years ago committed by GitHub
commit 1a626ee1e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -37,11 +37,9 @@ We can then update the keymap via [Focus][plugin:focus].
```c++ ```c++
#include <Kaleidoscope.h> #include <Kaleidoscope.h>
#include <Kaleidoscope-EEPROM-Keymap.h> #include <Kaleidoscope-EEPROM-Keymap.h>
#include <Kaleidoscope-EEPROM-Settings.h>
#include <Kaleidoscope-Focus.h> #include <Kaleidoscope-Focus.h>
KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings, KALEIDOSCOPE_INIT_PLUGINS(EEPROMKeymap,
EEPROMKeymap,
Focus); Focus);
void setup() { void setup() {
@ -52,10 +50,7 @@ void setup() {
Focus.addHook(FOCUS_HOOK_KEYMAP); Focus.addHook(FOCUS_HOOK_KEYMAP);
Focus.addHook(FOCUS_HOOK_KEYMAP_TRANSFER); Focus.addHook(FOCUS_HOOK_KEYMAP_TRANSFER);
Layer.getKey = EEPROMKeymap.getKeyOverride;
EEPROMKeymap.max_layers(1); EEPROMKeymap.max_layers(1);
EEPROMSettings.seal();
} }
``` ```

@ -20,7 +20,7 @@
#include <Kaleidoscope-Focus.h> #include <Kaleidoscope-Focus.h>
// *INDENT-OFF* // *INDENT-OFF*
const Key keymaps[][ROWS][COLS] PROGMEM = { KEYMAPS(
[0] = KEYMAP_STACKED [0] = KEYMAP_STACKED
(Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey, (Key_NoKey, Key_1, Key_2, Key_3, Key_4, Key_5, Key_NoKey,
Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab, Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
@ -37,10 +37,10 @@ const Key keymaps[][ROWS][COLS] PROGMEM = {
Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl, Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_skip), Key_skip),
}; )
// *INDENT-ON* // *INDENT-ON*
KALEIDOSCOPE_INIT_PLUGINS(EEPROMSettings, EEPROMKeymap, Focus); KALEIDOSCOPE_INIT_PLUGINS(EEPROMKeymap, Focus);
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -53,10 +53,7 @@ void setup() {
Focus.addHook(FOCUS_HOOK_HELP); Focus.addHook(FOCUS_HOOK_HELP);
Focus.addHook(FOCUS_HOOK_VERSION); Focus.addHook(FOCUS_HOOK_VERSION);
Layer.getKey = EEPROMKeymap.getKeyOverride;
EEPROMKeymap.max_layers(1); EEPROMKeymap.max_layers(1);
EEPROMSettings.seal();
} }
void loop() { void loop() {

@ -23,6 +23,13 @@ namespace kaleidoscope {
uint16_t EEPROMKeymap::keymap_base_; uint16_t EEPROMKeymap::keymap_base_;
uint8_t EEPROMKeymap::max_layers_; uint8_t EEPROMKeymap::max_layers_;
EventHandlerResult EEPROMKeymap::onSetup() {
::EEPROMSettings.onSetup();
Layer.getKey = ::EEPROMKeymap.getKeyOverride;
return EventHandlerResult::OK;
}
void EEPROMKeymap::max_layers(uint8_t max) { void EEPROMKeymap::max_layers(uint8_t max) {
max_layers_ = max; max_layers_ = max;
keymap_base_ = ::EEPROMSettings.requestSlice(max_layers_ * ROWS * COLS * 2); keymap_base_ = ::EEPROMSettings.requestSlice(max_layers_ * ROWS * COLS * 2);

@ -25,6 +25,8 @@ class EEPROMKeymap : public kaleidoscope::Plugin {
public: public:
EEPROMKeymap(void) {} EEPROMKeymap(void) {}
EventHandlerResult onSetup();
static void max_layers(uint8_t max); static void max_layers(uint8_t max);
static uint16_t keymap_base(void); static uint16_t keymap_base(void);

Loading…
Cancel
Save