Skip to content

Commit

Permalink
Do not wait for copy to complete before returning from updatePixels.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Riley committed Feb 19, 2018
1 parent 91bfc04 commit b2794fa
Showing 1 changed file with 9 additions and 4 deletions.
Expand Up @@ -157,6 +157,7 @@ int digitalLeds_initStrands(strand_t strands [], int numStrands)
if (pState->buf_data == nullptr) {
return -1;
}
pState->sem = nullptr;

rmt_set_pin(
static_cast<rmt_channel_t>(pStrand->rmtChannel),
Expand Down Expand Up @@ -213,6 +214,14 @@ void digitalLeds_resetPixels(strand_t * pStrand)
int IRAM_ATTR digitalLeds_updatePixels(strand_t * pStrand)
{
digitalLeds_stateData * pState = static_cast<digitalLeds_stateData*>(pStrand->_stateVars);

if (pState->sem) {
// Wait for any previously updating pixels.
xSemaphoreTake(pState->sem, portMAX_DELAY);
vSemaphoreDelete(pState->sem);
pState->sem = nullptr;
}

ledParams_t ledParams = ledParamsAll[pStrand->ledType];

// Pack pixels into transmission buffer
Expand Down Expand Up @@ -256,10 +265,6 @@ int IRAM_ATTR digitalLeds_updatePixels(strand_t * pStrand)
RMT.conf_ch[pStrand->rmtChannel].conf1.mem_rd_rst = 1;
RMT.conf_ch[pStrand->rmtChannel].conf1.tx_start = 1;

xSemaphoreTake(pState->sem, portMAX_DELAY);
vSemaphoreDelete(pState->sem);
pState->sem = nullptr;

return 0;
}

Expand Down

0 comments on commit b2794fa

Please sign in to comment.