mariusmotea / diyHue

Philips Hue emulator that is able to control multiple types of lights
Other
627 stars 107 forks source link

Request for SK6812 WWA led #204

Closed freddebo closed 6 years ago

freddebo commented 6 years ago

I recently bought a SK6812 WWA (natural White, Warm white and Amber) led strip with 114led/m to get a high brightness as a kitchen light. The WWA strip is not supported by any of the normal libraries but it is just another set of colors. It uses it like this:

Original WWA color Temerature
Red Amber 1800K
Green Natural White 6000-6500K
Blue Warm White 3000-3200K

Is it possible for you to change the SK6812 RGBW sketch easy to a WWA compatible?

mariusmotea commented 6 years ago

Hi,

i made something for you very quick, i don't promise anything but may work directly.

Check this:

https://gist.github.com/mariusmotea/21e5c1dcc6ec3915638e3dd442d86d98

Marius.

freddebo commented 6 years ago

Hi Marius, I'm super happy that you are able to provide this!

It almost works!

  1. The led-strip is only 3 led version and the original SK6812 includes the white also. So I just changed all the Rgbw to rgb colors instead.
  2. The colors are a bit mixed up just. I don't know where it happened but I made this following change in the order and it works:
  wwa[light][1] = (bri[light] * percent_cold) / 100;
  wwa[light][2] =  (bri[light] * percent_warm) / 100;
  wwa[light][0] =  (bri[light] * percent_amber) / 100;

I realized that the amber color is too week and need to be together with the warm white to become the bright warm white I want. So the thing now is that I would like to use both the amber and the warm white together for the warmest color and still use the warm white as a just "middle" warm white.

I tried mess around a bit with the convert_ct() function but I can't really get it working.

mariusmotea commented 6 years ago

The CT value on hue api is between 153 (cold white) and 500 (warm white). I design the code to balance between cold and warm white between 153 and 400 and from warm white and amber between 400 and 500. I propose to left warm white at 100% percent after 400 and balance just Amber.

Try this:

void convert_ct(uint8_t light) {

  uint8 percent_warm;
  uint8 percent_cold;
  uint8 percent_amber;

  if (ct[light] < 400) {
    percent_warm = ((ct[light] - 153) * 100) / 247;
    percent_cold = 100 - percent_warm;
    percent_amber = 0;
  } else {
    percent_cold = 0;
    percent_warm = 100;
    percent_amber = 100 - (500 - ct[light]);
  }

  wwa[light][1] = (bri[light] * percent_cold) / 100;
  wwa[light][2] =  (bri[light] * percent_warm) / 100;
  wwa[light][0] =  (bri[light] * percent_amber) / 100;
}

Please share the final code that is working. Marius.

freddebo commented 6 years ago

It works much better! Now when I know the ct value range I will fine tune it a bit. It is working but the colors of the Philips hue app and the actual colors differs a bit. Will try to see if I could get it working better!

I found that the group on/off toggle dosen't work, you have to set the brightness as a group or individual on/off to get it started / turned off. Do you think it could be because of the sketch or is it some part of the emulator?

mariusmotea commented 6 years ago

I believe there is an error in the sketch, can you provide more details? Brightness is working but on/off not? If you turn on/off the lights individually it is working?

freddebo commented 6 years ago

Group brightness is working but not the group on/off. Individual on/off and brightness is working as it should.

mariusmotea commented 6 years ago

Wired. Are you using Android or iPhone?

mariusmotea commented 6 years ago

Try to delete all light emulated by this strip and add them back with a new light search request.

mariusmotea commented 6 years ago

Any progress here?

freddebo commented 6 years ago

Sorry for late reply! It worked fine with group on/off after reinstalling the Hue-app on iPhone. The colors are right now a bit colder in the app-preview but it works great as it is! Will post pictures when I have installed the strip at the correct place!

I'm not familiar with Github but I think I got it right now, the result of the complete code is the #213 pull-request now.

Thank you for your support!