David Hoelscher 2 weeks ago
committed by GitHub
parent
commit
5a13d4abe6
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
6 changed files with 25 additions and 1 deletions
  1. +2
    -0
      docs/feature_layers.md
  2. +5
    -1
      keyboards/satt/comet46/keymaps/default-rgbled/keymap.c
  3. +4
    -0
      keyboards/satt/comet46/keymaps/default/keymap.c
  4. +4
    -0
      quantum/eeconfig.c
  5. +6
    -0
      quantum/keyboard.c
  6. +4
    -0
      quantum/quantum.c

+ 2
- 0
docs/feature_layers.md View File

@ -53,6 +53,8 @@ Layers stack on top of each other in numerical order. When determining what a ke
Sometimes, you might want to switch between layers in a macro or as part of a tap dance routine. `layer_on` activates a layer, and `layer_off` deactivates it. More layer-related functions can be found in [action_layer.h](https://github.com/qmk/qmk_firmware/blob/master/quantum/action_layer.h).
If you want to save multiple persistent default layers, you will want to avoid using the `set_single_persistent_default_layer` function which only supports one default persistent layer at a time. Instead, you can `#define DEFAULT_LAYER_BITMASK_ENABLE` and call the `eeconfig_update_default_layer` function directly, passing it an 8-bit wide bitfield representing the least significant byte of a layer_state_t variable. Note that this approach is limited to storing persistent default layers only between layers 0 and 7.
## Functions :id=functions
There are a number of functions (and variables) related to how you can use or manipulate the layers.


+ 5
- 1
keyboards/satt/comet46/keymaps/default-rgbled/keymap.c View File

@ -174,7 +174,11 @@ void matrix_init_user(void) {
void matrix_scan_user(void) {
uint8_t layer = get_highest_layer(layer_state);
uint8_t default_layer = biton32(eeconfig_read_default_layer());
#ifdef DEFAULT_LAYER_BITMASK_ENABLE
uint8_t default_layer = get_highest_layer(eeconfig_read_default_layer());
#else
uint8_t default_layer = eeconfig_read_default_layer();
#endif
switch (layer) {
case _LOWER:
set_led_red;


+ 4
- 0
keyboards/satt/comet46/keymaps/default/keymap.c View File

@ -158,7 +158,11 @@ bool oled_task_user(void) {
char layer_str[22];
oled_write_P(PSTR("Layer: "), false);
uint8_t layer = get_highest_layer(layer_state);
#ifdef DEFAULT_LAYER_BITMASK_ENABLE
uint8_t default_layer = get_highest_layer(eeconfig_read_default_layer());
#else
uint8_t default_layer = eeconfig_read_default_layer();
#endif
switch (layer) {
case _QWERTY:
switch (default_layer) {


+ 4
- 0
quantum/eeconfig.c View File

@ -51,7 +51,11 @@ void eeconfig_init_quantum(void) {
eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
eeprom_update_byte(EECONFIG_DEBUG, 0);
#if defined(DEFAULT_LAYER_BITMASK_ENABLE)
default_layer_state = (layer_state_t)1 << 0;
#else
default_layer_state = 0;
#endif
eeprom_update_byte(EECONFIG_DEFAULT_LAYER, default_layer_state);
// Enable oneshot and autocorrect by default: 0b0001 0100 0000 0000
eeprom_update_word(EECONFIG_KEYMAP, 0x1400);


+ 6
- 0
quantum/keyboard.c View File

@ -394,7 +394,13 @@ void quantum_init(void) {
#endif
/* read here just incase bootmagic process changed its value */
#if defined(DEFAULT_LAYER_BITMASK_ENABLE)
/* stored as 8-bit-wide bitmask, so write the value directly to default_layer */
layer_state_t default_layer = (layer_state_t)eeconfig_read_default_layer();
#else
/* stored as a layer number, so left shift 1 by the stored value */
layer_state_t default_layer = (layer_state_t)(1UL << eeconfig_read_default_layer());
#endif
default_layer_set(default_layer);
/* Also initialize layer state to trigger callback functions for layer_state */


+ 4
- 0
quantum/quantum.c View File

@ -490,7 +490,11 @@ void set_single_persistent_default_layer(uint8_t default_layer) {
#if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS)
PLAY_SONG(default_layer_songs[default_layer]);
#endif
#if defined(DEFAULT_LAYER_BITMASK_ENABLE)
eeconfig_update_default_layer((layer_state_t)1 << default_layer);
#else
eeconfig_update_default_layer(default_layer);
#endif
default_layer_set((layer_state_t)1 << default_layer);
}


Loading…
Cancel
Save