AchimPieters / ESP8266-HomeKit-NeoPixel-Light-Strip

ESP8266 – HomeKit NeoPixel Light Strip
https:\\www.studiopieters.nl
MIT License
11 stars 4 forks source link

Wrong colors on RGBW strip #2

Open dbartelmus opened 4 years ago

dbartelmus commented 4 years ago

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 commented 4 years ago

@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

rmuike commented 4 years ago

@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 commented 4 years ago

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

dbartelmus commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

AchimPieters commented 4 years ago

very interesting! am curious how you would tackle RGBW?

dbartelmus commented 4 years ago

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

Kristian8606 commented 4 years ago

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 commented 4 years ago

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

Kristian8606 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

Kristian8606 commented 4 years ago

LED_COUNT must match your pixels count

dbartelmus commented 4 years ago

It cannot be higher or less? Why is that, it’s not close circuit

AchimPieters commented 4 years ago

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 commented 4 years ago

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

AchimPieters commented 4 years ago

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

dbartelmus commented 4 years ago

It does, goes nicely with Siri :)

dbartelmus commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

Yes you are right. Anyway no one cares much about SK6812.

W dniu sob., 1.08.2020 o 14:38 Vincent Niehues notifications@github.com napisał(a):

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

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AchimPieters/ESP8266-HomeKit-NeoPixel-Light-Strip/issues/2#issuecomment-667525647, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPTVE3IBNWCLL4YJSKW6SLR6QECVANCNFSM4JO3WDHQ .

-- DAMIAN BARTELMUSIT Specialist / DevOps

www.panther.software https://panther.software/ +48-PANTHER-00 (+48726843700)

vniehues commented 4 years ago

well... i do :D

dbartelmus commented 4 years ago

Yes, I like and use this strip also, but have no time to figure out how to connect it properly with HomeKit framework neither existing ESP8266 code

W dniu sob., 1.08.2020 o 14:51 Vincent Niehues notifications@github.com napisał(a):

well... i do :D

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AchimPieters/ESP8266-HomeKit-NeoPixel-Light-Strip/issues/2#issuecomment-667527292, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPTVE6G3YEM7FCCS6QDU2DR6QFV7ANCNFSM4JO3WDHQ .

-- DAMIAN BARTELMUSIT Specialist / DevOps

www.panther.software https://panther.software/ +48-PANTHER-00 (+48726843700)