From 79dfa290c77a572c1d7f7918304264be643d5992 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Fri, 29 Jan 2016 19:12:28 -0800 Subject: [PATCH] Cleaner separation for our 'Storage' class --- KeyboardConfig.h | 1 - KeyboardioFirmware.h | 2 -- KeyboardioFirmware.ino | 2 +- storage.cpp => Storage.cpp | 6 +++--- storage.h => Storage.h | 5 +++-- key_events.h | 3 +-- 6 files changed, 8 insertions(+), 11 deletions(-) rename storage.cpp => Storage.cpp (72%) rename storage.h => Storage.h (66%) diff --git a/KeyboardConfig.h b/KeyboardConfig.h index 3a9533ae..9c935c11 100644 --- a/KeyboardConfig.h +++ b/KeyboardConfig.h @@ -5,7 +5,6 @@ #include "KeyboardioSX1509.h" #define USE_HSV_CURVE 1 -#define EEPROM_KEYMAP_LOCATION 0 #define RIGHT_COLS 8 diff --git a/KeyboardioFirmware.h b/KeyboardioFirmware.h index e56c63c3..e9380b83 100644 --- a/KeyboardioFirmware.h +++ b/KeyboardioFirmware.h @@ -1,8 +1,6 @@ #pragma once #include -//add your includes for the project KeyboardIO here -#include //end of add your includes here #ifdef __cplusplus diff --git a/KeyboardioFirmware.ino b/KeyboardioFirmware.ino index 836db63e..c9c0d5b4 100644 --- a/KeyboardioFirmware.ino +++ b/KeyboardioFirmware.ino @@ -39,7 +39,7 @@ void setup() { LEDControl.boot_animation(); implementation_pins_setup(); - temporary_keymap = primary_keymap = Storage.load_primary_keymap(); + temporary_keymap = primary_keymap = Storage.load_primary_keymap(KEYMAPS); } diff --git a/storage.cpp b/Storage.cpp similarity index 72% rename from storage.cpp rename to Storage.cpp index a33d6ea1..ce5ed885 100644 --- a/storage.cpp +++ b/Storage.cpp @@ -1,4 +1,4 @@ -#include "storage.h" +#include "Storage.h" Storage_::Storage_(void) { @@ -8,9 +8,9 @@ void Storage_::save_primary_keymap(uint8_t keymap) { EEPROM.write(EEPROM_KEYMAP_LOCATION, keymap); } -uint8_t Storage_::load_primary_keymap() { +uint8_t Storage_::load_primary_keymap(uint8_t keymap_count) { uint8_t keymap = EEPROM.read(EEPROM_KEYMAP_LOCATION); - if (keymap >= KEYMAPS ) { + if (keymap >= keymap_count) { return 0; // undefined positions get saved as 255 } return 0; // return keymap; diff --git a/storage.h b/Storage.h similarity index 66% rename from storage.h rename to Storage.h index 866e9c4f..03caf182 100644 --- a/storage.h +++ b/Storage.h @@ -2,12 +2,13 @@ #include #include -#include "KeyboardConfig.h" + +#define EEPROM_KEYMAP_LOCATION 0 class Storage_ { public: Storage_(void); - uint8_t load_primary_keymap(void); + uint8_t load_primary_keymap(uint8_t keymap_count); void save_primary_keymap(uint8_t keymap); }; diff --git a/key_events.h b/key_events.h index 675a6fb2..14977797 100644 --- a/key_events.h +++ b/key_events.h @@ -5,8 +5,7 @@ #include "matrix_state.h" #include "MouseWrapper.h" #include "LEDControl.h" -#include "storage.h" - +#include "Storage.h" extern uint8_t matrixState[ROWS][COLS]; extern const Key keymaps[KEYMAPS][ROWS][COLS];