Skip to content

Commit

Permalink
Properly set graphics thread delay
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhien committed Aug 15, 2023
1 parent 8dbcdca commit 615c65a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,23 @@ static int draw_webp(uint8_t *buf, size_t len) {
}

int lastTimestamp = 0;
int delay = 0;
TickType_t drawStartTick = xTaskGetTickCount();
// Set delay to > 0 for initial delay; else FreeRTOS assertion fails
int delay = 1;

// Draw each frame, and sleep for the delay
for (int j = 0; j < animation.frame_count; j++) {
uint8_t *pix;
int timestamp;
WebPAnimDecoderGetNext(decoder, &pix, &timestamp);
vTaskDelay(pdMS_TO_TICKS(delay));
xTaskDelayUntil(&drawStartTick, pdMS_TO_TICKS(delay));
drawStartTick = xTaskGetTickCount();
display_draw(pix, animation.canvas_width, animation.canvas_height, 4, 0, 1,
2);
delay = timestamp - lastTimestamp;
lastTimestamp = timestamp;
}
vTaskDelay(pdMS_TO_TICKS(delay));
xTaskDelayUntil(&drawStartTick, pdMS_TO_TICKS(delay));

// In case of a single frame, sleep for 1s
if (animation.frame_count == 1) {
Expand Down

0 comments on commit 615c65a

Please sign in to comment.