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.

198 lines
6.0 KiB

  1. /**
  2. * @file hotswap.c
  3. *
  4. Copyright 2020 astro <yuleiz@gmail.com>
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "hotswap.h"
  17. #ifdef RGB_MATRIX_ENABLE
  18. const is31_led __flash g_is31_leds[DRIVER_LED_TOTAL] = {
  19. /* Refer to IS31 manual for these locations
  20. * driver
  21. * | R location
  22. * | | G location
  23. * | | | B location
  24. * | | | | */
  25. // left CA
  26. {0, C1_1, C3_2, C4_2},
  27. {0, C1_2, C2_2, C4_3},
  28. {0, C1_3, C2_3, C3_3},
  29. {0, C1_4, C2_4, C3_4},
  30. {0, C1_5, C2_5, C3_5},
  31. {0, C1_6, C2_6, C3_6},
  32. {0, C1_7, C2_7, C3_7},
  33. {0, C1_8, C2_8, C3_8},
  34. //{0, C5_1, C4_1, C6_1},
  35. //{0, C5_8, C4_8, C6_8},
  36. {0, C9_1, C8_1, C7_1},
  37. {0, C9_2, C8_2, C7_2},
  38. //{0, C9_3, C8_3, C7_3},
  39. {0, C9_4, C8_4, C7_4},
  40. {0, C9_5, C8_5, C7_5},
  41. {0, C9_6, C8_6, C7_6},
  42. {0, C9_7, C8_7, C6_6},
  43. {0, C9_8, C7_7, C6_7},
  44. // left CB
  45. {0, C1_9, C3_10, C4_10},
  46. {0, C1_10, C2_10, C4_11},
  47. {0, C1_11, C2_11, C3_11},
  48. {0, C1_12, C2_12, C3_12},
  49. {0, C1_13, C2_13, C3_13},
  50. {0, C1_14, C2_14, C3_14},
  51. {0, C1_15, C2_15, C3_15},
  52. {0, C1_16, C2_16, C3_16},
  53. {0, C5_9, C4_9, C6_9},
  54. {0, C5_16, C4_16, C6_16},
  55. {0, C9_9, C8_9, C7_9},
  56. {0, C9_10, C8_10, C7_10},
  57. {0, C9_11, C8_11, C7_11},
  58. {0, C9_12, C8_12, C7_12},
  59. {0, C9_13, C8_13, C7_13},
  60. {0, C9_14, C8_14, C7_14},
  61. {0, C9_15, C8_15, C6_14},
  62. {0, C9_16, C7_15, C6_15},
  63. // right CA
  64. {1, C1_1, C3_2, C4_2},
  65. {1, C1_2, C2_2, C4_3},
  66. {1, C1_3, C2_3, C3_3},
  67. {1, C1_4, C2_4, C3_4},
  68. {1, C1_5, C2_5, C3_5},
  69. {1, C1_6, C2_6, C3_6},
  70. {1, C1_7, C2_7, C3_7},
  71. {1, C1_8, C2_8, C3_8},
  72. //{1, C5_1, C4_1, C6_1},
  73. //{1, C5_8, C4_8, C6_8},
  74. {1, C9_1, C8_1, C7_1},
  75. {1, C9_2, C8_2, C7_2},
  76. {1, C9_3, C8_3, C7_3},
  77. {1, C9_4, C8_4, C7_4},
  78. {1, C9_5, C8_5, C7_5},
  79. {1, C9_6, C8_6, C7_6},
  80. {1, C9_7, C8_7, C6_6},
  81. {1, C9_8, C7_7, C6_7},
  82. // right CB
  83. {1, C1_9, C3_10, C4_10},
  84. {1, C1_10, C2_10, C4_11},
  85. {1, C1_11, C2_11, C3_11},
  86. {1, C1_12, C2_12, C3_12},
  87. {1, C1_13, C2_13, C3_13},
  88. //{1, C1_14, C2_14, C3_14},
  89. {1, C1_15, C2_15, C3_15},
  90. {1, C1_16, C2_16, C3_16},
  91. //{1, C5_9, C4_9, C6_9},
  92. //{1, C5_16, C4_16, C6_16},
  93. {1, C9_9, C8_9, C7_9},
  94. {1, C9_10, C8_10, C7_10},
  95. {1, C9_11, C8_11, C7_11},
  96. {1, C9_12, C8_12, C7_12},
  97. {1, C9_13, C8_13, C7_13},
  98. {1, C9_14, C8_14, C7_14},
  99. {1, C9_15, C8_15, C6_14},
  100. {1, C9_16, C7_15, C6_15},
  101. };
  102. led_config_t g_led_config = {
  103. {
  104. { 18, 19, 20, 21, 22, 23, 24, 16, 17, 36, 37, 38, 39, 40},
  105. { 26, 27, 28, 29, 30, 31, 25, 48, 41, 42, 43, 44, 45, 46},
  106. { 8, 7, 0, 32, 33, 34, 35, 49, 50, 51, 52, 53, NO_LED, 47},
  107. { 9, NO_LED, 10, 1, 2, 3, 4, 5, 56, 55, 57, 58, 59, 54},
  108. { 14, 13, 12, 11, NO_LED, NO_LED, 6, 15, NO_LED, NO_LED, 60, 61, 62, 63},
  109. },
  110. {
  111. { 48, 32},{ 48, 48},{ 64, 48},{ 80, 48},{ 96, 48},{112, 48},{112, 64},{ 32, 32},
  112. { 16, 32},{ 16, 48}, { 32, 48},{ 64, 64},{ 40, 64},{ 20, 64},{ 0, 64},
  113. { 0, 0},{ 16, 0},{ 32, 0},{ 48, 0},{ 64, 0},{ 80, 0},{ 96, 0},{ 96, 16},
  114. { 0, 16},{ 16, 16},
  115. { 32, 16},{ 48, 16},{ 64, 16},{ 80, 16},{ 64, 32},{ 80, 32},{ 96, 32},{112, 32},
  116. {112, 0},{128, 0},{144, 0},{160, 0},{176, 0},{192, 0},{208, 0},{224, 0},
  117. {128, 16},{144, 16},{160, 16},{176, 16},{192, 16},{216, 16},{216, 32},{112, 16},
  118. {128, 32},{144, 32},{160, 32},{176, 32},{192, 32}, {224, 48},{144, 48},
  119. {128, 48},{160, 48},{176, 48},{192, 48},{160, 64},{180, 64},{200, 64},{224, 64}
  120. },
  121. {
  122. 4, 4, 4, 4, 4, 4, 4, 4,
  123. 1, 1, 4, 1, 1, 1, 1,
  124. 1, 4, 4, 4, 4, 4, 4, 4,
  125. 1, 4,
  126. 4, 4, 4, 4, 4, 4, 4, 4,
  127. 4, 4, 4, 4, 4, 4, 1, 1,
  128. 4, 4, 4, 4, 4, 1, 1, 4,
  129. 4, 4, 4, 4, 4, 1, 4,
  130. 4, 4, 4, 1, 1, 1, 1, 1,
  131. }
  132. };
  133. __attribute__ ((weak))
  134. void rgb_matrix_indicators_user(void) {
  135. if (host_keyboard_led_state().caps_lock) {
  136. rgb_matrix_set_color(8, 0xFF, 0x0, 0x0);
  137. }
  138. }
  139. #endif //RGB_MATRIX_ENABLE
  140. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  141. if (record->event.pressed) {
  142. switch(keycode) {
  143. #if defined(RGB_MATRIX_DISABLE_KEYCODES)
  144. case RGB_MATRIX_TOGGLE: // toggle rgb matrix
  145. rgb_matrix_toggle();
  146. return false;
  147. case RGB_MATRIX_STEP:
  148. rgb_matrix_step();
  149. return false;
  150. case RGB_MATRIX_INC_HUE:
  151. rgb_matrix_increase_hue();
  152. return false;
  153. case RGB_MATRIX_DEC_HUE:
  154. rgb_matrix_decrease_hue();
  155. return false;
  156. case RGB_MATRIX_INC_SAT:
  157. rgb_matrix_increase_sat();
  158. return false;
  159. case RGB_MATRIX_DEC_SAT:
  160. rgb_matrix_decrease_sat();
  161. return false;
  162. case RGB_MATRIX_INC_VAL:
  163. rgb_matrix_increase_val();
  164. return false;
  165. case RGB_MATRIX_DEC_VAL:
  166. rgb_matrix_decrease_val();
  167. return false;
  168. #endif
  169. default:
  170. break;
  171. }
  172. }
  173. return true;
  174. }