Skip to content

Commit

Permalink
LED/RGB Matrix: prefix driver defines (qmk#22088)
Browse files Browse the repository at this point in the history
  • Loading branch information
fauxpark authored and mechlovin committed Oct 25, 2023
1 parent bce698f commit 5b86c86
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 80 deletions.
40 changes: 20 additions & 20 deletions builddefs/common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ ifeq ($(strip $(LED_MATRIX_ENABLE)), yes)
$(call CATASTROPHIC_ERROR,Invalid LED_MATRIX_DRIVER,LED_MATRIX_DRIVER="$(LED_MATRIX_DRIVER)" is not a valid matrix type)
endif
OPT_DEFS += -DLED_MATRIX_ENABLE
OPT_DEFS += -DLED_MATRIX_$(strip $(shell echo $(LED_MATRIX_DRIVER) | tr '[:lower:]' '[:upper:]'))
ifneq (,$(filter $(MCU), atmega16u2 atmega32u2 at90usb162))
# ATmegaxxU2 does not have hardware MUL instruction - lib8tion must be told to use software multiplication routines
OPT_DEFS += -DLIB8_ATTINY
Expand All @@ -376,42 +377,42 @@ endif
CIE1931_CURVE := yes

ifeq ($(strip $(LED_MATRIX_DRIVER)), is31fl3731)
OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE
OPT_DEFS += -DHAL_USE_I2C=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led/issi
SRC += is31fl3731-simple.c
QUANTUM_LIB_SRC += i2c_master.c
endif

ifeq ($(strip $(LED_MATRIX_DRIVER)), is31fl3742a)
OPT_DEFS += -DIS31FLCOMMON -DIS31FL3742A -DSTM32_I2C -DHAL_USE_I2C=TRUE
OPT_DEFS += -DIS31FLCOMMON -DHAL_USE_I2C=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led/issi
SRC += is31flcommon.c
QUANTUM_LIB_SRC += i2c_master.c
endif

ifeq ($(strip $(LED_MATRIX_DRIVER)), is31fl3743a)
OPT_DEFS += -DIS31FLCOMMON -DIS31FL3743A -DSTM32_I2C -DHAL_USE_I2C=TRUE
OPT_DEFS += -DIS31FLCOMMON -DHAL_USE_I2C=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led/issi
SRC += is31flcommon.c
QUANTUM_LIB_SRC += i2c_master.c
endif

ifeq ($(strip $(LED_MATRIX_DRIVER)), is31fl3745)
OPT_DEFS += -DIS31FLCOMMON -DIS31FL3745 -DSTM32_I2C -DHAL_USE_I2C=TRUE
OPT_DEFS += -DIS31FLCOMMON -DHAL_USE_I2C=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led/issi
SRC += is31flcommon.c
QUANTUM_LIB_SRC += i2c_master.c
endif

ifeq ($(strip $(LED_MATRIX_DRIVER)), is31fl3746a)
OPT_DEFS += -DIS31FLCOMMON -DIS31FL3746A -DSTM32_I2C -DHAL_USE_I2C=TRUE
OPT_DEFS += -DIS31FLCOMMON -DHAL_USE_I2C=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led/issi
SRC += is31flcommon.c
QUANTUM_LIB_SRC += i2c_master.c
endif

ifeq ($(strip $(LED_MATRIX_DRIVER)), ckled2001)
OPT_DEFS += -DCKLED2001 -DSTM32_I2C -DHAL_USE_I2C=TRUE
OPT_DEFS += -DHAL_USE_I2C=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led
SRC += ckled2001-simple.c
QUANTUM_LIB_SRC += i2c_master.c
Expand All @@ -432,6 +433,7 @@ ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
$(call CATASTROPHIC_ERROR,Invalid RGB_MATRIX_DRIVER,RGB_MATRIX_DRIVER="$(RGB_MATRIX_DRIVER)" is not a valid matrix type)
endif
OPT_DEFS += -DRGB_MATRIX_ENABLE
OPT_DEFS += -DRGB_MATRIX_$(strip $(shell echo $(RGB_MATRIX_DRIVER) | tr '[:lower:]' '[:upper:]'))
ifneq (,$(filter $(MCU), atmega16u2 atmega32u2 at90usb162))
# ATmegaxxU2 does not have hardware MUL instruction - lib8tion must be told to use software multiplication routines
OPT_DEFS += -DLIB8_ATTINY
Expand All @@ -448,96 +450,94 @@ endif
RGB_KEYCODES_ENABLE := yes

ifeq ($(strip $(RGB_MATRIX_DRIVER)), aw20216s)
OPT_DEFS += -DAW20216S -DSTM32_SPI -DHAL_USE_SPI=TRUE
OPT_DEFS += -DHAL_USE_SPI=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led
SRC += aw20216s.c
QUANTUM_LIB_SRC += spi_master.c
endif

ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3218)
OPT_DEFS += -DIS31FL3218 -DSTM32_I2C -DHAL_USE_I2C=TRUE
OPT_DEFS += -DHAL_USE_I2C=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led/issi
SRC += is31fl3218.c
QUANTUM_LIB_SRC += i2c_master.c
endif

ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3731)
OPT_DEFS += -DIS31FL3731 -DSTM32_I2C -DHAL_USE_I2C=TRUE
OPT_DEFS += -DHAL_USE_I2C=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led/issi
SRC += is31fl3731.c
QUANTUM_LIB_SRC += i2c_master.c
endif

ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3733)
OPT_DEFS += -DIS31FL3733 -DSTM32_I2C -DHAL_USE_I2C=TRUE
OPT_DEFS += -DHAL_USE_I2C=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led/issi
SRC += is31fl3733.c
QUANTUM_LIB_SRC += i2c_master.c
endif

ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3736)
OPT_DEFS += -DIS31FL3736 -DSTM32_I2C -DHAL_USE_I2C=TRUE
OPT_DEFS += -DHAL_USE_I2C=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led/issi
SRC += is31fl3736.c
QUANTUM_LIB_SRC += i2c_master.c
endif

ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3737)
OPT_DEFS += -DIS31FL3737 -DSTM32_I2C -DHAL_USE_I2C=TRUE
OPT_DEFS += -DHAL_USE_I2C=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led/issi
SRC += is31fl3737.c
QUANTUM_LIB_SRC += i2c_master.c
endif

ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3741)
OPT_DEFS += -DIS31FL3741 -DSTM32_I2C -DHAL_USE_I2C=TRUE
OPT_DEFS += -DHAL_USE_I2C=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led/issi
SRC += is31fl3741.c
QUANTUM_LIB_SRC += i2c_master.c
endif

ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3742a)
OPT_DEFS += -DIS31FLCOMMON -DIS31FL3742A -DSTM32_I2C -DHAL_USE_I2C=TRUE
OPT_DEFS += -DIS31FLCOMMON -DHAL_USE_I2C=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led/issi
SRC += is31flcommon.c
QUANTUM_LIB_SRC += i2c_master.c
endif

ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3743a)
OPT_DEFS += -DIS31FLCOMMON -DIS31FL3743A -DSTM32_I2C -DHAL_USE_I2C=TRUE
OPT_DEFS += -DIS31FLCOMMON -DHAL_USE_I2C=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led/issi
SRC += is31flcommon.c
QUANTUM_LIB_SRC += i2c_master.c
endif

ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3745)
OPT_DEFS += -DIS31FLCOMMON -DIS31FL3745 -DSTM32_I2C -DHAL_USE_I2C=TRUE
OPT_DEFS += -DIS31FLCOMMON -DHAL_USE_I2C=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led/issi
SRC += is31flcommon.c
QUANTUM_LIB_SRC += i2c_master.c
endif

ifeq ($(strip $(RGB_MATRIX_DRIVER)), is31fl3746a)
OPT_DEFS += -DIS31FLCOMMON -DIS31FL3746A -DSTM32_I2C -DHAL_USE_I2C=TRUE
OPT_DEFS += -DIS31FLCOMMON -DHAL_USE_I2C=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led/issi
SRC += is31flcommon.c
QUANTUM_LIB_SRC += i2c_master.c
endif

ifeq ($(strip $(RGB_MATRIX_DRIVER)), ckled2001)
OPT_DEFS += -DCKLED2001 -DSTM32_I2C -DHAL_USE_I2C=TRUE
OPT_DEFS += -DHAL_USE_I2C=TRUE
COMMON_VPATH += $(DRIVER_PATH)/led
SRC += ckled2001.c
QUANTUM_LIB_SRC += i2c_master.c
endif

ifeq ($(strip $(RGB_MATRIX_DRIVER)), ws2812)
OPT_DEFS += -DWS2812
WS2812_DRIVER_REQUIRED := yes
endif

ifeq ($(strip $(RGB_MATRIX_DRIVER)), apa102)
OPT_DEFS += -DAPA102
APA102_DRIVER_REQUIRED := yes
endif

Expand Down
8 changes: 4 additions & 4 deletions drivers/led/issi/is31flcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
#include "progmem.h"

// Which variant header file to use
#ifdef IS31FL3742A
#if defined(LED_MATRIX_IS31FL3742A) || defined(RGB_MATRIX_IS31FL3742A)
# include "is31fl3742.h"
#elif defined(IS31FL3743A)
#elif defined(LED_MATRIX_IS31FL3743A) || defined(RGB_MATRIX_IS31FL3743A)
# include "is31fl3743.h"
#elif defined(IS31FL3745)
#elif defined(LED_MATRIX_IS31FL3745) || defined(RGB_MATRIX_IS31FL3745)
# include "is31fl3745.h"
#elif defined(IS31FL3746A)
#elif defined(LED_MATRIX_IS31FL3746A) || defined(RGB_MATRIX_IS31FL3746A)
# include "is31fl3746.h"
#endif

Expand Down
6 changes: 3 additions & 3 deletions quantum/led_matrix/led_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
#include "led_matrix_types.h"
#include "keyboard.h"

#ifdef IS31FL3731
#ifdef LED_MATRIX_IS31FL3731
# include "is31fl3731-simple.h"
#elif defined(IS31FLCOMMON)
# include "is31flcommon.h"
#endif
#ifdef IS31FL3733
#ifdef LED_MATRIX_IS31FL3733
# include "is31fl3733-simple.h"
#endif
#ifdef CKLED2001
#ifdef LED_MATRIX_CKLED2001
# include "ckled2001-simple.h"
#endif

Expand Down
26 changes: 13 additions & 13 deletions quantum/led_matrix/led_matrix_drivers.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
* in their own files.
*/

#if defined(IS31FL3731) || defined(IS31FL3733) || defined(IS31FLCOMMON) || defined(CKLED2001)
#if defined(LED_MATRIX_IS31FL3731) || defined(LED_MATRIX_IS31FL3733) || defined(IS31FLCOMMON) || defined(LED_MATRIX_CKLED2001)
# include "i2c_master.h"

static void init(void) {
i2c_init();

# if defined(IS31FL3731)
# if defined(LED_MATRIX_IS31FL3731)
is31fl3731_init(LED_DRIVER_ADDR_1);
# if defined(LED_DRIVER_ADDR_2)
is31fl3731_init(LED_DRIVER_ADDR_2);
Expand All @@ -43,7 +43,7 @@ static void init(void) {
# endif
# endif

# elif defined(IS31FL3733)
# elif defined(LED_MATRIX_IS31FL3733)
# if !defined(LED_DRIVER_SYNC_1)
# define LED_DRIVER_SYNC_1 0
# endif
Expand Down Expand Up @@ -78,7 +78,7 @@ static void init(void) {
# endif
# endif
# endif
# elif defined(CKLED2001)
# elif defined(LED_MATRIX_CKLED2001)
# if defined(LED_DRIVER_SHUTDOWN_PIN)
setPinOutput(LED_DRIVER_SHUTDOWN_PIN);
writePinHigh(LED_DRIVER_SHUTDOWN_PIN);
Expand All @@ -97,19 +97,19 @@ static void init(void) {
# endif

for (int index = 0; index < LED_MATRIX_LED_COUNT; index++) {
# if defined(IS31FL3731)
# if defined(LED_MATRIX_IS31FL3731)
is31fl3731_set_led_control_register(index, true);
# elif defined(IS31FL3733)
# elif defined(LED_MATRIX_IS31FL3733)
is31fl3733_set_led_control_register(index, true);
# elif defined(IS31FLCOMMON)
IS31FL_simple_set_scaling_buffer(index, true);
# elif defined(CKLED2001)
# elif defined(LED_MATRIX_CKLED2001)
ckled2001_set_led_control_register(index, true);
# endif
}

// This actually updates the LED drivers
# if defined(IS31FL3731)
# if defined(LED_MATRIX_IS31FL3731)
is31fl3731_update_led_control_registers(LED_DRIVER_ADDR_1, 0);
# if defined(LED_DRIVER_ADDR_2)
is31fl3731_update_led_control_registers(LED_DRIVER_ADDR_2, 1);
Expand All @@ -121,7 +121,7 @@ static void init(void) {
# endif
# endif

# elif defined(IS31FL3733)
# elif defined(LED_MATRIX_IS31FL3733)
is31fl3733_update_led_control_registers(LED_DRIVER_ADDR_1, 0);
# if defined(LED_DRIVER_ADDR_2)
is31fl3733_update_led_control_registers(LED_DRIVER_ADDR_2, 1);
Expand All @@ -147,7 +147,7 @@ static void init(void) {
# endif
# endif
# endif
# elif defined(CKLED2001)
# elif defined(LED_MATRIX_CKLED2001)
ckled2001_update_led_control_registers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2)
ckled2001_update_led_control_registers(DRIVER_ADDR_2, 1);
Expand All @@ -161,7 +161,7 @@ static void init(void) {
# endif
}

# if defined(IS31FL3731)
# if defined(LED_MATRIX_IS31FL3731)
static void flush(void) {
is31fl3731_update_pwm_buffers(LED_DRIVER_ADDR_1, 0);
# if defined(LED_DRIVER_ADDR_2)
Expand All @@ -182,7 +182,7 @@ const led_matrix_driver_t led_matrix_driver = {
.set_value_all = is31fl3731_set_value_all,
};

# elif defined(IS31FL3733)
# elif defined(LED_MATRIX_IS31FL3733)
static void flush(void) {
is31fl3733_update_pwm_buffers(LED_DRIVER_ADDR_1, 0);
# if defined(LED_DRIVER_ADDR_2)
Expand Down Expand Up @@ -223,7 +223,7 @@ const led_matrix_driver_t led_matrix_driver = {
.set_value = IS31FL_simple_set_brightness,
.set_value_all = IS31FL_simple_set_brigntness_all,
};
# elif defined(CKLED2001)
# elif defined(LED_MATRIX_CKLED2001)
static void flush(void) {
ckled2001_update_pwm_buffers(DRIVER_ADDR_1, 0);
# if defined(DRIVER_ADDR_2)
Expand Down
18 changes: 9 additions & 9 deletions quantum/rgb_matrix/rgb_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@
#include "color.h"
#include "keyboard.h"

#if defined(IS31FL3218)
#if defined(RGB_MATRIX_IS31FL3218)
# include "is31fl3218.h"
#elif defined(IS31FL3731)
#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)
#elif defined(RGB_MATRIX_CKLED2001)
# include "ckled2001.h"
#elif defined(AW20216S)
#elif defined(RGB_MATRIX_AW20216S)
# include "aw20216s.h"
#elif defined(WS2812)
#elif defined(RGB_MATRIX_WS2812)
# include "ws2812.h"
#endif

Expand Down
Loading

0 comments on commit 5b86c86

Please sign in to comment.