logo

qmk_firmware

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

is31fl3731-mono.h (6008B)


  1. /* Copyright 2017 Jason Williams
  2. * Copyright 2018 Jack Humbert
  3. * Copyright 2019 Clueboard
  4. *
  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. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #pragma once
  19. #include <stdint.h>
  20. #include <stdbool.h>
  21. #include "progmem.h"
  22. #include "util.h"
  23. #define IS31FL3731_REG_COMMAND 0xFD
  24. #define IS31FL3731_COMMAND_FRAME_1 0x00
  25. #define IS31FL3731_COMMAND_FRAME_2 0x01
  26. #define IS31FL3731_COMMAND_FRAME_3 0x02
  27. #define IS31FL3731_COMMAND_FRAME_4 0x03
  28. #define IS31FL3731_COMMAND_FRAME_5 0x04
  29. #define IS31FL3731_COMMAND_FRAME_6 0x05
  30. #define IS31FL3731_COMMAND_FRAME_7 0x06
  31. #define IS31FL3731_COMMAND_FRAME_8 0x07
  32. #define IS31FL3731_COMMAND_FUNCTION 0x0B
  33. #define IS31FL3731_FRAME_REG_LED_CONTROL 0x00
  34. #define IS31FL3731_FRAME_REG_BLINK_CONTROL 0x12
  35. #define IS31FL3731_FRAME_REG_PWM 0x24
  36. #define IS31FL3731_FUNCTION_REG_CONFIG 0x00
  37. #define IS31FL3731_CONFIG_MODE_PICTURE 0x00
  38. #define IS31FL3731_CONFIG_MODE_AUTO_PLAY 0x08
  39. #define IS31FL3731_CONFIG_MODE_AUDIO_PLAY 0x18
  40. #define IS31FL3731_FUNCTION_REG_PICTURE_DISPLAY 0x01
  41. #define IS31FL3731_FUNCTION_REG_AUDIO_SYNC 0x06
  42. #define IS31FL3731_FUNCTION_REG_SHUTDOWN 0x0A
  43. // Not defined in the datasheet -- See AN for IC
  44. #define IS31FL3731_FUNCTION_REG_GHOST_IMAGE_PREVENTION 0xC2
  45. #define IS31FL3731_GHOST_IMAGE_PREVENTION_GEN 0x10
  46. #define IS31FL3731_I2C_ADDRESS_GND 0x74
  47. #define IS31FL3731_I2C_ADDRESS_SCL 0x75
  48. #define IS31FL3731_I2C_ADDRESS_SDA 0x76
  49. #define IS31FL3731_I2C_ADDRESS_VCC 0x77
  50. #if defined(LED_MATRIX_IS31FL3731)
  51. # define IS31FL3731_LED_COUNT LED_MATRIX_LED_COUNT
  52. #endif
  53. #if defined IS31FL3731_I2C_ADDRESS_4
  54. # define IS31FL3731_DRIVER_COUNT 4
  55. #elif defined IS31FL3731_I2C_ADDRESS_3
  56. # define IS31FL3731_DRIVER_COUNT 3
  57. #elif defined IS31FL3731_I2C_ADDRESS_2
  58. # define IS31FL3731_DRIVER_COUNT 2
  59. #elif defined IS31FL3731_I2C_ADDRESS_1
  60. # define IS31FL3731_DRIVER_COUNT 1
  61. #endif
  62. typedef struct is31fl3731_led_t {
  63. uint8_t driver : 2;
  64. uint8_t v;
  65. } PACKED is31fl3731_led_t;
  66. extern const is31fl3731_led_t PROGMEM g_is31fl3731_leds[IS31FL3731_LED_COUNT];
  67. void is31fl3731_init_drivers(void);
  68. void is31fl3731_init(uint8_t index);
  69. void is31fl3731_write_register(uint8_t index, uint8_t reg, uint8_t data);
  70. void is31fl3731_select_page(uint8_t index, uint8_t page);
  71. void is31fl3731_set_value(int index, uint8_t value);
  72. void is31fl3731_set_value_all(uint8_t value);
  73. void is31fl3731_set_led_control_register(uint8_t index, bool value);
  74. // This should not be called from an interrupt
  75. // (eg. from a timer interrupt).
  76. // Call this while idle (in between matrix scans).
  77. // If the buffer is dirty, it will update the driver with the buffer.
  78. void is31fl3731_update_pwm_buffers(uint8_t index);
  79. void is31fl3731_update_led_control_registers(uint8_t index);
  80. void is31fl3731_flush(void);
  81. #define C1_1 0x00
  82. #define C1_2 0x01
  83. #define C1_3 0x02
  84. #define C1_4 0x03
  85. #define C1_5 0x04
  86. #define C1_6 0x05
  87. #define C1_7 0x06
  88. #define C1_8 0x07
  89. #define C1_9 0x08
  90. #define C1_10 0x09
  91. #define C1_11 0x0A
  92. #define C1_12 0x0B
  93. #define C1_13 0x0C
  94. #define C1_14 0x0D
  95. #define C1_15 0x0E
  96. #define C1_16 0x0F
  97. #define C2_1 0x10
  98. #define C2_2 0x11
  99. #define C2_3 0x12
  100. #define C2_4 0x13
  101. #define C2_5 0x14
  102. #define C2_6 0x15
  103. #define C2_7 0x16
  104. #define C2_8 0x17
  105. #define C2_9 0x18
  106. #define C2_10 0x19
  107. #define C2_11 0x1A
  108. #define C2_12 0x1B
  109. #define C2_13 0x1C
  110. #define C2_14 0x1D
  111. #define C2_15 0x1E
  112. #define C2_16 0x1F
  113. #define C3_1 0x20
  114. #define C3_2 0x21
  115. #define C3_3 0x22
  116. #define C3_4 0x23
  117. #define C3_5 0x24
  118. #define C3_6 0x25
  119. #define C3_7 0x26
  120. #define C3_8 0x27
  121. #define C3_9 0x28
  122. #define C3_10 0x29
  123. #define C3_11 0x2A
  124. #define C3_12 0x2B
  125. #define C3_13 0x2C
  126. #define C3_14 0x2D
  127. #define C3_15 0x2E
  128. #define C3_16 0x2F
  129. #define C4_1 0x30
  130. #define C4_2 0x31
  131. #define C4_3 0x32
  132. #define C4_4 0x33
  133. #define C4_5 0x34
  134. #define C4_6 0x35
  135. #define C4_7 0x36
  136. #define C4_8 0x37
  137. #define C4_9 0x38
  138. #define C4_10 0x39
  139. #define C4_11 0x3A
  140. #define C4_12 0x3B
  141. #define C4_13 0x3C
  142. #define C4_14 0x3D
  143. #define C4_15 0x3E
  144. #define C4_16 0x3F
  145. #define C5_1 0x40
  146. #define C5_2 0x41
  147. #define C5_3 0x42
  148. #define C5_4 0x43
  149. #define C5_5 0x44
  150. #define C5_6 0x45
  151. #define C5_7 0x46
  152. #define C5_8 0x47
  153. #define C5_9 0x48
  154. #define C5_10 0x49
  155. #define C5_11 0x4A
  156. #define C5_12 0x4B
  157. #define C5_13 0x4C
  158. #define C5_14 0x4D
  159. #define C5_15 0x4E
  160. #define C5_16 0x4F
  161. #define C6_1 0x50
  162. #define C6_2 0x51
  163. #define C6_3 0x52
  164. #define C6_4 0x53
  165. #define C6_5 0x54
  166. #define C6_6 0x55
  167. #define C6_7 0x56
  168. #define C6_8 0x57
  169. #define C6_9 0x58
  170. #define C6_10 0x59
  171. #define C6_11 0x5A
  172. #define C6_12 0x5B
  173. #define C6_13 0x5C
  174. #define C6_14 0x5D
  175. #define C6_15 0x5E
  176. #define C6_16 0x5F
  177. #define C7_1 0x60
  178. #define C7_2 0x61
  179. #define C7_3 0x62
  180. #define C7_4 0x63
  181. #define C7_5 0x64
  182. #define C7_6 0x65
  183. #define C7_7 0x66
  184. #define C7_8 0x67
  185. #define C7_9 0x68
  186. #define C7_10 0x69
  187. #define C7_11 0x6A
  188. #define C7_12 0x6B
  189. #define C7_13 0x6C
  190. #define C7_14 0x6D
  191. #define C7_15 0x6E
  192. #define C7_16 0x6F
  193. #define C8_1 0x70
  194. #define C8_2 0x71
  195. #define C8_3 0x72
  196. #define C8_4 0x73
  197. #define C8_5 0x74
  198. #define C8_6 0x75
  199. #define C8_7 0x76
  200. #define C8_8 0x77
  201. #define C8_9 0x78
  202. #define C8_10 0x79
  203. #define C8_11 0x7A
  204. #define C8_12 0x7B
  205. #define C8_13 0x7C
  206. #define C8_14 0x7D
  207. #define C8_15 0x7E
  208. #define C8_16 0x7F
  209. #define C9_1 0x80
  210. #define C9_2 0x81
  211. #define C9_3 0x82
  212. #define C9_4 0x83
  213. #define C9_5 0x84
  214. #define C9_6 0x85
  215. #define C9_7 0x86
  216. #define C9_8 0x87
  217. #define C9_9 0x88
  218. #define C9_10 0x89
  219. #define C9_11 0x8A
  220. #define C9_12 0x8B
  221. #define C9_13 0x8C
  222. #define C9_14 0x8D
  223. #define C9_15 0x8E
  224. #define C9_16 0x8F