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 f179fcb0e..945b3d072 100644 --- a/drivers/ws2812.h +++ b/drivers/ws2812.h | |||
@@ -18,10 +18,40 @@ | |||
18 | #include "quantum/color.h" | 18 | #include "quantum/color.h" |
19 | 19 | ||
20 | /* | 20 | /* |
21 | * The WS2812 datasheets define T1H 900ns, T0H 350ns, T1L 350ns, T0L 900ns. Hence, by default, these | ||
22 | * are chosen to be conservative and avoid problems rather than for maximum throughput; in the code, | ||
23 | * this is done by default using a WS2812_TIMING parameter that accounts for the whole window (1250ns) | ||
24 | * and defining T1H and T0H; T1L and T0L are obtained by subtracting their low counterparts from the window. | ||
25 | * | ||
26 | * However, there are certain "WS2812"-like LEDs, like the SK6812s, which work in a similar | ||
27 | * communication topology but use different timings for the window and the T1L, T1H, T0L and T0H. | ||
28 | * This means that, albeit the same driver being applicable, the timings must be adapted. | ||
29 | */ | ||
30 | |||
31 | #ifndef WS2812_TIMING | ||
32 | # define WS2812_TIMING 1250 | ||
33 | #endif | ||
34 | |||
35 | #ifndef WS2812_T1H | ||
36 | # define WS2812_T1H 900 // Width of a 1 bit in ns | ||
37 | #endif | ||
38 | |||
39 | #ifndef WS2812_T1L | ||
40 | # define WS2812_T1L (WS2812_TIMING - WS2812_T1H) // Width of a 1 bit in ns | ||
41 | #endif | ||
42 | |||
43 | #ifndef WS2812_T0H | ||
44 | # define WS2812_T0H 350 // Width of a 0 bit in ns | ||
45 | #endif | ||
46 | |||
47 | #ifndef WS2812_T0L | ||
48 | # define WS2812_T0L (WS2812_TIMING - WS2812_T0H) // Width of a 0 bit in ns | ||
49 | #endif | ||
50 | |||
51 | /* | ||
21 | * Older WS2812s can handle a reset time (TRST) of 50us, but recent | 52 | * Older WS2812s can handle a reset time (TRST) of 50us, but recent |
22 | * component revisions require a minimum of 280us. | 53 | * component revisions require a minimum of 280us. |
23 | */ | 54 | */ |
24 | |||
25 | #if !defined(WS2812_TRST_US) | 55 | #if !defined(WS2812_TRST_US) |
26 | # define WS2812_TRST_US 280 | 56 | # define WS2812_TRST_US 280 |
27 | #endif | 57 | #endif |