diff --git a/sonoff/xdrv_04_light.ino b/sonoff/xdrv_04_light.ino index 7843192f7..6d87b5a5b 100644 --- a/sonoff/xdrv_04_light.ino +++ b/sonoff/xdrv_04_light.ino @@ -1118,6 +1118,7 @@ boolean LightCommand() if (XdrvMailbox.data_len > 0) { char *p; uint16_t idx = XdrvMailbox.index; + Ws2812ForceSuspend(); for (char *color = strtok_r(XdrvMailbox.data, " ", &p); color; color = strtok_r(NULL, " ", &p)) { if (LightColorEntry(color, strlen(color))) { Ws2812SetColor(idx, light_entry_color[0], light_entry_color[1], light_entry_color[2], light_entry_color[3]); @@ -1127,6 +1128,8 @@ boolean LightCommand() break; } } + + Ws2812ForceUpdate(); } snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_INDEX_SVALUE, command, XdrvMailbox.index, Ws2812GetColor(XdrvMailbox.index, scolor)); } diff --git a/sonoff/xplg_ws2812.ino b/sonoff/xplg_ws2812.ino index 4d6410f90..2e576bfc8 100644 --- a/sonoff/xplg_ws2812.ino +++ b/sonoff/xplg_ws2812.ino @@ -93,7 +93,7 @@ uint8_t kRepeat[5] = { 1 }; // All uint8_t ws_show_next = 1; - +bool ws_suspend_update = false; /********************************************************************************************/ void Ws2812StripShow() @@ -365,6 +365,19 @@ void Ws2812SetColor(uint16_t led, uint8_t red, uint8_t green, uint8_t blue, uint strip->SetPixelColor(i, lcolor); } } + + if (!ws_suspend_update) { + strip->Show(); + ws_show_next = 1; + } +} + +void Ws2812ForceSuspend () { + ws_suspend_update = true; +} + +void Ws2812ForceUpdate () { + ws_suspend_update = false; strip->Show(); ws_show_next = 1; }