feat(ragb): Commit all the hotfixes

This commit is contained in:
sinavir 2024-11-07 20:58:01 +01:00
parent da09ce104a
commit 54170c0ee9
No known key found for this signature in database
3 changed files with 31 additions and 9 deletions

View file

@ -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":
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()

View file

@ -74,6 +74,7 @@
"jwt_secret:${config.age.secrets.ragbJWT.path}"
];
DynamicUser = true;
StateDirectory = "ragb-backend";
};
};
}

View file

@ -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