aboutsummaryrefslogtreecommitdiff
path: root/quantum/eeconfig.c
diff options
context:
space:
mode:
authorNick Brassel <[email protected]>2024-11-27 21:29:12 +1100
committerNick Brassel <[email protected]>2024-11-27 21:29:12 +1100
commit9f76541b29056150cf57d69569a14a59e13995c7 (patch)
tree66c7398d873fcda88aebe3090603aefe045ff52e /quantum/eeconfig.c
parent57be4871616ee9a8fe042f6186010d436ec7d4b1 (diff)
parenteb04b94eecbb9b3e64ca9c74f937b5f762440b17 (diff)
downloadqmk_firmware-9f76541b29056150cf57d69569a14a59e13995c7.tar.gz
qmk_firmware-9f76541b29056150cf57d69569a14a59e13995c7.zip
Merge branch 'develop'0.27.0
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);
}