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.

266 lines
7.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. /*
  2. Copyright 2018 Jack Humbert <jack.humb@gmail.com>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include "moonlander.h"
  15. bool mcp23018_leds[3] = {0, 0, 0};
  16. void matrix_init_kb(void) {
  17. setPinOutput(B5);
  18. setPinOutput(B4);
  19. setPinOutput(B3);
  20. writePinLow(B5);
  21. writePinLow(B4);
  22. writePinLow(B3);
  23. mcp23018_leds[0] = 0; // blue
  24. mcp23018_leds[1] = 0; // green
  25. mcp23018_leds[2] = 0; // red
  26. eeconfig_init();
  27. }
  28. void matrix_scan_kb(void) {
  29. }
  30. uint32_t layer_state_set_kb(uint32_t state) {
  31. ML_LED_1(0);
  32. ML_LED_2(0);
  33. ML_LED_3(0);
  34. ML_LED_4(0);
  35. ML_LED_5(0);
  36. ML_LED_6(0);
  37. uint8_t layer = biton32(state);
  38. switch (layer) {
  39. case 0:
  40. break;
  41. case 1:
  42. ML_LED_1(1);
  43. ML_LED_4(1);
  44. break;
  45. case 2:
  46. ML_LED_2(1);
  47. ML_LED_5(1);
  48. break;
  49. case 3:
  50. ML_LED_3(1);
  51. break;
  52. case 4:
  53. ML_LED_4(1);
  54. break;
  55. case 5:
  56. ML_LED_5(1);
  57. break;
  58. case 6:
  59. ML_LED_6(1);
  60. break;
  61. default:
  62. break;
  63. }
  64. return state;
  65. }
  66. const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
  67. /* Refer to IS31 manual for these locations
  68. * driver
  69. * | R location
  70. * | | G location
  71. * | | | B location
  72. * | | | | */
  73. {0, C3_2, C1_1, C4_2}, // 1
  74. {0, C2_2, C1_2, C4_3},
  75. {0, C2_3, C1_3, C3_3},
  76. {0, C2_4, C1_4, C3_4},
  77. {0, C2_5, C1_5, C3_5},
  78. {0, C2_6, C1_6, C3_6},
  79. {0, C2_7, C1_7, C3_7},
  80. {0, C2_8, C1_8, C3_8},
  81. {0, C3_1, C2_1, C4_1},
  82. {0, C7_8, C6_8, C8_8}, // 10
  83. {0, C7_7, C6_7, C9_8},
  84. {0, C8_7, C6_6, C9_7},
  85. {0, C8_6, C7_6, C9_6},
  86. {0, C8_5, C7_5, C9_5},
  87. {0, C8_4, C7_4, C9_4},
  88. {0, C8_3, C7_3, C9_3},
  89. {0, C8_2, C7_2, C9_2},
  90. {0, C8_1, C7_1, C9_1},
  91. {0, C3_10, C1_9, C4_10}, // 19
  92. {0, C2_10, C1_10, C4_11},
  93. {0, C2_11, C1_11, C3_11},
  94. {0, C2_12, C1_12, C3_12},
  95. {0, C2_13, C1_13, C3_13},
  96. {0, C2_14, C1_14, C3_14},
  97. {0, C2_15, C1_15, C3_15},
  98. {0, C2_16, C1_16, C3_16},
  99. {0, C3_9, C2_9, C4_9},
  100. {0, C7_16, C6_16, C8_16}, // 28
  101. {0, C7_15, C6_15, C9_16},
  102. {0, C8_15, C6_14, C9_15},
  103. {0, C8_10, C7_10, C9_10},
  104. {0, C8_9, C7_9, C9_9},
  105. {0, C8_11, C7_11, C9_11},
  106. {0, C8_12, C7_12, C9_12},
  107. {0, C8_13, C7_13, C9_13},
  108. // {0, C8_14, C7_14, C9_4}
  109. {1, C3_2, C1_1, C4_2}, // 1
  110. {1, C2_2, C1_2, C4_3},
  111. {1, C2_3, C1_3, C3_3},
  112. {1, C2_4, C1_4, C3_4},
  113. {1, C2_5, C1_5, C3_5},
  114. {1, C2_6, C1_6, C3_6},
  115. {1, C2_7, C1_7, C3_7},
  116. {1, C2_8, C1_8, C3_8},
  117. {1, C3_1, C2_1, C4_1},
  118. {1, C7_8, C6_8, C8_8}, // 10
  119. {1, C7_7, C6_7, C9_8},
  120. {1, C8_7, C6_6, C9_7},
  121. {1, C8_6, C7_6, C9_6},
  122. {1, C8_5, C7_5, C9_5},
  123. {1, C8_4, C7_4, C9_4},
  124. {1, C8_3, C7_3, C9_3},
  125. {1, C8_2, C7_2, C9_2},
  126. {1, C8_1, C7_1, C9_1},
  127. {1, C3_10, C1_9, C4_10}, // 19
  128. {1, C2_10, C1_10, C4_11},
  129. {1, C2_11, C1_11, C3_11},
  130. {1, C2_12, C1_12, C3_12},
  131. {1, C2_13, C1_13, C3_13},
  132. {1, C2_14, C1_14, C3_14},
  133. {1, C2_15, C1_15, C3_15},
  134. {1, C2_16, C1_16, C3_16},
  135. {1, C3_9, C2_9, C4_9},
  136. {1, C7_16, C6_16, C8_16}, // 28
  137. {1, C7_15, C6_15, C9_16},
  138. {1, C8_15, C6_14, C9_15},
  139. {1, C8_10, C7_10, C9_10},
  140. {1, C8_9, C7_9, C9_9},
  141. {1, C8_11, C7_11, C9_11},
  142. {1, C8_12, C7_12, C9_12},
  143. {1, C8_13, C7_13, C9_13},
  144. };
  145. rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
  146. /*{row | col << 4}
  147. | {x=0..224, y=0..64}
  148. | | modifier
  149. | | | */
  150. {{0|(0<<4)}, {17.23*0, 21.33*0}, 1},
  151. {{1|(0<<4)}, {17.23*0, 21.33*1}, 4},
  152. {{2|(0<<4)}, {17.23*0, 21.33*2}, 4},
  153. {{3|(0<<4)}, {17.23*0, 21.33*3}, 4},
  154. {{4|(0<<4)}, {17.23*0, 21.33*4}, 4},
  155. {{0|(1<<4)}, {17.23*1, 21.33*0}, 4},
  156. {{1|(1<<4)}, {17.23*1, 21.33*1}, 4},
  157. {{2|(1<<4)}, {17.23*1, 21.33*2}, 4},
  158. {{3|(1<<4)}, {17.23*1, 21.33*3}, 4},
  159. {{4|(1<<4)}, {17.23*1, 21.33*4}, 4},
  160. {{0|(2<<4)}, {17.23*2, 21.33*0}, 4},
  161. {{1|(2<<4)}, {17.23*2, 21.33*1}, 4},
  162. {{2|(2<<4)}, {17.23*2, 21.33*2}, 4},
  163. {{3|(2<<4)}, {17.23*2, 21.33*3}, 4},
  164. {{4|(2<<4)}, {17.23*2, 21.33*4}, 4},
  165. {{0|(3<<4)}, {17.23*3, 21.33*0}, 4},
  166. {{1|(3<<4)}, {17.23*3, 21.33*1}, 4},
  167. {{2|(3<<4)}, {17.23*3, 21.33*2}, 4},
  168. {{3|(3<<4)}, {17.23*3, 21.33*3}, 4},
  169. {{4|(3<<4)}, {17.23*3, 21.33*4}, 4},
  170. {{0|(4<<4)}, {17.23*4, 21.33*0}, 4},
  171. {{1|(4<<4)}, {17.23*4, 21.33*1}, 4},
  172. {{2|(4<<4)}, {17.23*4, 21.33*2}, 4},
  173. {{3|(4<<4)}, {17.23*4, 21.33*3}, 4},
  174. {{4|(4<<4)}, {17.23*4, 21.33*4}, 4},
  175. {{0|(5<<4)}, {17.23*5, 21.33*0}, 4},
  176. {{1|(5<<4)}, {17.23*5, 21.33*1}, 4},
  177. {{2|(5<<4)}, {17.23*5, 21.33*2}, 4},
  178. {{3|(5<<4)}, {17.23*5, 21.33*3}, 4},
  179. {{0|(6<<4)}, {17.23*6, 21.33*0}, 4},
  180. {{1|(6<<4)}, {17.23*6, 21.33*1}, 4},
  181. {{2|(6<<4)}, {17.23*6, 21.33*2}, 4},
  182. // cluster
  183. {{5|(0<<4)}, {17.23*5.5, 21.33*4}, 4},
  184. {{5|(1<<4)}, {17.23*6.0, 21.33*5}, 4},
  185. {{5|(2<<4)}, {17.23*6.5, 21.33*6}, 4},
  186. {{0|(0<<4)}, {17.23*13, 21.33*0}, 1},
  187. {{1|(0<<4)}, {17.23*13, 21.33*1}, 4},
  188. {{2|(0<<4)}, {17.23*13, 21.33*2}, 4},
  189. {{3|(0<<4)}, {17.23*13, 21.33*3}, 4},
  190. {{4|(0<<4)}, {17.23*13, 21.33*4}, 4},
  191. {{0|(1<<4)}, {17.23*12, 21.33*0}, 4},
  192. {{1|(1<<4)}, {17.23*12, 21.33*1}, 4},
  193. {{2|(1<<4)}, {17.23*12, 21.33*2}, 4},
  194. {{3|(1<<4)}, {17.23*12, 21.33*3}, 4},
  195. {{4|(1<<4)}, {17.23*12, 21.33*4}, 4},
  196. {{0|(2<<4)}, {17.23*11, 21.33*0}, 4},
  197. {{1|(2<<4)}, {17.23*11, 21.33*1}, 4},
  198. {{2|(2<<4)}, {17.23*11, 21.33*2}, 4},
  199. {{3|(2<<4)}, {17.23*11, 21.33*3}, 4},
  200. {{4|(2<<4)}, {17.23*11, 21.33*4}, 4},
  201. {{0|(3<<4)}, {17.23*10, 21.33*0}, 4},
  202. {{1|(3<<4)}, {17.23*10, 21.33*1}, 4},
  203. {{2|(3<<4)}, {17.23*10, 21.33*2}, 4},
  204. {{3|(3<<4)}, {17.23*10, 21.33*3}, 4},
  205. {{4|(3<<4)}, {17.23*10, 21.33*4}, 4},
  206. {{0|(4<<4)}, {17.23*9, 21.33*0}, 4},
  207. {{1|(4<<4)}, {17.23*9, 21.33*1}, 4},
  208. {{2|(4<<4)}, {17.23*9, 21.33*2}, 4},
  209. {{3|(4<<4)}, {17.23*9, 21.33*3}, 4},
  210. {{4|(4<<4)}, {17.23*9, 21.33*4}, 4},
  211. {{0|(5<<4)}, {17.23*8, 21.33*0}, 4},
  212. {{1|(5<<4)}, {17.23*8, 21.33*1}, 4},
  213. {{2|(5<<4)}, {17.23*8, 21.33*2}, 4},
  214. {{3|(5<<4)}, {17.23*8, 21.33*3}, 4},
  215. {{0|(6<<4)}, {17.23*7, 21.33*0}, 4},
  216. {{1|(6<<4)}, {17.23*7, 21.33*1}, 4},
  217. {{2|(6<<4)}, {17.23*7, 21.33*2}, 4},
  218. // cluster
  219. {{5|(0<<4)}, {17.23*7.5, 21.33*4}, 4},
  220. {{5|(1<<4)}, {17.23*7.0, 21.33*5}, 4},
  221. {{5|(2<<4)}, {17.23*6.5, 21.33*6}, 4},
  222. };