kershner / screenBloom

Fake Ambilight for Philips Hue via Python
http://www.screenbloom.com
331 stars 48 forks source link

Feature: Spliting screen by the number of bulbs #4

Closed TwanoO67 closed 8 years ago

TwanoO67 commented 8 years ago

Hi Tyler,

Here's another feature idea:

It would be nice to split the screen by the number of selected bulbs.

For example: if you have two bulbs, one in the left of the room, the other one on the right. You would select "split 2 vertical", then select one bulb for left, the other one for the right. And when you calc the average pixel color, you only have to use the half of the matrix for one value, and the other one for the other bulb.

Idealy, I would imagine a 16x16 grid in the app html, where you could select your bulbs positions. For example: one could select a 4x16 top zone to use with a LightStrip, and then two 12x8 left and right zone, to use with bulbs

kershner commented 8 years ago

That's an excellent idea and I've already been planning on doing some 'region' parsing of the image for the next update. I like the idea about the grid in the front end, that could honestly make things a bit simpler to implement.

TwanoO67 commented 8 years ago

To help on that implementation, I did a PoC for the grid part in JS: https://jsfiddle.net/fp1mLxxc/6/

Edit: Added some select to match zones with bulbs https://jsfiddle.net/fp1mLxxc/10/

Btw, 'zones' are stackable (so one cell can be used for several zones), but at the moment the background-color is set at the last selected zone's color.

Edit2: Fixed some css issue and added indexed tab for available_lights: https://jsfiddle.net/fp1mLxxc/11/

kershner commented 8 years ago

This is really cool, nice work. I'll definitely be looking at this for when I start working on the image grid feature. If you start hacking up the ScreenBloom code and get this added in before I do, let me know so I can check it out.

TwanoO67 commented 8 years ago

Hi Tyler,

I got a first version of the zone implementation here: https://github.com/TwanoO67/screenBloom

it's working, but it needs more testing, explanation and probably some css too... ( And I missed your last commit tonight, so it's not updated with your master at the moment ) I will try to work more on that during the weekend, so if you have ideas for that I'm taking :)

kershner commented 8 years ago

That's so cool, took a few looks through it but haven't tried to run it yet. Keep me posted if you keep working on it and I'll try to get it running locally asap to contribute.

EDIT Reading through more of your code I came across this handy little optimization, which is now in both live builds. Can't believe I missed that lol.

kershner commented 8 years ago

Hey man I just cloned your fork and checked it out. It's really impressive and cool! This could be a really great feature. Do you mind if I mess around with it and use it in the main code base? I'll definitely credit you wherever I'm able to.

Of course if you wanna keep working on it we can always get a pull request going.

TwanoO67 commented 8 years ago

I didn't add the time to go further this week-end, so do as you want with that, and I will continue with your version if you need help :)

kershner commented 8 years ago

Awesome, I'm gonna leave this issue open while I work on it incase I had some questions. In fact, I had one right away - what is the purpose of this ast.literal_eval call? I'm guessing the zones list stored in the config needs to be modded when you read it out in order to work with it in some way?

TwanoO67 commented 8 years ago

I think that was needed to transform the string representation of the dict, into the real dict value. But I'm new to python so it's maybe an error...

Furthermore, this config definitely should be converted to a json string, it's more human readable/editable :)

kershner commented 8 years ago

Gonna close this out, as it has been fully integrated into the project for a while now. Thanks again for your initial work, TwanO.