From a691a949ab99e908b4c6fcdce65a1c3b8e577e8e Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 5 Feb 2017 09:02:32 +0100 Subject: [PATCH] Merge Storage into Model01 Moved over the primary layer read/write code from KeyboardioFirmware, and renamed them to `load_primary_layer`/`save_primary_layer`, because they deal with layers, not keymaps now. Signed-off-by: Gergely Nagy --- src/Keyboardio-Hardware-Model01.cpp | 15 +++++++++++++++ src/Keyboardio-Hardware-Model01.h | 3 +++ 2 files changed, 18 insertions(+) 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;