Browse Source

WS2812 driver improvements (#20262)

pull/20311/head
Ryan 1 year ago
committed by GitHub
parent
commit
647c2835e6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 68 additions and 77 deletions
  1. +5
    -9
      builddefs/common_features.mk
  2. +2
    -0
      data/mappings/info_config.hjson
  3. +4
    -2
      data/schemas/keyboard.jsonschema
  4. +2
    -2
      docs/ws2812_driver.md
  5. +1
    -1
      keyboards/1k/keymaps/default/rules.mk
  6. +1
    -1
      keyboards/1k/keymaps/media/rules.mk
  7. +1
    -1
      keyboards/dp60/keymaps/indicator/led_driver.c
  8. +1
    -1
      keyboards/handwired/promethium/rules.mk
  9. +2
    -1
      keyboards/matrix/noah/rules.mk
  10. +1
    -2
      keyboards/mschwingen/modelm/led_ws2812/rules.mk
  11. +1
    -1
      keyboards/oddforge/vea/info.json
  12. +0
    -33
      keyboards/oddforge/vea/vea.c
  13. +1
    -10
      keyboards/oddforge/vea/vea.h
  14. +34
    -0
      keyboards/oddforge/vea/ws2812_custom.c
  15. +1
    -1
      keyboards/work_louder/rgb_functions.c
  16. +2
    -2
      keyboards/xelus/dawn60/rev1/rules.mk
  17. +2
    -2
      keyboards/xelus/dawn60/rev1_qmk/rules.mk
  18. +1
    -1
      keyboards/xiudi/xd002/keymaps/multilayer_rgb/rules.mk
  19. +1
    -1
      keyboards/xiudi/xd002/keymaps/rgb_lite/rules.mk
  20. +0
    -0
      platforms/avr/drivers/ws2812_bitbang.c
  21. +5
    -5
      platforms/avr/drivers/ws2812_i2c.c
  22. +0
    -0
      platforms/chibios/drivers/ws2812_bitbang.c
  23. +0
    -1
      quantum/rgb_matrix/rgb_matrix_drivers.c

+ 5
- 9
builddefs/common_features.mk View File

@ -574,7 +574,7 @@ ifeq ($(strip $(BACKLIGHT_ENABLE)), yes)
endif
endif
VALID_WS2812_DRIVER_TYPES := bitbang pwm spi i2c vendor
VALID_WS2812_DRIVER_TYPES := bitbang custom i2c pwm spi vendor
WS2812_DRIVER ?= bitbang
ifeq ($(strip $(WS2812_DRIVER_REQUIRED)), yes)
@ -584,15 +584,11 @@ ifeq ($(strip $(WS2812_DRIVER_REQUIRED)), yes)
OPT_DEFS += -DWS2812_DRIVER_$(strip $(shell echo $(WS2812_DRIVER) | tr '[:lower:]' '[:upper:]'))
ifeq ($(strip $(WS2812_DRIVER)), bitbang)
SRC += ws2812.c
else
SRC += ws2812_$(strip $(WS2812_DRIVER)).c
SRC += ws2812_$(strip $(WS2812_DRIVER)).c
ifeq ($(strip $(PLATFORM)), CHIBIOS)
ifeq ($(strip $(WS2812_DRIVER)), pwm)
OPT_DEFS += -DSTM32_DMA_REQUIRED=TRUE
endif
ifeq ($(strip $(PLATFORM)), CHIBIOS)
ifeq ($(strip $(WS2812_DRIVER)), pwm)
OPT_DEFS += -DSTM32_DMA_REQUIRED=TRUE
endif
endif


+ 2
- 0
data/mappings/info_config.hjson View File

@ -119,6 +119,8 @@
"USB_MAX_POWER_CONSUMPTION": {"info_key": "usb.max_power", "value_type": "int"},
"USB_POLLING_INTERVAL_MS": {"info_key": "usb.polling_interval", "value_type": "int"},
"USB_SUSPEND_WAKEUP_DELAY": {"info_key": "usb.suspend_wakeup_delay", "value_type": "int"},
"WS2812_I2C_ADDRESS": {"info_key": "ws2812.i2c_address", "value_type": "hex"},
"WS2812_I2C_TIMEOUT": {"info_key": "ws2812.i2c_timeout", "value_type": "int"},
// Items we want flagged in lint
"NO_ACTION_MACRO": {"info_key": "_invalid.no_action_macro", "invalid": true},


+ 4
- 2
data/schemas/keyboard.jsonschema View File

@ -707,8 +707,10 @@
"properties": {
"driver": {
"type": "string",
"enum": ["bitbang", "i2c", "pwm", "spi", "vendor"]
}
"enum": ["bitbang", "custom", "i2c", "pwm", "spi", "vendor"]
},
"i2c_address": {"$ref": "qmk.definitions.v1#/hex_number_2d"},
"i2c_timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"}
}
}
}


+ 2
- 2
docs/ws2812_driver.md View File

@ -72,8 +72,8 @@ WS2812_DRIVER = i2c
Configure the hardware via your config.h:
```c
#define WS2812_ADDRESS 0xb0 // default: 0xb0
#define WS2812_TIMEOUT 100 // default: 100
#define WS2812_I2C_ADDRESS 0xB0 // default: 0xB0
#define WS2812_I2C_TIMEOUT 100 // default: 100
```
### SPI


+ 1
- 1
keyboards/1k/keymaps/default/rules.mk View File

@ -1,2 +1,2 @@
SRC += ws2812.c
WS2812_DRIVER_REQUIRED = yes
SRC += color.c

+ 1
- 1
keyboards/1k/keymaps/media/rules.mk View File

@ -1,3 +1,3 @@
SRC += ws2812.c
WS2812_DRIVER_REQUIRED = yes
SRC += color.c
EXTRAKEY_ENABLE = yes

+ 1
- 1
keyboards/dp60/keymaps/indicator/led_driver.c View File

@ -18,7 +18,7 @@
#define RGB_DI_PIN RGB_INDICATOR_PIN
#define ws2812_setleds indicator_setleds
#define ws2812_setleds_pin indicator_setleds_pin
#include "ws2812.c"
#include "ws2812_bitbang.c"
void indicator_write(LED_TYPE *start_led, uint8_t num_leds)
{


+ 1
- 1
keyboards/handwired/promethium/rules.mk View File

@ -19,8 +19,8 @@ PS2_DRIVER = interrupt
CUSTOM_MATRIX = yes
BLUETOOTH_ENABLE = yes
BLUETOOTH_DRIVER = BluefruitLE
WS2812_DRIVER_REQUIRED = yes
SRC += ws2812.c
SRC += rgbsps.c
SRC += analog.c
SRC += matrix.c


+ 2
- 1
keyboards/matrix/noah/rules.mk View File

@ -29,7 +29,8 @@ RGB_MATRIX_DRIVER = IS31FL3731
RGBLIGHT_ENABLE = yes
RGBLIGHT_CUSTOM_DRIVER = yes
WS2812_DRIVER_REQUIRED = yes
CUSTOM_MATRIX = yes
# project specific files
SRC += ws2812.c matrix.c
SRC += matrix.c

+ 1
- 2
keyboards/mschwingen/modelm/led_ws2812/rules.mk View File

@ -1,2 +1 @@
# variant for WS2812 LEDs
SRC += ws2812.c
WS2812_DRIVER_REQUIRED = yes

+ 1
- 1
keyboards/oddforge/vea/info.json View File

@ -12,7 +12,7 @@
"pin": "D4"
},
"ws2812": {
"driver": "i2c"
"driver": "custom"
},
"indicators": {
"caps_lock": "D1",


+ 0
- 33
keyboards/oddforge/vea/vea.c View File

@ -1,33 +0,0 @@
/*
Copyright 2021 MajorKoos <github.com/majorkoos>
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
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vea.h"
void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { vea_setleds(start_led, num_leds); }
void vea_rgb_init(void) { i2c_init(); }
// Setleds for standard RGB
void vea_setleds(LED_TYPE *ledarray, uint16_t leds) {
static bool s_init = false;
if (!s_init) {
vea_rgb_init();
s_init = true;
}
i2c_transmit(WS2812_ADDRESS, (uint8_t *)ledarray, sizeof(LED_TYPE) * (leds >> 1), WS2812_TIMEOUT);
i2c_transmit(WS2812_ADDRESS_SPLIT, (uint8_t *)ledarray+(sizeof(LED_TYPE) * (leds >> 1)), sizeof(LED_TYPE) * (leds - (leds >> 1)), WS2812_TIMEOUT);
};

+ 1
- 10
keyboards/oddforge/vea/vea.h View File

@ -16,17 +16,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "quantum.h"
#include "i2c_master.h"
#include "rgblight.h"
#include "ws2812.h"
#include "led.h"
#define WS2812_ADDRESS 0xb0
#define WS2812_ADDRESS_SPLIT 0xb8
#define WS2812_TIMEOUT 100
void vea_setleds(LED_TYPE *ledarray, uint16_t leds);
#include "quantum.h"
/*
LEFT


+ 34
- 0
keyboards/oddforge/vea/ws2812_custom.c View File

@ -0,0 +1,34 @@
#include "ws2812.h"
#include "i2c_master.h"
#ifdef RGBW
# error "RGBW not supported"
#endif
#ifndef WS2812_I2C_ADDRESS
# define WS2812_I2C_ADDRESS 0xB0
#endif
#ifndef WS2812_I2C_ADDRESS_RIGHT
# define WS2812_I2C_ADDRESS_RIGHT 0xB8
#endif
#ifndef WS2812_I2C_TIMEOUT
# define WS2812_I2C_TIMEOUT 100
#endif
void ws2812_init(void) {
i2c_init();
}
// Setleds for standard RGB
void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) {
static bool s_init = false;
if (!s_init) {
ws2812_init();
s_init = true;
}
i2c_transmit(WS2812_I2C_ADDRESS, (uint8_t *)ledarray, sizeof(LED_TYPE) * (leds >> 1), WS2812_I2C_TIMEOUT);
i2c_transmit(WS2812_I2C_ADDRESS_RIGHT, (uint8_t *)ledarray+(sizeof(LED_TYPE) * (leds >> 1)), sizeof(LED_TYPE) * (leds - (leds >> 1)), WS2812_I2C_TIMEOUT);
}

+ 1
- 1
keyboards/work_louder/rgb_functions.c View File

@ -22,7 +22,7 @@
#define ws2812_setleds ws2812_rgb_setleds
#include "ws2812.c"
#include "ws2812_bitbang.c"
void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) {
ws2812_setleds(start_led, num_leds);


+ 2
- 2
keyboards/xelus/dawn60/rev1/rules.mk View File

@ -17,13 +17,13 @@ AUDIO_ENABLE = no # Audio output
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. - We have custom RGB underglow
CIE1931_CURVE = yes
WS2812_DRIVER_REQUIRED = yes
# project specific files
SRC += keyboards/wilba_tech/wt_main.c \
keyboards/wilba_tech/wt_rgb_backlight.c \
quantum/color.c \
drivers/led/issi/is31fl3731.c \
ws2812.c
drivers/led/issi/is31fl3731.c
QUANTUM_LIB_SRC += i2c_master.c

+ 2
- 2
keyboards/xelus/dawn60/rev1_qmk/rules.mk View File

@ -19,12 +19,12 @@ RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. - We have custom RGB
RGB_MATRIX_ENABLE = yes # Enable RGB matrix effects.
RGB_MATRIX_DRIVER = custom # Enable RGB matrix effects.
WS2812_DRIVER_REQUIRED = yes
COMMON_VPATH += $(DRIVER_PATH)/issi
# project specific files
SRC += drivers/led/issi/is31fl3731.c \
ws2812.c
SRC += drivers/led/issi/is31fl3731.c
QUANTUM_LIB_SRC += i2c_master.c


+ 1
- 1
keyboards/xiudi/xd002/keymaps/multilayer_rgb/rules.mk View File

@ -1,2 +1,2 @@
SRC += ws2812.c
WS2812_DRIVER_REQUIRED = yes
EXTRAKEY_ENABLE = yes

+ 1
- 1
keyboards/xiudi/xd002/keymaps/rgb_lite/rules.mk View File

@ -1 +1 @@
SRC += ws2812.c
WS2812_DRIVER_REQUIRED = yes

platforms/avr/drivers/ws2812.c → platforms/avr/drivers/ws2812_bitbang.c View File


+ 5
- 5
platforms/avr/drivers/ws2812_i2c.c View File

@ -5,12 +5,12 @@
# error "RGBW not supported"
#endif
#ifndef WS2812_ADDRESS
# define WS2812_ADDRESS 0xb0
#ifndef WS2812_I2C_ADDRESS
# define WS2812_I2C_ADDRESS 0xB0
#endif
#ifndef WS2812_TIMEOUT
# define WS2812_TIMEOUT 100
#ifndef WS2812_I2C_TIMEOUT
# define WS2812_I2C_TIMEOUT 100
#endif
void ws2812_init(void) {
@ -25,5 +25,5 @@ void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) {
s_init = true;
}
i2c_transmit(WS2812_ADDRESS, (uint8_t *)ledarray, sizeof(LED_TYPE) * leds, WS2812_TIMEOUT);
i2c_transmit(WS2812_I2C_ADDRESS, (uint8_t *)ledarray, sizeof(LED_TYPE) * leds, WS2812_I2C_TIMEOUT);
}

platforms/chibios/drivers/ws2812.c → platforms/chibios/drivers/ws2812_bitbang.c View File


+ 0
- 1
quantum/rgb_matrix/rgb_matrix_drivers.c View File

@ -359,7 +359,6 @@ LED_TYPE rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT];
static void init(void) {}
static void flush(void) {
// Assumes use of RGB_DI_PIN
ws2812_setleds(rgb_matrix_ws2812_array, RGB_MATRIX_LED_COUNT);
}


Loading…
Cancel
Save