Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add definition WS2812_BYTE_ORDER to fix RGB LED issues #10184

Merged
merged 12 commits into from
Dec 6, 2020
10 changes: 10 additions & 0 deletions docs/ws2812_driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ The default setting is 280 µs, which should work for most cases, but this can b
#define WS2812_TRST_US 80
```

### Addressable LED byte order
hineybush marked this conversation as resolved.
Show resolved Hide resolved

The WS2812B-2020 addressable LED has a physically different layout with reversed internal red and green LEDs.
Without correction, this causes the two internal LEDs to swap colors and display the wrong color.
The default setting GRB allows other addressable LEDs to work properly with the correct byte structure (G[7-0]R[7-0]G[7-0]), however the WS2812B-2020 needs the green and red bytes reversed.
hineybush marked this conversation as resolved.
Show resolved Hide resolved

```c
#define WS2812_BYTE_ORDER RGB
hineybush marked this conversation as resolved.
Show resolved Hide resolved
```

hineybush marked this conversation as resolved.
Show resolved Hide resolved
### Bitbang
Default driver, the absence of configuration assumes this driver. To configure it, add this to your rules.mk:

Expand Down
12 changes: 11 additions & 1 deletion quantum/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,23 @@
# define LED_TYPE RGB
#endif


#ifndef WS2812_BYTE_ORDER
// default structure - G[7..0]R[7..0]B[7..0]
// WS2812 specific layout
typedef struct PACKED {
hineybush marked this conversation as resolved.
Show resolved Hide resolved
uint8_t g;
uint8_t r;
uint8_t b;
} cRGB;
hineybush marked this conversation as resolved.
Show resolved Hide resolved

#elif (WS2812_BYTE_ORDER == RGB)
// WS2812B-2020 structure - R[7..0]G[7..0]B[7..0]
typedef struct PACKED {
uint8_t r;
uint8_t g;
uint8_t b;
} cRGB;
#endif
hineybush marked this conversation as resolved.
Show resolved Hide resolved
typedef cRGB RGB;
hineybush marked this conversation as resolved.
Show resolved Hide resolved

// WS2812 specific layout
Expand Down