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.

203 lines
4.1 KiB

  1. /* Copyright 2017 Jason Williams
  2. * Copyright 2018 Jack Humbert
  3. * Copyright 2018 Yiancar
  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. typedef struct is31_led {
  22. uint8_t driver : 2;
  23. uint8_t r;
  24. uint8_t g;
  25. uint8_t b;
  26. } __attribute__((packed)) is31_led;
  27. extern const is31_led g_is31_leds[DRIVER_LED_TOTAL];
  28. void IS31FL3737_init(uint8_t addr);
  29. void IS31FL3737_write_register(uint8_t addr, uint8_t reg, uint8_t data);
  30. void IS31FL3737_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
  31. void IS31FL3737_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
  32. void IS31FL3737_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
  33. void IS31FL3737_set_led_control_register(uint8_t index, bool red, bool green, bool blue);
  34. // This should not be called from an interrupt
  35. // (eg. from a timer interrupt).
  36. // Call this while idle (in between matrix scans).
  37. // If the buffer is dirty, it will update the driver with the buffer.
  38. void IS31FL3737_update_pwm_buffers(uint8_t addr1, uint8_t addr2);
  39. void IS31FL3737_update_led_control_registers(uint8_t addr1, uint8_t addr2);
  40. #define A_1 0x00
  41. #define A_2 0x01
  42. #define A_3 0x02
  43. #define A_4 0x03
  44. #define A_5 0x04
  45. #define A_6 0x05
  46. #define A_7 0x08
  47. #define A_8 0x09
  48. #define A_9 0x0A
  49. #define A_10 0x0B
  50. #define A_11 0x0C
  51. #define A_12 0x0D
  52. #define B_1 0x10
  53. #define B_2 0x11
  54. #define B_3 0x12
  55. #define B_4 0x13
  56. #define B_5 0x14
  57. #define B_6 0x15
  58. #define B_7 0x18
  59. #define B_8 0x19
  60. #define B_9 0x1A
  61. #define B_10 0x1B
  62. #define B_11 0x1C
  63. #define B_12 0x1D
  64. #define C_1 0x20
  65. #define C_2 0x21
  66. #define C_3 0x22
  67. #define C_4 0x23
  68. #define C_5 0x24
  69. #define C_6 0x25
  70. #define C_7 0x28
  71. #define C_8 0x29
  72. #define C_9 0x2A
  73. #define C_10 0x2B
  74. #define C_11 0x2C
  75. #define C_12 0x2D
  76. #define D_1 0x30
  77. #define D_2 0x31
  78. #define D_3 0x32
  79. #define D_4 0x33
  80. #define D_5 0x34
  81. #define D_6 0x35
  82. #define D_7 0x38
  83. #define D_8 0x39
  84. #define D_9 0x3A
  85. #define D_10 0x3B
  86. #define D_11 0x3C
  87. #define D_12 0x3D
  88. #define E_1 0x40
  89. #define E_2 0x41
  90. #define E_3 0x42
  91. #define E_4 0x43
  92. #define E_5 0x44
  93. #define E_6 0x45
  94. #define E_7 0x48
  95. #define E_8 0x49
  96. #define E_9 0x4A
  97. #define E_10 0x4B
  98. #define E_11 0x4C
  99. #define E_12 0x4D
  100. #define F_1 0x50
  101. #define F_2 0x51
  102. #define F_3 0x52
  103. #define F_4 0x53
  104. #define F_5 0x54
  105. #define F_6 0x55
  106. #define F_7 0x58
  107. #define F_8 0x59
  108. #define F_9 0x5A
  109. #define F_10 0x5B
  110. #define F_11 0x5C
  111. #define F_12 0x5D
  112. #define G_1 0x60
  113. #define G_2 0x61
  114. #define G_3 0x62
  115. #define G_4 0x63
  116. #define G_5 0x64
  117. #define G_6 0x65
  118. #define G_7 0x68
  119. #define G_8 0x69
  120. #define G_9 0x6A
  121. #define G_10 0x6B
  122. #define G_11 0x6C
  123. #define G_12 0x6D
  124. #define H_1 0x70
  125. #define H_2 0x71
  126. #define H_3 0x72
  127. #define H_4 0x73
  128. #define H_5 0x74
  129. #define H_6 0x75
  130. #define H_7 0x78
  131. #define H_8 0x79
  132. #define H_9 0x7A
  133. #define H_10 0x7B
  134. #define H_11 0x7C
  135. #define H_12 0x7D
  136. #define I_1 0x80
  137. #define I_2 0x81
  138. #define I_3 0x82
  139. #define I_4 0x83
  140. #define I_5 0x84
  141. #define I_6 0x85
  142. #define I_7 0x88
  143. #define I_8 0x89
  144. #define I_9 0x8A
  145. #define I_10 0x8B
  146. #define I_11 0x8C
  147. #define I_12 0x8D
  148. #define J_1 0x90
  149. #define J_2 0x91
  150. #define J_3 0x92
  151. #define J_4 0x93
  152. #define J_5 0x94
  153. #define J_6 0x95
  154. #define J_7 0x98
  155. #define J_8 0x99
  156. #define J_9 0x9A
  157. #define J_10 0x9B
  158. #define J_11 0x9C
  159. #define J_12 0x9D
  160. #define K_1 0xA0
  161. #define K_2 0xA1
  162. #define K_3 0xA2
  163. #define K_4 0xA3
  164. #define K_5 0xA4
  165. #define K_6 0xA5
  166. #define K_7 0xA8
  167. #define K_8 0xA9
  168. #define K_9 0xAA
  169. #define K_10 0xAB
  170. #define K_11 0xAC
  171. #define K_12 0xAD
  172. #define L_1 0xB0
  173. #define L_2 0xB1
  174. #define L_3 0xB2
  175. #define L_4 0xB3
  176. #define L_5 0xB4
  177. #define L_6 0xB5
  178. #define L_7 0xB8
  179. #define L_8 0xB9
  180. #define L_9 0xBA
  181. #define L_10 0xBB
  182. #define L_11 0xBC
  183. #define L_12 0xBD