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.

179 lines
4.1 KiB

  1. /* Copyright 2018 Jason Williams (Wilba)
  2. * Copyright 2021 Doni Crosby
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #pragma once
  18. #include <stdint.h>
  19. #include <stdbool.h>
  20. #include "progmem.h"
  21. // Simple interface option.
  22. // If these aren't defined, just define them to make it compile
  23. #ifndef DRIVER_COUNT
  24. # define DRIVER_COUNT 2
  25. #endif
  26. #ifndef DRIVER_LED_TOTAL
  27. # define DRIVER_LED_TOTAL 96
  28. #endif
  29. typedef struct is31_led {
  30. uint8_t driver : 2;
  31. uint8_t r;
  32. uint8_t g;
  33. uint8_t b;
  34. } __attribute__((packed)) is31_led;
  35. extern const is31_led PROGMEM g_is31_leds[DRIVER_LED_TOTAL];
  36. void IS31FL3736_init(uint8_t addr);
  37. void IS31FL3736_write_register(uint8_t addr, uint8_t reg, uint8_t data);
  38. void IS31FL3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
  39. void IS31FL3736_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
  40. void IS31FL3736_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
  41. void IS31FL3736_set_led_control_register(uint8_t index, bool red, bool green, bool blue);
  42. void IS31FL3736_mono_set_brightness(int index, uint8_t value);
  43. void IS31FL3736_mono_set_brightness_all(uint8_t value);
  44. void IS31FL3736_mono_set_led_control_register(uint8_t index, bool enabled);
  45. // This should not be called from an interrupt
  46. // (eg. from a timer interrupt).
  47. // Call this while idle (in between matrix scans).
  48. // If the buffer is dirty, it will update the driver with the buffer.
  49. void IS31FL3736_update_pwm_buffers(uint8_t addr1, uint8_t addr2);
  50. void IS31FL3736_update_led_control_registers(uint8_t addr1, uint8_t addr2);
  51. #define PUR_0R 0x00 // No PUR resistor
  52. #define PUR_05KR 0x01 // 0.5k Ohm resistor
  53. #define PUR_1KR 0x02 // 1.0k Ohm resistor
  54. #define PUR_2KR 0x03 // 2.0k Ohm resistor
  55. #define PUR_4KR 0x04 // 4.0k Ohm resistor
  56. #define PUR_8KR 0x05 // 8.0k Ohm resistor
  57. #define PUR_16KR 0x06 // 16k Ohm resistor
  58. #define PUR_32KR 0x07 // 32k Ohm resistor
  59. #define A_1 0x00
  60. #define A_2 0x02
  61. #define A_3 0x04
  62. #define A_4 0x06
  63. #define A_5 0x08
  64. #define A_6 0x0A
  65. #define A_7 0x0C
  66. #define A_8 0x0E
  67. #define B_1 0x10
  68. #define B_2 0x12
  69. #define B_3 0x14
  70. #define B_4 0x16
  71. #define B_5 0x18
  72. #define B_6 0x1A
  73. #define B_7 0x1C
  74. #define B_8 0x1E
  75. #define C_1 0x20
  76. #define C_2 0x22
  77. #define C_3 0x24
  78. #define C_4 0x26
  79. #define C_5 0x28
  80. #define C_6 0x2A
  81. #define C_7 0x2C
  82. #define C_8 0x2E
  83. #define D_1 0x30
  84. #define D_2 0x32
  85. #define D_3 0x34
  86. #define D_4 0x36
  87. #define D_5 0x38
  88. #define D_6 0x3A
  89. #define D_7 0x3C
  90. #define D_8 0x3E
  91. #define E_1 0x40
  92. #define E_2 0x42
  93. #define E_3 0x44
  94. #define E_4 0x46
  95. #define E_5 0x48
  96. #define E_6 0x4A
  97. #define E_7 0x4C
  98. #define E_8 0x4E
  99. #define F_1 0x50
  100. #define F_2 0x52
  101. #define F_3 0x54
  102. #define F_4 0x56
  103. #define F_5 0x58
  104. #define F_6 0x5A
  105. #define F_7 0x5C
  106. #define F_8 0x5E
  107. #define G_1 0x60
  108. #define G_2 0x62
  109. #define G_3 0x64
  110. #define G_4 0x66
  111. #define G_5 0x68
  112. #define G_6 0x6A
  113. #define G_7 0x6C
  114. #define G_8 0x6E
  115. #define H_1 0x70
  116. #define H_2 0x72
  117. #define H_3 0x74
  118. #define H_4 0x76
  119. #define H_5 0x78
  120. #define H_6 0x7A
  121. #define H_7 0x7C
  122. #define H_8 0x7E
  123. #define I_1 0x80
  124. #define I_2 0x82
  125. #define I_3 0x84
  126. #define I_4 0x86
  127. #define I_5 0x88
  128. #define I_6 0x8A
  129. #define I_7 0x8C
  130. #define I_8 0x8E
  131. #define J_1 0x90
  132. #define J_2 0x92
  133. #define J_3 0x94
  134. #define J_4 0x96
  135. #define J_5 0x98
  136. #define J_6 0x9A
  137. #define J_7 0x9C
  138. #define J_8 0x9E
  139. #define K_1 0xA0
  140. #define K_2 0xA2
  141. #define K_3 0xA4
  142. #define K_4 0xA6
  143. #define K_5 0xA8
  144. #define K_6 0xAA
  145. #define K_7 0xAC
  146. #define K_8 0xAE
  147. #define L_1 0xB0
  148. #define L_2 0xB2
  149. #define L_3 0xB4
  150. #define L_4 0xB6
  151. #define L_5 0xB8
  152. #define L_6 0xBA
  153. #define L_7 0xBC
  154. #define L_8 0xBE