From f7cf40fa77164d7be9358ce83f7f5939d71b38bc Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 18 Mar 2024 22:03:27 +1100 Subject: Add init function to RGBLight driver struct (#23076) --- quantum/rgblight/rgblight.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'quantum/rgblight/rgblight.c') diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index 530cb04688..28b58feea6 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c @@ -247,6 +247,8 @@ void rgblight_init(void) { rgblight_mode_noeeprom(rgblight_config.mode); } + rgblight_driver.init(); + is_rgblight_initialized = true; } -- cgit v1.2.3 From 583cde398a28e429485b440de38a2ed9ec528830 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 22 Mar 2024 17:04:13 +1100 Subject: Un-`extern` RGBLight `led[]` array (#23322) --- docs/feature_rgblight.md | 15 ----- keyboards/hineybush/hbcp/hbcp.c | 5 +- keyboards/hineybush/hbcp/keymaps/hiney/keymap.c | 50 ++------------ keyboards/neson_design/nico/info.json | 3 +- keyboards/neson_design/nico/nico.c | 90 ------------------------- keyboards/neson_design/nico/rules.mk | 1 - keyboards/snes_macropad/snes_macropad.c | 16 ----- quantum/rgblight/rgblight.c | 18 ++--- quantum/rgblight/rgblight.h | 7 -- 9 files changed, 17 insertions(+), 188 deletions(-) delete mode 100644 keyboards/neson_design/nico/nico.c (limited to 'quantum/rgblight/rgblight.c') diff --git a/docs/feature_rgblight.md b/docs/feature_rgblight.md index b7ba075731..a6a89d1d00 100644 --- a/docs/feature_rgblight.md +++ b/docs/feature_rgblight.md @@ -356,27 +356,12 @@ Usually lighting layers apply their configured brightness once activated. If you If you need to change your RGB lighting in code, for example in a macro to change the color whenever you switch layers, QMK provides a set of functions to assist you. See [`rgblight.h`](https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight/rgblight.h) for the full list, but the most commonly used functions include: -### Utility Functions -|Function |Description | -|--------------------------------------------|-------------------------------------------------------------------| -|`sethsv(hue, sat, val, ledbuf)` |Set ledbuf to the given HSV value | -|`sethsv_raw(hue, sat, val, ledbuf)` |Set ledbuf to the given HSV value without RGBLIGHT_LIMIT_VAL check | -|`setrgb(r, g, b, ledbuf)` |Set ledbuf to the given RGB value where `r`/`g`/`b` | - ### Low level Functions |Function |Description | |--------------------------------------------|-------------------------------------------| |`rgblight_set()` |Flush out led buffers to LEDs | |`rgblight_set_clipping_range(pos, num)` |Set clipping Range. see [Clipping Range](#clipping-range) | -Example: -```c -sethsv(HSV_WHITE, (rgb_led_t *)&led[0]); // led 0 -sethsv(HSV_RED, (rgb_led_t *)&led[1]); // led 1 -sethsv(HSV_GREEN, (rgb_led_t *)&led[2]); // led 2 -rgblight_set(); // Utility functions do not call rgblight_set() automatically, so they need to be called explicitly. -``` - ### Effects and Animations Functions #### effect range setting |Function |Description | diff --git a/keyboards/hineybush/hbcp/hbcp.c b/keyboards/hineybush/hbcp/hbcp.c index 5b22c69007..e422b46fdc 100644 --- a/keyboards/hineybush/hbcp/hbcp.c +++ b/keyboards/hineybush/hbcp/hbcp.c @@ -82,12 +82,9 @@ void keyboard_post_init_user(void) { __attribute__ ((weak)) void hbcp_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end) { - rgb_led_t tmp_led; - sethsv_raw(hue, sat, val, &tmp_led); for (uint8_t i = start; i < end; i++) { - led[i] = tmp_led; + rgblight_sethsv_at(hue, sat, val, i); } - rgblight_set(); } #endif diff --git a/keyboards/hineybush/hbcp/keymaps/hiney/keymap.c b/keyboards/hineybush/hbcp/keymaps/hiney/keymap.c index 2311d4020f..2d73326c9a 100644 --- a/keyboards/hineybush/hbcp/keymaps/hiney/keymap.c +++ b/keyboards/hineybush/hbcp/keymaps/hiney/keymap.c @@ -15,13 +15,6 @@ */ #include QMK_KEYBOARD_H -// Defines the keycodes used by our macros in process_record_user -enum custom_keycodes { - QMKBEST = SAFE_RANGE, - ALTCUT, - QMKURL -}; - const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [0] = LAYOUT_wkl( /* Base */ @@ -45,55 +38,24 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), }; -bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { - case ALTCUT: - if (record->event.pressed) { - // when keycode QMKBEST is pressed - send_string_with_delay_P(PSTR(SS_TAP(X_TAB)SS_TAP(X_T)SS_TAP(X_V)SS_TAP(X_B)), 20); // altium macro - } else { - // when keycode QMKBEST is released - } - break; - case QMKURL: - if (record->event.pressed) { - // when keycode QMKURL is pressed - SEND_STRING("https://qmk.fm/" SS_TAP(X_ENTER)); - } else { - // when keycode QMKURL is released - } - break; - } - return true; -} - -void matrix_init_user(void) { - -} - -void matrix_scan_user(void) { - -} - #ifdef RGBLIGHT_ENABLE // The first three LEDs are used as indicators for CAPS_LOCK, NUM_LOCK and SCROLL_LOCK. bool led_update_user(led_t led_state) { if (led_state.caps_lock) { - sethsv_raw(HSV_SOFT_RED, (rgb_led_t *)&led[0]); + rgblight_sethsv_at(HSV_SOFT_RED, 0); } else { - sethsv(HSV_BLACK, (rgb_led_t *)&led[0]); + rgblight_sethsv_at(HSV_BLACK, 0); } if (led_state.num_lock) { - sethsv_raw(HSV_WARM_WHITE, (rgb_led_t *)&led[1]); + rgblight_sethsv_at(HSV_WARM_WHITE, 1); } else { - sethsv(HSV_BLACK, (rgb_led_t *)&led[1]); + rgblight_sethsv_at(HSV_BLACK, 1); } if (led_state.scroll_lock) { - sethsv_raw(HSV_SOFT_BLUE, (rgb_led_t *)&led[2]); + rgblight_sethsv_at(HSV_SOFT_BLUE, 2); } else { - sethsv(HSV_BLACK, (rgb_led_t *)&led[2]); + rgblight_sethsv_at(HSV_BLACK, 2); } - rgblight_set(); return false; } diff --git a/keyboards/neson_design/nico/info.json b/keyboards/neson_design/nico/info.json index 1c86d9a1ae..477ac3ba7c 100644 --- a/keyboards/neson_design/nico/info.json +++ b/keyboards/neson_design/nico/info.json @@ -25,8 +25,7 @@ "pin": "B0" }, "rgblight": { - "led_count": 5, - "driver": "custom" + "led_count": 5 }, "url": "", "usb": { diff --git a/keyboards/neson_design/nico/nico.c b/keyboards/neson_design/nico/nico.c deleted file mode 100644 index 0738a3ee98..0000000000 --- a/keyboards/neson_design/nico/nico.c +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @file nico.c - * - Copyright 2023 astro - - 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 . - */ - -#include "quantum.h" -#include "ws2812.h" -#ifdef RGBLIGHT_ENABLE - -static bool alert = false; -static bool backup = false; -static rgb_led_t caps_led; -static uint16_t last_ticks = 0; - -#define ALERT_INTERVAL 500 -#define ALERM_LED_R 0xFF -#define ALERM_LED_G 0xA5 -#define ALERM_LED_B 0x00 -//golden 0xFF, 0xD9, 0x00 - -void housekeeping_task_kb(void) -{ - if (host_keyboard_led_state().caps_lock) { - if (!backup) { - caps_led.r = led[4].r; - caps_led.g = led[4].g; - caps_led.b = led[4].b; - backup = true; - } - if(alert) { - led[4].r = ALERM_LED_G; - led[4].g = ALERM_LED_R; - led[4].b = ALERM_LED_B; - } else { - led[4].r = 0; - led[4].g = 0; - led[4].b = 0; - } - if (timer_elapsed(last_ticks) > ALERT_INTERVAL) { - alert = !alert; - last_ticks = timer_read(); - } - ws2812_setleds(led, RGBLIGHT_LED_COUNT); - } else { - if (backup) { - led[4].r = caps_led.r; - led[4].g = caps_led.g; - led[4].b = caps_led.b; - backup = false; - ws2812_setleds(led, RGBLIGHT_LED_COUNT); - } - } - housekeeping_task_user(); -} - -void setleds_custom(rgb_led_t *start_led, uint16_t num_leds) -{ - start_led[2].r = start_led[0].r; - start_led[2].g = start_led[0].g; - start_led[2].b = start_led[0].b; - - start_led[3].r = start_led[1].r; - start_led[3].g = start_led[1].g; - start_led[3].b = start_led[1].b; - - uint8_t tmp = start_led[4].g; - start_led[4].g = start_led[4].r; - start_led[4].r = tmp; - ws2812_setleds(start_led, RGBLIGHT_LED_COUNT); -} - -const rgblight_driver_t rgblight_driver = { - .init = ws2812_init, - .setleds = setleds_custom, -}; -#endif \ No newline at end of file diff --git a/keyboards/neson_design/nico/rules.mk b/keyboards/neson_design/nico/rules.mk index 9a69649289..e69de29bb2 100644 --- a/keyboards/neson_design/nico/rules.mk +++ b/keyboards/neson_design/nico/rules.mk @@ -1 +0,0 @@ -WS2812_DRIVER_REQUIRED = yes diff --git a/keyboards/snes_macropad/snes_macropad.c b/keyboards/snes_macropad/snes_macropad.c index 9f4f410fa3..74fa434fb2 100644 --- a/keyboards/snes_macropad/snes_macropad.c +++ b/keyboards/snes_macropad/snes_macropad.c @@ -86,22 +86,6 @@ static void setupForFlashing(void) { // Force data to be rendered oled_render_dirty(true); - - // Set alternating backlight colors - const uint8_t max = 20; - rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); - for (size_t i = 0; i < RGBLIGHT_LED_COUNT; ++i) { - rgb_led_t *led_ = (rgb_led_t *)&led[i]; - switch (i % 2) { - case 0: - setrgb(max, 0, max, led_); - break; - case 1: - setrgb(0, max, max, led_); - break; - } - } - rgblight_set(); } bool process_record_kb(uint16_t keycode, keyrecord_t *record) { diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index 28b58feea6..b17a501eef 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c @@ -145,6 +145,15 @@ __attribute__((weak)) RGB rgblight_hsv_to_rgb(HSV hsv) { return hsv_to_rgb(hsv); } +void setrgb(uint8_t r, uint8_t g, uint8_t b, rgb_led_t *led1) { + led1->r = r; + led1->g = g; + led1->b = b; +#ifdef RGBW + led1->w = 0; +#endif +} + void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, rgb_led_t *led1) { HSV hsv = {hue, sat, val}; RGB rgb = rgblight_hsv_to_rgb(hsv); @@ -155,15 +164,6 @@ void sethsv(uint8_t hue, uint8_t sat, uint8_t val, rgb_led_t *led1) { sethsv_raw(hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val, led1); } -void setrgb(uint8_t r, uint8_t g, uint8_t b, rgb_led_t *led1) { - led1->r = r; - led1->g = g; - led1->b = b; -#ifdef RGBW - led1->w = 0; -#endif -} - void rgblight_check_config(void) { /* Add some out of bound checks for RGB light config */ diff --git a/quantum/rgblight/rgblight.h b/quantum/rgblight/rgblight.h index 9e2b073776..0ed67ff6e3 100644 --- a/quantum/rgblight/rgblight.h +++ b/quantum/rgblight/rgblight.h @@ -240,8 +240,6 @@ void rgblight_unblink_all_but_layer(uint8_t layer); #endif -extern rgb_led_t led[RGBLIGHT_LED_COUNT]; - extern const uint8_t RGBLED_BREATHING_INTERVALS[4] PROGMEM; extern const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[3] PROGMEM; extern const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[3] PROGMEM; @@ -290,11 +288,6 @@ typedef struct _rgblight_ranges_t { extern rgblight_ranges_t rgblight_ranges; -/* === Utility Functions ===*/ -void sethsv(uint8_t hue, uint8_t sat, uint8_t val, rgb_led_t *led1); -void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, rgb_led_t *led1); // without RGBLIGHT_LIMIT_VAL check -void setrgb(uint8_t r, uint8_t g, uint8_t b, rgb_led_t *led1); - /* === Low level Functions === */ void rgblight_set(void); void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds); -- cgit v1.2.3 From d0ee4a1cb26ef2aeb6f512c92c3f810c443e1ca4 Mon Sep 17 00:00:00 2001 From: Dasky <32983009+daskygit@users.noreply.github.com> Date: Sun, 24 Mar 2024 00:20:05 +0000 Subject: Fix rgblight init (#23335) --- quantum/rgblight/rgblight.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'quantum/rgblight/rgblight.c') diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index b17a501eef..62137c020b 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c @@ -243,12 +243,12 @@ void rgblight_init(void) { rgblight_timer_init(); // setup the timer + rgblight_driver.init(); + if (rgblight_config.enable) { rgblight_mode_noeeprom(rgblight_config.mode); } - rgblight_driver.init(); - is_rgblight_initialized = true; } @@ -1568,4 +1568,4 @@ uint8_t rgblight_velocikey_match_speed(uint8_t minValue, uint8_t maxValue) { return MAX(minValue, maxValue - (maxValue - minValue) * ((float)typing_speed / TYPING_SPEED_MAX_VALUE)); } -#endif \ No newline at end of file +#endif -- cgit v1.2.3 From 0ff53b24984e88f385638e47ea076b4d2945c0c6 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 28 Apr 2024 00:36:54 +1000 Subject: Rename `RGBW` define to `WS2812_RGBW` (#23585) --- data/mappings/info_config.hjson | 3 ++- data/schemas/keyboard.jsonschema | 6 +++++- docs/config_options.md | 2 +- docs/feature_rgblight.md | 2 +- docs/reference_info_json.md | 6 +++--- docs/ws2812_driver.md | 22 ++++++++++++++++++++++ keyboards/ergodox_ez/config.h | 2 -- keyboards/ergodox_ez/info.json | 3 ++- keyboards/ergodox_ez/shine/rgblight_custom.c | 4 ++-- keyboards/handwired/tennie/config.h | 2 -- keyboards/handwired/tennie/keyboard.json | 3 ++- keyboards/oddforge/vea/ws2812_custom.c | 2 +- keyboards/rgbkb/pan/pan.c | 2 +- keyboards/westfoxtrot/aanzee/config.h | 2 -- keyboards/westfoxtrot/aanzee/keyboard.json | 3 ++- platforms/avr/drivers/ws2812_i2c.c | 2 +- .../drivers/vendor/RP/RP2040/ws2812_vendor.c | 6 +++--- platforms/chibios/drivers/ws2812_bitbang.c | 2 +- platforms/chibios/drivers/ws2812_pwm.c | 8 ++++---- platforms/chibios/drivers/ws2812_spi.c | 4 ++-- quantum/color.c | 2 +- quantum/color.h | 4 ++-- quantum/rgb_matrix/rgb_matrix_drivers.c | 2 +- quantum/rgblight/rgblight.c | 18 +++++++++--------- 24 files changed, 68 insertions(+), 44 deletions(-) (limited to 'quantum/rgblight/rgblight.c') diff --git a/data/mappings/info_config.hjson b/data/mappings/info_config.hjson index c0417b8839..b61ca04071 100644 --- a/data/mappings/info_config.hjson +++ b/data/mappings/info_config.hjson @@ -164,7 +164,6 @@ "RGBLIGHT_DEFAULT_SAT": {"info_key": "rgblight.default.sat", "value_type": "int"}, "RGBLIGHT_DEFAULT_VAL": {"info_key": "rgblight.default.val", "value_type": "int"}, "RGBLIGHT_DEFAULT_SPD": {"info_key": "rgblight.default.speed", "value_type": "int"}, - "RGBW": {"info_key": "rgblight.rgbw", "value_type": "flag"}, // Secure "SECURE_IDLE_TIMEOUT": {"info_key": "secure.idle_timeout", "value_type": "int"}, @@ -215,6 +214,7 @@ "WS2812_DI_PIN": {"info_key": "ws2812.pin"}, "WS2812_I2C_ADDRESS": {"info_key": "ws2812.i2c_address", "value_type": "hex"}, "WS2812_I2C_TIMEOUT": {"info_key": "ws2812.i2c_timeout", "value_type": "int"}, + "WS2812_RGBW": {"info_key": "ws2812.rgbw", "value_type": "flag"}, "LAYOUTS": {"info_key": "layout_aliases", "value_type": "mapping"}, @@ -229,6 +229,7 @@ "PREVENT_STUCK_MODIFIERS": {"info_key": "_invalid.prevent_stuck_mods", "invalid": true}, "QMK_KEYS_PER_SCAN": {"info_key": "qmk.keys_per_scan", "value_type": "int", "deprecated": true}, "RGB_DI_PIN": {"info_key": "rgblight.pin", "invalid": true, "replace_with": "WS2812_DI_PIN or APA102_DI_PIN"}, + "RGBW": {"info_key": "rgblight.rgbw", "invalid": true, "replace_with": "WS2812_RGBW"}, "RGB_DISABLE_WHEN_USB_SUSPENDED": {"info_key": "_invalid.rgb_matrix_sleep", "invalid": true, "replace_with": "RGB_MATRIX_SLEEP"}, "RGBLIGHT_ANIMATIONS": {"info_key": "_invalid.rgblight.animations.all", "value_type": "flag", "invalid": true}, "TAPPING_FORCE_HOLD": {"info_key": "tapping.force_hold", "value_type": "flag", "deprecated": true}, diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 585c64777f..de01809b43 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -661,7 +661,10 @@ "$ref": "qmk.definitions.v1#/mcu_pin", "$comment": "Deprecated: use ws2812.pin instead" }, - "rgbw": {"type": "boolean"}, + "rgbw": { + "type": "boolean", + "$comment": "Deprecated: use ws2812.rgbw instead" + }, "saturation_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, "sleep": {"type": "boolean"}, "split": {"type": "boolean"}, @@ -937,6 +940,7 @@ "enum": ["bitbang", "custom", "i2c", "pwm", "spi", "vendor"] }, "pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, + "rgbw": {"type": "boolean"}, "i2c_address": {"$ref": "qmk.definitions.v1#/hex_number_2d"}, "i2c_timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"} } diff --git a/docs/config_options.md b/docs/config_options.md index fca80e54fd..046429a587 100644 --- a/docs/config_options.md +++ b/docs/config_options.md @@ -237,7 +237,7 @@ If you define these options you will enable the associated feature, which may in * units to step when in/decreasing saturation * `#define RGBLIGHT_VAL_STEP 12` * units to step when in/decreasing value (brightness) -* `#define RGBW` +* `#define WS2812_RGBW` * Enables RGBW LED support ## Mouse Key Options diff --git a/docs/feature_rgblight.md b/docs/feature_rgblight.md index a6a89d1d00..ae37ceca92 100644 --- a/docs/feature_rgblight.md +++ b/docs/feature_rgblight.md @@ -6,7 +6,7 @@ QMK has the ability to control RGB LEDs attached to your keyboard. This is commo Some keyboards come with RGB LEDs preinstalled. Others must have them installed after the fact. See the [Hardware Modification](#hardware-modification) section for information on adding RGB lighting to your keyboard. -Currently QMK supports the following addressable LEDs (however, the white LED in RGBW variants is not supported): +Currently QMK supports the following addressable LEDs: * WS2811, WS2812, WS2812B, WS2812C, etc. * SK6812, SK6812MINI, SK6805 diff --git a/docs/reference_info_json.md b/docs/reference_info_json.md index d1dc5d3bea..5b06e9a326 100644 --- a/docs/reference_info_json.md +++ b/docs/reference_info_json.md @@ -588,9 +588,6 @@ Configures the [RGB Lighting](feature_rgblight.md) feature. * `max_brightness` * The maximum value which the HSV "V" component is scaled to, from 0 to 255. * Default: `255` - * `rgbw` - * Enable RGBW LEDs. - * Default: `false` * `saturation_steps` * The number of saturation adjustment steps. * Default: `17` @@ -855,3 +852,6 @@ Configures the [WS2812](ws2812_driver.md) driver. * `i2c_timeout` * The I²C timeout in milliseconds (`i2c` driver only). * Default: `100` (100 ms) + * `rgbw` + * Enable RGBW LEDs. + * Default: `false` diff --git a/docs/ws2812_driver.md b/docs/ws2812_driver.md index 006529cc8a..8851c042f0 100644 --- a/docs/ws2812_driver.md +++ b/docs/ws2812_driver.md @@ -33,6 +33,7 @@ Add the following to your `config.h`: |`WS2812_T0H` |`350` |The length of a "0" bit's high phase in nanoseconds | |`WS2812_TRST_US` |`280` |The length of the reset phase in microseconds | |`WS2812_BYTE_ORDER`|`WS2812_BYTE_ORDER_GRB`|The byte order of the RGB data | +|`WS2812_RGBW` |*Not defined* |Enables RGBW support (except `i2c` driver) | ### Timing Adjustment :id=timing-adjustment @@ -58,6 +59,27 @@ Where the byte order may be one of: |`RGB` |WS2812B-2020 | |`BGR` |TM1812 | +### RGBW Support :id=rgbw-support + +Rendering the color white with RGB LEDs is typically inconsistent due to inherent variations between each individual LED die. However, some WS2812 variants (such as SK6812RGBW) also possess a white LED along with the red, green, and blue channels, which allows for a more accurate white to be displayed. + +QMK can automatically convert the RGB data to be sent to the LEDs to mix in the white channel: + +``` +w = min(r, g, b) +r -= w +g -= w +b -= w +``` + +Thus, an RGB triplet of `255,255,255` will simply turn on the white LED fully (`0,0,0,255`). + +To enable RGBW conversion, add the following to your `config.h`: + +```c +#define WS2812_RGBW +``` + ## Driver Configuration :id=driver-configuration Driver selection can be configured in `rules.mk` as `WS2812_DRIVER`, or in `info.json` as `ws2812.driver`. Valid values are `bitbang` (default), `i2c`, `spi`, `pwm`, `vendor`, or `custom`. See below for information on individual drivers. diff --git a/keyboards/ergodox_ez/config.h b/keyboards/ergodox_ez/config.h index 8209c21dba..3688e00785 100644 --- a/keyboards/ergodox_ez/config.h +++ b/keyboards/ergodox_ez/config.h @@ -73,8 +73,6 @@ along with this program. If not, see . /* fix space cadet rollover issue */ #define DISABLE_SPACE_CADET_ROLLOVER -#define RGBW - /* * The debounce filtering reports a key/switch change directly, * without any extra delay. After that the debounce logic will filter diff --git a/keyboards/ergodox_ez/info.json b/keyboards/ergodox_ez/info.json index f2495a409c..a560e97a0b 100644 --- a/keyboards/ergodox_ez/info.json +++ b/keyboards/ergodox_ez/info.json @@ -27,7 +27,8 @@ "debounce_type": "sym_eager_pr" }, "ws2812": { - "pin": "D7" + "pin": "D7", + "rgbw": true }, "rgb_matrix": { "animations": { diff --git a/keyboards/ergodox_ez/shine/rgblight_custom.c b/keyboards/ergodox_ez/shine/rgblight_custom.c index feac50cba0..29060e76fc 100644 --- a/keyboards/ergodox_ez/shine/rgblight_custom.c +++ b/keyboards/ergodox_ez/shine/rgblight_custom.c @@ -25,7 +25,7 @@ void setleds_custom(rgb_led_t *led, uint16_t led_num) { uint16_t length = 0; int i = 0; int j = 0; -# ifdef RGBW +# ifdef WS2812_RGBW int bytes_per_led = 4; # else int bytes_per_led = 3; @@ -52,7 +52,7 @@ void setleds_custom(rgb_led_t *led, uint16_t led_num) { data[j++] = data_byte[0]; data[j++] = data_byte[1]; data[j++] = data_byte[2]; -#ifdef RGBW +#ifdef WS2812_RGBW data[j++] = data_byte[3]; #endif } diff --git a/keyboards/handwired/tennie/config.h b/keyboards/handwired/tennie/config.h index 7c77f53a82..dcbcfeaaa8 100644 --- a/keyboards/handwired/tennie/config.h +++ b/keyboards/handwired/tennie/config.h @@ -17,8 +17,6 @@ along with this program. If not, see . #pragma once -#define RGBW - /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE /* Locking resynchronize hack */ diff --git a/keyboards/handwired/tennie/keyboard.json b/keyboards/handwired/tennie/keyboard.json index 34e6676c95..36c1266d50 100644 --- a/keyboards/handwired/tennie/keyboard.json +++ b/keyboards/handwired/tennie/keyboard.json @@ -26,7 +26,8 @@ } }, "ws2812": { - "pin": "D1" + "pin": "D1", + "rgbw": true }, "features": { "bootmagic": true, diff --git a/keyboards/oddforge/vea/ws2812_custom.c b/keyboards/oddforge/vea/ws2812_custom.c index a037b88b3e..317f98130b 100644 --- a/keyboards/oddforge/vea/ws2812_custom.c +++ b/keyboards/oddforge/vea/ws2812_custom.c @@ -1,7 +1,7 @@ #include "ws2812.h" #include "i2c_master.h" -#ifdef RGBW +#ifdef WS2812_RGBW # error "RGBW not supported" #endif diff --git a/keyboards/rgbkb/pan/pan.c b/keyboards/rgbkb/pan/pan.c index 191ff1ac1f..401831e0e2 100644 --- a/keyboards/rgbkb/pan/pan.c +++ b/keyboards/rgbkb/pan/pan.c @@ -42,7 +42,7 @@ static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) { rgb_matrix_ws2812_array[i].g = g; rgb_matrix_ws2812_array[i].b = b; } -# ifdef RGBW +# ifdef WS2812_RGBW convert_rgb_to_rgbw(&rgb_matrix_ws2812_array[i]); # endif } diff --git a/keyboards/westfoxtrot/aanzee/config.h b/keyboards/westfoxtrot/aanzee/config.h index c024f9d8d9..cd1f84bc1f 100644 --- a/keyboards/westfoxtrot/aanzee/config.h +++ b/keyboards/westfoxtrot/aanzee/config.h @@ -17,8 +17,6 @@ along with this program. If not, see . #pragma once -#define RGBW - /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE /* Locking resynchronize hack */ diff --git a/keyboards/westfoxtrot/aanzee/keyboard.json b/keyboards/westfoxtrot/aanzee/keyboard.json index 7a12a3e52e..898fe9e62b 100644 --- a/keyboards/westfoxtrot/aanzee/keyboard.json +++ b/keyboards/westfoxtrot/aanzee/keyboard.json @@ -52,7 +52,8 @@ } }, "ws2812": { - "pin": "E6" + "pin": "E6", + "rgbw": true }, "processor": "atmega32u4", "bootloader": "atmel-dfu", diff --git a/platforms/avr/drivers/ws2812_i2c.c b/platforms/avr/drivers/ws2812_i2c.c index 60b466c32a..86a5ac8394 100644 --- a/platforms/avr/drivers/ws2812_i2c.c +++ b/platforms/avr/drivers/ws2812_i2c.c @@ -1,7 +1,7 @@ #include "ws2812.h" #include "i2c_master.h" -#ifdef RGBW +#ifdef WS2812_RGBW # error "RGBW not supported" #endif diff --git a/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c b/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c index 95a827e4b8..41a5311719 100644 --- a/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c +++ b/platforms/chibios/drivers/vendor/RP/RP2040/ws2812_vendor.c @@ -161,7 +161,7 @@ static void ws2812_dma_callback(void* p, uint32_t ct) { // FIFO is already empty. rtcnt_t time_to_completion = (pio_sm_get_tx_fifo_level(pio, STATE_MACHINE) + 1) * MAX(WS2812_T1H + WS2812_T1L, WS2812_T0H + WS2812_T0L); -#if defined(RGBW) +#if defined(WS2812_RGBW) time_to_completion *= 32; #else time_to_completion *= 24; @@ -222,7 +222,7 @@ void ws2812_init(void) { sm_config_set_sideset(&config, 1, false, false); #endif -#if defined(RGBW) +#if defined(WS2812_RGBW) sm_config_set_out_shift(&config, false, true, 32); #else sm_config_set_out_shift(&config, false, true, 24); @@ -270,7 +270,7 @@ void ws2812_setleds(rgb_led_t* ledarray, uint16_t leds) { sync_ws2812_transfer(); for (int i = 0; i < leds; i++) { -#if defined(RGBW) +#if defined(WS2812_RGBW) WS2812_BUFFER[i] = rgbw8888_to_u32(ledarray[i].r, ledarray[i].g, ledarray[i].b, ledarray[i].w); #else WS2812_BUFFER[i] = rgbw8888_to_u32(ledarray[i].r, ledarray[i].g, ledarray[i].b, 0); diff --git a/platforms/chibios/drivers/ws2812_bitbang.c b/platforms/chibios/drivers/ws2812_bitbang.c index 9ed6bacd5a..96378ec0ac 100644 --- a/platforms/chibios/drivers/ws2812_bitbang.c +++ b/platforms/chibios/drivers/ws2812_bitbang.c @@ -101,7 +101,7 @@ void ws2812_setleds(rgb_led_t *ledarray, uint16_t leds) { sendByte(ledarray[i].r); #endif -#ifdef RGBW +#ifdef WS2812_RGBW sendByte(ledarray[i].w); #endif } diff --git a/platforms/chibios/drivers/ws2812_pwm.c b/platforms/chibios/drivers/ws2812_pwm.c index 7dc3414ead..1e9d2ebb41 100644 --- a/platforms/chibios/drivers/ws2812_pwm.c +++ b/platforms/chibios/drivers/ws2812_pwm.c @@ -16,7 +16,7 @@ /* Adapted from https://github.com/joewa/WS2812-LED-Driver_ChibiOS/ */ -#ifdef RGBW +#ifdef WS2812_RGBW # define WS2812_CHANNELS 4 #else # define WS2812_CHANNELS 3 @@ -262,7 +262,7 @@ # define WS2812_BLUE_BIT(led, bit) WS2812_BIT((led), 0, (bit)) #endif -#ifdef RGBW +#ifdef WS2812_RGBW /** * @brief Determine the index in @ref ws2812_frame_buffer "the frame buffer" of a given white bit * @@ -381,7 +381,7 @@ void ws2812_write_led_rgbw(uint16_t led_number, uint8_t r, uint8_t g, uint8_t b, ws2812_frame_buffer[WS2812_RED_BIT(led_number, bit)] = ((r >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0; ws2812_frame_buffer[WS2812_GREEN_BIT(led_number, bit)] = ((g >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0; ws2812_frame_buffer[WS2812_BLUE_BIT(led_number, bit)] = ((b >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0; -#ifdef RGBW +#ifdef WS2812_RGBW ws2812_frame_buffer[WS2812_WHITE_BIT(led_number, bit)] = ((w >> bit) & 0x01) ? WS2812_DUTYCYCLE_1 : WS2812_DUTYCYCLE_0; #endif } @@ -390,7 +390,7 @@ void ws2812_write_led_rgbw(uint16_t led_number, uint8_t r, uint8_t g, uint8_t b, // Setleds for standard RGB void ws2812_setleds(rgb_led_t* ledarray, uint16_t leds) { for (uint16_t i = 0; i < leds; i++) { -#ifdef RGBW +#ifdef WS2812_RGBW ws2812_write_led_rgbw(i, ledarray[i].r, ledarray[i].g, ledarray[i].b, ledarray[i].w); #else ws2812_write_led(i, ledarray[i].r, ledarray[i].g, ledarray[i].b); diff --git a/platforms/chibios/drivers/ws2812_spi.c b/platforms/chibios/drivers/ws2812_spi.c index 5b990ccaa0..ad2e87781c 100644 --- a/platforms/chibios/drivers/ws2812_spi.c +++ b/platforms/chibios/drivers/ws2812_spi.c @@ -76,7 +76,7 @@ #endif #define BYTES_FOR_LED_BYTE 4 -#ifdef RGBW +#ifdef WS2812_RGBW # define WS2812_CHANNELS 4 #else # define WS2812_CHANNELS 3 @@ -131,7 +131,7 @@ static void set_led_color_rgb(rgb_led_t color, int pos) { for (int j = 0; j < 4; j++) tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 2 + j] = get_protocol_eq(color.r, j); #endif -#ifdef RGBW +#ifdef WS2812_RGBW for (int j = 0; j < 4; j++) tx_start[BYTES_FOR_LED * pos + BYTES_FOR_LED_BYTE * 4 + j] = get_protocol_eq(color.w, j); #endif diff --git a/quantum/color.c b/quantum/color.c index 395383f428..96d548a33c 100644 --- a/quantum/color.c +++ b/quantum/color.c @@ -109,7 +109,7 @@ RGB hsv_to_rgb_nocie(HSV hsv) { return hsv_to_rgb_impl(hsv, false); } -#ifdef RGBW +#ifdef WS2812_RGBW void convert_rgb_to_rgbw(rgb_led_t *led) { // Determine lowest value in all three colors, put that into // the white channel and then shift all colors by that amount diff --git a/quantum/color.h b/quantum/color.h index 00a3bfb3f8..b6a9dd0641 100644 --- a/quantum/color.h +++ b/quantum/color.h @@ -96,7 +96,7 @@ typedef struct PACKED rgb_led_t { uint8_t g; uint8_t r; #endif -#ifdef RGBW +#ifdef WS2812_RGBW uint8_t w; #endif } rgb_led_t; @@ -111,6 +111,6 @@ typedef struct PACKED HSV { RGB hsv_to_rgb(HSV hsv); RGB hsv_to_rgb_nocie(HSV hsv); -#ifdef RGBW +#ifdef WS2812_RGBW void convert_rgb_to_rgbw(rgb_led_t *led); #endif diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c index 4370996d0e..db3a2ef9e0 100644 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ b/quantum/rgb_matrix/rgb_matrix_drivers.c @@ -185,7 +185,7 @@ static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) { rgb_matrix_ws2812_array[i].r = r; rgb_matrix_ws2812_array[i].g = g; rgb_matrix_ws2812_array[i].b = b; -# ifdef RGBW +# ifdef WS2812_RGBW convert_rgb_to_rgbw(&rgb_matrix_ws2812_array[i]); # endif } diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index 62137c020b..b0f2dfdc1d 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c @@ -149,7 +149,7 @@ void setrgb(uint8_t r, uint8_t g, uint8_t b, rgb_led_t *led1) { led1->r = r; led1->g = g; led1->b = b; -#ifdef RGBW +#ifdef WS2812_RGBW led1->w = 0; #endif } @@ -652,7 +652,7 @@ void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { led[i].r = r; led[i].g = g; led[i].b = b; -#ifdef RGBW +#ifdef WS2812_RGBW led[i].w = 0; #endif } @@ -667,7 +667,7 @@ void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index) { led[index].r = r; led[index].g = g; led[index].b = b; -#ifdef RGBW +#ifdef WS2812_RGBW led[index].w = 0; #endif rgblight_set(); @@ -704,7 +704,7 @@ void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8 led[i].r = r; led[i].g = g; led[i].b = b; -#ifdef RGBW +#ifdef WS2812_RGBW led[i].w = 0; #endif } @@ -905,7 +905,7 @@ void rgblight_set(void) { led[i].r = 0; led[i].g = 0; led[i].b = 0; -#ifdef RGBW +#ifdef WS2812_RGBW led[i].w = 0; #endif } @@ -933,7 +933,7 @@ void rgblight_set(void) { start_led = led + rgblight_ranges.clipping_start_pos; #endif -#ifdef RGBW +#ifdef WS2812_RGBW for (uint8_t i = 0; i < num_leds; i++) { convert_rgb_to_rgbw(&start_led[i]); } @@ -1263,7 +1263,7 @@ void rgblight_effect_snake(animation_status_t *anim) { ledp->r = 0; ledp->g = 0; ledp->b = 0; -# ifdef RGBW +# ifdef WS2812_RGBW ledp->w = 0; # endif for (j = 0; j < RGBLIGHT_EFFECT_SNAKE_LENGTH; j++) { @@ -1323,7 +1323,7 @@ void rgblight_effect_knight(animation_status_t *anim) { led[i].r = 0; led[i].g = 0; led[i].b = 0; -# ifdef RGBW +# ifdef WS2812_RGBW led[i].w = 0; # endif } @@ -1337,7 +1337,7 @@ void rgblight_effect_knight(animation_status_t *anim) { led[cur].r = 0; led[cur].g = 0; led[cur].b = 0; -# ifdef RGBW +# ifdef WS2812_RGBW led[cur].w = 0; # endif } -- cgit v1.2.3