Skip to content

Commit

Permalink
LED/RGB Matrix: add header for drivers (qmk#22628)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored and mechlovin committed Jan 17, 2024
1 parent 1ae3569 commit 05acb14
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 75 deletions.
39 changes: 1 addition & 38 deletions quantum/led_matrix/led_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,9 @@
#include <stdint.h>
#include <stdbool.h>
#include "led_matrix_types.h"
#include "led_matrix_drivers.h"
#include "keyboard.h"

#if defined(LED_MATRIX_IS31FL3218)
# include "is31fl3218-simple.h"
#elif defined(LED_MATRIX_IS31FL3731)
# include "is31fl3731-simple.h"
#endif
#ifdef LED_MATRIX_IS31FL3733
# include "is31fl3733-simple.h"
#endif
#ifdef LED_MATRIX_IS31FL3736
# include "is31fl3736-simple.h"
#endif
#ifdef LED_MATRIX_IS31FL3737
# include "is31fl3737-simple.h"
#endif
#ifdef LED_MATRIX_IS31FL3741
# include "is31fl3741-simple.h"
#endif
#if defined(IS31FLCOMMON)
# include "is31flcommon.h"
#endif
#ifdef LED_MATRIX_SNLED27351
# include "snled27351-simple.h"
#endif

#ifndef LED_MATRIX_TIMEOUT
# define LED_MATRIX_TIMEOUT 0
#endif
Expand Down Expand Up @@ -193,18 +170,6 @@ led_flags_t led_matrix_get_flags(void);
void led_matrix_set_flags(led_flags_t flags);
void led_matrix_set_flags_noeeprom(led_flags_t flags);

typedef struct {
/* Perform any initialisation required for the other driver functions to work. */
void (*init)(void);

/* Set the brightness of a single LED in the buffer. */
void (*set_value)(int index, uint8_t value);
/* Set the brightness of all LEDS on the keyboard in the buffer. */
void (*set_value_all)(uint8_t value);
/* Flush any buffered changes to the hardware. */
void (*flush)(void);
} led_matrix_driver_t;

static inline bool led_matrix_check_finished_leds(uint8_t led_idx) {
#if defined(LED_MATRIX_SPLIT)
if (is_keyboard_left()) {
Expand All @@ -217,8 +182,6 @@ static inline bool led_matrix_check_finished_leds(uint8_t led_idx) {
#endif
}

extern const led_matrix_driver_t led_matrix_driver;

extern led_eeconfig_t led_matrix_eeconfig;

extern uint32_t g_led_timer;
Expand Down
2 changes: 1 addition & 1 deletion quantum/led_matrix/led_matrix_drivers.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "led_matrix.h"
#include "led_matrix_drivers.h"

/* Each driver needs to define a struct:
*
Expand Down
38 changes: 38 additions & 0 deletions quantum/led_matrix/led_matrix_drivers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2023 QMK
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <stdint.h>

#if defined(LED_MATRIX_IS31FL3218)
# include "is31fl3218-simple.h"
#elif defined(LED_MATRIX_IS31FL3731)
# include "is31fl3731-simple.h"
#elif defined(LED_MATRIX_IS31FL3733)
# include "is31fl3733-simple.h"
#elif defined(LED_MATRIX_IS31FL3736)
# include "is31fl3736-simple.h"
#elif defined(LED_MATRIX_IS31FL3737)
# include "is31fl3737-simple.h"
#elif defined(LED_MATRIX_IS31FL3741)
# include "is31fl3741-simple.h"
#elif defined(IS31FLCOMMON)
# include "is31flcommon.h"
#elif defined(LED_MATRIX_SNLED27351)
# include "snled27351-simple.h"
#endif

typedef struct {
/* Perform any initialisation required for the other driver functions to work. */
void (*init)(void);

/* Set the brightness of a single LED in the buffer. */
void (*set_value)(int index, uint8_t value);
/* Set the brightness of all LEDS on the keyboard in the buffer. */
void (*set_value_all)(uint8_t value);
/* Flush any buffered changes to the hardware. */
void (*flush)(void);
} led_matrix_driver_t;

extern const led_matrix_driver_t led_matrix_driver;
36 changes: 1 addition & 35 deletions quantum/rgb_matrix/rgb_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()) {
Expand All @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion quantum/rgb_matrix/rgb_matrix_drivers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 41 additions & 0 deletions quantum/rgb_matrix/rgb_matrix_drivers.h
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 05acb14

Please sign in to comment.