From e8bbcaa6719cd355db3183863f1b5169e0e0d34a Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sun, 16 Sep 2018 15:46:29 -0400 Subject: [PATCH] working on arm and avr --- common_features.mk | 68 +++++++++++++++--- drivers/arm/ws2812.c | 33 +++++++++ drivers/arm/ws2812.h | 6 ++ drivers/avr/ws2812.c | 28 +++++++- drivers/avr/ws2812.h | 4 ++ keyboards/clueboard/card/card.c | 12 ++++ keyboards/clueboard/card/config.h | 7 +- .../clueboard/card/keymaps/default/rules.mk | 21 ------ keyboards/clueboard/card/rules.mk | 13 ++-- keyboards/planck/rev6/config.h | 6 ++ keyboards/planck/rev6/rev6.c | 22 +++++- keyboards/planck/rev6/rules.mk | 3 +- quantum/rgb_matrix.c | 69 ++++++++++++++++--- quantum/rgb_matrix.h | 12 +++- 14 files changed, 253 insertions(+), 51 deletions(-) diff --git a/common_features.mk b/common_features.mk index b12b6ae518..08bf893b7c 100644 --- a/common_features.mk +++ b/common_features.mk @@ -61,8 +61,8 @@ endif ifeq ($(strip $(STENO_ENABLE)), yes) OPT_DEFS += -DSTENO_ENABLE - VIRTSER_ENABLE := yes - SRC += $(QUANTUM_DIR)/process_keycode/process_steno.c + VIRTSER_ENABLE := yes + SRC += $(QUANTUM_DIR)/process_keycode/process_steno.c endif ifeq ($(strip $(VIRTSER_ENABLE)), yes) @@ -75,9 +75,9 @@ ifeq ($(strip $(FAUXCLICKY_ENABLE)), yes) endif ifeq ($(strip $(POINTING_DEVICE_ENABLE)), yes) - OPT_DEFS += -DPOINTING_DEVICE_ENABLE - OPT_DEFS += -DMOUSE_ENABLE - SRC += $(QUANTUM_DIR)/pointing_device.c + OPT_DEFS += -DPOINTING_DEVICE_ENABLE + OPT_DEFS += -DMOUSE_ENABLE + SRC += $(QUANTUM_DIR)/pointing_device.c endif ifeq ($(strip $(UCIS_ENABLE)), yes) @@ -110,12 +110,14 @@ ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) ifeq ($(strip $(RGBLIGHT_CUSTOM_DRIVER)), yes) OPT_DEFS += -DRGBLIGHT_CUSTOM_DRIVER else - SRC += ws2812.c + SRC += ws2812.c endif endif ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes) OPT_DEFS += -DRGB_MATRIX_ENABLE + OPT_DEFS += -DIS31FL3731 + COMMON_VPATH += $(DRIVER_PATH)/issi SRC += is31fl3731.c SRC += i2c_master.c SRC += $(QUANTUM_DIR)/color.c @@ -123,6 +125,37 @@ ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes) CIE1931_CURVE = yes endif +ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3731) + OPT_DEFS += -DRGB_MATRIX_ENABLE + OPT_DEFS += -DIS31FL3731 + COMMON_VPATH += $(DRIVER_PATH)/issi + SRC += is31fl3731.c + SRC += i2c_master.c + SRC += $(QUANTUM_DIR)/color.c + SRC += $(QUANTUM_DIR)/rgb_matrix.c + CIE1931_CURVE = yes +endif + +ifeq ($(strip $(RGB_MATRIX_ENABLE)), IS31FL3733) + OPT_DEFS += -DRGB_MATRIX_ENABLE + OPT_DEFS += -DIS31FL3733 + COMMON_VPATH += $(DRIVER_PATH)/issi + SRC += is31fl3733.c + SRC += i2c_master.c + SRC += $(QUANTUM_DIR)/color.c + SRC += $(QUANTUM_DIR)/rgb_matrix.c + CIE1931_CURVE = yes +endif + +ifeq ($(strip $(RGB_MATRIX_ENABLE)), WS2812) + OPT_DEFS += -DRGB_MATRIX_ENABLE + OPT_DEFS += -DWS2812 + SRC += ws2812.c + SRC += $(QUANTUM_DIR)/color.c + SRC += $(QUANTUM_DIR)/rgb_matrix.c + CIE1931_CURVE = yes +endif + ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) OPT_DEFS += -DTAP_DANCE_ENABLE SRC += $(QUANTUM_DIR)/process_keycode/process_tap_dance.c @@ -169,7 +202,7 @@ ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) ifeq ($(strip $(VISUALIZER_ENABLE)), yes) CIE1931_CURVE = yes endif - ifeq ($(strip $(BACKLIGHT_CUSTOM_DRIVER)), yes) + ifeq ($(strip $(BACKLIGHT_CUSTOM_DRIVER)), yes) OPT_DEFS += -DBACKLIGHT_CUSTOM_DRIVER endif endif @@ -200,7 +233,12 @@ endif ifeq ($(strip $(HD44780_ENABLE)), yes) SRC += drivers/avr/hd44780.c - OPT_DEFS += -DHD44780_ENABLE + OPT_DEFS += -DHD44780_ENABLE +endif + +ifeq ($(strip $(DYNAMIC_KEYMAP_ENABLE)), yes) + OPT_DEFS += -DDYNAMIC_KEYMAP_ENABLE + SRC += $(QUANTUM_DIR)/dynamic_keymap.c endif QUANTUM_SRC:= \ @@ -210,5 +248,17 @@ QUANTUM_SRC:= \ $(QUANTUM_DIR)/process_keycode/process_leader.c ifndef CUSTOM_MATRIX - QUANTUM_SRC += $(QUANTUM_DIR)/matrix.c + ifeq ($(strip $(SPLIT_KEYBOARD)), yes) + QUANTUM_SRC += $(QUANTUM_DIR)/split_common/matrix.c + else + QUANTUM_SRC += $(QUANTUM_DIR)/matrix.c + endif +endif + +ifeq ($(strip $(SPLIT_KEYBOARD)), yes) + OPT_DEFS += -DSPLIT_KEYBOARD + QUANTUM_SRC += $(QUANTUM_DIR)/split_common/split_flags.c \ + $(QUANTUM_DIR)/split_common/split_util.c \ + $(QUANTUM_DIR)/split_common/i2c.c \ + $(QUANTUM_DIR)/split_common/serial.c endif diff --git a/drivers/arm/ws2812.c b/drivers/arm/ws2812.c index a176755098..3d4f92967e 100644 --- a/drivers/arm/ws2812.c +++ b/drivers/arm/ws2812.c @@ -13,6 +13,7 @@ static int sLeds; static stm32_gpio_t *sPort; static uint32_t sMask; uint8_t* dma_source; +static LED_TYPE led_array[RGBLED_NUM]; void setColor(uint8_t color, uint8_t *buf,uint32_t mask){ int i; @@ -43,6 +44,14 @@ void setColorRGB(Color c, uint8_t *buf, uint32_t mask) { * @param[out] o_fb initialized frame buffer * */ + +void WS2812_init(void) { + static uint8_t * p; + //uint32_t port = RGBLED_PORT; + //ledDriverInit(RGBLED_NUM, (stm32_gpio_t *)(port & 0xFFF0), 1 << (port & 0xF), &p); + ledDriverInit(RGBLED_NUM, GPIOA, 0b00000010, &p); +} + void ledDriverInit(int leds, stm32_gpio_t *port, uint32_t mask, uint8_t **o_fb) { sLeds=leds; sPort=port; @@ -167,3 +176,27 @@ void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds) { void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds) { } + +void WS2812_send_color( uint8_t index ) { + setColor(led_array[index].g, (fb+24*index), sMask); + setColor(led_array[index].r, (fb+24*index)+8, sMask); + setColor(led_array[index].b, (fb+24*index)+16, sMask); +} + +void WS2812_set_color( uint8_t index, uint8_t red, uint8_t green, uint8_t blue ) { + led_array[index].r = red; + led_array[index].g = green; + led_array[index].b = blue; +} + +void WS2812_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) { + for (int i = 0; i < RGBLED_NUM; i++) { + WS2812_set_color( i, red, green, blue ); + } +} + +void WS2812_send_colors(void) { + for (int i = 0; i < RGBLED_NUM; i++) { + WS2812_send_color( i ); + } +} diff --git a/drivers/arm/ws2812.h b/drivers/arm/ws2812.h index cd8d11f0d6..299330921d 100644 --- a/drivers/arm/ws2812.h +++ b/drivers/arm/ws2812.h @@ -28,4 +28,10 @@ void ledDriverWaitCycle(void); void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds); void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds); + +void WS2812_init(void); +void WS2812_set_color( uint8_t index, uint8_t red, uint8_t green, uint8_t blue ); +void WS2812_set_color_all( uint8_t red, uint8_t green, uint8_t blue ); +void WS2812_send_colors(void); + #endif /* LEDDRIVER_H_ */ diff --git a/drivers/avr/ws2812.c b/drivers/avr/ws2812.c index 59e032bf71..6f73223593 100644 --- a/drivers/avr/ws2812.c +++ b/drivers/avr/ws2812.c @@ -27,6 +27,8 @@ #include #include "debug.h" +static LED_TYPE led_array[RGBLED_NUM]; + #ifdef RGBW_BB_TWI // Port for the I2C @@ -128,11 +130,11 @@ unsigned char I2C_Write(unsigned char c) c <<= 1; } - + I2C_WriteBit(0); _delay_us(I2C_DELAY); _delay_us(I2C_DELAY); - + // _delay_us(I2C_DELAY); //return I2C_ReadBit(); return 0; @@ -141,6 +143,28 @@ unsigned char I2C_Write(unsigned char c) #endif +// for RGB matrix + +void WS2812_init(void) { + +} + +void WS2812_set_color( uint8_t index, uint8_t red, uint8_t green, uint8_t blue ) { + led_array[index].r = red; + led_array[index].g = green; + led_array[index].b = blue; +} + +void WS2812_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) { + for (int i = 0; i < RGBLED_NUM; i++) { + WS2812_set_color( i, red, green, blue ); + } +} + +void inline WS2812_send_colors(void) { + ws2812_setleds_pin(led_array, RGBLED_NUM, _BV(RGB_DI_PIN & 0xF)); +} + // Setleds for standard RGB void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) { diff --git a/drivers/avr/ws2812.h b/drivers/avr/ws2812.h index f7e0c31440..a4c09e15fc 100644 --- a/drivers/avr/ws2812.h +++ b/drivers/avr/ws2812.h @@ -30,6 +30,10 @@ #include "rgblight_types.h" +void WS2812_init(void); +void WS2812_set_color( uint8_t index, uint8_t red, uint8_t green, uint8_t blue ); +void WS2812_set_color_all( uint8_t red, uint8_t green, uint8_t blue ); +void WS2812_send_colors(void); /* User Interface * diff --git a/keyboards/clueboard/card/card.c b/keyboards/clueboard/card/card.c index 9b4b397d92..653750b0ad 100644 --- a/keyboards/clueboard/card/card.c +++ b/keyboards/clueboard/card/card.c @@ -3,6 +3,18 @@ #define BL_GREEN OCR1A #define BL_BLUE OCR1C +const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { + + /*{row | col << 4} + | {x=0..224, y=0..64} + | | modifier + | | | */ + {{0|(0<<4)}, {0, 32}, 0}, + {{0|(1<<4)}, {75, 32}, 0}, + {{0|(2<<4)}, {150, 32}, 0}, + {{0|(2<<4)}, {224, 23}, 0}, +}; + void matrix_init_kb(void) { // put your keyboard start-up code here // runs once when the firmware starts up diff --git a/keyboards/clueboard/card/config.h b/keyboards/clueboard/card/config.h index 6520eb5574..83aa99f08f 100644 --- a/keyboards/clueboard/card/config.h +++ b/keyboards/clueboard/card/config.h @@ -48,7 +48,7 @@ along with this program. If not, see . /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION ROW2COL - + /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCING_DELAY 20 @@ -146,6 +146,11 @@ along with this program. If not, see . #define RGBLIGHT_SAT_STEP 17 #define RGBLIGHT_VAL_STEP 17 +#define WS2812_LED_N RGBLED_NUM +#define DRIVER_LED_TOTAL RGBLED_NUM + +#define RGB_MATRIX_KEYPRESSES + /* * Feature disable options * These options are also useful to firmware size reduction. diff --git a/keyboards/clueboard/card/keymaps/default/rules.mk b/keyboards/clueboard/card/keymaps/default/rules.mk index 8ee841da02..e69de29bb2 100644 --- a/keyboards/clueboard/card/keymaps/default/rules.mk +++ b/keyboards/clueboard/card/keymaps/default/rules.mk @@ -1,21 +0,0 @@ -# Build Options -# change to "no" to disable the options, or define them in the Makefile in -# the appropriate keymap folder that will get included automatically -# -BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = no # Mouse keys(+4700) -EXTRAKEY_ENABLE = no # Audio control and System control(+450) -CONSOLE_ENABLE = yes # Console for debug(+400) -COMMAND_ENABLE = yes # Commands for debug and configuration -NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality -MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = yes # Audio output on port C6 -UNICODE_ENABLE = no # Unicode -BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend - -ifndef QUANTUM_DIR - include ../../../../Makefile -endif diff --git a/keyboards/clueboard/card/rules.mk b/keyboards/clueboard/card/rules.mk index 2117c81272..2a270fed2d 100644 --- a/keyboards/clueboard/card/rules.mk +++ b/keyboards/clueboard/card/rules.mk @@ -54,16 +54,17 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 # change yes to no to disable # BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = yes # Mouse keys(+4700) -EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = yes # Console for debug(+400) -COMMAND_ENABLE = yes # Commands for debug and configuration +MOUSEKEY_ENABLE = no # Mouse keys(+4700) +EXTRAKEY_ENABLE = no # Audio control and System control(+450) +CONSOLE_ENABLE = no # Console for debug(+400) +COMMAND_ENABLE = no # Commands for debug and configuration # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend # if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work NKRO_ENABLE = no # USB Nkey Rollover -RGBLIGHT_ENABLE = yes # Enable keyboard underlight functionality (+4870) -BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality by default +RGBLIGHT_ENABLE = no # Enable keyboard underlight functionality (+4870) +RGB_MATRIX_ENABLE = WS2812 +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality by default MIDI_ENABLE = no # MIDI controls UNICODE_ENABLE = no # Unicode BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID diff --git a/keyboards/planck/rev6/config.h b/keyboards/planck/rev6/config.h index 8c8da2cea2..3c7d2cb381 100644 --- a/keyboards/planck/rev6/config.h +++ b/keyboards/planck/rev6/config.h @@ -128,7 +128,13 @@ #define RGBLIGHT_ANIMATIONS #define WS2812_LED_N 9 + #define RGBLED_NUM WS2812_LED_N +#define RGBLED_PORT ((uint32_t)GPIOA | 1) +#define DRIVER_LED_TOTAL RGBLED_NUM + +#define RGB_MATRIX_KEYPRESSES + #define WS2812_TIM_N 2 #define WS2812_TIM_CH 2 #define PORT_WS2812 GPIOA diff --git a/keyboards/planck/rev6/rev6.c b/keyboards/planck/rev6/rev6.c index f1d0a17038..ab10eb45f1 100644 --- a/keyboards/planck/rev6/rev6.c +++ b/keyboards/planck/rev6/rev6.c @@ -16,6 +16,24 @@ #include "rev6.h" #include "rgblight.h" +const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = { + + /*{row | col << 4} + | {x=0..224, y=0..64} + | | modifier + | | | */ + {{0|(0<<4)}, {112, 39}, 0}, + {{0|(1<<4)}, {148, 60}, 0}, + {{0|(2<<4)}, {206, 53}, 0}, + {{0|(3<<4)}, {206, 3}, 0}, + {{0|(4<<4)}, {150, 3}, 0}, + {{0|(5<<4)}, {74, 3}, 0}, + {{0|(6<<4)}, {18, 3}, 0}, + {{0|(7<<4)}, {18, 54}, 0}, + {{0|(8<<4)}, {77, 60}, 0} +}; + + uint8_t *o_fb; uint16_t counterst = 0; @@ -25,7 +43,7 @@ void matrix_init_kb(void) { // rgblight_mode(1); // rgblight_setrgb(0xFF, 0xFF, 0xFF); - ledDriverInit(9, GPIOA, 0b00000010, &o_fb); + //ledDriverInit(9, GPIOA, 0b00000010, &o_fb); //testPatternFB(o_fb); matrix_init_user(); @@ -37,5 +55,5 @@ void matrix_scan_kb(void) { //testPatternFB(o_fb); } counterst = (counterst + 1) % 1024; - rgblight_task(); + //rgblight_task(); } diff --git a/keyboards/planck/rev6/rules.mk b/keyboards/planck/rev6/rules.mk index 5d339fc88e..283df7a883 100644 --- a/keyboards/planck/rev6/rules.mk +++ b/keyboards/planck/rev6/rules.mk @@ -52,5 +52,6 @@ COMMAND_ENABLE = yes # Commands for debug and configuration NKRO_ENABLE = yes # USB Nkey Rollover CUSTOM_MATRIX = yes # Custom matrix file AUDIO_ENABLE = yes -RGBLIGHT_ENABLE = yes +RGBLIGHT_ENABLE = no +RGB_MATRIX_ENABLE = WS2812 # SERIAL_LINK_ENABLE = yes diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index b4bbc3dc07..514d6e7543 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c @@ -1,5 +1,6 @@ /* Copyright 2017 Jason Williams * Copyright 2017 Jack Humbert + * Copyright 2018 Yiancar * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,18 +18,21 @@ #include "rgb_matrix.h" -#include -#include "i2c_master.h" -#include -#include #include "progmem.h" #include "config.h" #include "eeprom.h" -#include "lufa.h" #include rgb_config_t rgb_matrix_config; +#ifndef MAX + #define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) +#endif + +#ifndef MIN + #define MIN(a,b) ((a) < (b)? (a): (b)) +#endif + #ifndef RGB_DISABLE_AFTER_TIMEOUT #define RGB_DISABLE_AFTER_TIMEOUT 0 #endif @@ -73,7 +77,7 @@ void eeconfig_update_rgb_matrix_default(void) { rgb_matrix_config.hue = 0; rgb_matrix_config.sat = 255; rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS; - rgb_matrix_config.speed = 0; + rgb_matrix_config.speed = 1; eeconfig_update_rgb_matrix(rgb_matrix_config.raw); } void eeconfig_debug_rgb_matrix(void) { @@ -106,16 +110,35 @@ void map_row_column_to_led( uint8_t row, uint8_t column, uint8_t *led_i, uint8_t } void rgb_matrix_update_pwm_buffers(void) { +#ifdef IS31FL3731 IS31FL3731_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); IS31FL3731_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); +#elif defined(IS31FL3733) + IS31FL3733_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); + IS31FL3733_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); +#elif defined(WS2812) + WS2812_send_colors(); +#endif } void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) { +#ifdef IS31FL3731 IS31FL3731_set_color( index, red, green, blue ); +#elif defined(IS31FL3733) + IS31FL3733_set_color( index, red, green, blue ); +#elif defined(WS2812) + WS2812_set_color( index, red, green, blue ); +#endif } void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) { +#ifdef IS31FL3731 IS31FL3731_set_color_all( red, green, blue ); +#elif defined(IS31FL3733) + IS31FL3733_set_color_all( red, green, blue ); +#elif defined(WS2812) + WS2812_set_color_all( red, green, blue ); +#endif } bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { @@ -460,7 +483,7 @@ void rgb_matrix_rainbow_moving_chevron(void) { for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { led = g_rgb_leds[i]; // uint8_t r = g_tick; - uint8_t r = 32; + uint8_t r = 128; hsv.h = (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * abs(led.point.y - 32.0)* sin(r * PI / 128) + (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * (led.point.x - (g_tick / 256.0 * 224)) * cos(r * PI / 128) + rgb_matrix_config.hue; rgb = hsv_to_rgb( hsv ); rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b ); @@ -579,6 +602,9 @@ void rgb_matrix_custom(void) { // } } +static uint8_t tick_slower = 5; +static uint8_t tick_counter = 0; + void rgb_matrix_task(void) { static uint8_t toggle_enable_last = 255; if (!rgb_matrix_config.enable) { @@ -593,7 +619,10 @@ void rgb_matrix_task(void) { return; } - g_tick++; + if (tick_counter == 0) { + g_tick++; + } + tick_counter = ( tick_counter + 1) % tick_slower; if ( g_any_key_hit < 0xFFFFFFFF ) { g_any_key_hit++; @@ -751,17 +780,33 @@ void rgb_matrix_init(void) { void rgb_matrix_setup_drivers(void) { // Initialize TWI +#ifdef IS31FL3731 i2c_init(); IS31FL3731_init( DRIVER_ADDR_1 ); IS31FL3731_init( DRIVER_ADDR_2 ); +#elif defined (IS31FL3733) + i2c_init(); + IS31FL3733_init( DRIVER_ADDR_1 ); +#elif defined(WS2812) + WS2812_init(); +#endif for ( int index = 0; index < DRIVER_LED_TOTAL; index++ ) { + __attribute__((unused)) bool enabled = true; // This only caches it for later +#ifdef IS31FL3731 IS31FL3731_set_led_control_register( index, enabled, enabled, enabled ); +#elif defined (IS31FL3733) + IS31FL3733_set_led_control_register( index, enabled, enabled, enabled ); +#endif } // This actually updates the LED drivers +#ifdef IS31FL3731 IS31FL3731_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); +#elif defined (IS31FL3733) + IS31FL3733_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); +#endif } // Deals with the messy details of incrementing an integer @@ -811,11 +856,19 @@ void rgb_matrix_test_led( uint8_t index, bool red, bool green, bool blue ) { { if ( i == index ) { +#ifdef IS31FL3731 IS31FL3731_set_led_control_register( i, red, green, blue ); +#elif defined (IS31FL3733) + IS31FL3733_set_led_control_register( i, red, green, blue ); +#endif } else { +#ifdef IS31FL3731 IS31FL3731_set_led_control_register( i, false, false, false ); +#elif defined (IS31FL3733) + IS31FL3733_set_led_control_register( i, false, false, false ); +#endif } } } diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index 5769314002..e308e65a43 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h @@ -1,5 +1,6 @@ /* Copyright 2017 Jason Williams * Copyright 2017 Jack Humbert + * Copyright 2018 Yiancar * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,9 +22,18 @@ #include #include #include "color.h" -#include "is31fl3731.h" #include "quantum.h" +#ifdef IS31FL3731 + #include "i2c_master.h" + #include "is31fl3731.h" +#elif defined (IS31FL3733) + #include "i2c_master.h" + #include "is31fl3733.h" +#elif defined (WS2812) + #include "ws2812.h" +#endif + typedef struct Point { uint8_t x; uint8_t y;