From 3139d0dc20cf55565ea6654e8e9ef4a78363ff21 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 23 Jan 2019 14:43:54 -0800 Subject: [PATCH] Use common delay function during display init so we don't starve background tasks. --- shared-module/displayio/Display.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index f75f0392f7..7946111b73 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -29,6 +29,7 @@ #include "py/runtime.h" #include "shared-bindings/displayio/FourWire.h" #include "shared-bindings/displayio/ParallelBus.h" +#include "shared-bindings/time/__init__.h" #include @@ -73,18 +74,15 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, uint8_t *data = cmd + 2; self->send(self->bus, true, cmd, 1); self->send(self->bus, false, data, data_size); + uint16_t delay_length_ms = 10; if (delay) { data_size++; - uint16_t delay_length_ms = *(cmd + 1 + data_size); + delay_length_ms = *(cmd + 1 + data_size); if (delay_length_ms == 255) { delay_length_ms = 500; } - uint64_t start = ticks_ms; - while (ticks_ms - start < delay_length_ms) {} - } else { - uint64_t start = ticks_ms; - while (ticks_ms - start < 10) {} } + common_hal_time_delay_ms(delay_length_ms); i += 2 + data_size; } self->end_transaction(self->bus);