mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 05:15:25 +03:00
Improve cycle times by avoiding an led strip update while one is still
in progress.
This commit is contained in:
parent
b200e2cb2d
commit
0861310537
3 changed files with 16 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue