diff options
author | Joel Challis <git@zvecr.com> | 2021-11-25 19:35:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-25 19:35:06 +0000 |
commit | 5e9c29da0df045b03ada9278c34f37b22349a6f7 (patch) | |
tree | 3dbe67afa346513de1132e23c636b5ad01bc3550 /drivers/ws2812.h | |
parent | 3d0062071133ad76504ede49a66063115c4a06c5 (diff) | |
download | qmk_firmware-5e9c29da0df045b03ada9278c34f37b22349a6f7.tar.gz qmk_firmware-5e9c29da0df045b03ada9278c34f37b22349a6f7.zip |
Tidy up adjustable ws2812 timing (#15299)
Diffstat (limited to 'drivers/ws2812.h')
-rw-r--r-- | drivers/ws2812.h | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/drivers/ws2812.h b/drivers/ws2812.h index f179fcb0ef..945b3d0728 100644 --- a/drivers/ws2812.h +++ b/drivers/ws2812.h @@ -18,10 +18,40 @@ #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 |