Add SignalRGB control via WLED emulation
The clock answers like a WLED device (mDNS _wled._tcp, /json/info, /json/state, realtime UDP on 21324 and DDP on 4048), so SignalRGB can drive the 4 backlight LEDs, one per tube, LED 0 = left tube. Frames are shown at most 30 times a second (WLED_MAX_FPS); the normal effect returns 2.5 s after they stop, and the alarm flash still wins. Three new settings on the RGB page: enable (also a Home Assistant switch), stay dark while the tubes are off, and scale by the RGB brightness. They are stored in EEPROM after prm with their own magic value, so the update does not factory-reset the clock. page.js and site.css are now sent with no-cache: browsers kept them for a year and ran the old script after a web UI update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c4e0c29791
commit
ae87849e75
9 files changed
+446
-20
No files matched your search
@@ -11,7 +11,7 @@
|
||||
// Sensors: temperature/humidity/pressure/lux/radar (whichever exist on this clock), WiFi signal
|
||||
// Controls: Tubes (switch, runtime only), Day/Night brightness (numbers), Auto dim (switch),
|
||||
// Cathode protect (button); with USE_NEOPIXEL also Backlight (light: on/off, brightness, colour)
|
||||
// and LED effect (select).
|
||||
// and LED effect (select); with USE_WLED_REALTIME also SignalRGB (switch, = prmExt.wledEnable).
|
||||
// Changes made on the clock's own web page are reported back to HA by mqttSend().
|
||||
// Settings changed from HA are saved to EEPROM a few seconds after the last change (one flash write per burst).
|
||||
//
|
||||
@@ -85,6 +85,9 @@ HAButton mqttCathodeProtect("cathode_protect");
|
||||
HASelect mqttLedEffect("led_effect");
|
||||
byte mqttLastEffect = 2; //effect restored when the backlight is switched on from HA (rainbow flow by default)
|
||||
#endif
|
||||
#ifdef USE_WLED_REALTIME
|
||||
HASwitch mqttWled("signalrgb");
|
||||
#endif
|
||||
|
||||
//Bounded copy of an MQTT payload into a zero-terminated buffer.
|
||||
// FIXED: the old onMqttMessage() memcpy'd the payload into a 100-byte stack buffer without a length check or a
|
||||
@@ -263,6 +266,14 @@ void onLedEffectCommand(int8_t index, HASelect* sender) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_WLED_REALTIME
|
||||
void onWledCommand(bool state, HASwitch* sender) {
|
||||
prmExt.wledEnable = state; //wledHandle() starts/stops the listeners
|
||||
sender->setState(state);
|
||||
mqttRequestSave();
|
||||
}
|
||||
#endif
|
||||
|
||||
void setupMqtt() {
|
||||
char mactmp[20];
|
||||
|
||||
@@ -364,6 +375,12 @@ void setupMqtt() {
|
||||
mqttLedEffect.onCommand(onLedEffectCommand);
|
||||
#endif
|
||||
|
||||
#ifdef USE_WLED_REALTIME
|
||||
mqttWled.setName("SignalRGB");
|
||||
mqttWled.setIcon("mdi:monitor-shimmer");
|
||||
mqttWled.onCommand(onWledCommand);
|
||||
#endif
|
||||
|
||||
mqtt.onMessage(onMqttMessage);
|
||||
mqtt.onConnected(onMqttConnected);
|
||||
|
||||
@@ -405,6 +422,9 @@ void mqttReportState() {
|
||||
mqttBacklight.setRGBColor(wheelToRgb(prm.rgbFixColor));
|
||||
mqttLedEffect.setState(prm.rgbEffect);
|
||||
#endif
|
||||
#ifdef USE_WLED_REALTIME
|
||||
mqttWled.setState(prmExt.wledEnable);
|
||||
#endif
|
||||
}
|
||||
|
||||
void mqttSend() {
|
||||
|
||||
Reference in new issue
Block a user