is31fl3737.h 4.2 KB

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