From 919f7ef21868e2b418b9000ab200afc1c33b9619 Mon Sep 17 00:00:00 2001 From: Pavel Brychta Date: Wed, 4 Aug 2021 10:22:52 +0200 Subject: [PATCH] Rozsireni pouziti mutexu --- src/wsLED.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 } } }