summaryrefslogtreecommitdiff
path: root/quantum/rgb_matrix
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/rgb_matrix')
-rw-r--r--quantum/rgb_matrix/animations/flower_blooming_anim.h53
-rw-r--r--quantum/rgb_matrix/animations/rgb_matrix_effects.inc1
-rw-r--r--quantum/rgb_matrix/rgb_matrix.c87
-rw-r--r--quantum/rgb_matrix/rgb_matrix.h120
-rw-r--r--quantum/rgb_matrix/rgb_matrix_drivers.c399
-rw-r--r--quantum/rgb_matrix/rgb_matrix_types.h15
6 files changed, 322 insertions, 353 deletions
diff --git a/quantum/rgb_matrix/animations/flower_blooming_anim.h b/quantum/rgb_matrix/animations/flower_blooming_anim.h
new file mode 100644
index 0000000000..7629fde858
--- /dev/null
+++ b/quantum/rgb_matrix/animations/flower_blooming_anim.h
@@ -0,0 +1,53 @@
+/* Copyright 2023 HorrorTroll <https://github.com/HorrorTroll>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef ENABLE_RGB_MATRIX_FLOWER_BLOOMING
+RGB_MATRIX_EFFECT(FLOWER_BLOOMING)
+# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+
+typedef HSV (*flower_blooming_f)(HSV hsv, uint8_t i, uint8_t time);
+
+bool effect_runner_bloom(effect_params_t* params, flower_blooming_f effect_func) {
+ RGB_MATRIX_USE_LIMITS(led_min, led_max);
+
+ uint8_t time = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed / 10, 1));
+ for (uint8_t i = led_min; i < led_max; i++) {
+ RGB_MATRIX_TEST_LED_FLAGS();
+ if (g_led_config.point[i].y > k_rgb_matrix_center.y) {
+ RGB bgr = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time));
+ rgb_matrix_set_color(i, bgr.b, bgr.g, bgr.r);
+ } else {
+ RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time));
+ rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
+ }
+ }
+ return rgb_matrix_check_finished_leds(led_max);
+}
+
+static HSV FLOWER_BLOOMING_math(HSV hsv, uint8_t i, uint8_t time) {
+ if (g_led_config.point[i].y > k_rgb_matrix_center.y)
+ hsv.h = g_led_config.point[i].x * 3 - g_led_config.point[i].y * 3 + time;
+ else
+ hsv.h = g_led_config.point[i].x * 3 - g_led_config.point[i].y * 3 - time;
+ return hsv;
+}
+
+bool FLOWER_BLOOMING(effect_params_t* params) {
+ return effect_runner_bloom(params, &FLOWER_BLOOMING_math);
+}
+
+# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS
+#endif // ENABLE_RGB_MATRIX_FLOWER_BLOOMING
diff --git a/quantum/rgb_matrix/animations/rgb_matrix_effects.inc b/quantum/rgb_matrix/animations/rgb_matrix_effects.inc
index ac7bac428d..df34718838 100644
--- a/quantum/rgb_matrix/animations/rgb_matrix_effects.inc
+++ b/quantum/rgb_matrix/animations/rgb_matrix_effects.inc
@@ -21,6 +21,7 @@
#include "dual_beacon_anim.h"
#include "rainbow_beacon_anim.h"
#include "rainbow_pinwheels_anim.h"
+#include "flower_blooming_anim.h"
#include "raindrops_anim.h"
#include "jellybean_raindrops_anim.h"
#include "hue_breathing_anim.h"
diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c
index 96be615162..d93d189827 100644
--- a/quantum/rgb_matrix/rgb_matrix.c
+++ b/quantum/rgb_matrix/rgb_matrix.c
@@ -60,56 +60,6 @@ __attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) {
// -----End rgb effect includes macros-------
// ------------------------------------------
-#ifndef RGB_MATRIX_TIMEOUT
-# define RGB_MATRIX_TIMEOUT 0
-#endif
-
-#if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
-# undef RGB_MATRIX_MAXIMUM_BRIGHTNESS
-# define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
-#endif
-
-#if !defined(RGB_MATRIX_HUE_STEP)
-# define RGB_MATRIX_HUE_STEP 8
-#endif
-
-#if !defined(RGB_MATRIX_SAT_STEP)
-# define RGB_MATRIX_SAT_STEP 16
-#endif
-
-#if !defined(RGB_MATRIX_VAL_STEP)
-# define RGB_MATRIX_VAL_STEP 16
-#endif
-
-#if !defined(RGB_MATRIX_SPD_STEP)
-# define RGB_MATRIX_SPD_STEP 16
-#endif
-
-#if !defined(RGB_MATRIX_DEFAULT_MODE)
-# ifdef ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
-# define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT
-# else
-// fallback to solid colors if RGB_MATRIX_CYCLE_LEFT_RIGHT is disabled in userspace
-# define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_SOLID_COLOR
-# endif
-#endif
-
-#if !defined(RGB_MATRIX_DEFAULT_HUE)
-# define RGB_MATRIX_DEFAULT_HUE 0
-#endif
-
-#if !defined(RGB_MATRIX_DEFAULT_SAT)
-# define RGB_MATRIX_DEFAULT_SAT UINT8_MAX
-#endif
-
-#if !defined(RGB_MATRIX_DEFAULT_VAL)
-# define RGB_MATRIX_DEFAULT_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS
-#endif
-
-#if !defined(RGB_MATRIX_DEFAULT_SPD)
-# define RGB_MATRIX_DEFAULT_SPD UINT8_MAX / 2
-#endif
-
// globals
rgb_config_t rgb_matrix_config; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr
uint32_t g_rgb_timer;
@@ -149,7 +99,7 @@ void eeconfig_update_rgb_matrix(void) {
void eeconfig_update_rgb_matrix_default(void) {
dprintf("eeconfig_update_rgb_matrix_default\n");
- rgb_matrix_config.enable = 1;
+ rgb_matrix_config.enable = RGB_MATRIX_DEFAULT_ON;
rgb_matrix_config.mode = RGB_MATRIX_DEFAULT_MODE;
rgb_matrix_config.hsv = (HSV){RGB_MATRIX_DEFAULT_HUE, RGB_MATRIX_DEFAULT_SAT, RGB_MATRIX_DEFAULT_VAL};
rgb_matrix_config.speed = RGB_MATRIX_DEFAULT_SPD;
@@ -433,8 +383,7 @@ void rgb_matrix_task(void) {
case RENDERING:
rgb_task_render(effect);
if (effect) {
- // Only run the basic indicators in the last render iteration (default there are 5 iterations)
- if (rgb_effect_params.iter == RGB_MATRIX_LED_PROCESS_MAX_ITERATIONS) {
+ if (rgb_task_state == FLUSHING) { // ensure we only draw basic indicators once rendering is finished
rgb_matrix_indicators();
}
rgb_matrix_indicators_advanced(&rgb_effect_params);
@@ -461,6 +410,36 @@ __attribute__((weak)) bool rgb_matrix_indicators_user(void) {
return true;
}
+struct rgb_matrix_limits_t rgb_matrix_get_limits(uint8_t iter) {
+ struct rgb_matrix_limits_t limits = {0};
+#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < RGB_MATRIX_LED_COUNT
+# if defined(RGB_MATRIX_SPLIT)
+ limits.led_min_index = RGB_MATRIX_LED_PROCESS_LIMIT * (iter);
+ limits.led_max_index = limits.led_min_index + RGB_MATRIX_LED_PROCESS_LIMIT;
+ if (limits.led_max_index > RGB_MATRIX_LED_COUNT) limits.led_max_index = RGB_MATRIX_LED_COUNT;
+ uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT;
+ if (is_keyboard_left() && (limits.led_max_index > k_rgb_matrix_split[0])) limits.led_max_index = k_rgb_matrix_split[0];
+ if (!(is_keyboard_left()) && (limits.led_min_index < k_rgb_matrix_split[0])) limits.led_min_index = k_rgb_matrix_split[0];
+# else
+ limits.led_min_index = RGB_MATRIX_LED_PROCESS_LIMIT * (iter);
+ limits.led_max_index = limits.led_min_index + RGB_MATRIX_LED_PROCESS_LIMIT;
+ if (limits.led_max_index > RGB_MATRIX_LED_COUNT) limits.led_max_index = RGB_MATRIX_LED_COUNT;
+# endif
+#else
+# if defined(RGB_MATRIX_SPLIT)
+ limits.led_min_index = 0;
+ limits.led_max_index = RGB_MATRIX_LED_COUNT;
+ const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT;
+ if (is_keyboard_left() && (limits.led_max_index > k_rgb_matrix_split[0])) limits.led_max_index = k_rgb_matrix_split[0];
+ if (!(is_keyboard_left()) && (limits.led_min_index < k_rgb_matrix_split[0])) limits.led_min_index = k_rgb_matrix_split[0];
+# else
+ limits.led_min_index = 0;
+ limits.led_max_index = RGB_MATRIX_LED_COUNT;
+# endif
+#endif
+ return limits;
+}
+
void rgb_matrix_indicators_advanced(effect_params_t *params) {
/* special handling is needed for "params->iter", since it's already been incremented.
* Could move the invocations to rgb_task_render, but then it's missing a few checks
@@ -736,7 +715,7 @@ void rgb_matrix_decrease_speed(void) {
void rgb_matrix_set_flags_eeprom_helper(led_flags_t flags, bool write_to_eeprom) {
rgb_matrix_config.flags = flags;
eeconfig_flag_rgb_matrix(write_to_eeprom);
- dprintf("rgb matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.flags);
+ dprintf("rgb matrix set flags [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.flags);
}
led_flags_t rgb_matrix_get_flags(void) {
diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h
index 38040fb0cc..9a3ffb8ea3 100644
--- a/quantum/rgb_matrix/rgb_matrix.h
+++ b/quantum/rgb_matrix/rgb_matrix.h
@@ -24,26 +24,81 @@
#include "color.h"
#include "keyboard.h"
-#ifdef IS31FL3731
+#if defined(RGB_MATRIX_IS31FL3218)
+# include "is31fl3218.h"
+#elif defined(RGB_MATRIX_IS31FL3731)
# include "is31fl3731.h"
-#elif defined(IS31FL3733)
+#elif defined(RGB_MATRIX_IS31FL3733)
# include "is31fl3733.h"
-#elif defined(IS31FL3736)
+#elif defined(RGB_MATRIX_IS31FL3736)
# include "is31fl3736.h"
-#elif defined(IS31FL3737)
+#elif defined(RGB_MATRIX_IS31FL3737)
# include "is31fl3737.h"
-#elif defined(IS31FL3741)
+#elif defined(RGB_MATRIX_IS31FL3741)
# include "is31fl3741.h"
#elif defined(IS31FLCOMMON)
# include "is31flcommon.h"
-#elif defined(CKLED2001)
-# include "ckled2001.h"
-#elif defined(AW20216)
-# include "aw20216.h"
-#elif defined(WS2812)
+#elif defined(RGB_MATRIX_SNLED27351)
+# include "snled27351.h"
+#elif defined(RGB_MATRIX_AW20216S)
+# include "aw20216s.h"
+#elif defined(RGB_MATRIX_WS2812)
# include "ws2812.h"
#endif
+#ifndef RGB_MATRIX_TIMEOUT
+# define RGB_MATRIX_TIMEOUT 0
+#endif
+
+#ifndef RGB_MATRIX_MAXIMUM_BRIGHTNESS
+# define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX
+#endif
+
+#ifndef RGB_MATRIX_HUE_STEP
+# define RGB_MATRIX_HUE_STEP 8
+#endif
+
+#ifndef RGB_MATRIX_SAT_STEP
+# define RGB_MATRIX_SAT_STEP 16
+#endif
+
+#ifndef RGB_MATRIX_VAL_STEP
+# define RGB_MATRIX_VAL_STEP 16
+#endif
+
+#ifndef RGB_MATRIX_SPD_STEP
+# define RGB_MATRIX_SPD_STEP 16
+#endif
+
+#ifndef RGB_MATRIX_DEFAULT_ON
+# define RGB_MATRIX_DEFAULT_ON true
+#endif
+
+#ifndef RGB_MATRIX_DEFAULT_MODE
+# ifdef ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
+# define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT
+# else
+// fallback to solid colors if RGB_MATRIX_CYCLE_LEFT_RIGHT is disabled in userspace
+# define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_SOLID_COLOR
+# endif
+#endif
+
+#ifndef RGB_MATRIX_DEFAULT_HUE
+# define RGB_MATRIX_DEFAULT_HUE 0
+#endif
+
+#ifndef RGB_MATRIX_DEFAULT_SAT
+# define RGB_MATRIX_DEFAULT_SAT UINT8_MAX
+#endif
+
+#ifndef RGB_MATRIX_DEFAULT_VAL
+# define RGB_MATRIX_DEFAULT_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS
+#endif
+
+#ifndef RGB_MATRIX_DEFAULT_SPD
+# define RGB_MATRIX_DEFAULT_SPD UINT8_MAX / 2
+#endif
+
#ifndef RGB_MATRIX_LED_FLUSH_LIMIT
# define RGB_MATRIX_LED_FLUSH_LIMIT 16
#endif
@@ -51,37 +106,20 @@
#ifndef RGB_MATRIX_LED_PROCESS_LIMIT
# define RGB_MATRIX_LED_PROCESS_LIMIT ((RGB_MATRIX_LED_COUNT + 4) / 5)
#endif
-#define RGB_MATRIX_LED_PROCESS_MAX_ITERATIONS ((RGB_MATRIX_LED_COUNT + RGB_MATRIX_LED_PROCESS_LIMIT - 1) / RGB_MATRIX_LED_PROCESS_LIMIT)
-
-#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < RGB_MATRIX_LED_COUNT
-# if defined(RGB_MATRIX_SPLIT)
-# define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
- uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * (iter); \
- uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \
- if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT; \
- uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; \
- if (is_keyboard_left() && (max > k_rgb_matrix_split[0])) max = k_rgb_matrix_split[0]; \
- if (!(is_keyboard_left()) && (min < k_rgb_matrix_split[0])) min = k_rgb_matrix_split[0];
-# else
-# define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
- uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * (iter); \
- uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \
- if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT;
-# endif
-#else
-# if defined(RGB_MATRIX_SPLIT)
-# define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
- uint8_t min = 0; \
- uint8_t max = RGB_MATRIX_LED_COUNT; \
- const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; \
- if (is_keyboard_left() && (max > k_rgb_matrix_split[0])) max = k_rgb_matrix_split[0]; \
- if (!(is_keyboard_left()) && (min < k_rgb_matrix_split[0])) min = k_rgb_matrix_split[0];
-# else
-# define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
- uint8_t min = 0; \
- uint8_t max = RGB_MATRIX_LED_COUNT;
-# endif
-#endif
+
+struct rgb_matrix_limits_t {
+ uint8_t led_min_index;
+ uint8_t led_max_index;
+};
+
+struct rgb_matrix_limits_t rgb_matrix_get_limits(uint8_t iter);
+
+#define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
+ struct rgb_matrix_limits_t limits = rgb_matrix_get_limits(iter); \
+ uint8_t min = limits.led_min_index; \
+ uint8_t max = limits.led_max_index; \
+ (void)min; \
+ (void)max;
#define RGB_MATRIX_USE_LIMITS(min, max) RGB_MATRIX_USE_LIMITS_ITER(min, max, params->iter)
diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c
index 695ecc78a4..0fe93ee077 100644
--- a/quantum/rgb_matrix/rgb_matrix_drivers.c
+++ b/quantum/rgb_matrix/rgb_matrix_drivers.c
@@ -24,87 +24,83 @@
* be here if shared between boards.
*/
-#if defined(IS31FL3731) || defined(IS31FL3733) || defined(IS31FL3736) || defined(IS31FL3737) || defined(IS31FL3741) || defined(IS31FLCOMMON) || defined(CKLED2001)
+#if defined(RGB_MATRIX_IS31FL3218) || defined(RGB_MATRIX_IS31FL3731) || defined(RGB_MATRIX_IS31FL3733) || defined(RGB_MATRIX_IS31FL3736) || defined(RGB_MATRIX_IS31FL3737) || defined(RGB_MATRIX_IS31FL3741) || defined(IS31FLCOMMON) || defined(RGB_MATRIX_SNLED27351)
# include "i2c_master.h"
-// TODO: Remove this at some later date
-# if defined(DRIVER_ADDR_1) && defined(DRIVER_ADDR_2)
-# if DRIVER_ADDR_1 == DRIVER_ADDR_2
-# error "Setting DRIVER_ADDR_2 == DRIVER_ADDR_1 is obsolete. If you are only using one ISSI driver, set DRIVER_COUNT to 1 and remove DRIVER_ADDR_2"
-# endif
-# endif
-
static void init(void) {
i2c_init();
-# if defined(IS31FL3731)
- is31fl3731_init(DRIVER_ADDR_1);
-# if defined(DRIVER_ADDR_2)
- is31fl3731_init(DRIVER_ADDR_2);
-# if defined(DRIVER_ADDR_3)
- is31fl3731_init(DRIVER_ADDR_3);
-# if defined(DRIVER_ADDR_4)
- is31fl3731_init(DRIVER_ADDR_4);
+# if defined(RGB_MATRIX_IS31FL3218)
+ is31fl3218_init();
+
+# elif defined(RGB_MATRIX_IS31FL3731)
+ is31fl3731_init(IS31FL3731_I2C_ADDRESS_1);
+# if defined(IS31FL3731_I2C_ADDRESS_2)
+ is31fl3731_init(IS31FL3731_I2C_ADDRESS_2);
+# if defined(IS31FL3731_I2C_ADDRESS_3)
+ is31fl3731_init(IS31FL3731_I2C_ADDRESS_3);
+# if defined(IS31FL3731_I2C_ADDRESS_4)
+ is31fl3731_init(IS31FL3731_I2C_ADDRESS_4);
# endif
# endif
# endif
-# elif defined(IS31FL3733)
-# if !defined(DRIVER_SYNC_1)
-# define DRIVER_SYNC_1 0
+# elif defined(RGB_MATRIX_IS31FL3733)
+# if !defined(IS31FL3733_SYNC_1)
+# define IS31FL3733_SYNC_1 0
# endif
- is31fl3733_init(DRIVER_ADDR_1, DRIVER_SYNC_1);
-# if defined(DRIVER_ADDR_2)
-# if !defined(DRIVER_SYNC_2)
-# define DRIVER_SYNC_2 0
+ is31fl3733_init(IS31FL3733_I2C_ADDRESS_1, IS31FL3733_SYNC_1);
+# if defined(IS31FL3733_I2C_ADDRESS_2)
+# if !defined(IS31FL3733_SYNC_2)
+# define IS31FL3733_SYNC_2 0
# endif
- is31fl3733_init(DRIVER_ADDR_2, DRIVER_SYNC_2);
-# if defined(DRIVER_ADDR_3)
-# if !defined(DRIVER_SYNC_3)
-# define DRIVER_SYNC_3 0
+ is31fl3733_init(IS31FL3733_I2C_ADDRESS_2, IS31FL3733_SYNC_2);
+# if defined(IS31FL3733_I2C_ADDRESS_3)
+# if !defined(IS31FL3733_SYNC_3)
+# define IS31FL3733_SYNC_3 0
# endif
- is31fl3733_init(DRIVER_ADDR_3, DRIVER_SYNC_3);
-# if defined(DRIVER_ADDR_4)
-# if !defined(DRIVER_SYNC_4)
-# define DRIVER_SYNC_4 0
+ is31fl3733_init(IS31FL3733_I2C_ADDRESS_3, IS31FL3733_SYNC_3);
+# if defined(IS31FL3733_I2C_ADDRESS_4)
+# if !defined(IS31FL3733_SYNC_4)
+# define IS31FL3733_SYNC_4 0
# endif
- is31fl3733_init(DRIVER_ADDR_4, DRIVER_SYNC_4);
+ is31fl3733_init(IS31FL3733_I2C_ADDRESS_4, IS31FL3733_SYNC_4);
# endif
# endif
# endif
-# elif defined(IS31FL3736)
- is31fl3736_init(DRIVER_ADDR_1);
-# if defined(DRIVER_ADDR_2)
- is31fl3736_init(DRIVER_ADDR_2);
-# if defined(DRIVER_ADDR_3)
- is31fl3736_init(DRIVER_ADDR_3);
-# if defined(DRIVER_ADDR_4)
- is31fl3736_init(DRIVER_ADDR_4);
+# elif defined(RGB_MATRIX_IS31FL3736)
+ is31fl3736_init(IS31FL3736_I2C_ADDRESS_1);
+# if defined(IS31FL3736_I2C_ADDRESS_2)
+ is31fl3736_init(IS31FL3736_I2C_ADDRESS_2);
+# if defined(IS31FL3736_I2C_ADDRESS_3)
+ is31fl3736_init(IS31FL3736_I2C_ADDRESS_3);
+# if defined(IS31FL3736_I2C_ADDRESS_4)
+ is31fl3736_init(IS31FL3736_I2C_ADDRESS_4);
# endif
# endif
# endif
-# elif defined(IS31FL3737)
- is31fl3737_init(DRIVER_ADDR_1);
-# if defined(DRIVER_ADDR_2)
- is31fl3737_init(DRIVER_ADDR_2);
-# if defined(DRIVER_ADDR_3)
- is31fl3737_init(DRIVER_ADDR_3);
-# if defined(DRIVER_ADDR_4)
- is31fl3737_init(DRIVER_ADDR_4);
+# elif defined(RGB_MATRIX_IS31FL3737)
+ is31fl3737_init(IS31FL3737_I2C_ADDRESS_1);
+# if defined(IS31FL3737_I2C_ADDRESS_2)
+ is31fl3737_init(IS31FL3737_I2C_ADDRESS_2);
+# if defined(IS31FL3737_I2C_ADDRESS_3)
+ is31fl3737_init(IS31FL3737_I2C_ADDRESS_3);
+# if defined(IS31FL3737_I2C_ADDRESS_4)
+ is31fl3737_init(IS31FL3737_I2C_ADDRESS_4);
# endif
# endif
# endif
-# elif defined(IS31FL3741)
- is31fl3741_init(DRIVER_ADDR_1);
-# if defined(DRIVER_ADDR_2)
- is31fl3741_init(DRIVER_ADDR_2);
-# if defined(DRIVER_ADDR_3)
- is31fl3741_init(DRIVER_ADDR_3);
-# if defined(DRIVER_ADDR_4)
- is31fl3741_init(DRIVER_ADDR_4);
+# elif defined(RGB_MATRIX_IS31FL3741)
+ is31fl3741_init(IS31FL3741_I2C_ADDRESS_1);
+# if defined(IS31FL3741_I2C_ADDRESS_2)
+ is31fl3741_init(IS31FL3741_I2C_ADDRESS_2);
+# if defined(IS31FL3741_I2C_ADDRESS_3)
+ is31fl3741_init(IS31FL3741_I2C_ADDRESS_3);
+# if defined(IS31FL3741_I2C_ADDRESS_4)
+ is31fl3741_init(IS31FL3741_I2C_ADDRESS_4);
# endif
# endif
# endif
@@ -121,14 +117,14 @@ static void init(void) {
# endif
# endif
-# elif defined(CKLED2001)
- ckled2001_init(DRIVER_ADDR_1);
-# if defined(DRIVER_ADDR_2)
- ckled2001_init(DRIVER_ADDR_2);
-# if defined(DRIVER_ADDR_3)
- ckled2001_init(DRIVER_ADDR_3);
-# if defined(DRIVER_ADDR_4)
- ckled2001_init(DRIVER_ADDR_4);
+# elif defined(RGB_MATRIX_SNLED27351)
+ snled27351_init(SNLED27351_I2C_ADDRESS_1);
+# if defined(SNLED27351_I2C_ADDRESS_2)
+ snled27351_init(SNLED27351_I2C_ADDRESS_2);
+# if defined(SNLED27351_I2C_ADDRESS_3)
+ snled27351_init(SNLED27351_I2C_ADDRESS_3);
+# if defined(SNLED27351_I2C_ADDRESS_4)
+ snled27351_init(SNLED27351_I2C_ADDRESS_4);
# endif
# endif
# endif
@@ -138,80 +134,85 @@ static void init(void) {
bool enabled = true;
// This only caches it for later
-# if defined(IS31FL3731)
+# if defined(RGB_MATRIX_IS31FL3218)
+ is31fl3218_set_led_control_register(index, enabled, enabled, enabled);
+# elif defined(RGB_MATRIX_IS31FL3731)
is31fl3731_set_led_control_register(index, enabled, enabled, enabled);
-# elif defined(IS31FL3733)
+# elif defined(RGB_MATRIX_IS31FL3733)
is31fl3733_set_led_control_register(index, enabled, enabled, enabled);
-# elif defined(IS31FL3736)
+# elif defined(RGB_MATRIX_IS31FL3736)
is31fl3736_set_led_control_register(index, enabled, enabled, enabled);
-# elif defined(IS31FL3737)
+# elif defined(RGB_MATRIX_IS31FL3737)
is31fl3737_set_led_control_register(index, enabled, enabled, enabled);
-# elif defined(IS31FL3741)
+# elif defined(RGB_MATRIX_IS31FL3741)
is31fl3741_set_led_control_register(index, enabled, enabled, enabled);
# elif defined(IS31FLCOMMON)
IS31FL_RGB_set_scaling_buffer(index, enabled, enabled, enabled);
-# elif defined(CKLED2001)
- ckled2001_set_led_control_register(index, enabled, enabled, enabled);
+# elif defined(RGB_MATRIX_SNLED27351)
+ snled27351_set_led_control_register(index, enabled, enabled, enabled);
# endif
}
// This actually updates the LED drivers
-# if defined(IS31FL3731)
- is31fl3731_update_led_control_registers(DRIVER_ADDR_1, 0);
-# if defined(DRIVER_ADDR_2)
- is31fl3731_update_led_control_registers(DRIVER_ADDR_2, 1);
-# if defined(DRIVER_ADDR_3)
- is31fl3731_update_led_control_registers(DRIVER_ADDR_3, 2);
-# if defined(DRIVER_ADDR_4)
- is31fl3731_update_led_control_registers(DRIVER_ADDR_4, 3);
+# if defined(RGB_MATRIX_IS31FL3218)
+ is31fl3218_update_led_control_registers();
+
+# elif defined(RGB_MATRIX_IS31FL3731)
+ is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_1, 0);
+# if defined(IS31FL3731_I2C_ADDRESS_2)
+ is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_2, 1);
+# if defined(IS31FL3731_I2C_ADDRESS_3)
+ is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_3, 2);
+# if defined(IS31FL3731_I2C_ADDRESS_4)
+ is31fl3731_update_led_control_registers(IS31FL3731_I2C_ADDRESS_4, 3);
# endif
# endif
# endif
-# elif defined(IS31FL3733)
- is31fl3733_update_led_control_registers(DRIVER_ADDR_1, 0);
-# if defined(DRIVER_ADDR_2)
- is31fl3733_update_led_control_registers(DRIVER_ADDR_2, 1);
-# if defined(DRIVER_ADDR_3)
- is31fl3733_update_led_control_registers(DRIVER_ADDR_3, 2);
-# if defined(DRIVER_ADDR_4)
- is31fl3733_update_led_control_registers(DRIVER_ADDR_4, 3);
+# elif defined(RGB_MATRIX_IS31FL3733)
+ is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_1, 0);
+# if defined(IS31FL3733_I2C_ADDRESS_2)
+ is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_2, 1);
+# if defined(IS31FL3733_I2C_ADDRESS_3)
+ is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_3, 2);
+# if defined(IS31FL3733_I2C_ADDRESS_4)
+ is31fl3733_update_led_control_registers(IS31FL3733_I2C_ADDRESS_4, 3);
# endif
# endif
# endif
-# elif defined(IS31FL3736)
- is31fl3736_update_led_control_registers(DRIVER_ADDR_1, 0);
-# if defined(DRIVER_ADDR_2)
- is31fl3736_update_led_control_registers(DRIVER_ADDR_2, 1);
-# if defined(DRIVER_ADDR_3)
- is31fl3736_update_led_control_registers(DRIVER_ADDR_3, 2);
-# if defined(DRIVER_ADDR_4)
- is31fl3736_update_led_control_registers(DRIVER_ADDR_4, 3);
+# elif defined(RGB_MATRIX_IS31FL3736)
+ is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_1, 0);
+# if defined(IS31FL3736_I2C_ADDRESS_2)
+ is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_2, 1);
+# if defined(IS31FL3736_I2C_ADDRESS_3)
+ is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_3, 2);
+# if defined(IS31FL3736_I2C_ADDRESS_4)
+ is31fl3736_update_led_control_registers(IS31FL3736_I2C_ADDRESS_4, 3);
# endif
# endif
# endif
-# elif defined(IS31FL3737)
- is31fl3737_update_led_control_registers(DRIVER_ADDR_1, 0);
-# if defined(DRIVER_ADDR_2)
- is31fl3737_update_led_control_registers(DRIVER_ADDR_2, 1);
-# if defined(DRIVER_ADDR_3)
- is31fl3737_update_led_control_registers(DRIVER_ADDR_3, 2);
-# if defined(DRIVER_ADDR_4)
- is31fl3737_update_led_control_registers(DRIVER_ADDR_4, 3);
+# elif defined(RGB_MATRIX_IS31FL3737)
+ is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_1, 0);
+# if defined(IS31FL3737_I2C_ADDRESS_2)
+ is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_2, 1);
+# if defined(IS31FL3737_I2C_ADDRESS_3)
+ is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_3, 2);
+# if defined(IS31FL3737_I2C_ADDRESS_4)
+ is31fl3737_update_led_control_registers(IS31FL3737_I2C_ADDRESS_4, 3);
# endif
# endif
# endif
-# elif defined(IS31FL3741)
- is31fl3741_update_led_control_registers(DRIVER_ADDR_1, 0);
-# if defined(DRIVER_ADDR_2)
- is31fl3741_update_led_control_registers(DRIVER_ADDR_2, 1);
-# if defined(DRIVER_ADDR_3)
- is31fl3741_update_led_control_registers(DRIVER_ADDR_3, 2);
-# if defined(DRIVER_ADDR_4)
- is31fl3741_update_led_control_registers(DRIVER_ADDR_4, 3);
+# elif defined(RGB_MATRIX_IS31FL3741)
+ is31fl3741_update_led_control_registers(IS31FL3741_I2C_ADDRESS_1, 0);
+# if defined(IS31FL3741_I2C_ADDRESS_2)
+ is31fl3741_update_led_control_registers(IS31FL3741_I2C_ADDRESS_2, 1);
+# if defined(IS31FL3741_I2C_ADDRESS_3)
+ is31fl3741_update_led_control_registers(IS31FL3741_I2C_ADDRESS_3, 2);
+# if defined(IS31FL3741_I2C_ADDRESS_4)
+ is31fl3741_update_led_control_registers(IS31FL3741_I2C_ADDRESS_4, 3);
# endif
# endif
# endif
@@ -231,203 +232,113 @@ static void init(void) {
# endif
# endif
-# elif defined(CKLED2001)
- ckled2001_update_led_control_registers(DRIVER_ADDR_1, 0);
-# if defined(DRIVER_ADDR_2)
- ckled2001_update_led_control_registers(DRIVER_ADDR_2, 1);
-# if defined(DRIVER_ADDR_3)
- ckled2001_update_led_control_registers(DRIVER_ADDR_3, 2);
-# if defined(DRIVER_ADDR_4)
- ckled2001_update_led_control_registers(DRIVER_ADDR_4, 3);
+# elif defined(RGB_MATRIX_SNLED27351)
+ snled27351_update_led_control_registers(SNLED27351_I2C_ADDRESS_1, 0);
+# if defined(SNLED27351_I2C_ADDRESS_2)
+ snled27351_update_led_control_registers(SNLED27351_I2C_ADDRESS_2, 1);
+# if defined(SNLED27351_I2C_ADDRESS_3)
+ snled27351_update_led_control_registers(SNLED27351_I2C_ADDRESS_3, 2);
+# if defined(SNLED27351_I2C_ADDRESS_4)
+ snled27351_update_led_control_registers(SNLED27351_I2C_ADDRESS_4, 3);
# endif
# endif
# endif
# endif
}
-# if defined(IS31FL3731)
-static void flush(void) {
- is31fl3731_update_pwm_buffers(DRIVER_ADDR_1, 0);
-# if defined(DRIVER_ADDR_2)
- is31fl3731_update_pwm_buffers(DRIVER_ADDR_2, 1);
-# if defined(DRIVER_ADDR_3)
- is31fl3731_update_pwm_buffers(DRIVER_ADDR_3, 2);
-# if defined(DRIVER_ADDR_4)
- is31fl3731_update_pwm_buffers(DRIVER_ADDR_4, 3);
-# endif
-# endif
-# endif
-}
-
+# if defined(RGB_MATRIX_IS31FL3218)
const rgb_matrix_driver_t rgb_matrix_driver = {
.init = init,
- .flush = flush,
- .set_color = is31fl3731_set_color,
- .set_color_all = is31fl3731_set_color_all,
+ .flush = is31fl3218_update_pwm_buffers,
+ .set_color = is31fl3218_set_color,
+ .set_color_all = is31fl3218_set_color_all,
};
-# elif defined(IS31FL3733)
-static void flush(void) {
- is31fl3733_update_pwm_buffers(DRIVER_ADDR_1, 0);
-# if defined(DRIVER_ADDR_2)
- is31fl3733_update_pwm_buffers(DRIVER_ADDR_2, 1);
-# if defined(DRIVER_ADDR_3)
- is31fl3733_update_pwm_buffers(DRIVER_ADDR_3, 2);
-# if defined(DRIVER_ADDR_4)
- is31fl3733_update_pwm_buffers(DRIVER_ADDR_4, 3);
-# endif
-# endif
-# endif
-}
+# elif defined(RGB_MATRIX_IS31FL3731)
+const rgb_matrix_driver_t rgb_matrix_driver = {
+ .init = init,
+ .flush = is31fl3731_flush,
+ .set_color = is31fl3731_set_color,
+ .set_color_all = is31fl3731_set_color_all,
+};
+# elif defined(RGB_MATRIX_IS31FL3733)
const rgb_matrix_driver_t rgb_matrix_driver = {
.init = init,
- .flush = flush,
+ .flush = is31fl3733_flush,
.set_color = is31fl3733_set_color,
.set_color_all = is31fl3733_set_color_all,
};
-# elif defined(IS31FL3736)
-static void flush(void) {
- is31fl3736_update_pwm_buffers(DRIVER_ADDR_1, 0);
-# if defined(DRIVER_ADDR_2)
- is31fl3736_update_pwm_buffers(DRIVER_ADDR_2, 1);
-# if defined(DRIVER_ADDR_3)
- is31fl3736_update_pwm_buffers(DRIVER_ADDR_3, 2);
-# if defined(DRIVER_ADDR_4)
- is31fl3736_update_pwm_buffers(DRIVER_ADDR_4, 3);
-# endif
-# endif
-# endif
-}
-
+# elif defined(RGB_MATRIX_IS31FL3736)
const rgb_matrix_driver_t rgb_matrix_driver = {
.init = init,
- .flush = flush,
+ .flush = is31fl3736_flush,
.set_color = is31fl3736_set_color,
.set_color_all = is31fl3736_set_color_all,
};
-# elif defined(IS31FL3737)
-static void flush(void) {
- is31fl3737_update_pwm_buffers(DRIVER_ADDR_1, 0);
-# if defined(DRIVER_ADDR_2)
- is31fl3737_update_pwm_buffers(DRIVER_ADDR_2, 1);
-# if defined(DRIVER_ADDR_3)
- is31fl3737_update_pwm_buffers(DRIVER_ADDR_3, 2);
-# if defined(DRIVER_ADDR_4)
- is31fl3737_update_pwm_buffers(DRIVER_ADDR_4, 3);
-# endif
-# endif
-# endif
-}
-
+# elif defined(RGB_MATRIX_IS31FL3737)
const rgb_matrix_driver_t rgb_matrix_driver = {
.init = init,
- .flush = flush,
+ .flush = is31fl3737_flush,
.set_color = is31fl3737_set_color,
.set_color_all = is31fl3737_set_color_all,
};
-# elif defined(IS31FL3741)
-static void flush(void) {
- is31fl3741_update_pwm_buffers(DRIVER_ADDR_1, 0);
-# if defined(DRIVER_ADDR_2)
- is31fl3741_update_pwm_buffers(DRIVER_ADDR_2, 1);
-# if defined(DRIVER_ADDR_3)
- is31fl3741_update_pwm_buffers(DRIVER_ADDR_3, 2);
-# if defined(DRIVER_ADDR_4)
- is31fl3741_update_pwm_buffers(DRIVER_ADDR_4, 3);
-# endif
-# endif
-# endif
-}
-
+# elif defined(RGB_MATRIX_IS31FL3741)
const rgb_matrix_driver_t rgb_matrix_driver = {
.init = init,
- .flush = flush,
+ .flush = is31fl3741_flush,
.set_color = is31fl3741_set_color,
.set_color_all = is31fl3741_set_color_all,
};
# elif defined(IS31FLCOMMON)
-static void flush(void) {
- IS31FL_common_update_pwm_register(DRIVER_ADDR_1, 0);
-# if defined(DRIVER_ADDR_2)
- IS31FL_common_update_pwm_register(DRIVER_ADDR_2, 1);
-# if defined(DRIVER_ADDR_3)
- IS31FL_common_update_pwm_register(DRIVER_ADDR_3, 2);
-# if defined(DRIVER_ADDR_4)
- IS31FL_common_update_pwm_register(DRIVER_ADDR_4, 3);
-# endif
-# endif
-# endif
-}
-
const rgb_matrix_driver_t rgb_matrix_driver = {
.init = init,
- .flush = flush,
+ .flush = IS31FL_common_flush,
.set_color = IS31FL_RGB_set_color,
.set_color_all = IS31FL_RGB_set_color_all,
};
-# elif defined(CKLED2001)
-static void flush(void) {
- ckled2001_update_pwm_buffers(DRIVER_ADDR_1, 0);
-# if defined(DRIVER_ADDR_2)
- ckled2001_update_pwm_buffers(DRIVER_ADDR_2, 1);
-# if defined(DRIVER_ADDR_3)
- ckled2001_update_pwm_buffers(DRIVER_ADDR_3, 2);
-# if defined(DRIVER_ADDR_4)
- ckled2001_update_pwm_buffers(DRIVER_ADDR_4, 3);
-# endif
-# endif
-# endif
-}
-
+# elif defined(RGB_MATRIX_SNLED27351)
const rgb_matrix_driver_t rgb_matrix_driver = {
.init = init,
- .flush = flush,
- .set_color = ckled2001_set_color,
- .set_color_all = ckled2001_set_color_all,
+ .flush = snled27351_flush,
+ .set_color = snled27351_set_color,
+ .set_color_all = snled27351_set_color_all,
};
# endif
-#elif defined(AW20216)
+#elif defined(RGB_MATRIX_AW20216S)
# include "spi_master.h"
static void init(void) {
spi_init();
- aw20216_init(DRIVER_1_CS, DRIVER_1_EN);
-# if defined(DRIVER_2_CS)
- aw20216_init(DRIVER_2_CS, DRIVER_2_EN);
-# endif
-}
-
-static void flush(void) {
- aw20216_update_pwm_buffers(DRIVER_1_CS, 0);
-# if defined(DRIVER_2_CS)
- aw20216_update_pwm_buffers(DRIVER_2_CS, 1);
+ aw20216s_init(AW20216S_CS_PIN_1, AW20216S_EN_PIN_1);
+# if defined(AW20216S_CS_PIN_2)
+ aw20216s_init(AW20216S_CS_PIN_2, AW20216S_EN_PIN_2);
# endif
}
const rgb_matrix_driver_t rgb_matrix_driver = {
.init = init,
- .flush = flush,
- .set_color = aw20216_set_color,
- .set_color_all = aw20216_set_color_all,
+ .flush = aw20216s_flush,
+ .set_color = aw20216s_set_color,
+ .set_color_all = aw20216s_set_color_all,
};
-#elif defined(WS2812)
-# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_CUSTOM_DRIVER)
+#elif defined(RGB_MATRIX_WS2812)
+# if defined(RGBLIGHT_WS2812)
# pragma message "Cannot use RGBLIGHT and RGB Matrix using WS2812 at the same time."
# pragma message "You need to use a custom driver, or re-implement the WS2812 driver to use a different configuration."
# endif
// LED color buffer
-LED_TYPE rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT];
-bool ws2812_dirty = false;
+rgb_led_t rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT];
+bool ws2812_dirty = false;
static void init(void) {
ws2812_dirty = false;
diff --git a/quantum/rgb_matrix/rgb_matrix_types.h b/quantum/rgb_matrix/rgb_matrix_types.h
index 53ff7321b8..0a3fd7cc0d 100644
--- a/quantum/rgb_matrix/rgb_matrix_types.h
+++ b/quantum/rgb_matrix/rgb_matrix_types.h
@@ -19,16 +19,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "color.h"
-
-#if defined(__GNUC__)
-# define PACKED __attribute__((__packed__))
-#else
-# define PACKED
-#endif
-
-#if defined(_MSC_VER)
-# pragma pack(push, 1)
-#endif
+#include "util.h"
#if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES)
# define RGB_MATRIX_KEYREACTIVE_ENABLED
@@ -94,7 +85,3 @@ typedef union {
} rgb_config_t;
_Static_assert(sizeof(rgb_config_t) == sizeof(uint64_t), "RGB Matrix EECONFIG out of spec.");
-
-#if defined(_MSC_VER)
-# pragma pack(pop)
-#endif