pimoroni / blinkt

Python Library for Blinkt; 8 APA102 LEDs for your Raspberry Pi
https://shop.pimoroni.com/products/blinkt
MIT License
314 stars 103 forks source link

MQTT example improvements #63

Closed strix-technica closed 2 years ago

strix-technica commented 6 years ago

Add a brightness control message.

The MQTT example is almost sufficiently well-developed to be used as a daemon, so add a command-line parser including daemon mode (needs module python-daemon, but only if --daemon specified so no additional dependencies required for foreground use as originally intended).

strix-technica commented 6 years ago

Killing the daemon requires a SIGKILL which doesn't switch off LEDs on termination. If anybody cares about this, I'll add a suitable signal handler.

SIGTERM now gracefully handled.

Gadgetoid commented 6 years ago

Nice! Thanks for taking the time to make a PR. I'll test/merge as soon as I can.

strix-technica commented 6 years ago

You're welcome, @Gadgetoid, glad it's of interest! I've just pushed some improvements to daemon mode making it behave a bit better, notably on SIGTERM.

I've also added support for multiple topics and an optional timeout mechanism such that a pixel that hasn't received a message in a defined time will be turned off. This is intended to signal failure of whatever was sending messages.

I'll send a different PR for that because the timeout thing involved a fair amount of restructuring of the code which might overly complicate things as an example. The multiple topics thing wouldn't be difficult to merge into this PR, though.