rgblight_layers.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "stanrc85.h"
  2. const rgblight_segment_t PROGMEM my_capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS(
  3. {3, 2, HSV_RED},
  4. {10, 2, HSV_RED}
  5. );
  6. const rgblight_segment_t PROGMEM my_layer1_layer[] = RGBLIGHT_LAYER_SEGMENTS(
  7. {3, 1, HSV_GREEN},
  8. {11, 1, HSV_GREEN}
  9. );
  10. const rgblight_segment_t PROGMEM my_layer2_layer[] = RGBLIGHT_LAYER_SEGMENTS(
  11. {3, 1, HSV_BLUE},
  12. {11, 1, HSV_BLUE}
  13. );
  14. const rgblight_segment_t PROGMEM my_layer3_layer[] = RGBLIGHT_LAYER_SEGMENTS(
  15. {3, 1, HSV_WHITE},
  16. {11, 1, HSV_WHITE}
  17. );
  18. // Now define the array of layers. Later layers take precedence
  19. const rgblight_segment_t* const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(
  20. my_capslock_layer,
  21. my_layer1_layer,
  22. my_layer2_layer,
  23. my_layer3_layer
  24. );
  25. void keyboard_post_init_user(void) {
  26. // Enable the LED layers
  27. rgblight_layers = my_rgb_layers;
  28. }
  29. layer_state_t layer_state_set_user(layer_state_t state) {
  30. // Both layers will light up if both kb layers are active
  31. rgblight_set_layer_state(1, layer_state_cmp(state, 1));
  32. rgblight_set_layer_state(2, layer_state_cmp(state, 2));
  33. rgblight_set_layer_state(3, layer_state_cmp(state, 3));
  34. return state;
  35. }
  36. bool led_update_user(led_t led_state) {
  37. rgblight_set_layer_state(0, led_state.caps_lock);
  38. return true;
  39. }