diff --git a/src/Keyboardio-Hardware-Model01.cpp b/src/Keyboardio-Hardware-Model01.cpp index bcd9033b..d2493e8d 100644 --- a/src/Keyboardio-Hardware-Model01.cpp +++ b/src/Keyboardio-Hardware-Model01.cpp @@ -1,5 +1,8 @@ #include #include +#include + +#define EEPROM_LAYER_LOCATION 0 KeyboardioScanner Model01::leftHand(0); KeyboardioScanner Model01::rightHand(3); @@ -170,4 +173,16 @@ void Model01::reboot_bootloader() { // happens before the watchdog reboots us } +void Model01::save_primary_layer(uint8_t layer) { + EEPROM.write(EEPROM_LAYER_LOCATION, layer); +} + +uint8_t Model01::load_primary_layer(uint8_t layer_count) { + uint8_t layer = EEPROM.read(EEPROM_LAYER_LOCATION); + if (layer >= layer_count) { + return 0; // undefined positions get saved as 255 + } + return 0; // return keymap; +} + HARDWARE_IMPLEMENTATION KeyboardHardware; diff --git a/src/Keyboardio-Hardware-Model01.h b/src/Keyboardio-Hardware-Model01.h index 448d0ca7..9c647943 100644 --- a/src/Keyboardio-Hardware-Model01.h +++ b/src/Keyboardio-Hardware-Model01.h @@ -25,6 +25,9 @@ class Model01 { void enable_scanner_power(void); void reboot_bootloader(); + uint8_t load_primary_layer(uint8_t layer_count); + void save_primary_layer(uint8_t layer); + keydata_t leftHandState; keydata_t rightHandState; keydata_t previousLeftHandState;