KLL Compiler
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

kiibohdPixelmap.c 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. /* Copyright (C) 2016 by Jacob Alexander
  2. *
  3. * This file 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 3 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This file is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this file. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. <|Information|>
  17. // ----- Includes -----
  18. // Compiler Includes
  19. #include <stdint.h>
  20. // KLL Includes
  21. #include <kll_defs.h.new.h>
  22. // Project Includes
  23. #include <pixel.h>
  24. // TODO Generate properly
  25. #define ISSI_Chips_define 4
  26. #define LED_BufferLength 144
  27. typedef struct LED_Buffer {
  28. uint16_t i2c_addr;
  29. uint16_t reg_addr;
  30. uint16_t buffer[LED_BufferLength];
  31. } LED_Buffer;
  32. extern LED_Buffer LED_pageBuffer[ ISSI_Chips_define ];
  33. // Buffer list
  34. //#define Pixel_BuffersLen 4
  35. //#define Pixel_TotalChannels 576
  36. PixelBuf Pixel_Buffers[] = {
  37. PixelBufElem( LED_BufferLength, 16, 0, LED_pageBuffer[0].buffer ),
  38. PixelBufElem( LED_BufferLength, 16, 144, LED_pageBuffer[1].buffer ),
  39. PixelBufElem( LED_BufferLength, 16, 288, LED_pageBuffer[2].buffer ),
  40. PixelBufElem( LED_BufferLength, 16, 432, LED_pageBuffer[3].buffer ),
  41. };
  42. // Pixel Mapping
  43. //#define Pixel_TotalPixels 128 // TODO Generate
  44. const PixelElement Pixel_Mapping[] = {
  45. // Function Row (1-16)
  46. Pixel_RGBChannel(0,33,49), // 1
  47. Pixel_RGBChannel(1,17,50), // 2
  48. Pixel_RGBChannel(2,18,34), // 3
  49. Pixel_RGBChannel(3,19,35), // 4
  50. Pixel_RGBChannel(4,20,36), // 5
  51. Pixel_RGBChannel(5,21,37), // 6
  52. Pixel_RGBChannel(6,22,38), // 7
  53. Pixel_RGBChannel(7,23,39), // 8
  54. Pixel_RGBChannel(128,112,96), // 9
  55. Pixel_RGBChannel(129,113,97), // 10
  56. Pixel_RGBChannel(130,114,98), // 11
  57. Pixel_RGBChannel(131,115,99), // 12
  58. Pixel_RGBChannel(132,116,100), // 13
  59. Pixel_RGBChannel(133,117,101), // 14
  60. Pixel_RGBChannel(134,118,85), // 15
  61. Pixel_RGBChannel(135,102,86), // 16
  62. // Number Row (17-33)
  63. Pixel_RGBChannel(8,41,57), // 17
  64. Pixel_RGBChannel(9,25,58), // 18
  65. Pixel_RGBChannel(10,26,42), // 19
  66. Pixel_RGBChannel(11,27,43), // 20
  67. Pixel_RGBChannel(12,28,44), // 21
  68. Pixel_RGBChannel(13,29,45), // 22
  69. Pixel_RGBChannel(14,30,46), // 23
  70. Pixel_RGBChannel(15,31,47), // 24
  71. Pixel_RGBChannel(136,120,104), // 25
  72. Pixel_RGBChannel(137,121,105), // 26
  73. Pixel_RGBChannel(138,122,106), // 27
  74. Pixel_RGBChannel(139,123,107), // 28
  75. Pixel_RGBChannel(140,124,108), // 29
  76. Pixel_RGBChannel(141,125,109), // 30
  77. Pixel_RGBChannel(142,126,93), // 31
  78. Pixel_RGBChannel(143,110,94), // 32
  79. Pixel_RGBChannel(144,177,193), // 33
  80. // Top Alpha Row (34-50)
  81. Pixel_RGBChannel(145,161,194), // 34
  82. Pixel_RGBChannel(146,162,178), // 35
  83. Pixel_RGBChannel(147,163,179), // 36
  84. Pixel_RGBChannel(148,164,180), // 37
  85. Pixel_RGBChannel(149,165,181), // 38
  86. Pixel_RGBChannel(150,166,182), // 39
  87. Pixel_RGBChannel(151,167,183), // 40
  88. Pixel_RGBChannel(272,256,240), // 41
  89. Pixel_RGBChannel(273,257,241), // 42
  90. Pixel_RGBChannel(274,258,242), // 43
  91. Pixel_RGBChannel(275,259,243), // 44
  92. Pixel_RGBChannel(276,260,244), // 45
  93. Pixel_RGBChannel(277,261,245), // 46
  94. Pixel_RGBChannel(278,262,229), // 47
  95. Pixel_RGBChannel(279,246,230), // 48
  96. Pixel_RGBChannel(152,185,201), // 49
  97. Pixel_RGBChannel(153,169,202), // 50
  98. // Mid Alpha Row (51-63)
  99. Pixel_RGBChannel(154,170,186), // 51
  100. Pixel_RGBChannel(155,171,187), // 52
  101. Pixel_RGBChannel(156,172,188), // 53
  102. Pixel_RGBChannel(157,173,189), // 54
  103. Pixel_RGBChannel(158,174,190), // 55
  104. Pixel_RGBChannel(159,175,191), // 56
  105. Pixel_RGBChannel(280,264,248), // 57
  106. Pixel_RGBChannel(281,265,249), // 58
  107. Pixel_RGBChannel(282,266,250), // 59
  108. Pixel_RGBChannel(283,267,251), // 60
  109. Pixel_RGBChannel(284,268,252), // 61
  110. Pixel_RGBChannel(285,269,253), // 62
  111. Pixel_RGBChannel(286,270,237), // 63
  112. // Low Alpha Row (64-76)
  113. Pixel_RGBChannel(287,254,238), // 64
  114. Pixel_RGBChannel(288,321,337), // 65
  115. Pixel_RGBChannel(289,305,338), // 66
  116. Pixel_RGBChannel(290,306,322), // 67
  117. Pixel_RGBChannel(291,307,323), // 68
  118. Pixel_RGBChannel(292,308,324), // 69
  119. Pixel_RGBChannel(293,309,325), // 70
  120. Pixel_RGBChannel(294,310,326), // 71
  121. Pixel_RGBChannel(295,311,327), // 72
  122. Pixel_RGBChannel(416,400,384), // 73
  123. Pixel_RGBChannel(417,401,385), // 74
  124. Pixel_RGBChannel(418,402,386), // 75
  125. Pixel_RGBChannel(419,403,387), // 76
  126. // Mod Row (77-87)
  127. Pixel_RGBChannel(420,404,388), // 77
  128. Pixel_RGBChannel(421,405,389), // 78
  129. Pixel_RGBChannel(422,406,373), // 79
  130. Pixel_RGBChannel(423,390,374), // 80
  131. Pixel_RGBChannel(296,329,345), // 81
  132. Pixel_RGBChannel(297,313,346), // 82
  133. Pixel_RGBChannel(298,314,330), // 83
  134. Pixel_RGBChannel(299,315,331), // 84
  135. Pixel_RGBChannel(300,316,332), // 85
  136. Pixel_RGBChannel(301,317,333), // 86
  137. Pixel_RGBChannel(302,318,334), // 87
  138. // Unused Pixels
  139. Pixel_Blank(), // 88
  140. Pixel_Blank(), // 89
  141. Pixel_Blank(), // 90
  142. Pixel_Blank(), // 91
  143. Pixel_Blank(), // 92
  144. Pixel_Blank(), // 93
  145. Pixel_Blank(), // 94
  146. Pixel_Blank(), // 95
  147. Pixel_Blank(), // 96
  148. /* Prototype 1 - K-Type
  149. Pixel_RGBChannel(303,319,335), // 88
  150. Pixel_RGBChannel(424,408,392), // 89
  151. Pixel_RGBChannel(425,409,393), // 90
  152. Pixel_RGBChannel(426,410,394), // 91
  153. Pixel_RGBChannel(427,411,395), // 92
  154. Pixel_RGBChannel(428,412,396), // 93
  155. Pixel_RGBChannel(429,413,397), // 94
  156. Pixel_RGBChannel(430,414,381), // 95
  157. */
  158. // Underlighting
  159. Pixel_RGBChannel(432,465,481), // 97
  160. Pixel_RGBChannel(433,449,482), // 98
  161. Pixel_RGBChannel(434,450,466), // 99
  162. Pixel_RGBChannel(435,451,467), // 100
  163. Pixel_RGBChannel(436,452,468), // 101
  164. Pixel_RGBChannel(437,453,469), // 102
  165. Pixel_RGBChannel(438,454,470), // 103
  166. Pixel_RGBChannel(439,455,471), // 104
  167. Pixel_RGBChannel(560,544,528), // 105
  168. Pixel_RGBChannel(561,545,529), // 106
  169. Pixel_RGBChannel(562,546,530), // 107
  170. Pixel_RGBChannel(563,547,531), // 108
  171. Pixel_RGBChannel(564,548,532), // 109
  172. Pixel_RGBChannel(565,549,533), // 110
  173. Pixel_RGBChannel(566,550,517), // 111
  174. Pixel_RGBChannel(567,534,518), // 112
  175. Pixel_RGBChannel(440,473,489), // 113
  176. Pixel_RGBChannel(441,457,490), // 114
  177. Pixel_RGBChannel(442,458,474), // 115
  178. Pixel_RGBChannel(443,459,475), // 116
  179. Pixel_RGBChannel(444,460,476), // 117
  180. Pixel_RGBChannel(445,461,477), // 118
  181. Pixel_RGBChannel(446,462,478), // 119
  182. Pixel_RGBChannel(447,463,479), // 120
  183. Pixel_RGBChannel(568,552,536), // 121
  184. Pixel_RGBChannel(569,553,537), // 122
  185. Pixel_RGBChannel(570,554,538), // 123
  186. Pixel_RGBChannel(571,555,539), // 124
  187. Pixel_RGBChannel(572,556,540), // 125
  188. Pixel_RGBChannel(573,557,541), // 126
  189. Pixel_RGBChannel(574,558,525), // 127
  190. Pixel_RGBChannel(575,542,526), // 128
  191. };
  192. // Pixel Display Mapping
  193. // TODO This table should be generated based off the physical x,y,z positions of each of the pixels
  194. // TODO type should be determined by Pixel_TotalPixels
  195. // Notes:
  196. // - Single rows, we ignore the space between the F row and the Number row
  197. // - 0.5 key spacing between the columns, in the case where multiple leds should be in the column, one is shifted to the right
  198. //#define Pixel_DisplayMapping_Cols 38
  199. //#define Pixel_DisplayMapping_Rows 6
  200. const uint8_t Pixel_DisplayMapping[] = {
  201. 97, 1, 0, 98, 0, 2, 99, 3, 0, 4,100, 5, 0,101, 6,102, 7, 0, 8,103, 9,104, 0, 10,105, 11, 0, 12,106, 13, 0,107, 14,108, 15, 0, 16,109,
  202. 128, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, 0, 30, 0, 0, 0, 31, 0, 32, 0, 33,110,
  203. 127, 34, 0, 0, 35, 0, 36, 0, 37, 0, 38, 0, 39, 0, 40, 0, 41, 0, 42, 0, 43, 0, 44, 0, 45, 0, 46, 0, 0, 47, 0, 0, 48, 0, 49, 0, 50,111,
  204. 0, 0, 51, 0, 0, 52, 0, 53, 0, 54, 0, 55, 0, 56, 0, 57, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 0, 0, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  205. 126, 0, 64, 0, 0, 0, 65, 0, 66, 0, 67, 0, 68, 0, 69, 0, 70, 0, 71, 0, 72, 0, 73, 0, 74, 0, 0, 0, 75, 0, 0, 0, 0, 0, 76, 0, 0,112,
  206. 125, 77, 0,124, 78, 0, 79,123, 0,122, 0, 0, 0,121, 80, 0,120, 0, 0,119, 0, 81,118, 0, 82,117, 83, 0,116, 84, 0,115, 85,114, 86, 0, 87,113,
  207. };
  208. // Frame of led changes
  209. // const uint8_t <animation>_frame<num>[] = { PixelMod, ... }
  210. #define s2bs(n) (n & 0xFF), (n >> 8)
  211. #define w2bs(n) (n & 0xFF), (n & 0xFF00) >> 8, (n & 0xFF0000) >> 16, (n & 0xFF000000) >> 24
  212. #define Pixel_ModRGB(pixel,change,color) PixelAddressType_Index, w2bs(pixel), PixelChange_##change, color
  213. #define Pixel_ModRGBCol(col,change,color) PixelAddressType_ColumnFill, s2bs(col), s2bs(0), PixelChange_##change, color
  214. #define Pixel_ModRGB_(pixel,change,r,g,b) PixelAddressType_Index, w2bs(pixel), PixelChange_##change, r, g, b
  215. const uint8_t testani_frame0[] = {
  216. Pixel_ModRGB_(0, Set, 30, 70, 120),
  217. PixelAddressType_End,
  218. };
  219. const uint8_t testani_frame1[] = {
  220. Pixel_ModRGB_(0, Set, 0, 0, 0),
  221. PixelAddressType_End,
  222. };
  223. const uint8_t testani_frame2[] = {
  224. Pixel_ModRGB_(0, Set, 60, 90, 140),
  225. PixelAddressType_End,
  226. };
  227. // Temp convenience colours
  228. #define RGB_HalfRed 127,0,0
  229. #define RGB_Red 255,0,0
  230. #define RGB_RedOrange 255,64,0
  231. #define RGB_Orange 255,127,0
  232. #define RGB_OrangeYellow 255,191,0
  233. #define RGB_Yellow 255,255,0
  234. #define RGB_YellowGreen 127,255,0
  235. #define RGB_Green 0,255,0
  236. #define RGB_GreenBlue 0,127,127
  237. #define RGB_Blue 0,0,255
  238. #define RGB_BlueIndigo 38,0,193
  239. #define RGB_Indigo 75,0,130
  240. #define RGB_IndigoViolet 101,0,193
  241. #define RGB_Violet 127,0,255
  242. #define RGB_HalfViolet 64,0,127
  243. #define RGB_White 255,255,255
  244. #define RGB_Black 0,0,0
  245. const uint8_t rainbow_inter_frame0[] = {
  246. Pixel_ModRGBCol(0, Set, RGB_Green),
  247. Pixel_ModRGBCol(9, Set, RGB_Yellow),
  248. Pixel_ModRGBCol(19, Set, RGB_Red),
  249. Pixel_ModRGBCol(28, Set, RGB_Violet),
  250. Pixel_ModRGBCol(37, Set, RGB_Blue),
  251. 0,
  252. };
  253. // Index of frames for animations
  254. // uint8_t *<animation>_frames[] = { <animation>_frame<num>, ... }
  255. const uint8_t *testani_frames[] = {
  256. testani_frame0,
  257. testani_frame1,
  258. testani_frame2,
  259. 0,
  260. };
  261. // Rainbox (interpolation) frame index
  262. const uint8_t *rainbow_inter_frames[] = {
  263. rainbow_inter_frame0,
  264. 0,
  265. };
  266. // Index of animations
  267. // uint8_t *Pixel_Animations[] = { <animation>_frames, ... }
  268. const uint8_t **Pixel_Animations[] = {
  269. testani_frames,
  270. rainbow_inter_frames,
  271. };