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.

169 lines
3.7 KiB

  1. /* Copyright 2018 Jason Williams (Wilba)
  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. // Simple interface option.
  21. // If these aren't defined, just define them to make it compile
  22. #ifndef DRIVER_COUNT
  23. # define DRIVER_COUNT 2
  24. #endif
  25. #ifndef DRIVER_LED_TOTAL
  26. # define DRIVER_LED_TOTAL 96
  27. #endif
  28. typedef struct is31_led {
  29. uint8_t driver : 2;
  30. uint8_t r;
  31. uint8_t g;
  32. uint8_t b;
  33. } __attribute__((packed)) is31_led;
  34. extern const is31_led __flash g_is31_leds[DRIVER_LED_TOTAL];
  35. void IS31FL3736_init(uint8_t addr);
  36. void IS31FL3736_write_register(uint8_t addr, uint8_t reg, uint8_t data);
  37. void IS31FL3736_write_pwm_buffer(uint8_t addr, uint8_t *pwm_buffer);
  38. void IS31FL3736_set_color(int index, uint8_t red, uint8_t green, uint8_t blue);
  39. void IS31FL3736_set_color_all(uint8_t red, uint8_t green, uint8_t blue);
  40. void IS31FL3736_set_led_control_register(uint8_t index, bool red, bool green, bool blue);
  41. void IS31FL3736_mono_set_brightness(int index, uint8_t value);
  42. void IS31FL3736_mono_set_brightness_all(uint8_t value);
  43. void IS31FL3736_mono_set_led_control_register(uint8_t index, bool enabled);
  44. // This should not be called from an interrupt
  45. // (eg. from a timer interrupt).
  46. // Call this while idle (in between matrix scans).
  47. // If the buffer is dirty, it will update the driver with the buffer.
  48. void IS31FL3736_update_pwm_buffers(uint8_t addr1, uint8_t addr2);
  49. void IS31FL3736_update_led_control_registers(uint8_t addr1, uint8_t addr2);
  50. #define A_1 0x00
  51. #define A_2 0x02
  52. #define A_3 0x04
  53. #define A_4 0x06
  54. #define A_5 0x08
  55. #define A_6 0x0A
  56. #define A_7 0x0C
  57. #define A_8 0x0E
  58. #define B_1 0x10
  59. #define B_2 0x12
  60. #define B_3 0x14
  61. #define B_4 0x16
  62. #define B_5 0x18
  63. #define B_6 0x1A
  64. #define B_7 0x1C
  65. #define B_8 0x1E
  66. #define C_1 0x20
  67. #define C_2 0x22
  68. #define C_3 0x24
  69. #define C_4 0x26
  70. #define C_5 0x28
  71. #define C_6 0x2A
  72. #define C_7 0x2C
  73. #define C_8 0x2E
  74. #define D_1 0x30
  75. #define D_2 0x32
  76. #define D_3 0x34
  77. #define D_4 0x36
  78. #define D_5 0x38
  79. #define D_6 0x3A
  80. #define D_7 0x3C
  81. #define D_8 0x3E
  82. #define E_1 0x40
  83. #define E_2 0x42
  84. #define E_3 0x44
  85. #define E_4 0x46
  86. #define E_5 0x48
  87. #define E_6 0x4A
  88. #define E_7 0x4C
  89. #define E_8 0x4E
  90. #define F_1 0x50
  91. #define F_2 0x52
  92. #define F_3 0x54
  93. #define F_4 0x56
  94. #define F_5 0x58
  95. #define F_6 0x5A
  96. #define F_7 0x5C
  97. #define F_8 0x5E
  98. #define G_1 0x60
  99. #define G_2 0x62
  100. #define G_3 0x64
  101. #define G_4 0x66
  102. #define G_5 0x68
  103. #define G_6 0x6A
  104. #define G_7 0x6C
  105. #define G_8 0x6E
  106. #define H_1 0x70
  107. #define H_2 0x72
  108. #define H_3 0x74
  109. #define H_4 0x76
  110. #define H_5 0x78
  111. #define H_6 0x7A
  112. #define H_7 0x7C
  113. #define H_8 0x7E
  114. #define I_1 0x80
  115. #define I_2 0x82
  116. #define I_3 0x84
  117. #define I_4 0x86
  118. #define I_5 0x88
  119. #define I_6 0x8A
  120. #define I_7 0x8C
  121. #define I_8 0x8E
  122. #define J_1 0x90
  123. #define J_2 0x92
  124. #define J_3 0x94
  125. #define J_4 0x96
  126. #define J_5 0x98
  127. #define J_6 0x9A
  128. #define J_7 0x9C
  129. #define J_8 0x9E
  130. #define K_1 0xA0
  131. #define K_2 0xA2
  132. #define K_3 0xA4
  133. #define K_4 0xA6
  134. #define K_5 0xA8
  135. #define K_6 0xAA
  136. #define K_7 0xAC
  137. #define K_8 0xAE
  138. #define L_1 0xB0
  139. #define L_2 0xB2
  140. #define L_3 0xB4
  141. #define L_4 0xB6
  142. #define L_5 0xB8
  143. #define L_6 0xBA
  144. #define L_7 0xBC
  145. #define L_8 0xBE