Skip to content

Commit 3139d0d

Browse files
committed
Use common delay function during display init so we don't starve background tasks.
1 parent aaa644b commit 3139d0d

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

shared-module/displayio/Display.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "py/runtime.h"
3030
#include "shared-bindings/displayio/FourWire.h"
3131
#include "shared-bindings/displayio/ParallelBus.h"
32+
#include "shared-bindings/time/__init__.h"
3233

3334
#include <stdint.h>
3435

@@ -73,18 +74,15 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
7374
uint8_t *data = cmd + 2;
7475
self->send(self->bus, true, cmd, 1);
7576
self->send(self->bus, false, data, data_size);
77+
uint16_t delay_length_ms = 10;
7678
if (delay) {
7779
data_size++;
78-
uint16_t delay_length_ms = *(cmd + 1 + data_size);
80+
delay_length_ms = *(cmd + 1 + data_size);
7981
if (delay_length_ms == 255) {
8082
delay_length_ms = 500;
8183
}
82-
uint64_t start = ticks_ms;
83-
while (ticks_ms - start < delay_length_ms) {}
84-
} else {
85-
uint64_t start = ticks_ms;
86-
while (ticks_ms - start < 10) {}
8784
}
85+
common_hal_time_delay_ms(delay_length_ms);
8886
i += 2 + data_size;
8987
}
9088
self->end_transaction(self->bus);

0 commit comments

Comments
 (0)