1 /* Copyright 2017 Jason Williams
2 * Copyright 2017 Jack Humbert
3 * Copyright 2018 Yiancar
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.
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.
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/>.
28 #include "is31fl3731.h"
29 #elif defined (IS31FL3733)
30 #include "is31fl3733.h"
33 typedef struct Point {
36 } __attribute__((packed)) Point;
38 typedef struct rgb_led {
42 uint8_t row:4; // 16 max
43 uint8_t col:4; // 16 max
48 } __attribute__((packed)) rgb_led;
51 extern const rgb_led g_rgb_leds[DRIVER_LED_TOTAL];
59 uint8_t speed :8;//EECONFIG needs to be increased to support this
63 enum _matrix_effects {
64 RGB_MATRIX_SOLID_COLOR = 1,
65 #ifndef DISABLE_RGB_MATRIX_ALPHAS_MODS
66 RGB_MATRIX_ALPHAS_MODS,
68 #ifndef DISABLE_RGB_MATRIX_DUAL_BEACON
69 RGB_MATRIX_DUAL_BEACON,
71 #ifndef DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
72 RGB_MATRIX_GRADIENT_UP_DOWN,
74 #ifndef DISABLE_RGB_MATRIX_RAINDROPS
77 #ifndef DISABLE_RGB_MATRIX_CYCLE_ALL
80 #ifndef DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
81 RGB_MATRIX_CYCLE_LEFT_RIGHT,
83 #ifndef DISABLE_RGB_MATRIX_CYCLE_UP_DOWN
84 RGB_MATRIX_CYCLE_UP_DOWN,
86 #ifndef DISABLE_RGB_MATRIX_RAINBOW_BEACON
87 RGB_MATRIX_RAINBOW_BEACON,
89 #ifndef DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
90 RGB_MATRIX_RAINBOW_PINWHEELS,
92 #ifndef DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
93 RGB_MATRIX_RAINBOW_MOVING_CHEVRON,
95 #ifndef DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS
96 RGB_MATRIX_JELLYBEAN_RAINDROPS,
98 #ifndef DISABLE_RGB_MATRIX_DIGITAL_RAIN
99 RGB_MATRIX_DIGITAL_RAIN,
101 #ifdef RGB_MATRIX_KEYPRESSES
102 #ifndef DISABLE_RGB_MATRIX_SOLID_REACTIVE
103 RGB_MATRIX_SOLID_REACTIVE,
105 #ifndef DISABLE_RGB_MATRIX_SPLASH
108 #ifndef DISABLE_RGB_MATRIX_MULTISPLASH
109 RGB_MATRIX_MULTISPLASH,
111 #ifndef DISABLE_RGB_MATRIX_SOLID_SPLASH
112 RGB_MATRIX_SOLID_SPLASH,
114 #ifndef DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
115 RGB_MATRIX_SOLID_MULTISPLASH,
118 RGB_MATRIX_EFFECT_MAX
121 void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue );
122 void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue );
124 // This runs after another backlight effect and replaces
125 // colors already set
126 void rgb_matrix_indicators(void);
127 void rgb_matrix_indicators_kb(void);
128 void rgb_matrix_indicators_user(void);
130 void rgb_matrix_init(void);
131 void rgb_matrix_setup_drivers(void);
133 void rgb_matrix_set_suspend_state(bool state);
134 void rgb_matrix_set_indicator_state(uint8_t state);
137 void rgb_matrix_task(void);
139 // This should not be called from an interrupt
140 // (eg. from a timer interrupt).
141 // Call this while idle (in between matrix scans).
142 // If the buffer is dirty, it will update the driver with the buffer.
143 void rgb_matrix_update_pwm_buffers(void);
145 bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record);
147 void rgb_matrix_increase(void);
148 void rgb_matrix_decrease(void);
150 // void *backlight_get_key_color_eeprom_address(uint8_t led);
151 // void backlight_get_key_color( uint8_t led, HSV *hsv );
152 // void backlight_set_key_color( uint8_t row, uint8_t column, HSV hsv );
154 uint32_t rgb_matrix_get_tick(void);
156 void rgb_matrix_toggle(void);
157 void rgb_matrix_enable(void);
158 void rgb_matrix_enable_noeeprom(void);
159 void rgb_matrix_disable(void);
160 void rgb_matrix_disable_noeeprom(void);
161 void rgb_matrix_step(void);
162 void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val);
163 void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val);
164 void rgb_matrix_step_reverse(void);
165 void rgb_matrix_increase_hue(void);
166 void rgb_matrix_decrease_hue(void);
167 void rgb_matrix_increase_sat(void);
168 void rgb_matrix_decrease_sat(void);
169 void rgb_matrix_increase_val(void);
170 void rgb_matrix_decrease_val(void);
171 void rgb_matrix_increase_speed(void);
172 void rgb_matrix_decrease_speed(void);
173 void rgb_matrix_mode(uint8_t mode);
174 void rgb_matrix_mode_noeeprom(uint8_t mode);
175 uint8_t rgb_matrix_get_mode(void);
177 #ifndef RGBLIGHT_ENABLE
178 #define rgblight_toggle() rgb_matrix_toggle()
179 #define rgblight_enable() rgb_matrix_enable()
180 #define rgblight_enable_noeeprom() rgb_matrix_enable_noeeprom()
181 #define rgblight_disable() rgb_matrix_disable()
182 #define rgblight_disable_noeeprom() rgb_matrix_disable_noeeprom()
183 #define rgblight_step() rgb_matrix_step()
184 #define rgblight_sethsv(hue, sat, val) rgb_matrix_sethsv(hue, sat, val)
185 #define rgblight_sethsv_noeeprom(hue, sat, val) rgb_matrix_sethsv_noeeprom(hue, sat, val)
186 #define rgblight_step_reverse() rgb_matrix_step_reverse()
187 #define rgblight_increase_hue() rgb_matrix_increase_hue()
188 #define rgblight_decrease_hue() rgb_matrix_decrease_hue()
189 #define rgblight_increase_sat() rgb_matrix_increase_sat()
190 #define rgblight_decrease_sat() rgb_matrix_decrease_sat()
191 #define rgblight_increase_val() rgb_matrix_increase_val()
192 #define rgblight_decrease_val() rgb_matrix_decrease_val()
193 #define rgblight_increase_speed() rgb_matrix_increase_speed()
194 #define rgblight_decrease_speed() rgb_matrix_decrease_speed()
195 #define rgblight_mode(mode) rgb_matrix_mode(mode)
196 #define rgblight_mode_noeeprom(mode) rgb_matrix_mode_noeeprom(mode)
197 #define rgblight_get_mode() rgb_matrix_get_mode()
202 /* Perform any initialisation required for the other driver functions to work. */
205 /* Set the colour of a single LED in the buffer. */
206 void (*set_color)(int index, uint8_t r, uint8_t g, uint8_t b);
207 /* Set the colour of all LEDS on the keyboard in the buffer. */
208 void (*set_color_all)(uint8_t r, uint8_t g, uint8_t b);
209 /* Flush any buffered changes to the hardware. */
211 } rgb_matrix_driver_t;
213 extern const rgb_matrix_driver_t rgb_matrix_driver;