Erste Versuche
This commit is contained in:
commit
b7586bed26
8 changed files with 253 additions and 0 deletions
49
foobaz.py
Normal file
49
foobaz.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#!/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()
|
||||
|
||||
run(host='localhost', port=8080, reloader=True)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue