diff --git a/src/main/drivers/light_ws2811strip.c b/src/main/drivers/light_ws2811strip.c index 2533eb8791..5be3995c61 100644 --- a/src/main/drivers/light_ws2811strip.c +++ b/src/main/drivers/light_ws2811strip.c @@ -149,6 +149,11 @@ void DMA1_Channel6_IRQHandler(void) } } +bool isWS2811LedStripReady(void) +{ + return !ws2811LedDataTransferInProgress; +} + static uint16_t dmaBufferOffset; static int16_t ledIndex; @@ -176,7 +181,11 @@ void updateLEDDMABuffer(uint8_t componentValue) */ void ws2811UpdateStrip(void) { - while(ws2811LedDataTransferInProgress); // wait until previous transfer completes + static uint32_t waitCounter = 0; + // wait until previous transfer completes + while(ws2811LedDataTransferInProgress) { + waitCounter++; + } dmaBufferOffset = 0; // reset buffer memory index ledIndex = 0; // reset led index diff --git a/src/main/drivers/light_ws2811strip.h b/src/main/drivers/light_ws2811strip.h index e5bbd09330..8cda6023dc 100644 --- a/src/main/drivers/light_ws2811strip.h +++ b/src/main/drivers/light_ws2811strip.h @@ -44,6 +44,8 @@ void setLedColor(uint16_t index, const rgbColor24bpp_t *color); void setStripColor(const rgbColor24bpp_t *color); void setStripColors(const rgbColor24bpp_t *colors); +bool isWS2811LedStripReady(void); + extern const rgbColor24bpp_t black; extern const rgbColor24bpp_t white; extern const rgbColor24bpp_t orange; diff --git a/src/main/mw.c b/src/main/mw.c index 69c26951cd..052d4d7d01 100755 --- a/src/main/mw.c +++ b/src/main/mw.c @@ -449,6 +449,10 @@ uint32_t nextBatteryFlashAt = 0; void updateLedStrip(void) { + if (!isWS2811LedStripReady()) { + return; + } + uint32_t now = micros(); bool indicatorFlashNow = (int32_t)(now - nextIndicatorFlashAt) >= 0L;