magicmonkey / lifxjs

JS library for LIFX bulbs
MIT License
274 stars 62 forks source link

More natural color values #33

Open meodai opened 9 years ago

meodai commented 9 years ago

I saw that the official API uses int16 numbers for the colours, but it feels unnatural to me. Would be nice to make abstraction of that at let us use a more natural writing style. something like: lx.lightsColour(170, '50%', '45%', .6, '1000ms') or maybe just provide a helper function that will do the math.

I think it would make it dramatically easier to use lifxjs for anyone likes me who comes from the frontend side of JS.

For me this is an issue, but please consider it as a suggestion.

cdl commented 9 years ago

+1 of this. Or allow me to drop in a Number from 0 to 1. I'm an EmberJS dude, non base 10 numbers are a bit over my head, and I'm assuming other people that wanna' just use this library to hack away on stuff.

kevincannon commented 9 years ago

I've used this function to convert values to the hex16 value:

function hex16(val) {
    val &= 0xFFFF;
    var hex = val.toString(16).toUpperCase();
    return ("0000" + hex).slice(-4);
}

However, i'm not sure what ranges hue, brightness etc.. accept. Is that documented anywhere?

MariusRumpf commented 9 years ago

@kevincannon You find the range information in the lifx docs https://github.com/LIFX/lifx-protocol-docs/blob/master/messages/light.md#hsbk

kevincannon commented 9 years ago

@MariusRumpf - neat, thanks for the info!

BTW - is node-lifx what I should be using with lights with the new Firmware? I noticed some functions broke since I updated.

MariusRumpf commented 9 years ago

node-lifx is still work in progress and missing key features like turning on or off the lights or set the colors. When it is in any working state I will publish it on npm and write docs for it. Since that I will help out with questions here where I can.

kevincannon commented 9 years ago

Great, thanks for the info. I was a bit confused. Luckily I still have one LIFX with the old firmware, so I can play with that.

Great library. It's been really amazing to use it! Thanks so much.