From 69ab57386994b315785719c1ef7a25f318b24b94 Mon Sep 17 00:00:00 2001 From: profezzorn Date: Mon, 17 Jan 2022 21:05:15 -0800 Subject: [PATCH] fix Teensy4 timing for 400kHz strings --- OctoWS2811_imxrt.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/OctoWS2811_imxrt.cpp b/OctoWS2811_imxrt.cpp index b3cc021..e9bb6e3 100644 --- a/OctoWS2811_imxrt.cpp +++ b/OctoWS2811_imxrt.cpp @@ -314,7 +314,8 @@ void OctoWS2811::show(void) TMR4_CNTR2 = comp1load[0] + 1; // wait for WS2812 reset - while (micros() - update_begin_micros < numbytes * 10 + 300) ; + uint32_t us_per_byte = (params & 0xC0) == WS2811_400kHz ? 20 : 10; + while (micros() - update_begin_micros < numbytes * us_per_bytes + 300) ; // start everything running! TMR4_ENBL = enable | 7; @@ -364,7 +365,8 @@ void OctoWS2811::isr(void) int OctoWS2811::busy(void) { if (!dma3.complete()) ; // DMA still running - if (micros() - update_begin_micros < numbytes * 10 + 300) return 1; // WS2812 reset + uint32_t us_per_byte = (params & 0xC0) == WS2811_400kHz ? 20 : 10; + if (micros() - update_begin_micros < numbytes * us_per_byte + 300) return 1; // WS2812 reset return 0; }