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
|
||||
|
||||
base = 'https://cdosea.0x2620.org/static/render/'
|
||||
lang = '1080p'
|
||||
lang = ''
|
||||
start = ''
|
||||
lights = False
|
||||
lanbox = False
|
||||
|
@ -14,6 +14,8 @@ font_size = 28
|
|||
|
||||
letter_offset = False
|
||||
lights_brightness = 255
|
||||
led_lights = 24
|
||||
letter_base_light = 25
|
||||
|
||||
conf = os.path.expanduser('~/.config/cdosea.json')
|
||||
if os.path.exists(conf):
|
||||
|
|
|
@ -55,7 +55,7 @@ CURRENT_STATE = [0] * 16
|
|||
|
||||
|
||||
# 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
|
||||
steps = int(duration * 10)
|
||||
if not steps:
|
||||
|
@ -79,33 +79,45 @@ def fade_to(sender, start, end, duration, channels=16, universe=1):
|
|||
else:
|
||||
a = old
|
||||
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)
|
||||
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
|
||||
flash_duration = 0.02
|
||||
base = 0
|
||||
brightness = config.lights_brightness
|
||||
universe = 1
|
||||
channels = 16
|
||||
channels = config.led_lights
|
||||
|
||||
sender = sacn.sACNsender()
|
||||
sender.start()
|
||||
sender.activate_output(universe)
|
||||
sender[universe].multicast = True
|
||||
sender[universe].dmx_data = [0] * channels
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
sender.stop()
|
||||
|
||||
|
||||
def switch(state, seq):
|
||||
|
@ -128,7 +140,14 @@ if __name__ == '__main__':
|
|||
letter_offset = 0
|
||||
letter = path.split('/')[-1][0].lower()
|
||||
if config.letter_offset:
|
||||
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:
|
||||
sleep = seq() + 15
|
||||
light = seq()
|
||||
|
@ -140,5 +159,7 @@ if __name__ == '__main__':
|
|||
if config.lanbox:
|
||||
switch(light + letter_offset, seq)
|
||||
else:
|
||||
flash(light + 1)
|
||||
flash(sender, universe, light + 1, letter)
|
||||
pos += sleep
|
||||
if not config.lanbox:
|
||||
sender.stop()
|
||||
|
|
Loading…
Reference in a new issue