Trivial first library wrapper for the storage functions

pull/18/head
Jesse Vincent 9 years ago
parent 425c470bdb
commit 956c974aed

@ -30,6 +30,7 @@ void setup();
#include "debouncing.h" #include "debouncing.h"
#include "KeyboardioSX1509.h" #include "KeyboardioSX1509.h"
#include "mouse_movement.h" #include "mouse_movement.h"
#include "storage.h"
//extern uint8_t usbMaxPower; //extern uint8_t usbMaxPower;
char x; char x;

@ -6,6 +6,8 @@
#include "KeyboardioFirmware.h" #include "KeyboardioFirmware.h"
#include "HID-Project.h" #include "HID-Project.h"
KeyboardStorage Storage;
void set_keymap(Key keymapEntry, byte matrixStateEntry) { void set_keymap(Key keymapEntry, byte matrixStateEntry) {
if (keymapEntry.flags & SWITCH_TO_KEYMAP) { if (keymapEntry.flags & SWITCH_TO_KEYMAP) {
// this logic sucks. there is a better way TODO this // this logic sucks. there is a better way TODO this
@ -27,7 +29,7 @@ void set_keymap(Key keymapEntry, byte matrixStateEntry) {
// switch keymap and stay there // switch keymap and stay there
if (key_toggled_on(matrixStateEntry)) { if (key_toggled_on(matrixStateEntry)) {
temporary_keymap = primary_keymap = keymapEntry.rawKey; temporary_keymap = primary_keymap = keymapEntry.rawKey;
save_primary_keymap(primary_keymap); Storage.save_primary_keymap(primary_keymap);
} }
} }
} }
@ -68,13 +70,14 @@ void setup() {
wdt_disable(); wdt_disable();
Serial.begin(115200); Serial.begin(115200);
//usbMaxPower = 100; //usbMaxPower = 100;
Keyboard.begin(); Keyboard.begin();
Mouse.begin(); Mouse.begin();
implementation_setup_leds(); implementation_setup_leds();
led_bootup(); led_bootup();
implementation_pins_setup(); implementation_pins_setup();
temporary_keymap = primary_keymap = load_primary_keymap(); temporary_keymap = primary_keymap = Storage.load_primary_keymap();
} }
@ -103,8 +106,7 @@ void handle_synthetic_key_press(byte switchState, Key mappedKey) {
if (key_toggled_on (switchState)) { if (key_toggled_on (switchState)) {
ConsumerControl.press(mappedKey.rawKey); ConsumerControl.press(mappedKey.rawKey);
} }
} } else if (mappedKey.flags & IS_INTERNAL) {
else if (mappedKey.flags & IS_INTERNAL) {
if (key_toggled_on (switchState)) { if (key_toggled_on (switchState)) {
if (mappedKey.rawKey == LED_TOGGLE) { if (mappedKey.rawKey == LED_TOGGLE) {
next_led_mode(); next_led_mode();

@ -1,10 +1,12 @@
#include "storage.h" #include "storage.h"
void save_primary_keymap(byte keymap) {
void KeyboardStorage::save_primary_keymap(byte keymap) {
EEPROM.write(EEPROM_KEYMAP_LOCATION, keymap); EEPROM.write(EEPROM_KEYMAP_LOCATION, keymap);
} }
byte load_primary_keymap() { byte KeyboardStorage::load_primary_keymap() {
byte keymap = EEPROM.read(EEPROM_KEYMAP_LOCATION); byte keymap = EEPROM.read(EEPROM_KEYMAP_LOCATION);
if (keymap >= KEYMAPS ) { if (keymap >= KEYMAPS ) {
return 0; // undefined positions get saved as 255 return 0; // undefined positions get saved as 255

@ -2,5 +2,8 @@
#include <EEPROM.h> #include <EEPROM.h>
#include "KeyboardConfig.h" #include "KeyboardConfig.h"
void save_primary_keymap(byte keymap); class KeyboardStorage {
byte load_primary_keymap(); public:
byte load_primary_keymap();
void save_primary_keymap(byte keymap);
};

Loading…
Cancel
Save