Prettier
This commit is contained in:
parent
fa1dfe2354
commit
1f59d9cd9a
12
dmx.py
12
dmx.py
|
@ -1,7 +1,7 @@
|
|||
import colorsys
|
||||
import socket
|
||||
import struct
|
||||
import threading
|
||||
import sys
|
||||
from threading import Thread
|
||||
from time import sleep, time
|
||||
|
||||
|
@ -59,7 +59,7 @@ class Steady:
|
|||
return (self.r, self.g, self.b)
|
||||
|
||||
def __str__(self):
|
||||
return f"steady({self.r}, {self.g}, {self.b})"
|
||||
return f"{type(self).__name__}({self.r}, {self.g}, {self.b})"
|
||||
|
||||
|
||||
class FadeTo(Steady):
|
||||
|
@ -74,7 +74,7 @@ class FadeTo(Steady):
|
|||
return (int(self.r * h), int(self.g * h), int(self.b * h))
|
||||
|
||||
def __str__(self):
|
||||
return f"fadeTo({self.r}, {self.g}, {self.b})"
|
||||
return f"{type(self).__name__}({self.r}, {self.g}, {self.b}, {self.t:.2f})"
|
||||
|
||||
|
||||
class RotatingRainbow:
|
||||
|
@ -94,7 +94,7 @@ class RotatingRainbow:
|
|||
return rgb
|
||||
|
||||
def __str__(self):
|
||||
return "RotatingRainbow"
|
||||
return "{type(self).__name__}"
|
||||
|
||||
|
||||
class Chase(Steady):
|
||||
|
@ -109,7 +109,7 @@ class Chase(Steady):
|
|||
return (int(self.r * l), int(self.g * l), int(self.b * l))
|
||||
|
||||
def __str__(self):
|
||||
return f"fadeTo({self.r}, {self.g}, {self.b})"
|
||||
return f"{type(self).__name__}({self.r}, {self.g}, {self.b}, {self.looptime:.2f})"
|
||||
|
||||
|
||||
class DMX:
|
||||
|
@ -169,4 +169,4 @@ class DMX:
|
|||
|
||||
def setAnimation(self, animation):
|
||||
self.animation = animation
|
||||
print(f"Animation: {animation}")
|
||||
print(f"Animation: {animation}", file=sys.stderr)
|
|
@ -2,11 +2,10 @@
|
|||
|
||||
import argparse
|
||||
import sys
|
||||
from time import sleep
|
||||
|
||||
from bottle import route, run, static_file, template, view
|
||||
from bottle import route, run, static_file, view
|
||||
|
||||
from dmx import DMX, Bar252, StairvilleLedPar56, Steady, RotatingRainbow, REDSpot18RGB, Chase
|
||||
from dmx import DMX, Bar252, StairvilleLedPar56, Steady, RotatingRainbow, REDSpot18RGB, Chase, FadeTo
|
||||
|
||||
|
||||
@route('/')
|
||||
|
@ -20,7 +19,6 @@ def static(path):
|
|||
|
||||
@route('/api/state/<state>')
|
||||
def update(state):
|
||||
print(f"state -> {state}")
|
||||
if state == "off":
|
||||
dmx.setAnimation(Steady(0, 0, 0))
|
||||
elif state == "white":
|
||||
|
@ -71,7 +69,7 @@ def main(args):
|
|||
else:
|
||||
print(f"Unknown room {args.room}", file=sys.stderr)
|
||||
sys.exit(64)
|
||||
dmx.update()
|
||||
dmx.setAnimation(FadeTo(128, 128, 128))
|
||||
dmx.start()
|
||||
|
||||
run(host='0.0.0.0', port=8080, reloader=False)
|
||||
|
|
Loading…
Reference in a new issue