/*
* The Ursary Control Panel
*
- * (c) 2014--2022 Martin Mares <mj@ucw.cz>
+ * (c) 2014-2023 Martin Mares <mj@ucw.cz>
*/
#undef LOCAL_DEBUG
* slider light color temperature
*/
-#define PCH_SINK "alsa_output.pci-0000_00_1f.3.analog-stereo"
+#define PCH_SINK "alsa_output.pci-0000_07_00.6.analog-stereo"
#define BT_SINK "bluez_sink.CC_98_8B_D0_8C_06.a2dp_sink"
#define LOGI_SOURCE "alsa_input.usb-046d_Logitech_Webcam_C925e_EF163C5F-02.analog-stereo"
}
}
+static void update_lights_from_ir(int ch, int dir)
+{
+ if (lights_on[ch])
+ lights_brightness[ch] = CLAMP(lights_brightness[ch] + 0.07*dir, 0., 1.);
+ else if (dir > 0)
+ {
+ lights_on[ch] = 1;
+ lights_brightness[ch] = 1;
+ }
+ else
+ {
+ lights_on[ch] = 1;
+ lights_brightness[ch] = 0.05;
+ }
+ send_lights(ch);
+}
+
+static void update_lights_on_off_ir(int ch)
+{
+ lights_on[ch] ^= 1;
+ send_lights(ch);
+}
+
+static void update_lights_temp_ir(void)
+{
+ if (!lights_on[0] && !lights_on[1])
+ return;
+
+ double t = (lights_temperature[0] + lights_temperature[1]) / 2;
+ if (t >= 0.66)
+ t = 0;
+ else if (t < 0.33)
+ t = 0.5;
+ else
+ t = 1;
+ lights_temperature[0] = lights_temperature[1] = t;
+
+ send_lights(0);
+ send_lights(1);
+}
+
/*** Rainbow ***/
static double rainbow_brightness;
schedule_update();
}
+static void notify_ir(const char *key)
+{
+ DBG("Received IR key %s", key);
+
+ // Lights
+ if (!strcmp(key, "preset+"))
+ update_lights_from_ir(1, 1);
+ else if (!strcmp(key, "preset-"))
+ update_lights_from_ir(1, -1);
+ else if (!strcmp(key, "tuning-up"))
+ update_lights_from_ir(0, 1);
+ else if (!strcmp(key, "tuning-down"))
+ update_lights_from_ir(0, -1);
+ else if (!strcmp(key, "band"))
+ update_lights_on_off_ir(1);
+ else if (!strcmp(key, "fm-mode"))
+ update_lights_on_off_ir(0);
+ else if (!strcmp(key, "dimmer"))
+ update_lights_temp_ir();
+
+ // Player
+ else if (!strcmp(key, "play"))
+ mpd_play();
+ else if (!strcmp(key, "stop"))
+ mpd_stop();
+ else if (!strcmp(key, "pause"))
+ mpd_pause(1);
+ else if (!strcmp(key, "prev-song"))
+ mpd_prev();
+ else if (!strcmp(key, "next-song"))
+ mpd_next();
+ else if (!strcmp(key, "rewind"))
+ update_sink_from_rotary(-2, PCH_SINK);
+ else if (!strcmp(key, "ffwd"))
+ update_sink_from_rotary(2, PCH_SINK);
+}
+
void notify_mqtt(const char *topic, const char *val)
{
const char blc[] = "burrow/lights/catarium/";
}
}
}
+
+ if (!strcmp(topic, "burrow/control/catarium-ir"))
+ notify_ir(val);
}
/*** Main entry point ***/