diff options
Diffstat (limited to 'quantum/led_matrix')
-rw-r--r-- | quantum/led_matrix/led_matrix.c | 33 | ||||
-rw-r--r-- | quantum/led_matrix/led_matrix.h | 56 | ||||
-rw-r--r-- | quantum/led_matrix/led_matrix_drivers.c | 223 | ||||
-rw-r--r-- | quantum/led_matrix/led_matrix_types.h | 15 |
4 files changed, 245 insertions, 82 deletions
diff --git a/quantum/led_matrix/led_matrix.c b/quantum/led_matrix/led_matrix.c index 1676a60aa3..c13ca94077 100644 --- a/quantum/led_matrix/led_matrix.c +++ b/quantum/led_matrix/led_matrix.c @@ -58,35 +58,6 @@ const led_point_t k_led_matrix_center = LED_MATRIX_CENTER; // -----End led effect includes macros------- // ------------------------------------------ -#ifndef LED_MATRIX_TIMEOUT -# define LED_MATRIX_TIMEOUT 0 -#endif - -#if !defined(LED_MATRIX_MAXIMUM_BRIGHTNESS) || LED_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX -# undef LED_MATRIX_MAXIMUM_BRIGHTNESS -# define LED_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX -#endif - -#if !defined(LED_MATRIX_VAL_STEP) -# define LED_MATRIX_VAL_STEP 8 -#endif - -#if !defined(LED_MATRIX_SPD_STEP) -# define LED_MATRIX_SPD_STEP 16 -#endif - -#if !defined(LED_MATRIX_DEFAULT_MODE) -# define LED_MATRIX_DEFAULT_MODE LED_MATRIX_SOLID -#endif - -#if !defined(LED_MATRIX_DEFAULT_VAL) -# define LED_MATRIX_DEFAULT_VAL LED_MATRIX_MAXIMUM_BRIGHTNESS -#endif - -#if !defined(LED_MATRIX_DEFAULT_SPD) -# define LED_MATRIX_DEFAULT_SPD UINT8_MAX / 2 -#endif - // globals led_eeconfig_t led_matrix_eeconfig; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr uint32_t g_led_timer; @@ -126,7 +97,7 @@ void eeconfig_update_led_matrix(void) { void eeconfig_update_led_matrix_default(void) { dprintf("eeconfig_update_led_matrix_default\n"); - led_matrix_eeconfig.enable = 1; + led_matrix_eeconfig.enable = LED_MATRIX_DEFAULT_ON; led_matrix_eeconfig.mode = LED_MATRIX_DEFAULT_MODE; led_matrix_eeconfig.val = LED_MATRIX_DEFAULT_VAL; led_matrix_eeconfig.speed = LED_MATRIX_DEFAULT_SPD; @@ -632,7 +603,7 @@ void led_matrix_decrease_speed(void) { void led_matrix_set_flags_eeprom_helper(led_flags_t flags, bool write_to_eeprom) { led_matrix_eeconfig.flags = flags; eeconfig_flag_led_matrix(write_to_eeprom); - dprintf("led matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.flags); + dprintf("led matrix set flags [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", led_matrix_eeconfig.flags); } led_flags_t led_matrix_get_flags(void) { diff --git a/quantum/led_matrix/led_matrix.h b/quantum/led_matrix/led_matrix.h index c2533ca49c..77d4f558ac 100644 --- a/quantum/led_matrix/led_matrix.h +++ b/quantum/led_matrix/led_matrix.h @@ -25,16 +25,60 @@ #include "led_matrix_types.h" #include "keyboard.h" -#ifdef IS31FL3731 +#if defined(LED_MATRIX_IS31FL3218) +# include "is31fl3218-simple.h" +#elif defined(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 -# include "ckled2001-simple.h" +#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 + +#ifndef LED_MATRIX_MAXIMUM_BRIGHTNESS +# define LED_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX +#endif + +#ifndef LED_MATRIX_VAL_STEP +# define LED_MATRIX_VAL_STEP 8 +#endif + +#ifndef LED_MATRIX_SPD_STEP +# define LED_MATRIX_SPD_STEP 16 +#endif + +#ifndef LED_MATRIX_DEFAULT_ON +# define LED_MATRIX_DEFAULT_ON true +#endif + +#ifndef LED_MATRIX_DEFAULT_MODE +# define LED_MATRIX_DEFAULT_MODE LED_MATRIX_SOLID +#endif + +#ifndef LED_MATRIX_DEFAULT_VAL +# define LED_MATRIX_DEFAULT_VAL LED_MATRIX_MAXIMUM_BRIGHTNESS +#endif + +#ifndef LED_MATRIX_DEFAULT_SPD +# define LED_MATRIX_DEFAULT_SPD UINT8_MAX / 2 #endif #ifndef LED_MATRIX_LED_FLUSH_LIMIT diff --git a/quantum/led_matrix/led_matrix_drivers.c b/quantum/led_matrix/led_matrix_drivers.c index 13c8935d11..f52870aea5 100644 --- a/quantum/led_matrix/led_matrix_drivers.c +++ b/quantum/led_matrix/led_matrix_drivers.c @@ -25,13 +25,16 @@ * in their own files. */ -#if defined(IS31FL3731) || defined(IS31FL3733) || defined(IS31FLCOMMON) || defined(CKLED2001) +#if defined(LED_MATRIX_IS31FL3218) || defined(LED_MATRIX_IS31FL3731) || defined(LED_MATRIX_IS31FL3733) || defined(LED_MATRIX_IS31FL3736) || defined(LED_MATRIX_IS31FL3737) || defined(LED_MATRIX_IS31FL3741) || defined(IS31FLCOMMON) || defined(LED_MATRIX_SNLED27351) # include "i2c_master.h" static void init(void) { i2c_init(); -# if defined(IS31FL3731) +# if defined(LED_MATRIX_IS31FL3218) + is31fl3218_init(); + +# elif defined(LED_MATRIX_IS31FL3731) is31fl3731_init(LED_DRIVER_ADDR_1); # if defined(LED_DRIVER_ADDR_2) is31fl3731_init(LED_DRIVER_ADDR_2); @@ -43,7 +46,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 @@ -67,6 +70,42 @@ static void init(void) { # endif # endif +# elif defined(LED_MATRIX_IS31FL3736) + is31fl3736_init(LED_DRIVER_ADDR_1); +# if defined(LED_DRIVER_ADDR_2) + is31fl3736_init(LED_DRIVER_ADDR_2); +# if defined(LED_DRIVER_ADDR_3) + is31fl3736_init(LED_DRIVER_ADDR_3); +# if defined(LED_DRIVER_ADDR_4) + is31fl3736_init(LED_DRIVER_ADDR_4); +# endif +# endif +# endif + +# elif defined(LED_MATRIX_IS31FL3737) + is31fl3737_init(LED_DRIVER_ADDR_1); +# if defined(LED_DRIVER_ADDR_2) + is31fl3737_init(LED_DRIVER_ADDR_2); +# if defined(LED_DRIVER_ADDR_3) + is31fl3737_init(LED_DRIVER_ADDR_3); +# if defined(LED_DRIVER_ADDR_4) + is31fl3737_init(LED_DRIVER_ADDR_4); +# endif +# endif +# endif + +# elif defined(LED_MATRIX_IS31FL3741) + is31fl3741_init(LED_DRIVER_ADDR_1); +# if defined(LED_DRIVER_ADDR_2) + is31fl3741_init(LED_DRIVER_ADDR_2); +# if defined(LED_DRIVER_ADDR_3) + is31fl3741_init(LED_DRIVER_ADDR_3); +# if defined(LED_DRIVER_ADDR_4) + is31fl3741_init(LED_DRIVER_ADDR_4); +# endif +# endif +# endif + # elif defined(IS31FLCOMMON) IS31FL_common_init(DRIVER_ADDR_1, ISSI_SSR_1); # if defined(LED_DRIVER_ADDR_2) @@ -78,38 +117,49 @@ static void init(void) { # endif # endif # endif -# elif defined(CKLED2001) +# elif defined(LED_MATRIX_SNLED27351) # if defined(LED_DRIVER_SHUTDOWN_PIN) setPinOutput(LED_DRIVER_SHUTDOWN_PIN); writePinHigh(LED_DRIVER_SHUTDOWN_PIN); # endif - ckled2001_init(DRIVER_ADDR_1); + snled27351_init(DRIVER_ADDR_1); # if defined(DRIVER_ADDR_2) - ckled2001_init(DRIVER_ADDR_2); + snled27351_init(DRIVER_ADDR_2); # if defined(DRIVER_ADDR_3) - ckled2001_init(DRIVER_ADDR_3); + snled27351_init(DRIVER_ADDR_3); # if defined(DRIVER_ADDR_4) - ckled2001_init(DRIVER_ADDR_4); + snled27351_init(DRIVER_ADDR_4); # endif # endif # endif # endif for (int index = 0; index < LED_MATRIX_LED_COUNT; index++) { -# if defined(IS31FL3731) +# if defined(LED_MATRIX_IS31FL3218) + is31fl3218_set_led_control_register(index, true); +# elif 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(LED_MATRIX_IS31FL3736) + is31fl3736_set_led_control_register(index, true); +# elif defined(LED_MATRIX_IS31FL3737) + is31fl3737_set_led_control_register(index, true); +# elif defined(LED_MATRIX_IS31FL3741) + is31fl3741_set_led_control_register(index, true); # elif defined(IS31FLCOMMON) IS31FL_simple_set_scaling_buffer(index, true); -# elif defined(CKLED2001) - ckled2001_set_led_control_register(index, true); +# elif defined(LED_MATRIX_SNLED27351) + snled27351_set_led_control_register(index, true); # endif } // This actually updates the LED drivers -# if defined(IS31FL3731) +# if defined(LED_MATRIX_IS31FL3218) + is31fl3218_update_led_control_registers(); + +# elif 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); @@ -121,7 +171,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); @@ -133,6 +183,42 @@ static void init(void) { # endif # endif +# elif defined(LED_MATRIX_IS31FL3736) + is31fl3736_update_led_control_registers(LED_DRIVER_ADDR_1, 0); +# if defined(LED_DRIVER_ADDR_2) + is31fl3736_update_led_control_registers(LED_DRIVER_ADDR_2, 1); +# if defined(LED_DRIVER_ADDR_3) + is31fl3736_update_led_control_registers(LED_DRIVER_ADDR_3, 2); +# if defined(LED_DRIVER_ADDR_4) + is31fl3736_update_led_control_registers(LED_DRIVER_ADDR_4, 3); +# endif +# endif +# endif + +# elif defined(LED_MATRIX_IS31FL3737) + is31fl3737_update_led_control_registers(LED_DRIVER_ADDR_1, 0); +# if defined(LED_DRIVER_ADDR_2) + is31fl3737_update_led_control_registers(LED_DRIVER_ADDR_2, 1); +# if defined(LED_DRIVER_ADDR_3) + is31fl3737_update_led_control_registers(LED_DRIVER_ADDR_3, 2); +# if defined(LED_DRIVER_ADDR_4) + is31fl3737_update_led_control_registers(LED_DRIVER_ADDR_4, 3); +# endif +# endif +# endif + +# elif defined(LED_MATRIX_IS31FL3741) + is31fl3741_update_led_control_registers(LED_DRIVER_ADDR_1, 0); +# if defined(LED_DRIVER_ADDR_2) + is31fl3741_update_led_control_registers(LED_DRIVER_ADDR_2, 1); +# if defined(LED_DRIVER_ADDR_3) + is31fl3741_update_led_control_registers(LED_DRIVER_ADDR_3, 2); +# if defined(LED_DRIVER_ADDR_4) + is31fl3741_update_led_control_registers(LED_DRIVER_ADDR_4, 3); +# endif +# endif +# endif + # elif defined(IS31FLCOMMON) # ifdef ISSI_MANUAL_SCALING IS31FL_set_manual_scaling_buffer(); @@ -147,21 +233,33 @@ static void init(void) { # endif # endif # endif -# elif defined(CKLED2001) - ckled2001_update_led_control_registers(DRIVER_ADDR_1, 0); +# elif defined(LED_MATRIX_SNLED27351) + snled27351_update_led_control_registers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) - ckled2001_update_led_control_registers(DRIVER_ADDR_2, 1); + snled27351_update_led_control_registers(DRIVER_ADDR_2, 1); # if defined(DRIVER_ADDR_3) - ckled2001_update_led_control_registers(DRIVER_ADDR_3, 2); + snled27351_update_led_control_registers(DRIVER_ADDR_3, 2); # if defined(DRIVER_ADDR_4) - ckled2001_update_led_control_registers(DRIVER_ADDR_4, 3); + snled27351_update_led_control_registers(DRIVER_ADDR_4, 3); # endif # endif # endif # endif } -# if defined(IS31FL3731) +# if defined(LED_MATRIX_IS31FL3218) +static void flush(void) { + is31fl3218_update_pwm_buffers(); +} + +const led_matrix_driver_t led_matrix_driver = { + .init = init, + .flush = flush, + .set_value = is31fl3218_set_value, + .set_value_all = is31fl3218_set_value_all, +}; + +# elif defined(LED_MATRIX_IS31FL3731) static void flush(void) { is31fl3731_update_pwm_buffers(LED_DRIVER_ADDR_1, 0); # if defined(LED_DRIVER_ADDR_2) @@ -176,13 +274,13 @@ static void flush(void) { } const led_matrix_driver_t led_matrix_driver = { - .init = init, - .flush = flush, - .set_value = is31fl3731_set_value, + .init = init, + .flush = flush, + .set_value = is31fl3731_set_value, .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) @@ -203,6 +301,69 @@ const led_matrix_driver_t led_matrix_driver = { .set_value_all = is31fl3733_set_value_all, }; +# elif defined(LED_MATRIX_IS31FL3736) +static void flush(void) { + is31fl3736_update_pwm_buffers(LED_DRIVER_ADDR_1, 0); +# if defined(LED_DRIVER_ADDR_2) + is31fl3736_update_pwm_buffers(LED_DRIVER_ADDR_2, 1); +# if defined(LED_DRIVER_ADDR_3) + is31fl3736_update_pwm_buffers(LED_DRIVER_ADDR_3, 2); +# if defined(LED_DRIVER_ADDR_4) + is31fl3736_update_pwm_buffers(LED_DRIVER_ADDR_4, 3); +# endif +# endif +# endif +} + +const led_matrix_driver_t led_matrix_driver = { + .init = init, + .flush = flush, + .set_value = is31fl3736_set_value, + .set_value_all = is31fl3736_set_value_all, +}; + +# elif defined(LED_MATRIX_IS31FL3737) +static void flush(void) { + is31fl3737_update_pwm_buffers(LED_DRIVER_ADDR_1, 0); +# if defined(LED_DRIVER_ADDR_2) + is31fl3737_update_pwm_buffers(LED_DRIVER_ADDR_2, 1); +# if defined(LED_DRIVER_ADDR_3) + is31fl3737_update_pwm_buffers(LED_DRIVER_ADDR_3, 2); +# if defined(LED_DRIVER_ADDR_4) + is31fl3737_update_pwm_buffers(LED_DRIVER_ADDR_4, 3); +# endif +# endif +# endif +} + +const led_matrix_driver_t led_matrix_driver = { + .init = init, + .flush = flush, + .set_value = is31fl3737_set_value, + .set_value_all = is31fl3737_set_value_all, +}; + +# elif defined(LED_MATRIX_IS31FL3741) +static void flush(void) { + is31fl3741_update_pwm_buffers(LED_DRIVER_ADDR_1, 0); +# if defined(LED_DRIVER_ADDR_2) + is31fl3741_update_pwm_buffers(LED_DRIVER_ADDR_2, 1); +# if defined(LED_DRIVER_ADDR_3) + is31fl3741_update_pwm_buffers(LED_DRIVER_ADDR_3, 2); +# if defined(LED_DRIVER_ADDR_4) + is31fl3741_update_pwm_buffers(LED_DRIVER_ADDR_4, 3); +# endif +# endif +# endif +} + +const led_matrix_driver_t led_matrix_driver = { + .init = init, + .flush = flush, + .set_value = is31fl3741_set_value, + .set_value_all = is31fl3741_set_value_all, +}; + # elif defined(IS31FLCOMMON) static void flush(void) { IS31FL_common_update_pwm_register(DRIVER_ADDR_1, 0); @@ -223,15 +384,15 @@ 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_SNLED27351) static void flush(void) { - ckled2001_update_pwm_buffers(DRIVER_ADDR_1, 0); + snled27351_update_pwm_buffers(DRIVER_ADDR_1, 0); # if defined(DRIVER_ADDR_2) - ckled2001_update_pwm_buffers(DRIVER_ADDR_2, 1); + snled27351_update_pwm_buffers(DRIVER_ADDR_2, 1); # if defined(DRIVER_ADDR_3) - ckled2001_update_pwm_buffers(DRIVER_ADDR_3, 2); + snled27351_update_pwm_buffers(DRIVER_ADDR_3, 2); # if defined(DRIVER_ADDR_4) - ckled2001_update_pwm_buffers(DRIVER_ADDR_4, 3); + snled27351_update_pwm_buffers(DRIVER_ADDR_4, 3); # endif # endif # endif @@ -240,8 +401,8 @@ static void flush(void) { const led_matrix_driver_t led_matrix_driver = { .init = init, .flush = flush, - .set_value = ckled2001_set_value, - .set_value_all = ckled2001_set_value_all, + .set_value = snled27351_set_value, + .set_value_all = snled27351_set_value_all, }; # endif #endif diff --git a/quantum/led_matrix/led_matrix_types.h b/quantum/led_matrix/led_matrix_types.h index 6709a558bb..5a516ceb10 100644 --- a/quantum/led_matrix/led_matrix_types.h +++ b/quantum/led_matrix/led_matrix_types.h @@ -18,16 +18,7 @@ #include <stdint.h> #include <stdbool.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(LED_MATRIX_KEYPRESSES) || defined(LED_MATRIX_KEYRELEASES) # define LED_MATRIX_KEYREACTIVE_ENABLED @@ -92,7 +83,3 @@ typedef union { } led_eeconfig_t; _Static_assert(sizeof(led_eeconfig_t) == sizeof(uint32_t), "LED Matrix EECONFIG out of spec."); - -#if defined(_MSC_VER) -# pragma pack(pop) -#endif |