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 "KeyboardioSX1509.h"
#include "mouse_movement.h"
#include "storage.h"
//extern uint8_t usbMaxPower;
char x;

@ -6,6 +6,8 @@
#include "KeyboardioFirmware.h"
#include "HID-Project.h"
KeyboardStorage Storage;
void set_keymap(Key keymapEntry, byte matrixStateEntry) {
if (keymapEntry.flags & SWITCH_TO_KEYMAP) {
// 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
if (key_toggled_on(matrixStateEntry)) {
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();
Serial.begin(115200);
//usbMaxPower = 100;
Keyboard.begin();
Mouse.begin();
implementation_setup_leds();
led_bootup();
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)) {
ConsumerControl.press(mappedKey.rawKey);
}
}
else if (mappedKey.flags & IS_INTERNAL) {
} else if (mappedKey.flags & IS_INTERNAL) {
if (key_toggled_on (switchState)) {
if (mappedKey.rawKey == LED_TOGGLE) {
next_led_mode();

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

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

Loading…
Cancel
Save