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 support for white pixels #810

Open
frankonski opened this issue Mar 18, 2024 · 7 comments
Open

Add support for white pixels #810

frankonski opened this issue Mar 18, 2024 · 7 comments

Comments

@frankonski
Copy link
Contributor

Got myself a warm white & cold white led strip with WS2811 controller, which, after playing with the demo samples you added recently, was able to figure out that 1 pixel (1 IC) was lighting on warm white on Red, cold white on Blue, and Green was well... ignored.

So I went on to modify the pixelType type and added a new one:

  pixelType_t WHITE_WxC={15,0,23,0}; // GBR, R=warm white, G=nothing, B=cold white

and added a new Color constructor as such:

      Color WarmColdWhite(uint8_t warm, uint8_t cold)
      {
        this->red = warm;
        this->blue = cold;
        return(*this);        
      }

with its respective static public method in the Pixel class:

   static Color WarmColdWhite(uint8_t warm, uint8_t cold){return(Color().WarmColdWhite(warm,cold));}  // an alternative method for returning an RGB Color

then modified your flashColor() method sample with a flashWhite()...

void flashWhite(bool warm, bool cold) {
  for(int i=0;i<MAX_BRIGHTNESS;i++){
    testPixel.set(Pixel::WarmColdWhite(i*warm,i*cold),NPIXELS);
    delay(4);
  }
    
  for(int i=MAX_BRIGHTNESS;i>=0;i--){
    testPixel.set(Pixel::WarmColdWhite(i*warm,i*cold),NPIXELS);
    delay(4);
  }
}

and initialized the PixelStrand sample with pixel=new Pixel(pin,PixelType::WHITE_WxC);.

So far so good, all is working fine for now.

Now, where I am having issues is with a change to the Holiday Lights project which, using Eve, allows you to set the color of the RGB leg strip using the px->H.getValue(), S and V received from the app. The app has two tabs to define the color. One tab is called "Color", the second tab is called "White". From there, it looks like you can define start and end value for a gradian, from Warm White to Cold White. Defining Characteristic::ColorTemperature colorTemp; within the PixelStrand class, I was hoping to see a change to px->colorTemp.getNewVal<uint32_t>() within the ManualControl : SpecialEffect class, to no avail.

Setting LogLevel to 2, we can also see that even though the White tab is selected, Eve seems to send back HSV values, not any type of color temperature, or gradiant-style values..

Any suggestion to turn HSV values to this WarmWhite / ColdWhite pair of values?

@frankonski
Copy link
Contributor Author

.. I spoke too soon, ColorTemperature does seem to get updated now. I will do some cleanup and may end up submitting a draft PR if all works well.

@HomeSpan
Copy link
Owner

Can you send me a link to the specific strip you have -- I'm curious as to how they present the underlying specs. Since it seems like every possible combination is possible, rather than add a new Pixel type to HomeSpan, it may make sense to simply add some documentation so that these new use-cases can be extended directly from the users sketch.

@frankonski
Copy link
Contributor Author

Sorry, I saw your comment before I pushed a draft PR. You will notice the new method to set white colors, which makes the final code cleaner. Also, the new Pixel type will (I think) ensure that the Green is never set. Without this, I seemed to have strange lighting.

I can push a PR to Holiday Lights, or add an example if you'd like to see how it all worked out for me.

@JordanMalan
Copy link

JordanMalan commented Mar 23, 2024

+1 I'm using a strip that uses red for the 3000K and green for the 6000K
https://www.amazon.com/dp/B0BNDRF325?ref=ppx_yo2ov_dt_b_product_details&th=1

@frankonski
Copy link
Contributor Author

@JordanMalan, are you currently using HomeSpan 1.9.0, or the "dev" branch?
If you are using the "dev" branch, which pixelType_t type are you currently using to get warm for red, and cold for green?

Are you able to pull from my fork to cherry-pick my commit? I can try adding more white-only pixelType_t values so you can use it the way I did.

@JordanMalan
Copy link

JordanMalan commented Apr 5, 2024

@frankonski I'm using 1.8.0 since 1.9.0 seems to have some issue when adding to HomeKit. I'm using the example Pixel sketch.

The only real reason I wish this was better supported in homespan is so the color picker in the home app is correct.

I'll try to pull your code and test, I actually don't mind having many pixel types for different pin arrangements

You're using WHITE_WxC where I might use WHITE_WCx. But I wonder if there's a better way to do this in general, like if someone made a hypothetical red / white / blue strip for example it would be nice to have morph led which takes any user defined colors 🤷

Edit: I fixed my implementation to use the ColorTemperature characteristic instead of HSV, works good... At this point I have no more wants really

@frankonski
Copy link
Contributor Author

If you have pulled my fork for testing, try adding this pixel type (and using it) to src/extra/Pixel.h:

  pixelType_t WHITE_WCx={15,32,0,0}; // GBR, R=warm white, G=cold white, B=nothing  

Let me know if it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants