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 <algernon@madhouse-project.org>
pull/365/head
Gergely Nagy 8 years ago
parent cb25a04493
commit a691a949ab

@ -1,5 +1,8 @@
#include <KeyboardioFirmware.h> #include <KeyboardioFirmware.h>
#include <avr/wdt.h> #include <avr/wdt.h>
#include <EEPROM.h>
#define EEPROM_LAYER_LOCATION 0
KeyboardioScanner Model01::leftHand(0); KeyboardioScanner Model01::leftHand(0);
KeyboardioScanner Model01::rightHand(3); KeyboardioScanner Model01::rightHand(3);
@ -170,4 +173,16 @@ void Model01::reboot_bootloader() {
// happens before the watchdog reboots us // 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; HARDWARE_IMPLEMENTATION KeyboardHardware;

@ -25,6 +25,9 @@ class Model01 {
void enable_scanner_power(void); void enable_scanner_power(void);
void reboot_bootloader(); void reboot_bootloader();
uint8_t load_primary_layer(uint8_t layer_count);
void save_primary_layer(uint8_t layer);
keydata_t leftHandState; keydata_t leftHandState;
keydata_t rightHandState; keydata_t rightHandState;
keydata_t previousLeftHandState; keydata_t previousLeftHandState;

Loading…
Cancel
Save