From 54170c0ee998715c559c05bfc87ddc2086326aa3 Mon Sep 17 00:00:00 2001 From: sinavir Date: Thu, 7 Nov 2024 20:58:01 +0100 Subject: [PATCH] feat(ragb): Commit all the hotfixes --- machines/agb01/script.py | 35 ++++++++++++++++++++++++++++------- machines/hackens-org/ragb.nix | 1 + npins/sources.json | 4 ++-- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/machines/agb01/script.py b/machines/agb01/script.py index 3a9a17c..f89a885 100644 --- a/machines/agb01/script.py +++ b/machines/agb01/script.py @@ -1,10 +1,12 @@ +#!/nix/store/q1p072dnnx7fh7qfcavkmpwn3rgf2xh1-python3-3.12.5-env/bin/python + import json import logging import sys import requests from colour import Color -from pyjecteur.fixtures import Blinder, LedBar48Ch, Tradi +from pyjecteur.fixtures import Blinder, LedBar48Ch, Tradi, Wash, Lyre from pyjecteur.lights import Universe from pyjecteur.widget import Widget @@ -16,9 +18,9 @@ else: w = Widget("/dev/ttyUSB0") DIM = { - "blinder": 1.0, - "led_tub": 1.0, - "spot": 1.0, + "blinder": 0.1, + "led_tub": 0.3, + "spot": 0.3, } u = Universe(w) @@ -31,7 +33,7 @@ def strToProj(s): case "led_tub": return LedBar48Ch() case "blinder": - return Blinder() + return LedBar48Ch() r = requests.get("https://agb.hackens.org/api-docs/patch.json") @@ -45,7 +47,8 @@ current_addr = 0 for k, v in patch["lights"].items(): lights[k] = strToProj(v["kind"]) - u.register(lights[k], current_addr) + u.register(lights[k], v["channels"][0]*3) + print(v["kind"], v["channels"]) # update dmx since some params are set before lights[k].update_dmx() logging.info( @@ -55,8 +58,12 @@ for k, v in patch["lights"].items(): update[chan] = (k, i) # put the light name current_addr += lights[k].address_size +l = Lyre() +u.register(l, 489) def update_light(address, red, green, blue): + if address not in update: + return light, chan = update[address] kind = patch["lights"][light]["kind"] r, g, b = red * DIM[kind] / 255, (green * DIM[kind]) / 255, (blue * DIM[kind]) / 255 @@ -71,6 +78,8 @@ def update_light(address, red, green, blue): def run(): logging.info("Started") + bump = False + bump_color = None for line in sys.stdin: logging.debug(line) if line.startswith("data:"): @@ -78,7 +87,19 @@ def run(): logging.info(f"Received: {dataStr}") data = json.loads(dataStr) if data["type"] == "Color": - update_light(data["address"], **data["value"]) + if data["address"] == 90: + + r, g, b = data["value"]["red"] /255, data["value"]["green"] /255, data["value"]["blue"] /255 + w.color = Color(rgb = (r, g, b)) + else: + update_light(data["address"], **data["value"]) + else: + l.pan = data["pan"] + l.tilt = data["tilt"] + l.dimmer = data["focus"] + l.color = data["white_button"] *7 + 3 + + run() diff --git a/machines/hackens-org/ragb.nix b/machines/hackens-org/ragb.nix index 4cbf11c..4cd3d21 100644 --- a/machines/hackens-org/ragb.nix +++ b/machines/hackens-org/ragb.nix @@ -74,6 +74,7 @@ "jwt_secret:${config.age.secrets.ragbJWT.path}" ]; DynamicUser = true; + StateDirectory = "ragb-backend"; }; }; } diff --git a/npins/sources.json b/npins/sources.json index ca977a7..2d6aa9a 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -69,9 +69,9 @@ "url": "https://git.dgnum.eu/HackENS/ragb" }, "branch": "main", - "revision": "700d967ff35e86e498cc84595ead2ab0aa0e2bfc", + "revision": "ddfbbe50e385db3ffbf1dd1bf7ffb6102c968bf5", "url": null, - "hash": "0x32xms9zi6cnblsmfhp0d2jh21xdcn4gqp13i38i0hzqkwxvql1" + "hash": "00zz65qc1yzxlff65qv6818bhnqdbjnwcz00w34hiz0597ancdx0" } }, "version": 3