PhilipsHue / PhilipsHueSDK-Java-MultiPlatform-Android

The Software Development Kit for Philips Hue Java Mulfi-Platform and Android (beta)
273 stars 214 forks source link

SDK or source for the ambilight to hue color transition algorithm #2

Closed CrazyCoder closed 10 years ago

CrazyCoder commented 10 years ago

I'm trying to create a desktop and server version of the ambilight+hue mobile application and stuck with the colors conversion as this part is not available via SDK or the source code. Also, algorithm seems to be pretty complex.

It would be nice if it becomes a part of the SDK or if the source becomes open.

Please check my forum post for more details.

SteveyO commented 10 years ago

We have a few colour conversion methods in the PHUtilities class in the SDK.

There is a little code snippet for setting RGB values in the 'Coding Tips' section in the below link: https://github.com/PhilipsHue/PhilipsHueSDK-Java-MultiPlatform-Android/blob/master/Documentation/HackathonQuickStart.md

Let me know if this helps.

CrazyCoder commented 10 years ago

Thanks for the tip, I've already tried the suggested PHUtilities.calculateXYFromRGB method, but it's not really what convertRGBtoXY_final method in ambilight+hue app is doing. The main difference is that the latter somehow calculates the brightness of the hue lamps basing on the RGB colors of ambilight leds. Here is the poorly decompiled fragment. paramAtomicInteger1 is set inside the method to the brightness level and is used later in the code to set hue lamp brightness.

CrazyCoder commented 10 years ago

iOS Hue SDK seems to have something related, but Java PHUtilities doesn't have methods that return brightness, only XY.

SteveyO commented 10 years ago

Unfortunately I can't help you with the ambilight code. This was developed by an external company which appears to be a wrapper on top of the SDK and I have no knowledge of its inner workings. This is a little bit out of my domain sorry.

As far I am aware the brightness is obsolete in the iOS SDK due to it's innaccuracy.

CrazyCoder commented 10 years ago

OK, I've contacted ambilighthue@tpvision.com a couple of days ago, but got no response yet.

CrazyCoder commented 10 years ago

I've found some details about the algorithm here.

CrazyCoder commented 10 years ago

I've managed to reuse Android classes (bytecode) in the desktop Java application and it works perfectly. Algorithm in the documentation produces completely different colors that do not match ambilight colors/brightness. Android/iOS ambilight+hue app uses different transformation matrix leading to more accurate results.

SteveyO commented 10 years ago

Good news. Am pleased you got it working.

CrazyCoder commented 10 years ago

I've published the first version of my HAmbiSync application here: http://amip.tools-for.net/hambisync