1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 13:25:30 +03:00

Improve cycle times by avoiding an led strip update while one is still

in progress.
This commit is contained in:
Dominic Clifton 2014-06-08 12:54:52 +01:00
parent b200e2cb2d
commit 0861310537
3 changed files with 16 additions and 1 deletions

View file

@ -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

View file

@ -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;

View file

@ -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;