noah.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /**
  2. * noah.c
  3. */
  4. #include "quantum.h"
  5. void bootloader_jump(void) {
  6. // This board doesn't use the standard DFU bootloader, and no information is available regarding how to enter bootloader mode. All we can do here is reset.
  7. NVIC_SystemReset();
  8. }
  9. #ifdef RGBLIGHT_ENABLE
  10. #include <string.h>
  11. #include "rgblight.h"
  12. #include "ws2812.h"
  13. extern rgblight_config_t rgblight_config;
  14. // led 0 for caps lock, led 1 for scroll lock, led 3 for num lock
  15. // led 4 for layer 1, led 5 for layer 2, led 6 for layer 3, led 7 for layer 4
  16. #if RGBLIGHT_LED_COUNT < 7
  17. #error "MUST set the RGBLIGHT_LED_COUNT bigger than 7"
  18. #endif
  19. rgb_led_t noah_leds[RGBLIGHT_LED_COUNT];
  20. static bool noah_led_mode = false;
  21. void setleds_custom(rgb_led_t *ledarray, uint16_t num_leds) {
  22. memset(&noah_leds[0], 0, sizeof(noah_leds));
  23. if (!rgblight_config.enable) {
  24. for (uint8_t i = 0; i < RGBLIGHT_LED_COUNT; i++) {
  25. ledarray[i].r = 0;
  26. ledarray[i].g = 0;
  27. ledarray[i].b = 0;
  28. }
  29. }
  30. if (noah_led_mode) {
  31. led_t led_state = host_keyboard_led_state();
  32. if (led_state.caps_lock) {
  33. noah_leds[0] = ledarray[0];
  34. }
  35. if (led_state.scroll_lock) {
  36. noah_leds[1] = ledarray[1];
  37. }
  38. if (led_state.num_lock) {
  39. noah_leds[2] = ledarray[2];
  40. }
  41. for (int32_t i = 0; i < 4; i++) {
  42. if(layer_state_is(i+1)) {
  43. noah_leds[i + 3] = ledarray[i + 3];
  44. }
  45. }
  46. } else {
  47. memcpy(&noah_leds[0], &ledarray[0], sizeof(noah_leds));
  48. }
  49. ws2812_setleds(noah_leds, RGBLIGHT_LED_COUNT);
  50. }
  51. const rgblight_driver_t rgblight_driver = {
  52. .init = ws2812_init,
  53. .setleds = setleds_custom,
  54. };
  55. #endif
  56. #ifdef RGB_MATRIX_ENABLE
  57. const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT] = {
  58. /* Refer to IS31 manual for these locations
  59. * driver
  60. * | R location
  61. * | | G location
  62. * | | | B location
  63. * | | | | */
  64. {0, C1_10, C2_10, C4_11}, // RGB101
  65. {0, C1_11, C2_11, C3_11}, // RGB102
  66. {0, C1_12, C2_12, C3_12}, // RGB103
  67. {0, C1_13, C2_13, C3_13}, // RGB104
  68. {0, C1_14, C2_14, C3_14}, // RGB105
  69. {0, C1_15, C2_15, C3_15}, // RGB106
  70. {0, C1_16, C2_16, C3_16}, // RGB107
  71. {1, C1_1, C3_2, C4_2}, // RGB108
  72. {1, C1_2, C2_2, C4_3}, // RGB109
  73. {1, C1_3, C2_3, C3_3}, // RGB1010
  74. {1, C1_4, C2_4, C3_4}, // RGB1011
  75. {1, C1_5, C2_5, C3_5}, // RGB1012
  76. {1, C1_6, C2_6, C3_6}, // RGB1013
  77. {1, C1_7, C2_7, C3_7}, // RGB1015
  78. {1, C1_8, C2_8, C3_8}, // RGB1016
  79. {0, C1_9, C3_10, C4_10}, // RGB201
  80. {0, C5_9, C4_9, C6_9}, // RGB202
  81. {0, C9_9, C8_9, C7_9}, // RGB203
  82. {0, C9_10, C8_10, C7_10}, // RGB204
  83. {0, C9_11, C8_11, C7_11}, // RGB205
  84. {0, C9_12, C8_12, C7_12}, // RGB206
  85. {0, C9_13, C8_13, C7_13}, // RGB207
  86. {1, C5_1, C4_1, C6_1}, // RGB208
  87. {1, C9_1, C8_1, C7_1}, // RGB209
  88. {1, C9_2, C8_2, C7_2}, // RGB2010
  89. {1, C9_3, C8_3, C7_3}, // RGB2011
  90. {1, C9_4, C8_4, C7_4}, // RGB2012
  91. {1, C9_5, C8_5, C7_5}, // RGB2013
  92. {1, C9_6, C8_6, C7_6}, // RGB2014
  93. {1, C5_8, C4_8, C6_8}, // RGB2015
  94. {0, C9_1, C8_1, C7_1}, // RGB301
  95. {0, C1_1, C3_2, C4_2}, // RGB302
  96. {0, C5_1, C4_1, C6_1}, // RGB303
  97. {0, C5_16, C4_16, C6_16}, // RGB304
  98. {0, C1_2, C2_2, C4_3}, // RGB305
  99. {0, C9_14, C8_14, C7_14}, // RGB306
  100. {0, C9_15, C8_15, C6_14}, // RGB307
  101. {0, C9_16, C7_15, C6_15}, // RGB308
  102. {1, C1_10, C2_10, C4_11}, // RGB309
  103. {1, C1_11, C2_11, C3_11}, // RGB3010
  104. {1, C1_12, C2_12, C3_12}, // RGB3011
  105. {1, C1_13, C2_13, C3_13}, // RGB3012
  106. {1, C1_14, C2_14, C3_14}, // RGB3014
  107. {1, C9_7, C8_7, C6_6}, // RGB3013-2
  108. {1, C1_15, C2_15, C3_15}, // RGB3013
  109. {1, C9_8, C7_7, C6_7}, // RGB3015
  110. {0, C9_3, C8_3, C7_3}, // RGB401-2
  111. {0, C9_2, C8_2, C7_2}, // RGB401
  112. {0, C9_4, C8_4, C7_4}, // RGB4014
  113. {0, C9_5, C8_5, C7_5}, // RGB402
  114. {0, C9_6, C8_6, C7_6}, // RGB403
  115. {0, C1_3, C2_3, C3_3}, // RGB404
  116. {0, C1_4, C2_4, C3_4}, // RGB405
  117. {0, C1_6, C2_6, C3_6}, // RGB406
  118. {0, C1_5, C2_5, C3_5}, // RGB407
  119. {1, C1_9, C3_10, C4_10}, // RGB408
  120. {1, C5_9, C4_9, C6_9}, // RGB409
  121. {1, C9_9, C8_9, C7_9}, // RGB4010
  122. {1, C9_10, C8_10, C7_10}, // RGB4011
  123. {1, C9_11, C8_11, C7_11}, // RGB4012
  124. {1, C5_16, C4_16, C6_16}, // RGB4013
  125. {1, C1_16, C2_16, C3_16}, // RGB4015
  126. {0, C9_7, C8_7, C6_6}, // RGB501
  127. {0, C9_8, C7_7, C6_7}, // RGB502
  128. {0, C5_8, C4_8, C6_8}, // RGB503
  129. {0, C1_8, C2_8, C3_8}, // RGB506
  130. {0, C1_7, C2_7, C3_7}, // RGB506-2
  131. {1, C9_12, C8_12, C7_12}, // RGB507
  132. {1, C9_13, C8_13, C7_13}, // RGB508
  133. {1, C9_14, C8_14, C7_14}, // RGB5010
  134. {1, C9_15, C8_15, C6_14}, // RGB5011
  135. {1, C9_16, C7_15, C6_15}, // RGB5012
  136. };
  137. #endif
  138. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  139. if (record->event.pressed) {
  140. switch(keycode) {
  141. #ifdef RGBLIGHT_ENABLE
  142. case KC_F24: // switch the led mode on or off
  143. noah_led_mode = !noah_led_mode;
  144. return false;
  145. #ifdef RGB_MATRIX_ENABLE
  146. case KC_F13: // toggle rgb matrix
  147. rgb_matrix_toggle();
  148. return false;
  149. case KC_F14:
  150. rgb_matrix_step();
  151. return false;
  152. #endif
  153. #endif
  154. default:
  155. break;
  156. }
  157. }
  158. return process_record_user(keycode, record);
  159. }