From d8557e9cb1334d6ecb5659cec3a31a64113afabf Mon Sep 17 00:00:00 2001 From: Patrick Moessler Date: Sun, 28 Jan 2024 22:59:40 +0100 Subject: [PATCH] improve timing --- components/qspi_74hc595_4x_display/qspi_74hc595_4x_display.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/qspi_74hc595_4x_display/qspi_74hc595_4x_display.cpp b/components/qspi_74hc595_4x_display/qspi_74hc595_4x_display.cpp index c13b294..0bb6efa 100644 --- a/components/qspi_74hc595_4x_display/qspi_74hc595_4x_display.cpp +++ b/components/qspi_74hc595_4x_display/qspi_74hc595_4x_display.cpp @@ -154,11 +154,12 @@ void QSPI_74HC595_4X_DISPLAYComponent::display() const uint8_t *buf_ptr = reinterpret_cast(this->buffer_); for (uint8_t i = 0; i < 8; i++) { + uint32_t start = micros(); this->enable(); this->write_cmd_addr_data(0, 0, 0, 0, buf_ptr, 8, 4); buf_ptr += 8; this->disable(); - delay_microseconds_safe(delay); + delay_microseconds_safe(delay - (micros() - start)); } // zero out everything to have a somewhat uniform duty cycle for all digits this->enable();