From e77a5bc4bb6e4536fc3063e86b2ec4e39dbc6407 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 1 May 2020 22:55:49 +0200 Subject: [PATCH] Lights: Second channel --- ursaryd.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ursaryd.c b/ursaryd.c index 50b50c5..29b4340 100644 --- a/ursaryd.c +++ b/ursaryd.c @@ -31,7 +31,7 @@ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * 0 sink PCH mute switch to PCH * 1 sink BT mute switch to BT - * 2 - mic non-mute - + * 2 ceil brightness mic non-mute ceiling lights on * 3 desk brightness - desk lights on * 4 MPD mute MPD play/pause * 5 Albireo MPV mute MPD stop @@ -491,17 +491,18 @@ static void update_lights(void) if (!dmx_is_ready()) { noct_set_ring(3, RING_MODE_SINGLE_ON, 0x7f); + noct_set_button(10, 0); noct_set_button(11, 0); return; } - for (uint i=0; i<1; i++) + for (uint i=0; i<2; i++) { uint warm, cold; if (lights_on[i]) { - noct_set_ring(3, RING_MODE_LEFT, lights_brightness[i] * 127); - noct_set_button(11, 1); + noct_set_ring(3-i, RING_MODE_LEFT, lights_brightness[i] * 127); + noct_set_button(11-i, 1); double r = 2; double x = (exp(r*lights_brightness[i]) - 1) / (exp(r) - 1); double t = lights_temperature[i]; @@ -512,8 +513,8 @@ static void update_lights(void) } else { - noct_set_ring(3, RING_MODE_LEFT, 0); - noct_set_button(11, 0); + noct_set_ring(3-i, RING_MODE_LEFT, 0); + noct_set_button(11-i, 0); warm = cold = 0; } DBG("Lights[%d]: on=%d bri=%.3f temp=%.3f -> warm=%d cold=%d", i, lights_on[i], lights_brightness[i], lights_temperature[i], warm, cold); @@ -532,6 +533,7 @@ static void update_lights_from_rotary(int ch, int delta) static void update_lights_from_slider(int value) { lights_temperature[0] = value / 127.; + lights_temperature[1] = value / 127.; update_lights(); } @@ -708,6 +710,9 @@ void notify_rotary(int rotary, int delta) case 1: update_sink_from_rotary(delta, BT_SINK); break; + case 2: + update_lights_from_rotary(1, delta); + break; case 3: update_lights_from_rotary(0, delta); break; @@ -739,6 +744,9 @@ void notify_button(int button, int on) case 9: update_default_sink_from_button(button, on); break; + case 10: + update_lights_from_button(1, on); + break; case 11: update_lights_from_button(0, on); break; -- 2.39.5