You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.7 KiB

  1. #include "stanrc85.h"
  2. static uint8_t middle = 0;
  3. static uint8_t bottom = 0;
  4. const rgblight_segment_t PROGMEM my_capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS(
  5. {2, 2, HSV_RED},
  6. {6, 2, HSV_RED}
  7. );
  8. const rgblight_segment_t PROGMEM my_layer1_layer[] = RGBLIGHT_LAYER_SEGMENTS(
  9. {2, 2, HSV_GREEN},
  10. {6, 2, HSV_GREEN}
  11. );
  12. const rgblight_segment_t PROGMEM my_layer2_layer[] = RGBLIGHT_LAYER_SEGMENTS(
  13. {2, 2, HSV_BLUE},
  14. {6, 2, HSV_BLUE}
  15. );
  16. const rgblight_segment_t PROGMEM my_layer3_layer[] = RGBLIGHT_LAYER_SEGMENTS(
  17. {2, 2, HSV_WHITE},
  18. {6, 2, HSV_WHITE}
  19. );
  20. // Now define the array of layers. Later layers take precedence
  21. const rgblight_segment_t* const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(
  22. my_capslock_layer,
  23. my_layer1_layer,
  24. my_layer2_layer,
  25. my_layer3_layer
  26. );
  27. void keyboard_post_init_user(void) {
  28. // Enable the LED layers
  29. rgblight_layers = my_rgb_layers;
  30. }
  31. layer_state_t layer_state_set_user(layer_state_t state) {
  32. // Both layers will light up if both kb layers are active
  33. rgblight_set_layer_state(1, layer_state_cmp(state, 1));
  34. rgblight_set_layer_state(2, layer_state_cmp(state, 2));
  35. rgblight_set_layer_state(3, layer_state_cmp(state, 3));
  36. middle = bottom = 0;
  37. switch (get_highest_layer(state)) {
  38. case _FN1_60:
  39. middle = 1;
  40. break;
  41. case _FN2_60:
  42. bottom = 1;
  43. break;
  44. case _DEFAULT:
  45. middle = 1;
  46. bottom = 1;
  47. break;
  48. default: // for any other layers, or the default layer
  49. break;
  50. }
  51. return state;
  52. }
  53. bool led_update_user(led_t led_state) {
  54. rgblight_set_layer_state(0, led_state.caps_lock);
  55. writePin(C7, led_state.caps_lock);
  56. writePin(C6, middle);
  57. writePin(B6, bottom);
  58. return false;
  59. }