Skip to content

Add ability for boards to provide a custom pixel order in neopixelWrite() #10128

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

Merged
merged 21 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a64ffd0
fix(esp32): Fixed the hint for the builtin neopixleWrite() function
sblantipodi Aug 7, 2024
96180dc
change(esp32): Added neopixelWriteOrdered() function
sblantipodi Aug 7, 2024
fc43ac4
change(esp32): Added neopixelWriteOrdered() function
sblantipodi Aug 7, 2024
ff20b12
change(esp32): Added neopixelWriteOrdered() function
sblantipodi Aug 7, 2024
77f8cae
change(esp32): Added the possibility to specify LED color order
sblantipodi Aug 13, 2024
35b0bc6
change(esp32): Added the possibility to specify LED color order
sblantipodi Aug 13, 2024
2b8ea08
Merge branch 'master' into master
SuGlider Aug 13, 2024
92f3d3b
feat(rgbled): add license information
SuGlider Aug 13, 2024
84b20f0
feat(rgbled): add color order enum
SuGlider Aug 14, 2024
1f0fc69
feat(rgbled): add color order feature
SuGlider Aug 14, 2024
0ca996a
feat(rgbled): change color order for lolin_s3_mini
SuGlider Aug 14, 2024
a0886af
fix(rgbled): suffix
SuGlider Aug 14, 2024
2bf9d99
fix(rgbled): suffix
SuGlider Aug 14, 2024
3dd5f70
ci(pre-commit): Apply automatic fixes
pre-commit-ci-lite[bot] Aug 14, 2024
f489e16
Merge branch 'master' into master
SuGlider Aug 16, 2024
2814861
fix(rgbled): it lacks GRB case
SuGlider Aug 16, 2024
347b7c7
fix(rgbled): add guard for rgb_led_color_order_t
SuGlider Aug 16, 2024
1705caf
fix(rgb-led): Implement rgbLedWriteOrdered()
me-no-dev Aug 19, 2024
e94fe39
ci(pre-commit): Apply automatic fixes
pre-commit-ci-lite[bot] Aug 19, 2024
530b263
Remove const to allow changing the order
me-no-dev Aug 19, 2024
ec3d597
Merge branch 'master' into master
SuGlider Aug 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(rgb-led): Implement rgbLedWriteOrdered()
  • Loading branch information
me-no-dev committed Aug 19, 2024
commit 1705cafc31deacac01bcd7864a6b356d19510342
14 changes: 9 additions & 5 deletions cores/esp32/esp32-hal-rgb-led.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

#include "esp32-hal-rgb-led.h"

void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val) {
void rgbLedWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val) {
rgbLedWriteOrdered(pin, RGB_BUILTIN_LED_COLOR_ORDER, red_val, green_val, blue_val);
}

void rgbLedWriteOrdered(uint8_t pin, rgb_led_color_order_t order, uint8_t red_val, uint8_t green_val, uint8_t blue_val) {
#if SOC_RMT_SUPPORTED
rmt_data_t led_data[24];

Expand All @@ -32,9 +36,7 @@ void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue
// default WS2812B color order is G, R, B
const int color[3] = {green_val, red_val, blue_val};

#if defined RGB_BUILTIN_LED_COLOR_ORDER
// the onboard RGB LED has a different color order
switch (RGB_BUILTIN_LED_COLOR_ORDER) {
switch (order) {
case LED_COLOR_ORDER_RGB:
color[0] = red_val;
color[1] = green_val;
Expand All @@ -59,8 +61,10 @@ void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue
color[0] = green_val;
color[1] = blue_val;
color[2] = red_val;
break;
default: // GRB
break;
}
#endif

int i = 0;
for (int col = 0; col < 3; col++) {
Expand Down
14 changes: 11 additions & 3 deletions cores/esp32/esp32-hal-rgb-led.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ extern "C" {
#define RGB_BRIGHTNESS 64
#endif

#if defined RGB_BUILTIN_LED_COLOR_ORDER
#ifndef RGB_BUILTIN_LED_COLOR_ORDER
#define RGB_BUILTIN_LED_COLOR_ORDER LED_COLOR_ORDER_GRB // default WS2812B color order
#endif

typedef enum {
LED_COLOR_ORDER_RGB,
LED_COLOR_ORDER_BGR,
Expand All @@ -20,9 +23,14 @@ typedef enum {
LED_COLOR_ORDER_GBR,
LED_COLOR_ORDER_GRB
} rgb_led_color_order_t;
#endif

void neopixelWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val);
void rgbLedWriteOrdered(uint8_t pin, rgb_led_color_order_t order, uint8_t red_val, uint8_t green_val, uint8_t blue_val);

// Will use RGB_BUILTIN_LED_COLOR_ORDER
void rgbLedWrite(uint8_t pin, uint8_t red_val, uint8_t green_val, uint8_t blue_val);

// Backward compatibility
#define neopixelWrite(p,r,g,b) rgbLedWrite(p,r,g,b)

#ifdef __cplusplus
}
Expand Down
Loading