logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

aw20216s.h (6944B)


  1. /* Copyright 2021 Jasper Chan (Gigahawk)
  2. *
  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. *
  8. * This program 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 program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. #include <stdint.h>
  18. #include <stdbool.h>
  19. #include "progmem.h"
  20. #include "gpio.h"
  21. #include "util.h"
  22. #define AW20216S_ID (0b1010 << 4)
  23. #define AW20216S_WRITE 0
  24. #define AW20216S_READ 1
  25. #define AW20216S_PAGE_FUNCTION (0x00 << 1)
  26. #define AW20216S_PAGE_PWM (0x01 << 1)
  27. #define AW20216S_PAGE_SCALING (0x02 << 1)
  28. #define AW20216S_PAGE_PATTERN_CHOICE (0x03 << 1)
  29. #define AW20216S_PAGE_PWM_SCALING (0x04 << 1)
  30. #define AW20216S_FUNCTION_REG_CONFIGURATION 0x00
  31. #define AW20216S_CONFIGURATION_SWSEL_1_12 (0b1011 << 4)
  32. #define AW20216S_CONFIGURATION_CHIPEN (0b1 << 0)
  33. #define AW20216S_FUNCTION_REG_GLOBAL_CURRENT 0x01
  34. #define AW20216S_FUNCTION_REG_RESET 0x2F
  35. #define AW20216S_RESET_MAGIC 0xAE
  36. #define AW20216S_FUNCTION_REG_MIX_FUNCTION 0x46
  37. #define AW20216S_MIX_FUNCTION_LPEN (0b1 << 1)
  38. #if defined(RGB_MATRIX_AW20216S)
  39. # define AW20216S_LED_COUNT RGB_MATRIX_LED_COUNT
  40. #endif
  41. #if defined(AW20216S_CS_PIN_2)
  42. # define AW20216S_DRIVER_COUNT 2
  43. #elif defined(AW20216S_CS_PIN_1)
  44. # define AW20216S_DRIVER_COUNT 1
  45. #endif
  46. typedef struct aw20216s_led_t {
  47. uint8_t driver : 2;
  48. uint8_t r;
  49. uint8_t g;
  50. uint8_t b;
  51. } PACKED aw20216s_led_t;
  52. extern const aw20216s_led_t PROGMEM g_aw20216s_leds[AW20216S_LED_COUNT];
  53. void aw20216s_init_drivers(void);
  54. void aw20216s_init(pin_t cs_pin);
  55. void aw20216s_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
  56. void aw20216s_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
  57. void aw20216s_update_pwm_buffers(pin_t cs_pin, uint8_t index);
  58. void aw20216s_flush(void);
  59. #define SW1_CS1 0x00
  60. #define SW1_CS2 0x01
  61. #define SW1_CS3 0x02
  62. #define SW1_CS4 0x03
  63. #define SW1_CS5 0x04
  64. #define SW1_CS6 0x05
  65. #define SW1_CS7 0x06
  66. #define SW1_CS8 0x07
  67. #define SW1_CS9 0x08
  68. #define SW1_CS10 0x09
  69. #define SW1_CS11 0x0A
  70. #define SW1_CS12 0x0B
  71. #define SW1_CS13 0x0C
  72. #define SW1_CS14 0x0D
  73. #define SW1_CS15 0x0E
  74. #define SW1_CS16 0x0F
  75. #define SW1_CS17 0x10
  76. #define SW1_CS18 0x11
  77. #define SW2_CS1 0x12
  78. #define SW2_CS2 0x13
  79. #define SW2_CS3 0x14
  80. #define SW2_CS4 0x15
  81. #define SW2_CS5 0x16
  82. #define SW2_CS6 0x17
  83. #define SW2_CS7 0x18
  84. #define SW2_CS8 0x19
  85. #define SW2_CS9 0x1A
  86. #define SW2_CS10 0x1B
  87. #define SW2_CS11 0x1C
  88. #define SW2_CS12 0x1D
  89. #define SW2_CS13 0x1E
  90. #define SW2_CS14 0x1F
  91. #define SW2_CS15 0x20
  92. #define SW2_CS16 0x21
  93. #define SW2_CS17 0x22
  94. #define SW2_CS18 0x23
  95. #define SW3_CS1 0x24
  96. #define SW3_CS2 0x25
  97. #define SW3_CS3 0x26
  98. #define SW3_CS4 0x27
  99. #define SW3_CS5 0x28
  100. #define SW3_CS6 0x29
  101. #define SW3_CS7 0x2A
  102. #define SW3_CS8 0x2B
  103. #define SW3_CS9 0x2C
  104. #define SW3_CS10 0x2D
  105. #define SW3_CS11 0x2E
  106. #define SW3_CS12 0x2F
  107. #define SW3_CS13 0x30
  108. #define SW3_CS14 0x31
  109. #define SW3_CS15 0x32
  110. #define SW3_CS16 0x33
  111. #define SW3_CS17 0x34
  112. #define SW3_CS18 0x35
  113. #define SW4_CS1 0x36
  114. #define SW4_CS2 0x37
  115. #define SW4_CS3 0x38
  116. #define SW4_CS4 0x39
  117. #define SW4_CS5 0x3A
  118. #define SW4_CS6 0x3B
  119. #define SW4_CS7 0x3C
  120. #define SW4_CS8 0x3D
  121. #define SW4_CS9 0x3E
  122. #define SW4_CS10 0x3F
  123. #define SW4_CS11 0x40
  124. #define SW4_CS12 0x41
  125. #define SW4_CS13 0x42
  126. #define SW4_CS14 0x43
  127. #define SW4_CS15 0x44
  128. #define SW4_CS16 0x45
  129. #define SW4_CS17 0x46
  130. #define SW4_CS18 0x47
  131. #define SW5_CS1 0x48
  132. #define SW5_CS2 0x49
  133. #define SW5_CS3 0x4A
  134. #define SW5_CS4 0x4B
  135. #define SW5_CS5 0x4C
  136. #define SW5_CS6 0x4D
  137. #define SW5_CS7 0x4E
  138. #define SW5_CS8 0x4F
  139. #define SW5_CS9 0x50
  140. #define SW5_CS10 0x51
  141. #define SW5_CS11 0x52
  142. #define SW5_CS12 0x53
  143. #define SW5_CS13 0x54
  144. #define SW5_CS14 0x55
  145. #define SW5_CS15 0x56
  146. #define SW5_CS16 0x57
  147. #define SW5_CS17 0x58
  148. #define SW5_CS18 0x59
  149. #define SW6_CS1 0x5A
  150. #define SW6_CS2 0x5B
  151. #define SW6_CS3 0x5C
  152. #define SW6_CS4 0x5D
  153. #define SW6_CS5 0x5E
  154. #define SW6_CS6 0x5F
  155. #define SW6_CS7 0x60
  156. #define SW6_CS8 0x61
  157. #define SW6_CS9 0x62
  158. #define SW6_CS10 0x63
  159. #define SW6_CS11 0x64
  160. #define SW6_CS12 0x65
  161. #define SW6_CS13 0x66
  162. #define SW6_CS14 0x67
  163. #define SW6_CS15 0x68
  164. #define SW6_CS16 0x69
  165. #define SW6_CS17 0x6A
  166. #define SW6_CS18 0x6B
  167. #define SW7_CS1 0x6C
  168. #define SW7_CS2 0x6D
  169. #define SW7_CS3 0x6E
  170. #define SW7_CS4 0x6F
  171. #define SW7_CS5 0x70
  172. #define SW7_CS6 0x71
  173. #define SW7_CS7 0x72
  174. #define SW7_CS8 0x73
  175. #define SW7_CS9 0x74
  176. #define SW7_CS10 0x75
  177. #define SW7_CS11 0x76
  178. #define SW7_CS12 0x77
  179. #define SW7_CS13 0x78
  180. #define SW7_CS14 0x79
  181. #define SW7_CS15 0x7A
  182. #define SW7_CS16 0x7B
  183. #define SW7_CS17 0x7C
  184. #define SW7_CS18 0x7D
  185. #define SW8_CS1 0x7E
  186. #define SW8_CS2 0x7F
  187. #define SW8_CS3 0x80
  188. #define SW8_CS4 0x81
  189. #define SW8_CS5 0x82
  190. #define SW8_CS6 0x83
  191. #define SW8_CS7 0x84
  192. #define SW8_CS8 0x85
  193. #define SW8_CS9 0x86
  194. #define SW8_CS10 0x87
  195. #define SW8_CS11 0x88
  196. #define SW8_CS12 0x89
  197. #define SW8_CS13 0x8A
  198. #define SW8_CS14 0x8B
  199. #define SW8_CS15 0x8C
  200. #define SW8_CS16 0x8D
  201. #define SW8_CS17 0x8E
  202. #define SW8_CS18 0x8F
  203. #define SW9_CS1 0x90
  204. #define SW9_CS2 0x91
  205. #define SW9_CS3 0x92
  206. #define SW9_CS4 0x93
  207. #define SW9_CS5 0x94
  208. #define SW9_CS6 0x95
  209. #define SW9_CS7 0x96
  210. #define SW9_CS8 0x97
  211. #define SW9_CS9 0x98
  212. #define SW9_CS10 0x99
  213. #define SW9_CS11 0x9A
  214. #define SW9_CS12 0x9B
  215. #define SW9_CS13 0x9C
  216. #define SW9_CS14 0x9D
  217. #define SW9_CS15 0x9E
  218. #define SW9_CS16 0x9F
  219. #define SW9_CS17 0xA0
  220. #define SW9_CS18 0xA1
  221. #define SW10_CS1 0xA2
  222. #define SW10_CS2 0xA3
  223. #define SW10_CS3 0xA4
  224. #define SW10_CS4 0xA5
  225. #define SW10_CS5 0xA6
  226. #define SW10_CS6 0xA7
  227. #define SW10_CS7 0xA8
  228. #define SW10_CS8 0xA9
  229. #define SW10_CS9 0xAA
  230. #define SW10_CS10 0xAB
  231. #define SW10_CS11 0xAC
  232. #define SW10_CS12 0xAD
  233. #define SW10_CS13 0xAE
  234. #define SW10_CS14 0xAF
  235. #define SW10_CS15 0xB0
  236. #define SW10_CS16 0xB1
  237. #define SW10_CS17 0xB2
  238. #define SW10_CS18 0xB3
  239. #define SW11_CS1 0xB4
  240. #define SW11_CS2 0xB5
  241. #define SW11_CS3 0xB6
  242. #define SW11_CS4 0xB7
  243. #define SW11_CS5 0xB8
  244. #define SW11_CS6 0xB9
  245. #define SW11_CS7 0xBA
  246. #define SW11_CS8 0xBB
  247. #define SW11_CS9 0xBC
  248. #define SW11_CS10 0xBD
  249. #define SW11_CS11 0xBE
  250. #define SW11_CS12 0xBF
  251. #define SW11_CS13 0xC0
  252. #define SW11_CS14 0xC1
  253. #define SW11_CS15 0xC2
  254. #define SW11_CS16 0xC3
  255. #define SW11_CS17 0xC4
  256. #define SW11_CS18 0xC5
  257. #define SW12_CS1 0xC6
  258. #define SW12_CS2 0xC7
  259. #define SW12_CS3 0xC8
  260. #define SW12_CS4 0xC9
  261. #define SW12_CS5 0xCA
  262. #define SW12_CS6 0xCB
  263. #define SW12_CS7 0xCC
  264. #define SW12_CS8 0xCD
  265. #define SW12_CS9 0xCE
  266. #define SW12_CS10 0xCF
  267. #define SW12_CS11 0xD0
  268. #define SW12_CS12 0xD1
  269. #define SW12_CS13 0xD2
  270. #define SW12_CS14 0xD3
  271. #define SW12_CS15 0xD4
  272. #define SW12_CS16 0xD5
  273. #define SW12_CS17 0xD6
  274. #define SW12_CS18 0xD7