aboutsummaryrefslogtreecommitdiff
path: root/quantum/eeconfig.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/eeconfig.c')
-rw-r--r--quantum/eeconfig.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c
index ffbbf43a95..e27f604f12 100644
--- a/quantum/eeconfig.c
+++ b/quantum/eeconfig.c
@@ -3,7 +3,6 @@
#include <stdbool.h>
#include "eeprom.h"
#include "eeconfig.h"
-#include "action_layer.h"
#if defined(EEPROM_DRIVER)
# include "eeprom_driver.h"
@@ -52,7 +51,7 @@ void eeconfig_init_quantum(void) {
eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
eeprom_update_byte(EECONFIG_DEBUG, 0);
default_layer_state = (layer_state_t)1 << 0;
- eeprom_update_byte(EECONFIG_DEFAULT_LAYER, default_layer_state);
+ eeconfig_update_default_layer(default_layer_state);
// Enable oneshot and autocorrect by default: 0b0001 0100 0000 0000
eeprom_update_word(EECONFIG_KEYMAP, 0x1400);
eeprom_update_byte(EECONFIG_BACKLIGHT, 0);
@@ -160,14 +159,30 @@ void eeconfig_update_debug(uint8_t val) {
*
* FIXME: needs doc
*/
-uint8_t eeconfig_read_default_layer(void) {
- return eeprom_read_byte(EECONFIG_DEFAULT_LAYER);
+layer_state_t eeconfig_read_default_layer(void) {
+ uint8_t val = eeprom_read_byte(EECONFIG_DEFAULT_LAYER);
+
+#ifdef DEFAULT_LAYER_STATE_IS_VALUE_NOT_BITMASK
+ // stored as a layer number, so convert back to bitmask
+ return 1 << val;
+#else
+ // stored as 8-bit-wide bitmask, so read the value directly - handling padding to 16/32 bit layer_state_t
+ return val;
+#endif
}
/** \brief eeconfig update default layer
*
* FIXME: needs doc
*/
-void eeconfig_update_default_layer(uint8_t val) {
+void eeconfig_update_default_layer(layer_state_t state) {
+#ifdef DEFAULT_LAYER_STATE_IS_VALUE_NOT_BITMASK
+ // stored as a layer number, so only store the highest layer
+ uint8_t val = get_highest_layer(state);
+#else
+ // stored as 8-bit-wide bitmask, so write the value directly - handling truncation from 16/32 bit layer_state_t
+ uint8_t val = state;
+#endif
+
eeprom_update_byte(EECONFIG_DEFAULT_LAYER, val);
}