From 1e97fd66840861cbc8dddf9d93103f12faa443b4 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Tue, 14 Jan 2014 14:50:28 -0500 Subject: [PATCH] move the persistent data handling functions out into their own file --- ArduinoKeyboard.ino | 25 ++----------------------- KeyboardEEPROM.h | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 23 deletions(-) create mode 100644 KeyboardEEPROM.h diff --git a/ArduinoKeyboard.ino b/ArduinoKeyboard.ino index 79d9dfbd..b6ba6cfd 100644 --- a/ArduinoKeyboard.ino +++ b/ArduinoKeyboard.ino @@ -19,7 +19,6 @@ #include #include -#include @@ -29,6 +28,7 @@ #define COLS 14 #define ROWS 5 +#define EEPROM_LAYER_LOCATION 0 static const byte colPins[COLS] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, A0 }; @@ -57,28 +57,7 @@ float carriedOverY =0; #include "keymaps_generated.h" - -#define EEPROM_LAYER_LOCATION 0 - -void save_current_layer(byte layer) -{ - Serial.print("telling eeprom thinks we're on layer "); - Serial.println(layer); - EEPROM.write(EEPROM_LAYER_LOCATION, layer); -} - -byte load_current_layer() -{ - byte layer = EEPROM.read(EEPROM_LAYER_LOCATION); - Serial.print("eeprom thinks we're on layer "); - Serial.println(layer); - if (layer >= LAYERS ) { - return 0; // undefined positions get saved as 255 - } - return layer; -} - - +#include "KeyboardEEPROM.h" void release_keys_not_being_pressed() { diff --git a/KeyboardEEPROM.h b/KeyboardEEPROM.h new file mode 100644 index 00000000..3dfea22c --- /dev/null +++ b/KeyboardEEPROM.h @@ -0,0 +1,19 @@ +#include + + +void save_current_layer(byte layer) +{ + EEPROM.write(EEPROM_LAYER_LOCATION, layer); +} + +byte load_current_layer() +{ + byte layer = EEPROM.read(EEPROM_LAYER_LOCATION); + if (layer >= LAYERS ) { + return 0; // undefined positions get saved as 255 + } + return layer; +} + + +