1
0
Fork 0

Tidy up adjustable ws2812 timing (#15299)

This commit is contained in:
Joel Challis 2021-11-25 19:35:06 +00:00 committed by GitHub
parent 3d00620711
commit 5e9c29da0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 58 deletions

View file

@ -17,11 +17,41 @@
#include "quantum/color.h"
/*
* The WS2812 datasheets define T1H 900ns, T0H 350ns, T1L 350ns, T0L 900ns. Hence, by default, these
* are chosen to be conservative and avoid problems rather than for maximum throughput; in the code,
* this is done by default using a WS2812_TIMING parameter that accounts for the whole window (1250ns)
* and defining T1H and T0H; T1L and T0L are obtained by subtracting their low counterparts from the window.
*
* However, there are certain "WS2812"-like LEDs, like the SK6812s, which work in a similar
* communication topology but use different timings for the window and the T1L, T1H, T0L and T0H.
* This means that, albeit the same driver being applicable, the timings must be adapted.
*/
#ifndef WS2812_TIMING
# define WS2812_TIMING 1250
#endif
#ifndef WS2812_T1H
# define WS2812_T1H 900 // Width of a 1 bit in ns
#endif
#ifndef WS2812_T1L
# define WS2812_T1L (WS2812_TIMING - WS2812_T1H) // Width of a 1 bit in ns
#endif
#ifndef WS2812_T0H
# define WS2812_T0H 350 // Width of a 0 bit in ns
#endif
#ifndef WS2812_T0L
# define WS2812_T0L (WS2812_TIMING - WS2812_T0H) // Width of a 0 bit in ns
#endif
/*
* Older WS2812s can handle a reset time (TRST) of 50us, but recent
* component revisions require a minimum of 280us.
*/
#if !defined(WS2812_TRST_US)
# define WS2812_TRST_US 280
#endif