Compare commits
2 commits
fa4387a187
...
9f319a5b21
Author | SHA1 | Date | |
---|---|---|---|
9f319a5b21 | |||
be9c333967 |
2 changed files with 39 additions and 16 deletions
|
@ -3,7 +3,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
base = 'https://cdosea.0x2620.org/static/render/'
|
base = 'https://cdosea.0x2620.org/static/render/'
|
||||||
lang = '1080p'
|
lang = ''
|
||||||
start = ''
|
start = ''
|
||||||
lights = False
|
lights = False
|
||||||
lanbox = False
|
lanbox = False
|
||||||
|
@ -14,6 +14,8 @@ font_size = 28
|
||||||
|
|
||||||
letter_offset = False
|
letter_offset = False
|
||||||
lights_brightness = 255
|
lights_brightness = 255
|
||||||
|
led_lights = 24
|
||||||
|
letter_base_light = 25
|
||||||
|
|
||||||
conf = os.path.expanduser('~/.config/cdosea.json')
|
conf = os.path.expanduser('~/.config/cdosea.json')
|
||||||
if os.path.exists(conf):
|
if os.path.exists(conf):
|
||||||
|
|
|
@ -55,7 +55,7 @@ CURRENT_STATE = [0] * 16
|
||||||
|
|
||||||
|
|
||||||
# avoid overload and turn light on with a fade
|
# avoid overload and turn light on with a fade
|
||||||
def fade_to(sender, start, end, duration, channels=16, universe=1):
|
def fade_to(sender, start, end, duration, channels=16, universe=1, lights=[]):
|
||||||
distance = end - start
|
distance = end - start
|
||||||
steps = int(duration * 10)
|
steps = int(duration * 10)
|
||||||
if not steps:
|
if not steps:
|
||||||
|
@ -79,33 +79,45 @@ def fade_to(sender, start, end, duration, channels=16, universe=1):
|
||||||
else:
|
else:
|
||||||
a = old
|
a = old
|
||||||
b = target
|
b = target
|
||||||
sender[universe].dmx_data = [a[x] if x % 2 else b[x] for x in range(channels)]
|
channel_data = [a[x] if x % 2 else b[x] for x in range(channels)]
|
||||||
|
sender[universe].dmx_data = channel_data + lights[channels:]
|
||||||
time.sleep(step)
|
time.sleep(step)
|
||||||
steps -= 1
|
steps -= 1
|
||||||
|
channel_data = [end] * channels
|
||||||
|
sender[universe].dmx_data = channel_data + lights[channels:]
|
||||||
|
|
||||||
|
def dmx_base(letter):
|
||||||
|
lights = [0] * 512
|
||||||
|
letter_offset = 101 - 1
|
||||||
|
for offset in range(letter_offset, letter_offset+27):
|
||||||
|
lights[offset] = config.letter_base_light
|
||||||
|
if letter:
|
||||||
|
lights[letter_offset + string.ascii_lowercase.index(letter.lower())] = 255
|
||||||
|
lights[letter_offset + 26] = 255
|
||||||
|
return lights
|
||||||
|
|
||||||
|
|
||||||
def flash(flashes):
|
def flash(sender, universe, flashes, letter):
|
||||||
step = 0.2
|
step = 0.2
|
||||||
flash_duration = 0.02
|
flash_duration = 0.02
|
||||||
base = 0
|
base = 0
|
||||||
brightness = config.lights_brightness
|
brightness = config.lights_brightness
|
||||||
universe = 1
|
channels = config.led_lights
|
||||||
channels = 16
|
|
||||||
|
|
||||||
sender = sacn.sACNsender()
|
|
||||||
sender.start()
|
|
||||||
sender.activate_output(universe)
|
|
||||||
sender[universe].multicast = True
|
|
||||||
sender[universe].dmx_data = [0] * channels
|
sender[universe].dmx_data = [0] * channels
|
||||||
while flashes:
|
while flashes:
|
||||||
fade_to(sender, base, brightness, flash_duration, channels, universe)
|
lights = dmx_base(letter)
|
||||||
|
fade_to(sender, base, brightness, flash_duration, channels, universe, lights)
|
||||||
time.sleep(step)
|
time.sleep(step)
|
||||||
sender[1].dmx_data = [0] * channels
|
lights = dmx_base(None)
|
||||||
|
channel_data = [0] * channels
|
||||||
|
sender[universe].dmx_data = channel_data + lights[channels:]
|
||||||
time.sleep(step)
|
time.sleep(step)
|
||||||
flashes -= 1
|
flashes -= 1
|
||||||
sender[universe].dmx_data = [0] * channels
|
lights = dmx_base(None)
|
||||||
|
channel_data = [0] * channels
|
||||||
|
sender[universe].dmx_data = channel_data + lights[channels:]
|
||||||
time.sleep(step)
|
time.sleep(step)
|
||||||
sender.stop()
|
|
||||||
|
|
||||||
|
|
||||||
def switch(state, seq):
|
def switch(state, seq):
|
||||||
|
@ -128,7 +140,14 @@ if __name__ == '__main__':
|
||||||
letter_offset = 0
|
letter_offset = 0
|
||||||
letter = path.split('/')[-1][0].lower()
|
letter = path.split('/')[-1][0].lower()
|
||||||
if config.letter_offset:
|
if config.letter_offset:
|
||||||
letter_offset = 11 + string.ascii_lowercase.index(letter) * 10
|
if config.lanbox:
|
||||||
|
letter_offset = 11 + string.ascii_lowercase.index(letter) * 10
|
||||||
|
if not config.lanbox:
|
||||||
|
universe = 1
|
||||||
|
sender = sacn.sACNsender()
|
||||||
|
sender.start()
|
||||||
|
sender.activate_output(universe)
|
||||||
|
sender[universe].multicast = True
|
||||||
while pos < duration - 15:
|
while pos < duration - 15:
|
||||||
sleep = seq() + 15
|
sleep = seq() + 15
|
||||||
light = seq()
|
light = seq()
|
||||||
|
@ -140,5 +159,7 @@ if __name__ == '__main__':
|
||||||
if config.lanbox:
|
if config.lanbox:
|
||||||
switch(light + letter_offset, seq)
|
switch(light + letter_offset, seq)
|
||||||
else:
|
else:
|
||||||
flash(light + 1)
|
flash(sender, universe, light + 1, letter)
|
||||||
pos += sleep
|
pos += sleep
|
||||||
|
if not config.lanbox:
|
||||||
|
sender.stop()
|
||||||
|
|
Loading…
Reference in a new issue