diff --git a/src/wsLED.cpp b/src/wsLED.cpp index 339cf24..9d9f2d7 100644 --- a/src/wsLED.cpp +++ b/src/wsLED.cpp @@ -192,12 +192,18 @@ void wsLED::blink(uint32_t speed) if (NOT_A_PIN != _pin) { if (LED_BLINK != _ledState) { +#if defined(ESP32) + xSemaphoreTake(_mutex, portMAX_DELAY); +#endif _handler.detach(); _ledState = LED_BLINK; _scale = 0xff; _subState = 1; _blinkSpeed = speed; _handler.attach_ms(5, ledTrampoline, this); +#if defined(ESP32) + xSemaphoreGive(_mutex); +#endif } } } @@ -207,11 +213,17 @@ void wsLED::breath(void) if (NOT_A_PIN != _pin) { if (LED_BREATH != _ledState) { +#if defined(ESP32) + xSemaphoreTake(_mutex, portMAX_DELAY); +#endif _handler.detach(); _ledState = LED_BREATH; _subState = 0; setColor(_color1); _handler.attach_ms(5, ledTrampoline, this); +#if defined(ESP32) + xSemaphoreGive(_mutex); +#endif } } }