JnyJny / busylight

Control USB connected presence lights from multiple vendors via the command-line or web API.
Apache License 2.0
227 stars 25 forks source link

[NEW LIGHT] fit-statUSB #162

Closed mchaker closed 2 years ago

mchaker commented 2 years ago

If you would like BusyLight to support a new device, please provide as much of the following as possible.

JnyJny commented 2 years ago

Cool! A new light and thank you for all the useful links. I've ordered an example and should have it shortly. Reviewing the docs, it appears to be a serial device rather than a HID device. I've been working on a re-write to incorporate serial devices side by side with HID lights, but it's still a work in progress with no real ETA. I'm having to re-write the class hierarchy AND learn how serial devices work with Python.

mchaker commented 2 years ago

Thanks for responding so quickly! If there's any way I can help with the serial device support or testing, let me know. :)

JnyJny commented 2 years ago

The serial communication part is pretty straight forward, it takes me back to the bad old day of talking to devices on parallel and non-USB serial ports. The light hierarchy is changing from

USBLight -> vendor_specific_light

to

         +--> HIDLight -> vendor_specific_lights
Light ---+
         +--> SerialLight -> vendor_specific_lights

So I'm having to find the common ground between HID and serial and move that into Light and then implement the protocol specific stuff. My goal is to have a similar interface that USBLight provides so that users don't have to know the implementation specific details of the light they just plugged in:

from busylight.lights import Light

light = Light.first_light()

light.on((255,0,0))
JnyJny commented 2 years ago

I'm working in branch feature/Light if you want to follow along, haven't committed anything yet but should have some basic stuff committed in the next 12 hours.

mchaker commented 2 years ago

I like your approach! I'll follow that branch.

JnyJny commented 2 years ago

I have a fit-statUSB light (and a MuteSync light/button which is also a serial device) and figured out how to drive it using the PySerial package. I'm replacing busylight.lights.USBLight and it's hierarchy with busylight.lights.Light which has subclasses HIDLight and SerialLight.

mchaker commented 2 years ago

Awesome! Thank you so much.

JnyJny commented 2 years ago

The fit-statUSB is working with the latest commit to the feature/Light branch. It's kind of a limited; it performs fade ins and fade outs for color transitions that are "builtin" and uncommanded. This isn't a big deal for turning the light on and off, but changing between colors quickly looks a little weird. ¯\_(ツ)_/¯ But it's working :) Same goes for the MuteSync serial device.

I'm going to get tests working again before merging this branch into the master branch.

henryruhs commented 2 years ago

Check this out for inspiration: https://pypi.org/project/pystatusb

JnyJny commented 2 years ago

I wasn't aware I needed inspiration, thanks Henry.

JnyJny commented 2 years ago

Commit 44053a846a62f0cfff9ee384c7319cedcb58dfb7 adds support for the fit-statUSB and two other lights in addition to a complete restructuring of the Light subclass hierarchy.

mchaker commented 2 years ago

Excellent!! I'll give it a try this week(end?)

Thank you so much

henryruhs commented 2 years ago

I ordered my version of this device aswell and will give feedback once it arrived. Thanks Erik