* 6 Albireo Zoom mute MPD prev
* 7 eveyrhing else mute MPD next
*
- * center -
+ * center rainbow brightness
* slider light color temperature
*/
}
}
+/*** Rainbow ***/
+
+static double rainbow_brightness;
+static timestamp_t rainbow_last_update;
+
+static void update_rainbow(void)
+{
+ noct_set_ring(8, RING_MODE_LEFT, rainbow_brightness * 127);
+}
+
+static void send_rainbow(void)
+{
+ char val[100];
+ snprintf(val, sizeof(val), "%.3f", rainbow_brightness);
+ mqtt_publish("burrow/lights/rainbow/brightness", val);
+ rainbow_last_update = main_get_now();
+ update_rainbow();
+}
+
+static void update_rainbow_from_rotary(int delta)
+{
+ rainbow_brightness = CLAMP(rainbow_brightness + 0.015*delta*abs(delta), 0., 1.);
+ send_rainbow();
+}
+
/*** Main update routines ***/
static struct main_timer update_timer;
update_source_buttons();
update_mpd();
update_lights();
+ update_rainbow();
}
void schedule_update(void)
case 3:
update_lights_from_rotary(0, delta);
break;
+ case 8:
+ update_rainbow_from_rotary(delta);
+ break;
case 9:
update_lights_from_slider(delta);
break;
update_lights();
}
}
+
+ if (!strcmp(topic, "burrow/lights/rainbow/brightness"))
+ {
+ double b;
+ if (sscanf(val, "%lf", &b) == 1 && b >= 0 && b <= 1)
+ {
+ timestamp_t now = main_get_now();
+ if (!rainbow_last_update || rainbow_last_update + 1000 < now)
+ {
+ DBG("Received foreign rainbow settings");
+ rainbow_brightness = b;
+ update_rainbow();
+ }
+ }
+ }
}
/*** Main entry point ***/