noah.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. // left CB
  65. {0, C1_9, C3_10, C4_10},
  66. {0, C1_10, C2_10, C4_11},
  67. {0, C1_11, C2_11, C3_11},
  68. {0, C1_12, C2_12, C3_12},
  69. {0, C1_13, C2_13, C3_13},
  70. {0, C1_14, C2_14, C3_14},
  71. {0, C1_15, C2_15, C3_15},
  72. {0, C1_16, C2_16, C3_16},
  73. {0, C5_9, C4_9, C6_9},
  74. {0, C5_16, C4_16, C6_16},
  75. {0, C9_9, C8_9, C7_9},
  76. {0, C9_10, C8_10, C7_10},
  77. {0, C9_11, C8_11, C7_11},
  78. {0, C9_12, C8_12, C7_12},
  79. {0, C9_13, C8_13, C7_13},
  80. {0, C9_14, C8_14, C7_14},
  81. {0, C9_15, C8_15, C6_14},
  82. {0, C9_16, C7_15, C6_15},
  83. // left CA
  84. {0, C1_1, C3_2, C4_2},
  85. {0, C1_2, C2_2, C4_3},
  86. {0, C1_3, C2_3, C3_3},
  87. {0, C1_4, C2_4, C3_4},
  88. {0, C1_5, C2_5, C3_5},
  89. {0, C1_6, C2_6, C3_6},
  90. {0, C1_7, C2_7, C3_7},
  91. {0, C1_8, C2_8, C3_8},
  92. {0, C5_1, C4_1, C6_1},
  93. {0, C5_8, C4_8, C6_8},
  94. {0, C9_1, C8_1, C7_1},
  95. {0, C9_2, C8_2, C7_2},
  96. {0, C9_3, C8_3, C7_3},
  97. {0, C9_4, C8_4, C7_4},
  98. {0, C9_5, C8_5, C7_5},
  99. {0, C9_6, C8_6, C7_6},
  100. {0, C9_7, C8_7, C6_6},
  101. {0, C9_8, C7_7, C6_7},
  102. // right CA
  103. {1, C1_1, C3_2, C4_2},
  104. {1, C1_2, C2_2, C4_3},
  105. {1, C1_3, C2_3, C3_3},
  106. {1, C1_4, C2_4, C3_4},
  107. {1, C1_5, C2_5, C3_5},
  108. {1, C1_6, C2_6, C3_6},
  109. {1, C1_7, C2_7, C3_7},
  110. {1, C1_8, C2_8, C3_8},
  111. {1, C5_1, C4_1, C6_1},
  112. {1, C5_8, C4_8, C6_8},
  113. {1, C9_1, C8_1, C7_1},
  114. {1, C9_2, C8_2, C7_2},
  115. {1, C9_3, C8_3, C7_3},
  116. {1, C9_4, C8_4, C7_4},
  117. {1, C9_5, C8_5, C7_5},
  118. {1, C9_6, C8_6, C7_6},
  119. {1, C9_7, C8_7, C6_6},
  120. {1, C9_8, C7_7, C6_7},
  121. // right CB
  122. {1, C1_9, C3_10, C4_10},
  123. {1, C1_10, C2_10, C4_11},
  124. {1, C1_11, C2_11, C3_11},
  125. {1, C1_12, C2_12, C3_12},
  126. {1, C1_13, C2_13, C3_13},
  127. {1, C1_14, C2_14, C3_14},
  128. {1, C1_15, C2_15, C3_15},
  129. {1, C1_16, C2_16, C3_16},
  130. {1, C5_9, C4_9, C6_9},
  131. {1, C5_16, C4_16, C6_16},
  132. {1, C9_9, C8_9, C7_9},
  133. {1, C9_10, C8_10, C7_10},
  134. {1, C9_11, C8_11, C7_11},
  135. {1, C9_12, C8_12, C7_12},
  136. {1, C9_13, C8_13, C7_13},
  137. {1, C9_14, C8_14, C7_14},
  138. {1, C9_15, C8_15, C6_14},
  139. {1, C9_16, C7_15, C6_15},
  140. };
  141. led_config_t g_led_config = {
  142. {
  143. { 1, 2, 3, 4, 5, 6, 7, 36, 37, 38, 39, 40, NO_LED, 41},
  144. { 0, 8, 10, 11, 12, 13, 14, 44, 46, 47, 48, 49, 50, 51},
  145. { 30, 18, 26, 9, 19, 15, 16, 17, 55, 56, 57, 58, 59, 60},
  146. { 29, 31, 32, 33, 20, 21, 23, 22, 54, 62, 64, 65, 66, 63},
  147. { 34, 35, 27, 25, 67, 68, 69, 70, 71, 61, 53, 45, 42, 43},
  148. },
  149. {
  150. { 0, 16},{ 0, 0},{ 15, 0},{ 30, 0},{ 45, 0},{ 60, 0},{ 75, 0},{ 90, 0},
  151. { 20, 16},{ 42, 32},
  152. { 45, 16},{ 50, 16},{ 65, 16},{ 80, 16},{ 95, 16},{ 70, 32},{ 84, 32},{ 98, 32},
  153. { 14, 32},{ 56, 32},{ 65, 48},{ 80, 48},{110, 48},{ 95, 48},{112, 64},{100, 64},
  154. { 42, 32},{ 38, 64},
  155. { 0, 32},{ 10, 48},{ 0, 48},{ 20, 48},{ 35, 48},{ 50, 48},{ 0, 64},{ 19, 64},
  156. {105, 0},{120, 0},{135, 0},{150, 0},{165, 0},{180, 0},{202, 0},{224, 0},
  157. {110, 16},{224, 16},
  158. {125, 16},{140, 16},{155, 16},{172, 16},{187, 16},{202, 16},{210, 32},{224, 32},
  159. {125, 48},{112, 32},{126, 32},{140, 32},{154, 32},{168, 32},{182, 32},{224, 48},
  160. {140, 48},{200, 48},
  161. {155, 48},{170, 48},{185, 48},{150, 64},{173, 64},{195, 64},{210, 64},{224, 64}
  162. },
  163. {
  164. 1, 1, 4, 4, 4, 4, 4, 4,
  165. 4, 4,
  166. 4, 4, 4, 4, 4, 4, 4, 4,
  167. 4, 4, 4, 4, 4, 4, 4, 4,
  168. 4, 4,
  169. 1, 1, 1, 4, 4, 4, 1, 1,
  170. 4, 4, 4, 4, 4, 4, 1, 1,
  171. 4, 1,
  172. 4, 4, 4, 4, 4, 4, 4, 1,
  173. 4, 4, 4, 4, 4, 4, 4, 1,
  174. 4, 4,
  175. 4, 4, 4, 1, 1, 1, 1, 1,
  176. }
  177. };
  178. #endif
  179. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  180. if (record->event.pressed) {
  181. switch(keycode) {
  182. #ifdef RGBLIGHT_ENABLE
  183. case KC_F24: // switch the led mode on or off
  184. noah_led_mode = !noah_led_mode;
  185. return false;
  186. #ifdef RGB_MATRIX_ENABLE
  187. case KC_F13: // toggle rgb matrix
  188. rgb_matrix_toggle();
  189. return false;
  190. case KC_F14:
  191. rgb_matrix_step();
  192. return false;
  193. #endif
  194. #endif
  195. default:
  196. break;
  197. }
  198. }
  199. return process_record_user(keycode, record);
  200. }