This commit is contained in:
Christoph Cullmann 2023-08-13 17:23:23 +02:00
parent a55ce6bf04
commit 3f637e3831
2 changed files with 38 additions and 54 deletions

View file

@ -50,6 +50,3 @@
#define RGBLIGHT_EFFECT_SNAKE
#define RGBLIGHT_EFFECT_STATIC_GRADIENT
#define RGBLIGHT_EFFECT_TWINKLE
// we want to have different backlight per layers
#define RGBLIGHT_LAYERS

View file

@ -40,59 +40,46 @@ static bool my_on_left_hand(keypos_t pos)
// our shared 34 keys keymap
#include "../common/keymap.h"
/* plwnck rev6 RGB layout:
* ----------------------------------
* | 6 5 4 3 |
* | 0 |
* | 7 8 1 2 |
* ----------------------------------
*/
const rgblight_segment_t PROGMEM base_layer[] = RGBLIGHT_LAYER_SEGMENTS(
{0, 9, HSV_WHITE}
);
const rgblight_segment_t PROGMEM sym_layer[] = RGBLIGHT_LAYER_SEGMENTS(
{0, 9, HSV_GOLD}
);
const rgblight_segment_t PROGMEM num_layer[] = RGBLIGHT_LAYER_SEGMENTS(
{0, 9, HSV_GREEN}
);
const rgblight_segment_t PROGMEM fn_layer[] = RGBLIGHT_LAYER_SEGMENTS(
{0, 9, HSV_RED}
);
const rgblight_segment_t PROGMEM nav_layer[] = RGBLIGHT_LAYER_SEGMENTS(
{0, 9, HSV_BLUE}
);
const rgblight_segment_t PROGMEM magic_layer[] = RGBLIGHT_LAYER_SEGMENTS(
{0, 9, RGB_CORAL}
);
const rgblight_segment_t * const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(
[_BASE] = base_layer,
[_SYM] = sym_layer,
[_NUM] = num_layer,
[_FN] = fn_layer,
[_NAV] = nav_layer,
[_MAGIC] = magic_layer
);
void keyboard_post_init_user(void) {
// Enable the LED layers
rgblight_layers = my_rgb_layers;
// always use the same effect
rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING);
rgblight_set_speed_noeeprom(2);
// trigger init of layer state
layer_state_set_user(layer_state);
}
// handle layer changes for backlight
layer_state_t layer_state_set_user(layer_state_t state) {
const uint8_t layer = get_highest_layer(state);
switch (layer) {
case _BASE:
rgblight_sethsv_noeeprom(HSV_WHITE);
break;
case _SYM:
rgblight_sethsv_noeeprom(HSV_RED);
break;
case _NUM:
rgblight_sethsv_noeeprom(HSV_GREEN);
break;
case _FN:
rgblight_sethsv_noeeprom(HSV_BLUE);
break;
case _NAV:
rgblight_sethsv_noeeprom(HSV_GOLD);
break;
case _MAGIC:
rgblight_sethsv_noeeprom(HSV_MAGENTA);
break;
default:
break;
}
layer_state_t layer_state_set_user(layer_state_t state)
{
rgblight_set_layer_state(_BASE, layer_state_cmp(state, _BASE));
rgblight_set_layer_state(_SYM, layer_state_cmp(state, _SYM));
rgblight_set_layer_state(_NUM, layer_state_cmp(state, _NUM));
rgblight_set_layer_state(_FN, layer_state_cmp(state, _FN));
rgblight_set_layer_state(_NAV, layer_state_cmp(state, _NAV));
rgblight_set_layer_state(_MAGIC, layer_state_cmp(state, _MAGIC));
return state;
}