From 7e460d3c8072cbddf98172be9e94ede8e6613de5 Mon Sep 17 00:00:00 2001 From: mark9064 <30447455+mark9064@users.noreply.github.com> Date: Fri, 27 Oct 2023 00:26:57 +0100 Subject: [PATCH] Use FreeRTOS delay instead of spinning the CPU --- src/drivers/St7789.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/drivers/St7789.cpp b/src/drivers/St7789.cpp index d1747c23..82cefc43 100644 --- a/src/drivers/St7789.cpp +++ b/src/drivers/St7789.cpp @@ -1,6 +1,5 @@ #include "drivers/St7789.h" #include -#include #include #include "drivers/Spi.h" @@ -55,7 +54,7 @@ void St7789::WriteSpi(const uint8_t* data, size_t size, const std::function(Commands::SoftwareReset)); - nrf_delay_ms(150); + vTaskDelay(pdMS_TO_TICKS(150)); } void St7789::SleepOut() { @@ -69,7 +68,7 @@ void St7789::SleepIn() { void St7789::ColMod() { WriteCommand(static_cast(Commands::ColMod)); WriteData(0x55); - nrf_delay_ms(10); + vTaskDelay(pdMS_TO_TICKS(10)); } void St7789::MemoryDataAccessControl() { @@ -106,12 +105,12 @@ void St7789::RowAddressSet() { void St7789::DisplayInversionOn() { WriteCommand(static_cast(Commands::DisplayInversionOn)); - nrf_delay_ms(10); + vTaskDelay(pdMS_TO_TICKS(10)); } void St7789::NormalModeOn() { WriteCommand(static_cast(Commands::NormalModeOn)); - nrf_delay_ms(10); + vTaskDelay(pdMS_TO_TICKS(10)); } void St7789::DisplayOn() { @@ -146,7 +145,7 @@ void St7789::SetVdv() { void St7789::DisplayOff() { WriteCommand(static_cast(Commands::DisplayOff)); - nrf_delay_ms(500); + vTaskDelay(pdMS_TO_TICKS(500)); } void St7789::VerticalScrollStartAddress(uint16_t line) { @@ -166,7 +165,7 @@ void St7789::DrawBuffer(uint16_t x, uint16_t y, uint16_t width, uint16_t height, void St7789::HardwareReset() { nrf_gpio_pin_clear(pinReset); - nrf_delay_ms(10); + vTaskDelay(pdMS_TO_TICKS(10)); nrf_gpio_pin_set(pinReset); }