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

Wrong colors on RGBW strip #2

Open
dbartelmus opened this issue Nov 18, 2019 · 27 comments
Open

Wrong colors on RGBW strip #2

dbartelmus opened this issue Nov 18, 2019 · 27 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@dbartelmus
Copy link

Hello, I've followed this tutorial https://www.instructables.com/id/ESP8266-HomeKit-NeoPixel-Light-Strip/ - and almost everything went smooth.
After flashing and getting strip to work there was issue of mixed up colours (each led have different colors) and wrong brightness on somecolors.
I'm using SK6812 RGBW - please help.

ps. is it possible to set custom amount of led or make/build bin file for it?

@AchimPieters
Copy link
Owner

@dbartelmus It's made for the WS2812 Integrated Light Source, so it's uses just Red, green and blue LEDs. The use for RGBW is on my todo list.

If you want to make you own start here: ESP HomeKit SDK – Full Installation

@AchimPieters AchimPieters self-assigned this Nov 19, 2019
@AchimPieters AchimPieters added good first issue Good for newcomers help wanted Extra attention is needed labels Nov 19, 2019
@rmuike
Copy link

rmuike commented Nov 19, 2019

@dbartelmus Use this https://github.com/maximkulkin/esp-homekit-demo/blob/master/examples/led_strip/led_strip.c and edit it so it fits your needs. That’s what I did.

@dbartelmus
Copy link
Author

Thank you greatly. I will share my job later with you.

@dbartelmus
Copy link
Author

dbartelmus commented Nov 20, 2019

This repository seems to support SK6812 through i2s - https://github.com/esp8266-setup/ws2812_i2s and I can see that author is using different bit patterns depending of led strand:

#if LED_TYPE == LED_TYPE_WS2812
const IRAM_DATA int16_t bitpatterns[16] = {
    0b1000100010001000, 0b1000100010001110, 0b1000100011101000, 0b1000100011101110,
    0b1000111010001000, 0b1000111010001110, 0b1000111011101000, 0b1000111011101110,
    0b1110100010001000, 0b1110100010001110, 0b1110100011101000, 0b1110100011101110,
    0b1110111010001000, 0b1110111010001110, 0b1110111011101000, 0b1110111011101110,
};
#endif

#if LED_TYPE == LED_TYPE_SK6812
static const uint16_t bitpatterns[16] = {
    0b1000100010001000, 0b1000100010001100, 0b1000100011001000, 0b1000100011001100,
    0b1000110010001000, 0b1000110010001100, 0b1000110011001000, 0b1000110011001100,
    0b1100100010001000, 0b1100100010001100, 0b1100100011001000, 0b1100100011001100,
    0b1100110010001000, 0b1100110010001100, 0b1100110011001000, 0b1100110011001100,
};
#endif

and code for ws2812_i2c that was linked above by @rmuike is from different source - it seems that this one is striped only for ws2812 strand - but I can be wrong.
On the other hand there is a function named hsi2rgb:
static void **hsi2rgb**(float h, float s, float i, ws2812_pixel_t* rgb)
and it's easy to find related one to RGBW hsi2rgbw - I'm curious if this as simple as this @rmuike?

@Kristian8606
Copy link

I would like to contribute to your example.
I added an on / off and reset button as well as a smooth color change and brightness.
https://github.com/Kristian8606/LED_Strip/blob/master/main.c

@AchimPieters
Copy link
Owner

@Kristian8606 Thank you for your contribution! I will have a look as soon as possible!

@AchimPieters
Copy link
Owner

very interesting! am curious how you would tackle RGBW?

@dbartelmus
Copy link
Author

I've tried to make approach for "W" (RGBW) of @Kristian8606 code customisation but without success

@Kristian8606
Copy link

The only LED strip I have is ws2812b which is rgb and does not support W.
I think the one that supports rgbw is sk6812, but I don't have one.

@AchimPieters
Copy link
Owner

Okay, that's a pity, but how would you approach it?

@Kristian8606
Copy link

Kristian8606 commented Feb 24, 2020

change this ws2812_i2s_init(LED_COUNT, PIXEL_RGBW); and this ws2812_i2s_update(pixels, PIXEL_RGBW); int r, g, b, w;

w = LED_RGB_SCALE * i * (1 -s);
rgb->red = (uint8_t) r;
rgb->green = (uint8_t) g;
rgb->blue = (uint8_t) b;
rgb->white= (uint8_t) w;

Someone to try will this work for sk6812?

@dbartelmus
Copy link
Author

I've tried this, the real deal with HomeKit is to separate RGB and White cold/White warm channel, not to mix it like the HSI to RGB method to with this code to emulate white with all colors.
This code seems to have some references for white channel, look at every commented section like: // convert HSI to RGBW and etc.
I've done all of this but even RGB is flickering some random color not to mention that I don't get separate white channel like this:
74273644-188e8e80-4d11-11ea-8af8-f70a12180c50

@dbartelmus
Copy link
Author

dbartelmus commented Feb 24, 2020

Try to build this, I think this comes originally from @Kristian8606 fork
main.c.zip
This is with uncommented and adapted (I think) for RGBW but I'm not sure how HomeKit API works

@dbartelmus
Copy link
Author

dbartelmus commented Feb 24, 2020

So this is output on sk6812 from main.c which I've attached - despite wifi.h and defining pass and ssid, you still need to connect manually device to your network and then add it to HomeKit, pin-code is 1111-111-111.

Colors are messed up, what's up with that? But it's stable

IMG_7140

@Kristian8606
Copy link

I understand that there are several types of sk6812 rgb and rgbw you need to be sure yours is rgbw

@Kristian8606
Copy link

LED_COUNT must match your pixels count

@dbartelmus
Copy link
Author

dbartelmus commented Feb 24, 2020 via email

@AchimPieters
Copy link
Owner

AchimPieters commented Feb 24, 2020

change this ws2812_i2s_init(LED_COUNT, PIXEL_RGBW); and this ws2812_i2s_update(pixels, PIXEL_RGBW); int r, g, b, w;

w = LED_RGB_SCALE * i * (1 -s);
rgb->red = (uint8_t) r;
rgb->green = (uint8_t) g;
rgb->blue = (uint8_t) b;
rgb->white= (uint8_t) w;

Someone to try will this work for sk6812?

Tested with a RGBW stip and It works!

@Kristian8606
Copy link

is it possible to make a video because soon i will not have such an LED strip

@AchimPieters
Copy link
Owner

Here's your proof of concept!
IMG_1249.mov.zip

@AchimPieters AchimPieters added the enhancement New feature or request label Feb 25, 2020
@dbartelmus
Copy link
Author

It does, goes nicely with Siri :)

@dbartelmus
Copy link
Author

dbartelmus commented Feb 26, 2020

SK6812 LED Strip RGBW With ESP under HOMEKIT - main.bin.zip
compiled bin for tests - id has some bugs like changing name and first time parity problem, and connection is overall slow BUT working.

@rmuike
Copy link

rmuike commented Apr 10, 2020

It works but the white channel is not in use when you set it to white.
BC814113-C47B-4A1C-8E28-A5865D54B4E8
This is what it is supposed to look like.
92224B85-39C9-421E-98DD-DA82620E220E

@vniehues
Copy link

vniehues commented Aug 1, 2020

@rmuike should it not be only white, when its set to white? Thats the point of rgbw, right?
@AchimPieters Any news on RGBW/SK6812 support?

@dbartelmus
Copy link
Author

dbartelmus commented Aug 1, 2020 via email

@vniehues
Copy link

vniehues commented Aug 1, 2020

well... i do :D

@dbartelmus
Copy link
Author

dbartelmus commented Aug 1, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants