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.

227 lines
6.4 KiB

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