From f96c7224a7aca557cad86143c691ac7c4058525a Mon Sep 17 00:00:00 2001 From: j Date: Tue, 19 Dec 2023 13:26:25 +0000 Subject: [PATCH] letter offset --- cdoseaplay/config.py | 2 ++ cdoseaplay/lights.py | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cdoseaplay/config.py b/cdoseaplay/config.py index 391ec84..2758cd0 100644 --- a/cdoseaplay/config.py +++ b/cdoseaplay/config.py @@ -12,6 +12,8 @@ font = 'Menlo' font_size = 28 # 30 for chinese +letter_offset = False + conf = os.path.expanduser('~/.config/cdosea.json') if os.path.exists(conf): with open(conf) as fd: diff --git a/cdoseaplay/lights.py b/cdoseaplay/lights.py index a59dca9..040582a 100755 --- a/cdoseaplay/lights.py +++ b/cdoseaplay/lights.py @@ -1,7 +1,8 @@ #!/usr/bin/python3 +import os +import string import subprocess import sys -import os import time import ox @@ -101,28 +102,29 @@ def fade_to(target, duration): def switch(state): - lights, duration = LIGHTS[state] if config.lanbox: import lanbox lb = lanbox.Lanbox() - #lb.getChannels(lights) - #lb.fadeTo(lights, fade) lb.layerGo(state) else: + lights, duration = LIGHTS[state] brightness = lights['7'] fade_to(brightness, duration) if __name__ == '__main__': path = sys.argv[1] - no_sleep = len(sys.argv) > 2 + no_sleep = len(sys.argv) > 2 and sys.argv[2] == "no-sleep" - n = int(os.path.getctime(path) - 1495280000) + n = int(os.path.getctime(path) - 1495280000) % 1000 info = ox.avinfo(path) duration = info.get('duration', 0) - seq = random(n * 1000) + seq = random(n * 100) pos = 0 lights = [] + letter_offset = 0 + if config.letter_offset: + letter_offset = 11 + string.ascii_lowercase.index(letter) * 10 while pos < duration - 15: sleep = seq() + 15 light = seq() @@ -130,5 +132,6 @@ if __name__ == '__main__': break if not no_sleep: time.sleep(sleep) - switch(light) + print("letter", letter, "offset", letter_offset, "light", light, "cue", letter_offset + light) + switch(light + letter_offset) pos += sleep