summaryrefslogtreecommitdiff
path: root/quantum/rgb_matrix
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/rgb_matrix')
-rw-r--r--quantum/rgb_matrix/rgb_matrix.c19
-rw-r--r--quantum/rgb_matrix/rgb_matrix.h36
-rw-r--r--quantum/rgb_matrix/rgb_matrix_drivers.c6
-rw-r--r--quantum/rgb_matrix/rgb_matrix_drivers.h41
4 files changed, 50 insertions, 52 deletions
diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c
index d93d189827..ebaf3077dc 100644
--- a/quantum/rgb_matrix/rgb_matrix.c
+++ b/quantum/rgb_matrix/rgb_matrix.c
@@ -76,9 +76,6 @@ 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_MATRIX_TIMEOUT > 0
-static uint32_t rgb_anykey_timer;
-#endif // RGB_MATRIX_TIMEOUT > 0
// double buffers
static uint32_t rgb_timer_buffer;
@@ -163,9 +160,6 @@ void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) {
#ifndef RGB_MATRIX_SPLIT
if (!is_keyboard_master()) return;
#endif
-#if RGB_MATRIX_TIMEOUT > 0
- rgb_anykey_timer = 0;
-#endif // RGB_MATRIX_TIMEOUT > 0
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
uint8_t led[LED_HITS_TO_REMEMBER];
@@ -246,18 +240,11 @@ static bool rgb_matrix_none(effect_params_t *params) {
}
static void rgb_task_timers(void) {
-#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_MATRIX_TIMEOUT > 0
+#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED)
uint32_t deltaTime = sync_timer_elapsed32(rgb_timer_buffer);
-#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_MATRIX_TIMEOUT > 0
+#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED)
rgb_timer_buffer = sync_timer_read32();
- // Update double buffer timers
-#if RGB_MATRIX_TIMEOUT > 0
- if (rgb_anykey_timer + deltaTime <= UINT32_MAX) {
- rgb_anykey_timer += deltaTime;
- }
-#endif // RGB_MATRIX_TIMEOUT > 0
-
// Update double buffer last hit timers
#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED
uint8_t count = last_hit_buffer.count;
@@ -370,7 +357,7 @@ void rgb_matrix_task(void) {
// while suspended and just do a software shutdown. This is a cheap hack for now.
bool suspend_backlight = suspend_state ||
#if RGB_MATRIX_TIMEOUT > 0
- (rgb_anykey_timer > (uint32_t)RGB_MATRIX_TIMEOUT) ||
+ (last_input_activity_elapsed() > (uint32_t)RGB_MATRIX_TIMEOUT) ||
#endif // RGB_MATRIX_TIMEOUT > 0
false;
diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h
index 9a3ffb8ea3..b1bf839bf6 100644
--- a/quantum/rgb_matrix/rgb_matrix.h
+++ b/quantum/rgb_matrix/rgb_matrix.h
@@ -21,31 +21,10 @@
#include <stdint.h>
#include <stdbool.h>
#include "rgb_matrix_types.h"
+#include "rgb_matrix_drivers.h"
#include "color.h"
#include "keyboard.h"
-#if defined(RGB_MATRIX_IS31FL3218)
-# include "is31fl3218.h"
-#elif defined(RGB_MATRIX_IS31FL3731)
-# include "is31fl3731.h"
-#elif defined(RGB_MATRIX_IS31FL3733)
-# include "is31fl3733.h"
-#elif defined(RGB_MATRIX_IS31FL3736)
-# include "is31fl3736.h"
-#elif defined(RGB_MATRIX_IS31FL3737)
-# include "is31fl3737.h"
-#elif defined(RGB_MATRIX_IS31FL3741)
-# include "is31fl3741.h"
-#elif defined(IS31FLCOMMON)
-# include "is31flcommon.h"
-#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
@@ -272,17 +251,6 @@ void rgb_matrix_set_flags_noeeprom(led_flags_t flags);
# define rgblight_decrease_speed_noeeprom rgb_matrix_decrease_speed_noeeprom
#endif
-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;
-
static inline bool rgb_matrix_check_finished_leds(uint8_t led_idx) {
#if defined(RGB_MATRIX_SPLIT)
if (is_keyboard_left()) {
@@ -295,8 +263,6 @@ static inline bool rgb_matrix_check_finished_leds(uint8_t led_idx) {
#endif
}
-extern const rgb_matrix_driver_t rgb_matrix_driver;
-
extern rgb_config_t rgb_matrix_config;
extern uint32_t g_rgb_timer;
diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c
index 0f979cb233..e7bed0bf72 100644
--- a/quantum/rgb_matrix/rgb_matrix_drivers.c
+++ b/quantum/rgb_matrix/rgb_matrix_drivers.c
@@ -14,7 +14,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "rgb_matrix.h"
+#include "rgb_matrix_drivers.h"
+
+#include <stdbool.h>
+#include "keyboard.h"
+#include "color.h"
#include "util.h"
/* Each driver needs to define the struct
diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.h b/quantum/rgb_matrix/rgb_matrix_drivers.h
new file mode 100644
index 0000000000..991344f087
--- /dev/null
+++ b/quantum/rgb_matrix/rgb_matrix_drivers.h
@@ -0,0 +1,41 @@
+// Copyright 2023 QMK
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <stdint.h>
+
+#if defined(RGB_MATRIX_AW20216S)
+# include "aw20216s.h"
+#elif defined(RGB_MATRIX_IS31FL3218)
+# include "is31fl3218.h"
+#elif defined(RGB_MATRIX_IS31FL3731)
+# include "is31fl3731.h"
+#elif defined(RGB_MATRIX_IS31FL3733)
+# include "is31fl3733.h"
+#elif defined(RGB_MATRIX_IS31FL3736)
+# include "is31fl3736.h"
+#elif defined(RGB_MATRIX_IS31FL3737)
+# include "is31fl3737.h"
+#elif defined(RGB_MATRIX_IS31FL3741)
+# include "is31fl3741.h"
+#elif defined(IS31FLCOMMON)
+# include "is31flcommon.h"
+#elif defined(RGB_MATRIX_SNLED27351)
+# include "snled27351.h"
+#elif defined(RGB_MATRIX_WS2812)
+# include "ws2812.h"
+#endif
+
+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;