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

Support for Fw1906 #3298

Closed
wants to merge 9 commits into from
Closed

Conversation

Robert-github-com
Copy link

Add support for RgbwwColor and GRBCW strips that use FW1906 chips.

This change requires:
#3293
and
Makuna/NeoPixelBus@978b62f
The fix in NeoPixelBus is not in any release yet, and I don't know the way to force platformio to fetch specific commit, so I temporary changed lib_deps to my branch, if someone wants to test. This needs to be changed before merging.

if (_type == TYPE_FW1906)
calculateCCT(c, ww, cw);

PolyBus::setPixelColor(_busPtr, _iType, pix, R(c), G(c), B(c), ww, cw, co);
Copy link
Collaborator

@softhack007 softhack007 Jul 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
setPixelColor() is on the critical path for performance.

Is it strictly necessary to extend the polyBus interface to explicitly require color components (r,g,b,w) instead keeping them in uint32_t and just adding the new byte for cw?

If I understand your code correctly, we will - for all kinds of busses - split RGBW into R(c), G(c), B(c), W(c), and later re-assemble them into uint32_t? This adds around 30-40 extra operations just to go back and forth between color formats. It might seem like a "small price", but when applied to a few thousand LEDs at 100 fps, it accumulates into a noticeable slowdown.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
The split is not required. I can change the interface. But in PolyBus::setPixelColor the uint32 is split for 4 uint8 local variables anyway, and this operation is removed. I don't want to guess witch version is faster.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification :-) so before changing, @blazoncek what do you think, which option would be more efficient?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave API as is and add a static variable to hold CCT information for PolyBus.

@blazoncek
Copy link
Collaborator

You can use something similar to:
https://github.com/makuna/neopixelbus#978b62f
in lib_deps to force specific commit to be used for a library.

Unfortunately I do not like using unreleased libraries so we'll probably wait until new version of NPB is released as I mentioned elsewhere that last NPB update caused us hedaches we are still recovering from.

Copy link
Collaborator

@blazoncek blazoncek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding a 5th value in setPixelColor() please extend PolyBus class to use pre-set CCT (perhaps as additional variable). Then extend BusManager to set this value from CCT methods it provides.

if (_type == TYPE_SK6812_RGBW || _type == TYPE_TM1814 || _type == TYPE_WS2812_1CH_X3) c = autoWhiteCalc(c);
if (_cct >= 1900) c = colorBalanceFromKelvin(_cct, c); //color correction from CCT
if (_type == TYPE_FW1906 || _type == TYPE_SK6812_RGBW || _type == TYPE_TM1814 || _type == TYPE_WS2812_1CH_X3) c = autoWhiteCalc(c);
if (_type != TYPE_FW1906 && _cct >= 1900) c = colorBalanceFromKelvin(_cct, c); //color correction from CCT
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's inapproptiate as user has an option to use color temperature calculated from RGB values.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is also not used for TYPE_ANALOG_5CH.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a bug?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in last update.

if (_type == TYPE_FW1906)
calculateCCT(c, ww, cw);

PolyBus::setPixelColor(_busPtr, _iType, pix, R(c), G(c), B(c), ww, cw, co);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave API as is and add a static variable to hold CCT information for PolyBus.

wled00/bus_manager.h Outdated Show resolved Hide resolved
wled00/const.h Outdated Show resolved Hide resolved
@Robert-github-com
Copy link
Author

I was trying this # notation but it seems not working in lib_deps. Its understandable that this change needs to wait for new release of NeoPixelBus. I push this for review, and for other people to test.

@blazoncek
Copy link
Collaborator

It does whe properly formatted. I'm away from computer so can't provide exact format ATM.

@Robert-github-com
Copy link
Author

Instead of adding a 5th value in setPixelColor() please extend PolyBus class to use pre-set CCT (perhaps as additional variable). Then extend BusManager to set this value from CCT methods it provides.

I've done it in a little different way. Instead of adding new static variables I call a static function from class Bus in PolyBus.

@blazoncek
Copy link
Collaborator

I hate the idea of mixing Bus into PolyBus so I removed the dependency.
I am not satisfied with the solution as it breaks regular behaviour of setPixelColor but I have yet to come up with something better. 😄

There is also an issue you did not address and that is reverse CCT for retrieving pixel information from getPixelColor(). Current implementation is lacking and needs to be addressed.

@Robert-github-com
Copy link
Author

I assumed that it is not an issue, no reverse CCT is used for other pixel formats in digital and PWM buses.

@blazoncek
Copy link
Collaborator

I assumed that it is not an issue, no reverse CCT is used for other pixel formats in digital and PWM buses.

Other CCT enabled bus (BusPwm) only ever deals with 1 pixel so quite less important (as no 1 pixel effects rely on previous pixel value) than BusDigital. But of course it is a flaw and you can address it if you wish at the same time.

@blazoncek
Copy link
Collaborator

@Robert-github-com I have re-checked original source regarding CCT handling (BusPwm) and came to conclusion that best approach would be to move your calculateCCT() out of Bus class as it has nothing to do with buses as such and place it into colors.cpp as a standalone function.
Then it would be Ok for me to be included in PolyBus as you originally intended.

Nevertheless, PolyBus currently has no concept of CCT and API only allows for uint32_t for color object so there is still something missing for linking bus CCT value and PolyBus way of rendering it in the "correct" way. (Don't forget BusPwm handles CCT internally ATM.)

@Aircoookie and @softhack007 what would be your idea for adding CCT handling to PolyBus? Do we keep it external in a similar way as I updated it or do we extend PolyBus API to include either CCT info or WW & CW color bytes? Or something completely different?

@Aircoookie
Copy link
Owner

@blazoncek this is something I already thought a lot about when originally adding CCT support.
Right now, there is just one CCT value per segment, so individual-pixel CCT control is not possible on the segment level. Also, there is no way to e.g. use a warm CT as primary and a cold as secondary color. This, as well as per-pixel CCT control is possible right now, but only with "CCT from RGB" mode, which was made with CCT-only devices in mind. For addressable RGBCCT like the FW1906, having CCT as part of the segment color objects becomes something we should seriously consider looking into.

I'd say adding support for CCT to PolyBus specifically should be as simple as adding another uint16_t (or uint32_t for performance?) parameter to PolyBus::setPixelColor(). I would pass the WW and CW bytes and do the conversion from CCT on the BusDigital level, though it shouldn't technically matter where it's done.
This will already give us per-segment CCT functionality, and we can look into adding true addressable CCT down the line. One option might be a custom color object used throughout all layers from Segment to BusDigital, or even use uint64_t down to PolyBus level. I'd assume this to have quite the performance impact though, so it'd be something we just have to test.

Also thought about cramming everything into the uint32_t and dealing with just 4 bits for white brightness and color temperature each, but excluded that possibility as it would be a terrible user experience, especially during transitions.

@Robert-github-com
Copy link
Author

So what is conclusion about API? At least for this change.

@avwuff
Copy link

avwuff commented Aug 13, 2023

I'm trying to compile this right now and give it a try as I have a similar light strip! Wish me luck!

@avwuff
Copy link

avwuff commented Aug 13, 2023

Unfortunately the chips in my strips appear to be something other than the FW1906, despite having a similar LED configuration. The chips themselves are entirely unlabled.

Sorry Robert, I wish I could have helped test this:
image

image

@softhack007 softhack007 added this to the 0.15.0 candidate milestone Sep 5, 2023
@deece
Copy link

deece commented Sep 25, 2023

Hi folks, I've squashed all the cleanup to create a minimal set of patches, and rebased on top of the current main. @Robert-github-com , you can grab it here: https://github.com/deece/WLED/tree/fw1906

@Robert-github-com
Copy link
Author

Hi folks, I've squashed all the cleanup to create a minimal set of patches, and rebased on top of the current main. @Robert-github-com , you can grab it here: https://github.com/deece/WLED/tree/fw1906

Great! Seems to work fine.

@valkjsaaa
Copy link

valkjsaaa commented Oct 21, 2023

Screenshot 2023-10-20 at 21 21 23

It worked for me. One small problem is that I can't seem to be able to change it to a mode where only the white LEDs are used with a blend of cold and warm color temperatures.

As shown in the screenshot, when I change the first slider to the left (turning off the color LED altogether), the second slide automatically slides to the rightmost (cold white), If I drag the second slider (white point) anywhere towards the left, the first slide immediately goes to 100%, and the color LEDs turn on (lower CRI) and make the color of objects in the room look weird.

Thanks!

@valkjsaaa
Copy link

It appears that because I implemented enabled Calculate CCT from RGB WLED can integrate with home assistant. Not sure if this is the expected behavior 🤔

@oakey81
Copy link

oakey81 commented Dec 21, 2023

@deece Hey man I compiled your FW1906 fork and uploaded to my ESP32. I cant see the option for FW1906 in the LED config.

@blazoncek
Copy link
Collaborator

It appears that because I implemented enabled Calculate CCT from RGB WLED can integrate with home assistant. Not sure if this is the expected behavior 🤔

That is a HA issue. It will not allow WLED with CCT.

@softhack007
Copy link
Collaborator

cant see the option for FW1906 in the LED config.

If you modify UI files in wled00/data, make sure to run npm install; npm run build in the console, and then rebuild the firmware. If you skip the "npm" step, modified UI files will not make it into the firmware.

https://kno.wled.ge/advanced/custom-features/#changing-web-ui

@oakey81
Copy link

oakey81 commented Dec 29, 2023

cant see the option for FW1906 in the LED config.

If you modify UI files in wled00/data, make sure to run npm install; npm run build in the console, and then rebuild the firmware. If you skip the "npm" step, modified UI files will not make it into the firmware.

https://kno.wled.ge/advanced/custom-features/#changing-web-ui

Hey man thanks for the reply. Im not much of a coder but can manage to compile wled in vscode. I am not quite sure on how i do this at all. Any extra help would be muchly appreciated. Thanks

@softhack007 softhack007 added the major This is a non-trivial major feature and will take some time to implement label Jan 3, 2024
Copy link

@shnhrrsn shnhrrsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really appreciate the effort here! I was able to work off of this PR and modify to fit my use case, saved me a lot of time!

@@ -232,6 +232,7 @@
#define TYPE_WS2811_400KHZ 24 //half-speed WS2812 protocol, used by very old WS2811 units
#define TYPE_TM1829 25
#define TYPE_UCS8903 26
#define TYPE_FW1906 28 //RGB + CW + WW + unused channel (6 channels per IC)
Copy link

@shnhrrsn shnhrrsn Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the ordering here is an incorrect assumption that impacts the flexibility of this PR.

FW1906 is just a dual RGB (or, more accurately, GRB) IC — there aren't specific CW/WW pins.

It's up to the manufacturer how to connect their LEDs, and unfortunately, they take liberties here.

The FW1906 strip I have, for instance, orders its channels as WW, null, G R B, CW. This ordering, while strange and annoying, actually does make sense — it lines up nicely with the physical ordering of the LEDs on the strip and optimized for the traces vs how humans want to think about it.

I'd think before this PR is super viable to merge, we need the ability to fully customize the channel orders like we can in RGB.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there shnhrrsn. I ordered 200 FW1906 ICs and have designed a driver board utilizing this IC. My only problem is getting the firmware working on my ESP32. I have done the whole npm run but i always get an error. What steps did you do to get this working or do you have a firmware build you could share so i can test my boards. Cheers mate

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oakey81 This thread is about line 235 in const.h, and color ordering of FW1906 chips.
please don't drift off-topic.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah mate i get that but I was just asking how he actually got the firmware compiled properly and working. As he stated he got it working. Anyway this whole thread jumps form one issue to the next if you scroll back a fair way.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we call that "code review". In contrast to "support request" ;-)

@softhack007
Copy link
Collaborator

softhack007 commented Jan 11, 2024

@oakey81 first you need to install NodeJS 11.0+ globally. Then run npm install; npm run build in the VSCode console panel.

https://kno.wled.ge/advanced/custom-features/#changing-web-ui

image

@oakey81
Copy link

oakey81 commented Jan 19, 2024

@oakey81 first you need to install NodeJS 11.0+ globally. Then run npm install; npm run build in the VSCode console panel.

https://kno.wled.ge/advanced/custom-features/#changing-web-ui

image

Thanks mate yeah it was the 'npm i' that i missed. sorted now and my setup works perfectly with all colours the right way round. I think some of the strips are not FW1906 IC and thats why the colour orders arent matching up. I actually ordered 200 x FW1906 ICs and have designed my own 5ch driver and RGBCW/WW downlight.

PXL_20240119_013555174.TS.2.mp4

@blazoncek
Copy link
Collaborator

@oakey81 please update and rebase for 0_15 branch if you think it is viable solution worth to be included and make a PR.

@oakey81
Copy link

oakey81 commented Jan 22, 2024

@blazoncek I am not sure what you mean by rebase as i am not a coder. My mate is very good at it and he saw what i was missing within about 30 sec. I just downloaded the FW1906 code off github and done the npm install and compiled to upload on my ESP32. And as i had designed my own 5ch driver board I followed the manufacturers data sheet and it runs perfectly. I do believe some of the RGBCCT strips might not be FW1906 ICs on them. But to answer your question. Yes I believe this is a viable PR for the next update. And also I see that the WS2805 RGBCCT IC has been released as a true 5ch chip not like the FW1906 6ch chip. So that could be another to add later aswell.

@deece
Copy link

deece commented Jan 22, 2024

I believe this was intended for @Robert-github-com . I already rebased and squashed down to a minimal set (see my earlier comments), so hopefully they're isn't much to change from there.

@blazoncek I am not sure what you mean by rebase as i am not a coder. My mate is very good at it and he saw what i was missing within about 30 sec. I just downloaded the FW1906 code off github and done the npm install and compiled to upload on my ESP32. And as i had designed my own 5ch driver board I followed the manufacturers data sheet and it runs perfectly. I do believe some of the RGBCCT strips might not be FW1906 ICs on them. But to answer your question. Yes I believe this is a viable PR for the next update. And also I see that the WS2805 RGBCCT IC has been released as a true 5ch chip not like the FW1906 6ch chip. So that could be another to add later aswell.

@oakey81
Copy link

oakey81 commented Jan 22, 2024

@deece Sorry I was just answering @blazoncek. As this is what he asked me. But as far as i can tell as a user of this it seems to work well with my hardware. Cheers for what u had done.

@blazoncek
Copy link
Collaborator

Unless someone makes a PR for 0_15 branch we're not going anywhere with this (until 0_15 is merged to main which may be months away).
I have more than enough other work and this is low priority for me.

As you can see from comments above the PR may require change in the very core of how WLED handles color and CCT so it will not be lightly taken.

@Suxsem
Copy link

Suxsem commented Mar 4, 2024

Hi guys, I'm seeing more and more of those chips out there, any news on official support? Thank you

@deece
Copy link

deece commented Mar 4, 2024

@blazoncek Is main sufficient, or do you want 0_15?

@blazoncek
Copy link
Collaborator

0_15

@mathojojo
Copy link

mathojojo commented Mar 7, 2024

I just received my FW1906 RGB+CTT ledstrip, and I notice that it's not actually implemented in wled, but it's a work in progress here.
I'm not sure to understand the actual state of the work. Should it work if I build from branch 0_15 ? If yes, I can test it of course, but I'm not sure how to select the correct branch.

In the same time NeoPixelBus is now at v2.7.8, with support for rgbwww. Maybe wled should use this version directly instead of 2.7.6
https://github.com/Makuna/NeoPixelBus/releases/tag/2.7.8

Using a wemos mini-S2 board, I already had to compile from GIT sources. But I never had to select a branch at any moment. Is there a git command to select another branch ?

Thank you for the work, and for your help.

@deece
Copy link

deece commented Mar 11, 2024

@blazoncek I've created a PR against 0-15 here: #3810

@deece
Copy link

deece commented Mar 23, 2024

@blazoncek With the merge of #3810, this can also be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major This is a non-trivial major feature and will take some time to implement
Projects
None yet
Development

Successfully merging this pull request may close these issues.