MikeCoder96 / HappyLighting-py

HappyLight BLE communication using Bleak (QHM Led Controller)
GNU Affero General Public License v3.0
21 stars 6 forks source link

Music visualizer updates #15

Closed read-0nly closed 1 year ago

read-0nly commented 1 year ago

This one is more a feature I want than work towards your checklist, sorry - I won't be insulted if you refuse the change

One nice thing about python, no need for reflection like with c# to do this sort of thing lol

As for the checklist, I barely grasp what IFTTT is so i'll need to do more reading, but if I could understand this one I could start working on it first:

Change color using mouse pointer

Do you mean like, just a color picker? Or do you mean translating the X/Y position to a color? How would you imagine the color mapping, a 2-d gradient? I think using an image as a color source could work well - if the user wants a gradient they can just use an image of a gradient and we could include some, but they'd be able to do other things with it too (for instance, maybe visual reactions to entering/leaving zones by using a black image with red hollow squares painted as borders)

I'm holding back on the next PR just to not cross streams (I stupidly based the scripting branch off this one, not the nogui one.), if this one is refused then i'll untangle it from the scripting PR. I implemented two script formats - .hls (for happylighting script), which is just a sequence of commands each on their own line like

on
wait 500
off
wait 500
on
quit

and you can also sideload .py files with it, it dynamically runs the async execute function which then either calls commands directly or could do things like overwrite functions on the fly before handing control over again.

import cmdver
import asyncio

async def execute():
    await cmdver.handle_command("off")
    await cmdver.handle_command("off")
    await cmdver.handle_command("wait")
    await cmdver.handle_command("on")
    await cmdver.handle_command("wait")
    await cmdver.handle_command("off")
    await cmdver.handle_command("wait")
    await cmdver.handle_command("on")
    await cmdver.handle_command("wait")
    await cmdver.handle_command("quit")

I wanted to add sideloading of python like this mostly because I have a friend with GOVEE lights - the hope is I'd be able to dynamically overwrite the BLEClass through sideloading with the specifics of the GOVEE protocol and just keep using the rest as-is otherwise. Through sideloading, I could mess with it without changing the base project.