lifxjs icon indicating copy to clipboard operation
lifxjs copied to clipboard

Documentation for fade_time

Open mmorrisontx opened this issue 11 years ago • 5 comments

I spent a while working with the fade_time parameter today, trying to figure out its quirkiness (because it certainly is not milliseconds or seconds). At least on the two kickstarter bulbs I received a few weeks ago, the following formula seems to apply:

(fade_time parameter) = ((seconds)*225)^2

I have tested this, and it seems to work appropriately for all fade times large and small (less than a second up to several minutes). The 225 value is estimated based on testing, but the formula definitely seem to be quadratic.

See this graph for my test results: http://i.imgur.com/sbUEkGi.png

It may be worth including this formula in the docs, or even accepting "seconds" as the parameter in code, and converting it with this formula before sending it to the bulb. Additional testing is probably required to make sure this works on other shipments of the bulb as well.

mmorrisontx avatar Jan 18 '14 15:01 mmorrisontx

Excellent sleuthing! I re-visited the Android application and you're right, the seconds description is wrong. They handle the value as if it's milliseconds but that could be one of many bugs.

riverar avatar Jan 18 '14 20:01 riverar

Seems there may be even more to it than that. Usually, my bulbs seem to follow the formula above, but occasionally they seem to flip into some other mode where fade_time means something entirely different. No idea what's going on at this point. Hopefully an official api will clear some things up at some point.

mmorrisontx avatar Jan 19 '14 23:01 mmorrisontx

Yeah - fade seems to work great on brightness and kelvin, but do something different when moving from color to color.

PhilWheat avatar Jan 19 '14 23:01 PhilWheat

Had another chance to play with this today. I've been using this code with acceptable results: https://gist.github.com/sonicsnes/8648212

It seems that any fades involving kelvin (either going to kelvin, or if the bulb was using kelvin BEFORE you called lightsColour), fadeTime represents milliseconds -- otherwise, it is calculated with the formula above.

Don't ask me why. Sounds like a firmware bug.

mmorrisontx avatar Jan 27 '14 13:01 mmorrisontx

Today I got the formula switch without even using Kelvins.

I found that calling setColor with a fadeTime of 0 resets it back to ((seconds)*225)^2

r9k avatar Feb 23 '14 21:02 r9k