add rainbow idle animation
This commit is contained in:
parent
c8630735c4
commit
ff3ea2f452
2 changed files with 43 additions and 1 deletions
24
dmx_queue.py
24
dmx_queue.py
|
@ -1,4 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
|
from colorsys import hsv_to_rgb
|
||||||
from queue import Empty
|
from queue import Empty
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
@ -58,6 +59,7 @@ class DMXQueue:
|
||||||
|
|
||||||
def _worker(self):
|
def _worker(self):
|
||||||
LOG.info('Worker startup')
|
LOG.info('Worker startup')
|
||||||
|
rotation = 0
|
||||||
while self.worker_should_be_running:
|
while self.worker_should_be_running:
|
||||||
try:
|
try:
|
||||||
level, component, text = self.queue.get_nowait()
|
level, component, text = self.queue.get_nowait()
|
||||||
|
@ -99,5 +101,25 @@ class DMXQueue:
|
||||||
sleep(0.03)
|
sleep(0.03)
|
||||||
self.queue.task_done()
|
self.queue.task_done()
|
||||||
except Empty:
|
except Empty:
|
||||||
sleep(0.1)
|
degrees_per_step = 360 / len(self.lights)
|
||||||
|
|
||||||
|
for idx, light in enumerate(self.lights):
|
||||||
|
light_degrees_dec = (
|
||||||
|
(rotation + (idx * degrees_per_step)) % 360 / 360
|
||||||
|
)
|
||||||
|
r, g, b = hsv_to_rgb(
|
||||||
|
light_degrees_dec, 1, self.args.rainbow_intensity / 100
|
||||||
|
)
|
||||||
|
|
||||||
|
light.red = int(r * 255)
|
||||||
|
light.green = int(g * 255)
|
||||||
|
light.blue = int(b * 200)
|
||||||
|
light.intensity = self.args.rainbow_brightness
|
||||||
|
self._bulk(*light.dump())
|
||||||
|
|
||||||
|
rotation = rotation + 1
|
||||||
|
if rotation >= 360:
|
||||||
|
rotation = 0
|
||||||
|
|
||||||
|
sleep(self.args.rainbow_speed / 1000)
|
||||||
LOG.info('Worker shutdown')
|
LOG.info('Worker shutdown')
|
||||||
|
|
20
main.py
20
main.py
|
@ -24,6 +24,26 @@ def main():
|
||||||
|
|
||||||
parser = ArgumentParser()
|
parser = ArgumentParser()
|
||||||
|
|
||||||
|
# rainbow is output if we have no effects
|
||||||
|
parser.add_argument(
|
||||||
|
'--rainbow-intensity',
|
||||||
|
type=int,
|
||||||
|
default=50,
|
||||||
|
help='intensity of the rainbow colours in percent ("value" in HSV)',
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--rainbow-brightness',
|
||||||
|
type=int,
|
||||||
|
default=150,
|
||||||
|
help='brightness of the rainbow colour (dmx value of dimmer)',
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--rainbow-speed',
|
||||||
|
type=int,
|
||||||
|
default=10,
|
||||||
|
help='speed of rainbow colour change (ms per degree hue)',
|
||||||
|
)
|
||||||
|
|
||||||
# MQTT
|
# MQTT
|
||||||
parser.add_argument('--mqtt-host', required=True)
|
parser.add_argument('--mqtt-host', required=True)
|
||||||
parser.add_argument('--mqtt-port', type=int, default=1883)
|
parser.add_argument('--mqtt-port', type=int, default=1883)
|
||||||
|
|
Loading…
Reference in a new issue