From bc4441afa753176e1901017708d8a739c38806eb Mon Sep 17 00:00:00 2001
From: Olivier Ortigues <o.ortigues@gmail.com>
Date: Tue, 18 Oct 2016 22:43:43 +0200
Subject: [PATCH] esp8266/espneopixel.c: Solve glitching LED issues with cpu at
 80MHz.

At the WS2812 driver level, a 400ns value was used for T0H (time high to
send a 0 bit) but LED specification says it should be 350ns +- 150ns.
Due to loop overhead the 400ns value could lead to T0H close to 500ns
which is too close from the limit value and gave glitches (bad data to
pixels) in some cases.  This patch makes the calculated T0H value 350ns.
---
 esp8266/espneopixel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/esp8266/espneopixel.c b/esp8266/espneopixel.c
index 27c773106..6c7659186 100644
--- a/esp8266/espneopixel.c
+++ b/esp8266/espneopixel.c
@@ -33,7 +33,7 @@ void /*ICACHE_RAM_ATTR*/ esp_neopixel_write(uint8_t pin, uint8_t *pixels, uint32
 #ifdef NEO_KHZ400
   if(is800KHz) {
 #endif
-    time0  = fcpu / 2500000; // 0.4us
+    time0  = fcpu / 2857143; // 0.35us
     time1  = fcpu / 1250000; // 0.8us
     period = fcpu /  800000; // 1.25us per bit
 #ifdef NEO_KHZ400
-- 
GitLab