Question About CCT Lights Sketch

I had a question about the Generic CCT Light Sketch in the DIYHue Lights repository. When the brightness of the light is at 100% but the CT is at the mid-point, both the WW and CW are set to 50% brightness. Isn’t this leaving 50% of the potential brightness of the LEDs out on the table and unused? It seems like an alternative would be to put the light that is favored at 100% and then the light that is unfavored scaled back at the appropriate percentage until you get the right mixture. Then you apply the brightness percentage to those values. For example, if you had a brightness of 100% and CT at the midpoint, you would have both CW and WW LEDs at 100%. However, if you had a CT that was 75% of the total, so towards the CW, you would have the CW LEDs at 100% and the WW at 50%. Then if the brightness were set to 75%, you would have the CW leds at 75% and the ww at 37%. Obviously this starts to become very unmanageable when you get down to less than 10% brightness but no CCT light handles those values correctly. I have a sengled bulb that at 5% when you adjust the CT there is a bright line change from one to the other rather than a gradual fade. So, I’m no so worried about the low end of the spectrum.

I’ve modified the convert_ct function from the sketch to the following:

void convert_ct(){
  int optimal_bri = int( 10 + light.bri / 1.04);
  float adjustment = float(optimal_bri/254.00000);
  float max_cool=0.000;
  float max_warm=0.000; 
  float bias = float( light.ct - 314.0000);
  if(bias == 0){
    max_cool = 255;
    max_warm = 255;
  }else if(bias > 0){
    max_warm = 255;
    max_cool = ((160-bias)/160)* 255.0000;
  }else if (bias <0){
    max_cool = 255;
    max_warm = ((160+bias)/160)*255.0000;
  }
   light.colors[0]l =int(max_cool * adjustment);
   light.colors[1] = int(max_warm * adjustment);
}

I tried substituting this in for the default convert_ct function and I was able to achieve MUCH higher brightness from my strip than I did with the default sketch. Now, there is a trade off. The difference in brightness between a CT of 314 and 474 or 154 is significant. In fact, 314 is twice as bright. But I am trying to maximize the brightness I can get out of my strip rather than leaving some out there unused. I will primarily leave the CT setting alone rather than adjusting it during the day. So, getting the most out of a smaller strip is more important to me in this case. This is being used as a primary light instead of biased/background lighting.

I’d be happy to do a pull request with the change if you want. It could even be a selectable option (max brightness vs. fidelity brightness). That way folks could choose. Let me know what you think.

1 Like

This is really nice! Thank you!

maybe we can use the inbuild map function to scale the values within a certain range?

Adding it to the repo with a seperate Tag would be cool!

I am actually working on implementing a single sketch with the ability to set the CT mode to either “fidelity brightness” or “maximum brightness”. Those were the terms I had come up with that described the two methods the best. I am actually running one of each currently. I have one light that I want to maximize the output of and another that is so bright I would rather keep the brightness the same across the entire range of the CT spectrum. I am working on adding a toggle switch to the main page. So, hopefully I will get time to work on it this week or next. Will send a PR as soon as I get something that I know works.