|
|
@ -25,6 +25,7 @@ extern "C" { |
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Ticker _light_comms_ticker; |
|
|
|
Ticker _light_save_ticker; |
|
|
|
Ticker _light_transition_ticker; |
|
|
|
|
|
|
@ -658,6 +659,26 @@ bool lightHasColor() { |
|
|
|
return _light_has_color; |
|
|
|
} |
|
|
|
|
|
|
|
void _lightComms(unsigned char mask) { |
|
|
|
|
|
|
|
// Report color & brightness to MQTT broker
|
|
|
|
#if MQTT_SUPPORT
|
|
|
|
if (mask & 0x01) lightMQTT(); |
|
|
|
if (mask & 0x02) lightMQTTGroup(); |
|
|
|
#endif
|
|
|
|
|
|
|
|
// Report color to WS clients (using current brightness setting)
|
|
|
|
#if WEB_SUPPORT
|
|
|
|
wsSend(_lightWebSocketOnSend); |
|
|
|
#endif
|
|
|
|
|
|
|
|
// Report channels to local broker
|
|
|
|
#if BROKER_SUPPORT
|
|
|
|
lightBroker(); |
|
|
|
#endif
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void lightUpdate(bool save, bool forward, bool group_forward) { |
|
|
|
|
|
|
|
_generateBrightness(); |
|
|
@ -672,21 +693,11 @@ void lightUpdate(bool save, bool forward, bool group_forward) { |
|
|
|
_light_steps_left = _light_use_transitions ? _light_transition_time / LIGHT_TRANSITION_STEP : 1; |
|
|
|
_light_transition_ticker.attach_ms(LIGHT_TRANSITION_STEP, _lightProviderUpdate); |
|
|
|
|
|
|
|
// Report channels to local broker
|
|
|
|
#if BROKER_SUPPORT
|
|
|
|
lightBroker(); |
|
|
|
#endif
|
|
|
|
|
|
|
|
// Report color & brightness to MQTT broker
|
|
|
|
#if MQTT_SUPPORT
|
|
|
|
if (forward) lightMQTT(); |
|
|
|
if (group_forward) lightMQTTGroup(); |
|
|
|
#endif
|
|
|
|
|
|
|
|
// Report color to WS clients (using current brightness setting)
|
|
|
|
#if WEB_SUPPORT
|
|
|
|
wsSend(_lightWebSocketOnSend); |
|
|
|
#endif
|
|
|
|
// Delay every communication 100ms to avoid jamming
|
|
|
|
unsigned char mask = 0; |
|
|
|
if (forward) mask += 1; |
|
|
|
if (group_forward) mask += 2; |
|
|
|
_light_comms_ticker.once_ms(LIGHT_COMMS_DELAY, _lightComms, mask); |
|
|
|
|
|
|
|
#if LIGHT_SAVE_ENABLED
|
|
|
|
// Delay saving to EEPROM 5 seconds to avoid wearing it out unnecessarily
|
|
|
|