Flackern fixen

Das Problem ist Reload=True, was forked und dadurch Threads dupliziert.

Verschiendene kleinere Verbesserungen, inkl. Parametrisierung
This commit is contained in:
Stefan Bethke 2022-07-21 18:45:46 +02:00
commit 9687886832
5 changed files with 338 additions and 27 deletions

View file

@ -1,8 +1,12 @@
#!/usr/bin/env python
import argparse
import sys
from time import sleep
from bottle import route, run, static_file, template, view
from dmx import DMX, Bar252, StairvilleLedPar56, Steady, RotatingRainbow
from dmx import DMX, Bar252, StairvilleLedPar56, Steady, RotatingRainbow, REDSpot18RGB, Chase
@route('/')
@ -27,23 +31,50 @@ def update(state):
dmx.setAnimation(Steady(0, 0, 255))
elif state == "rainbow":
dmx.setAnimation(RotatingRainbow())
elif state == "chase-blue":
dmx.setAnimation(Chase(0, 0, 255))
dmx.start()
return {'result': 'ok'}
dmx = DMX("10.31.242.35")
def main(args):
global dmx
dmx.rgbs = [
StairvilleLedPar56(dmx, 1),
StairvilleLedPar56(dmx, 8),
StairvilleLedPar56(dmx, 15),
StairvilleLedPar56(dmx, 22),
Bar252(dmx, 29),
Bar252(dmx, 40),
Bar252(dmx, 51),
Bar252(dmx, 62),
]
dmx.update()
dmx.start()
parser = argparse.ArgumentParser(prog='foobazdmx', description='Make the lights flicker.')
parser.add_argument('-a', '--artnet', type=str, required=True, help="Art-Net server")
parser.add_argument('-r', '--room', type=str, required=True, help="light setup for room")
args = parser.parse_args(args)
run(host='0.0.0.0', port=8080, server='wsgiref', reloader=True)
artnet = args.artnet
print(f"Starting DMX via Art-Net to {artnet}", file=sys.stderr)
# dmx = DMX("10.31.242.35")
dmx = DMX(artnet, maxchan=64)
if args.room == "shop":
dmx.rgbs = [
REDSpot18RGB(dmx, 1),
REDSpot18RGB(dmx, 5),
REDSpot18RGB(dmx, 9),
REDSpot18RGB(dmx, 13),
]
elif args.room == "big":
dmx.rgbs = [
StairvilleLedPar56(dmx, 1),
StairvilleLedPar56(dmx, 8),
StairvilleLedPar56(dmx, 15),
StairvilleLedPar56(dmx, 22),
Bar252(dmx, 29),
Bar252(dmx, 40),
Bar252(dmx, 51),
Bar252(dmx, 62),
]
else:
print(f"Unknown room {args.room}", file=sys.stderr)
sys.exit(64)
dmx.update()
dmx.start()
run(host='0.0.0.0', port=8080, reloader=False)
if __name__ == '__main__':
main(sys.argv[1:])