summaryrefslogtreecommitdiffstats
path: root/quantum/rgb_matrix.h
diff options
context:
space:
mode:
authorJames Laird-Wah <james@laird-wah.net>2018-09-27 16:40:18 +0200
committerJack Humbert <jack.humb@gmail.com>2018-09-27 16:40:18 +0200
commitf70f45ee677a2a39a759052a356e0c5d82e25424 (patch)
treec0d6a6d5a5791a57309b3deb398ca1dfcc499f78 /quantum/rgb_matrix.h
parent12ad59f99de0ecd2c81b92587c2858b3fb39523c (diff)
downloadqmk_firmware-f70f45ee677a2a39a759052a356e0c5d82e25424.tar.gz
qmk_firmware-f70f45ee677a2a39a759052a356e0c5d82e25424.tar.xz
RGB Matrix refactoring to open up for new drivers (#3913)
* rgb_matrix: use a driver ops struct This is intended to avoid #ifdef proliferation on adding more drivers, eg. model01, which use different architectures. * rgb_matrix: document driver struct members * rgb_matrix: remove unused LED testing code * rgb_matrix: don't build into IS31x drivers unless being used * rgb_matrix: refactor make config options This ensures that the necessary files are included for any custom RGB_MATRIX_ENABLE value, without having to add entries here for specific boards. This particularly affects model01 because its controller is integrated and won't be used anywhere else, so it's preferable not to put it in common_features.mk. This now validates the value of RGB_MATRIX_ENABLE. It was necessary to fix an error in ergodox_ez rules.mk using the wrong comment separator, yielding an invalid value. * IS31x drivers: don't write the control registers all the time This is only needed when they are changed. This is done in init() and board- or keymap-specific code is free to make further changes. * rgb_matrix: move structs from chip drivers to rgb_matrix_drivers.c This approach is specific to the rgb_matrix functionality, so keep it neatly separated from the raw chip drivers.
Diffstat (limited to 'quantum/rgb_matrix.h')
-rw-r--r--quantum/rgb_matrix.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h
index 046d98790..45caaac42 100644
--- a/quantum/rgb_matrix.h
+++ b/quantum/rgb_matrix.h
@@ -100,8 +100,6 @@ void rgb_matrix_indicators(void);
void rgb_matrix_indicators_kb(void);
void rgb_matrix_indicators_user(void);
-void rgb_matrix_single_LED_test(void);
-
void rgb_matrix_init(void);
void rgb_matrix_setup_drivers(void);
@@ -126,7 +124,6 @@ void rgb_matrix_decrease(void);
// void backlight_get_key_color( uint8_t led, HSV *hsv );
// void backlight_set_key_color( uint8_t row, uint8_t column, HSV hsv );
-void rgb_matrix_test_led( uint8_t index, bool red, bool green, bool blue );
uint32_t rgb_matrix_get_tick(void);
void rgblight_toggle(void);
@@ -143,4 +140,18 @@ void rgblight_decrease_speed(void);
void rgblight_mode(uint8_t mode);
uint32_t rgblight_get_mode(void);
+typedef struct {
+ /* Perform any initialisation required for the other driver functions to work. */
+ void (*init)(void);
+
+ /* Set the colour of a single LED in the buffer. */
+ void (*set_color)(int index, uint8_t r, uint8_t g, uint8_t b);
+ /* Set the colour of all LEDS on the keyboard in the buffer. */
+ void (*set_color_all)(uint8_t r, uint8_t g, uint8_t b);
+ /* Flush any buffered changes to the hardware. */
+ void (*flush)(void);
+} rgb_matrix_driver_t;
+
+extern const rgb_matrix_driver_t rgb_matrix_driver;
+
#endif