2022-07-20 22:27:40 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
from bottle import route, run, static_file, template, view
|
|
|
|
|
|
|
|
from dmx import DMX, Bar252, StairvilleLedPar56, Steady, RotatingRainbow
|
|
|
|
|
|
|
|
|
|
|
|
@route('/')
|
|
|
|
@view('index')
|
|
|
|
def index():
|
|
|
|
return {'foo': 'bar'}
|
|
|
|
|
|
|
|
@route('/static/<path:path>')
|
|
|
|
def static(path):
|
|
|
|
return static_file(path, root='static')
|
|
|
|
|
|
|
|
@route('/api/state/<state>')
|
|
|
|
def update(state):
|
|
|
|
print(f"state -> {state}")
|
|
|
|
if state == "off":
|
|
|
|
dmx.setAnimation(Steady(0, 0, 0))
|
|
|
|
elif state == "white":
|
|
|
|
dmx.setAnimation(Steady(255, 255, 255))
|
|
|
|
elif state == "red":
|
|
|
|
dmx.setAnimation(Steady(255, 0, 0))
|
|
|
|
elif state == "blue":
|
|
|
|
dmx.setAnimation(Steady(0, 0, 255))
|
|
|
|
elif state == "rainbow":
|
|
|
|
dmx.setAnimation(RotatingRainbow())
|
|
|
|
dmx.start()
|
|
|
|
return {'result': 'ok'}
|
|
|
|
|
|
|
|
dmx = DMX("10.31.242.35")
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
2022-07-20 22:57:08 +02:00
|
|
|
run(host='0.0.0.0', port=8080, server='wsgiref', reloader=True)
|
2022-07-20 22:27:40 +02:00
|
|
|
|