swinbkh / Ambilight2WLED

ESP8266 based conversion from Philips Ambilight to WLED
GNU General Public License v3.0
17 stars 2 forks source link

Number of colors per TV's Jointspace API #1

Open sergge1 opened 3 years ago

sergge1 commented 3 years ago

Hello @swinbkh . thanks for your work. I have not yet compilled WLED with your usermod. However, I have a question.

Response from my TV by request to http://ip-address:1925/6/ambilight/processed is the following:

{"layer1":
{"left":{
"0":{"r":38,"g":4,"b":7},
"1":{"r":33,"g":9,"b":8},
"2":{"r":61,"g":13,"b":8},
"3":{"r":56,"g":26,"b":15},
"4":{"r":26,"g":27,"b":14}},
"top":{
"0":{"r":26,"g":28,"b":14},
"1":{"r":35,"g":38,"b":21},
"2":{"r":44,"g":47,"b":29},
"3":{"r":46,"g":50,"b":34},
"4":{"r":50,"g":54,"b":39},
"5":{"r":51,"g":55,"b":43},
"6":{"r":47,"g":50,"b":41},
"7":{"r":49,"g":54,"b":46},
"8":{"r":53,"g":58,"b":52},
"9":{"r":68,"g":72,"b":67},
"10":{"r":63,"g":68,"b":64}},
"right":{
"0":{"r":60,"g":65,"b":61},
"1":{"r":68,"g":82,"b":95},
"2":{"r":254,"g":147,"b":82},
"3":{"r":171,"g":127,"b":129},
"4":{"r":61,"g":111,"b":228}
}}}

so we see 4 colors for left and right and 10 colors for the top. At the usermod for WLED I see that the ode analyzes 3 colors for left/right and 7 colors for the top.

Question: Should I update the code (just add additional lines for missed colors over the code) or it will work Ok?

swinbkh commented 3 years ago

@sergge1 , you must have a larger TV than I do!

I have a 43in and a 55in, and they both had the same number of LEDs, but now you've mentioned it...they're still on the small end of some of the ambilight models!

I will change this shortly to operate dynamically to however many LEDs are on the TV.

My intentions for the colour extraction were to take the average of the left colours on the TV, and show them on the leftmost end of a WLED strip, the top would be mapped to the center and the right edge of the TV to the rightmost end of the strip, but there are other configurations which others may prefer too.

Any preferences on how to handle colour mapping to a strip?

swinbkh commented 3 years ago

Should I update the code (just add additional lines for missed colors over the code) or it will work Ok?

For now, the usermod does not work, so even changing this to reflect your TV configuration won't work. Sorry :(

The usermod was uploaded as a placeholder to eventually implement as part of WLED. I managed to do the TV data capture, but not the WLED output!

sergge1 commented 3 years ago

@swinbkh you are right, I have 70'' tv.

sergge1 commented 3 years ago

Any preferences on how to handle colour mapping to a strip

your idea to map the average color to the strip is great. I really enjoy it.

Per my mind, this module should extend the Ambilight feature. If the user will put his strip on left+top+right - it will just repeat Ambilight, like no wow effect. I have different set up: I have a ceiling lamp controlled by WLED. It is at top of the room. So it would be great if this lamp will repeat top leds of TV. Also I have a kitchen with backlight controlled by WLED - it is to the right side - so it would be great to repeat the right side of TV's ambilight.

So , in general, I would prefer to have multi-WLED ability (e.g. to connect at least 3 instances for left, top,, right) and choose by which ambilight sidy each instance should be controlled.

sergge1 commented 3 years ago

i have compilled and checked the code. Added two pull requests - as was not able to compile without errors, now corrected. here is a current performance within my set-up: TV + WLED ceiling lamp - https://youtu.be/H4ltVsz7Qkk

We need to develop colour ьmapping, transition speed etc

swinbkh commented 3 years ago

@sergge1, I've merged your pull requests - Thanks for taking the time to add to the Readme too!

I tweaked your pull request to support both architectures (ESP8266/ESP32) since these are natively supported by WLED, and this allows either board to be used when this eventually gets to being a usermod for WLED.

Thanks for your video, it is interesting to see your usage case - it's completely different to mine; but I think it shows how important flexibility is in the configuration of this functionality. I think a good goal to have would be user-defined configuration, so that it's up to the end-user to decide how to setup.

I'll get in touch with WLED dev's to get some pointers for how to integrate into WLED. The example files are helpful, but driving LEDs - there is less info on that!

sergge1 commented 3 years ago

That would be great everything you have written - to have possibility to have a selections of prefferences. Best way - as a part of WLED or at least as a usermod. However, usermods have no inputs in UI. They can just show some info to INFO page at wled, but no selections, radiobuttons etc.

By the way. At the moment i see the significant bug. Steps:

  1. Turn on WLED and TV;
  2. Tunr on Ambilight2WLED, flashed on ESP8266. Everything works well;
  3. Turn off Ambilight2WLED (just switch off the power);
  4. WLED become unaccessible, only hard restart solves the problem;
swinbkh commented 3 years ago

Thanks for your testing @sergge1, I would imagine this is caused in the JSON payload to WLED. I too have been able to repeat this. This may be due to the type of payload being sent. It is a modification of the example provided here: https://github.com/Aircoookie/WLED/wiki/JSON-API

It was a very "quick and dirty" approach used to get it up and running!

I wonder if it is worth pursuing a fix for this, given that the ultimate ambition will be integration with WLED via a usermod, which will eventually replace this functionality.

sergge1 commented 3 years ago

I wonder if it is worth pursuing a fix for this, given that the ultimate ambition will be integration with WLED via a usermod, which will eventually replace this functionality.

got it. i will try to think also about usermod

quotschmacher commented 3 years ago

nice build. just for the information: my new 55oled705 gives back 3 colors for left and right and 7 for the top, even though there are much more leds build in. i think it would be a nice way to get the number of colors via the /ambilight/topology endpoint.