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 12KB

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