summaryrefslogtreecommitdiffstats
path: root/quantum/rgb_matrix/rgb_matrix.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/rgb_matrix/rgb_matrix.c')
-rw-r--r--quantum/rgb_matrix/rgb_matrix.c56
1 files changed, 29 insertions, 27 deletions
diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c
index 2730686839..539ca0e100 100644
--- a/quantum/rgb_matrix/rgb_matrix.c
+++ b/quantum/rgb_matrix/rgb_matrix.c
@@ -56,12 +56,8 @@ __attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) {
// -----End rgb effect includes macros-------
// ------------------------------------------
-#if defined(RGB_DISABLE_AFTER_TIMEOUT) && !defined(RGB_DISABLE_TIMEOUT)
-# define RGB_DISABLE_TIMEOUT (RGB_DISABLE_AFTER_TIMEOUT * 1200UL)
-#endif
-
-#ifndef RGB_DISABLE_TIMEOUT
-# define RGB_DISABLE_TIMEOUT 0
+#ifndef RGB_MATRIX_TIMEOUT
+# define RGB_MATRIX_TIMEOUT 0
#endif
#if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX
@@ -126,9 +122,9 @@ static uint8_t rgb_last_enable = UINT8_MAX;
static uint8_t rgb_last_effect = UINT8_MAX;
static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false};
static rgb_task_states rgb_task_state = SYNCING;
-#if RGB_DISABLE_TIMEOUT > 0
+#if RGB_MATRIX_TIMEOUT > 0
static uint32_t rgb_anykey_timer;
-#endif // RGB_DISABLE_TIMEOUT > 0
+#endif // RGB_MATRIX_TIMEOUT > 0
// double buffers
static uint32_t rgb_timer_buffer;
@@ -202,7 +198,7 @@ void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) {
void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) {
#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT)
- for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++)
+ for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++)
rgb_matrix_set_color(i, red, green, blue);
#else
rgb_matrix_driver.set_color_all(red, green, blue);
@@ -213,9 +209,9 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) {
#ifndef RGB_MATRIX_SPLIT
if (!is_keyboard_master()) return;
#endif
-#if RGB_DISABLE_TIMEOUT > 0
+#if RGB_MATRIX_TIMEOUT > 0
rgb_anykey_timer = 0;
-#endif // RGB_DISABLE_TIMEOUT > 0
+#endif // RGB_MATRIX_TIMEOUT > 0
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
uint8_t led[LED_HITS_TO_REMEMBER];
@@ -296,17 +292,17 @@ static bool rgb_matrix_none(effect_params_t *params) {
}
static void rgb_task_timers(void) {
-#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0
+#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_MATRIX_TIMEOUT > 0
uint32_t deltaTime = sync_timer_elapsed32(rgb_timer_buffer);
-#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_DISABLE_TIMEOUT > 0
+#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_MATRIX_TIMEOUT > 0
rgb_timer_buffer = sync_timer_read32();
// Update double buffer timers
-#if RGB_DISABLE_TIMEOUT > 0
+#if RGB_MATRIX_TIMEOUT > 0
if (rgb_anykey_timer + deltaTime <= UINT32_MAX) {
rgb_anykey_timer += deltaTime;
}
-#endif // RGB_DISABLE_TIMEOUT > 0
+#endif // RGB_MATRIX_TIMEOUT > 0
// Update double buffer last hit timers
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
@@ -419,9 +415,9 @@ void rgb_matrix_task(void) {
// Ideally we would also stop sending zeros to the LED driver PWM buffers
// while suspended and just do a software shutdown. This is a cheap hack for now.
bool suspend_backlight = suspend_state ||
-#if RGB_DISABLE_TIMEOUT > 0
- (rgb_anykey_timer > (uint32_t)RGB_DISABLE_TIMEOUT) ||
-#endif // RGB_DISABLE_TIMEOUT > 0
+#if RGB_MATRIX_TIMEOUT > 0
+ (rgb_anykey_timer > (uint32_t)RGB_MATRIX_TIMEOUT) ||
+#endif // RGB_MATRIX_TIMEOUT > 0
false;
uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode;
@@ -448,12 +444,15 @@ void rgb_matrix_task(void) {
void rgb_matrix_indicators(void) {
rgb_matrix_indicators_kb();
- rgb_matrix_indicators_user();
}
-__attribute__((weak)) void rgb_matrix_indicators_kb(void) {}
+__attribute__((weak)) bool rgb_matrix_indicators_kb(void) {
+ return rgb_matrix_indicators_user();
+}
-__attribute__((weak)) void rgb_matrix_indicators_user(void) {}
+__attribute__((weak)) bool rgb_matrix_indicators_user(void) {
+ return true;
+}
void rgb_matrix_indicators_advanced(effect_params_t *params) {
/* special handling is needed for "params->iter", since it's already been incremented.
@@ -461,21 +460,24 @@ void rgb_matrix_indicators_advanced(effect_params_t *params) {
* and not sure which would be better. Otherwise, this should be called from
* rgb_task_render, right before the iter++ line.
*/
-#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < DRIVER_LED_TOTAL
+#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < RGB_MATRIX_LED_COUNT
uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * (params->iter - 1);
uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT;
- if (max > DRIVER_LED_TOTAL) max = DRIVER_LED_TOTAL;
+ if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT;
#else
uint8_t min = 0;
- uint8_t max = DRIVER_LED_TOTAL;
+ uint8_t max = RGB_MATRIX_LED_COUNT;
#endif
rgb_matrix_indicators_advanced_kb(min, max);
- rgb_matrix_indicators_advanced_user(min, max);
}
-__attribute__((weak)) void rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {}
+__attribute__((weak)) bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
+ return rgb_matrix_indicators_advanced_user(led_min, led_max);
+}
-__attribute__((weak)) void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {}
+__attribute__((weak)) bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
+ return true;
+}
void rgb_matrix_init(void) {
rgb_matrix_driver.init();