add sacn support
This commit is contained in:
parent
ae30d09dc6
commit
1f4959d351
3 changed files with 57 additions and 6 deletions
|
@ -6,6 +6,7 @@ base = 'https://cdosea.0x2620.org/static/render/'
|
||||||
lang = '1080p'
|
lang = '1080p'
|
||||||
start = ''
|
start = ''
|
||||||
lights = False
|
lights = False
|
||||||
|
lanbox = False
|
||||||
font = 'Menlo'
|
font = 'Menlo'
|
||||||
# SimHei for chinese
|
# SimHei for chinese
|
||||||
font_size = 28
|
font_size = 28
|
||||||
|
|
|
@ -6,8 +6,10 @@ import time
|
||||||
|
|
||||||
import ox
|
import ox
|
||||||
import lanbox
|
import lanbox
|
||||||
|
import sacn
|
||||||
|
|
||||||
from .pi import random
|
from .pi import random
|
||||||
|
from . import config
|
||||||
|
|
||||||
|
|
||||||
# Screen 1-5, Control, 6,7
|
# Screen 1-5, Control, 6,7
|
||||||
|
@ -43,14 +45,61 @@ LIGHTS = {
|
||||||
9: (channels(0, 0.9), 0.1),
|
9: (channels(0, 0.9), 0.1),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CURRENT_STATE = [0] * 16
|
||||||
|
|
||||||
|
|
||||||
|
def send(state):
|
||||||
|
sender = sacn.sACNsender()
|
||||||
|
sender.start()
|
||||||
|
universe = 1
|
||||||
|
sender.activate_output(universe)
|
||||||
|
sender[1].multicast = True
|
||||||
|
n = 16
|
||||||
|
while n:
|
||||||
|
sender[1].dmx_data = [value] * n
|
||||||
|
time.sleep(1)
|
||||||
|
n -= 1
|
||||||
|
|
||||||
|
sender[1].dmx_data = [0]
|
||||||
|
time.sleep(10) # send the data for 10 seconds
|
||||||
|
|
||||||
|
|
||||||
|
def fade_to(target, duration):
|
||||||
|
global CURRENT_STATE
|
||||||
|
sender = sacn.sACNsender()
|
||||||
|
sender.start()
|
||||||
|
universe = 1
|
||||||
|
sender.activate_output(universe)
|
||||||
|
sender[1].multicast = True
|
||||||
|
current = CURRENT_STATE[0]
|
||||||
|
distance = target - current
|
||||||
|
steps = int(duration * 10)
|
||||||
|
step = duration/steps
|
||||||
|
delta = distance/steps
|
||||||
|
value = current
|
||||||
|
while steps:
|
||||||
|
value += delta
|
||||||
|
n = int(round(value))
|
||||||
|
if n != current:
|
||||||
|
current = n
|
||||||
|
sender[1].dmx_data = [n] * 16
|
||||||
|
CURRENT_STATE = sender[1].dmx_data[:16]
|
||||||
|
time.sleep(step)
|
||||||
|
steps -= 1
|
||||||
|
time.sleep(1)
|
||||||
|
sender.stop()
|
||||||
|
|
||||||
|
|
||||||
def switch(state):
|
def switch(state):
|
||||||
lights, fade = LIGHTS[state]
|
lights, duration = LIGHTS[state]
|
||||||
lb = lanbox.Lanbox()
|
if config.lanbox:
|
||||||
#lb.getChannels(lights)
|
lb = lanbox.Lanbox()
|
||||||
#lb.fadeTo(lights, fade)
|
#lb.getChannels(lights)
|
||||||
lb.layerGo(state)
|
#lb.fadeTo(lights, fade)
|
||||||
|
lb.layerGo(state)
|
||||||
|
else:
|
||||||
|
brightness = round(lights['7'] / 255 * 50)
|
||||||
|
fade_to(brightness, duration)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
path = sys.argv[1]
|
path = sys.argv[1]
|
||||||
|
|
1
setup.py
1
setup.py
|
@ -20,6 +20,7 @@ setup(
|
||||||
'tornado',
|
'tornado',
|
||||||
'mpmath',
|
'mpmath',
|
||||||
'lanbox',
|
'lanbox',
|
||||||
|
'sacn',
|
||||||
'mpv',
|
'mpv',
|
||||||
],
|
],
|
||||||
keywords=[],
|
keywords=[],
|
||||||
|
|
Loading…
Reference in a new issue