FastLED 3.10.8
Loading...
Searching...
No Matches
led_timing.h
Go to the documentation of this file.
1
18
19#pragma once
20
21#include "fl/stl/stdint.h"
22#include "fl/stl/noexcept.h"
23#include "fl/chipsets/clockless_encoder.h" // ClocklessEncoder enum (used by UCS7604 timings)
24
25// ============================================================================
26// Overclock Factor Configuration
27// ============================================================================
28
29// Allow overclocking of the clockless family of LEDs. 1.2 would be
30// 20% overclocking. In tests WS2812 can be overclocked at 20%, but
31// various manufacturers may be different. This is a global value
32// which is overridable by each supported chipset.
33
34#ifdef FASTLED_LED_OVERCLOCK
35#warning "FASTLED_LED_OVERCLOCK has been changed to FASTLED_OVERCLOCK. Please update your code."
36#define FASTLED_OVERCLOCK FASTLED_LED_OVERCLOCK
37#endif
38
39#ifndef FASTLED_OVERCLOCK
40#define FASTLED_OVERCLOCK 1.0
41#else
42#ifndef FASTLED_OVERCLOCK_SUPPRESS_WARNING
43#warning "FASTLED_OVERCLOCK is now active, #define FASTLED_OVERCLOCK_SUPPRESS_WARNING to disable this warning"
44#endif
45#endif
46
47// Per-chipset overclock factors (default to global FASTLED_OVERCLOCK)
48// These allow fine-grained control of overclocking for specific chipsets
49
50#ifndef FASTLED_OVERCLOCK_WS2812
51#define FASTLED_OVERCLOCK_WS2812 FASTLED_OVERCLOCK
52#endif
53
54#ifndef FASTLED_OVERCLOCK_WS2811
55#define FASTLED_OVERCLOCK_WS2811 FASTLED_OVERCLOCK
56#endif
57
58#ifndef FASTLED_OVERCLOCK_WS2813
59#define FASTLED_OVERCLOCK_WS2813 FASTLED_OVERCLOCK
60#endif
61
62#ifndef FASTLED_OVERCLOCK_WS2815
63#define FASTLED_OVERCLOCK_WS2815 FASTLED_OVERCLOCK
64#endif
65
66#ifndef FASTLED_OVERCLOCK_SK6822
67#define FASTLED_OVERCLOCK_SK6822 FASTLED_OVERCLOCK
68#endif
69
70#ifndef FASTLED_OVERCLOCK_SK6812
71#define FASTLED_OVERCLOCK_SK6812 FASTLED_OVERCLOCK
72#endif
73
74namespace fl {
75
76// The `ClocklessEncoder` enum used by certain timings (e.g., UCS7604) is
77// declared in `fl/chipsets/clockless_encoder.h` (included above). This file
78// stays focused on bit-period timing only.
79
80// ============================================================================
81// Centralized Nanosecond Timing Definitions
82// ============================================================================
83
87 u32 T1;
88 u32 T2;
89 u32 T3;
90 u32 RESET;
91 const char* name;
92};
93
94// ============================================================================
95// Fast-Speed Chipsets (800kHz - 1600kHz range)
96// ============================================================================
97
101 enum : u32 {
102 T1 = 350,
103 T2 = 660,
104 T3 = 350,
106 };
107};
108
109// User-overridable WS2812 timing macros
110// These allow compile-time customization for WS2812 variants (e.g., V5B)
111#ifndef FASTLED_WS2812_T1
112#define FASTLED_WS2812_T1 250
113#endif
114
115#ifndef FASTLED_WS2812_T2
116#define FASTLED_WS2812_T2 625
117#endif
118
119#ifndef FASTLED_WS2812_T3
120#define FASTLED_WS2812_T3 375
121#endif
122
127 enum : u32 {
131 RESET = 280
132 };
133 static constexpr const char* name() FL_NO_EXCEPT { return "WS2812_800KHZ"; }
134};
135
138
139// User-overridable WS2812B-V5 timing macros
140// These allow compile-time customization for WS2812B-V5 variants
141#ifndef FASTLED_WS2812B_V5_T1
142#define FASTLED_WS2812B_V5_T1 225
143#endif
144
145#ifndef FASTLED_WS2812B_V5_T2
146#define FASTLED_WS2812B_V5_T2 355
147#endif
148
149#ifndef FASTLED_WS2812B_V5_T3
150#define FASTLED_WS2812B_V5_T3 645
151#endif
152
163 enum : u32 {
167 RESET = 280 // WS2812B-V5 reset/latch time per datasheet
168 };
169};
170
173
177 enum : u32 {
178 T1 = 320,
179 T2 = 320,
180 T3 = 640,
181 RESET = 280
182 };
183};
184
188 enum : u32 {
189 T1 = 320,
190 T2 = 320,
191 T3 = 640,
192 RESET = 300
193 };
194};
195
201 enum : u32 {
202 T1 = 320,
203 T2 = 320,
204 T3 = 640,
205 RESET = 300
206 };
207};
208
215 enum : u32 {
216 T1 = 300,
217 T2 = 300,
218 T3 = 600,
219 RESET = 300
220 };
221};
222
226 enum : u32 {
227 T1 = 300,
228 T2 = 600,
229 T3 = 300,
230 RESET = 80
231 };
232};
233
239 enum : u32 {
240 T1 = 300,
241 T2 = 600,
242 T3 = 300,
243 RESET = 80
244 };
245};
246
250 enum : u32 {
251 T1 = 375,
252 T2 = 1000,
253 T3 = 375,
255 };
256};
257
261 enum : u32 {
262 T1 = 400,
263 T2 = 450,
264 T3 = 450,
266 };
267};
268
272 enum : u32 {
273 T1 = 400,
274 T2 = 400,
275 T3 = 450,
277 };
278};
279
283 enum : u32 {
284 T1 = 250,
285 T2 = 750,
286 T3 = 250,
288 };
289};
290
294 enum : u32 {
295 T1 = 350,
296 T2 = 350,
297 T3 = 450,
299 };
300};
301
308 enum : u32 {
309 T1 = 240,
310 T2 = 240,
311 T3 = 350,
312 RESET = 80
313 };
314 static constexpr ClocklessEncoder ENCODER =
316};
317
325 enum : u32 {
326 T1 = 400,
327 T2 = 450,
328 T3 = 400,
329 RESET = 24
330 };
331 static constexpr ClocklessEncoder ENCODER =
333};
334
338 enum : u32 {
339 T1 = 340,
340 T2 = 340,
341 T3 = 550,
342 RESET = 500
343 };
344};
345
349 enum : u32 {
350 T1 = 100,
351 T2 = 300,
352 T3 = 200,
353 RESET = 500
354 };
355};
356
360 enum : u32 {
361 T1 = 200,
362 T2 = 400,
363 T3 = 200,
365 };
366};
367
371 enum : u32 {
372 T1 = 350,
373 T2 = 1010,
374 T3 = 350,
376 };
377};
378
382 enum : u32 {
383 T1 = 300,
384 T2 = 600,
385 T3 = 300,
387 };
388};
389
400 enum : u32 {
401 T1 = 300,
402 T2 = 600,
403 T3 = 300,
404 RESET = 280
405 };
406};
407
415 enum : u32 {
416 T1 = 300,
417 T2 = 600,
418 T3 = 300,
419 RESET = 200
420 };
421};
422
423// ============================================================================
424// Medium-Speed Chipsets (400kHz - 600kHz range)
425// ============================================================================
426
434 enum : u32 {
435 T1 = 500, // T0H: 500ns (datasheet: 500ns ±150ns)
436 T2 = 700, // T1H - T0H: 700ns (T1H=1200ns per datasheet)
437 T3 = 1300, // T1L: 1300ns (datasheet: 1300ns ±150ns)
438 RESET = 280 // Reset time: 280µs (>50µs per datasheet)
439 };
440};
441
446 enum : u32 {
447 T1 = 250,
448 T2 = 1090,
449 T3 = 550,
451 };
452};
453
457 enum : u32 {
458 T1 = 500,
459 T2 = 1500,
460 T3 = 500,
462 };
463};
464
468 enum : u32 {
469 T1 = 800,
470 T2 = 1600,
471 T3 = 800,
473 };
474};
475
479 enum : u32 {
480 T1 = 700,
481 T2 = 1100,
482 T3 = 700,
484 };
485};
486
490 enum : u32 {
491 T1 = 800,
492 T2 = 800,
493 T3 = 800,
495 };
496};
497
501 enum : u32 {
502 T1 = 250,
503 T2 = 1000,
504 T3 = 350,
506 };
507};
508
509// ============================================================================
510// Legacy/Special Chipsets
511// ============================================================================
512
520 enum : u32 {
521 T1 = 250, // T0H: 250ns (half of 500ns @ 400kHz)
522 T2 = 350, // T1H - T0H: 350ns (T1H=600ns, half of 1200ns @ 400kHz)
523 T3 = 650, // T1L: 650ns (half of 1300ns @ 400kHz)
524 RESET = 280 // Reset time: 280µs (>50µs per datasheet)
525 };
526};
527
531 enum : u32 {
532 T1 = 400,
533 T2 = 400,
534 T3 = 400,
536 };
537};
538
542 enum : u32 {
543 T1 = 400,
544 T2 = 1000,
545 T3 = 400,
547 };
548};
549
550// ============================================================================
551// RGBW Chipsets (16-bit color depth variants)
552// ============================================================================
553
557 enum : u32 {
558 T1 = 360,
559 T2 = 600,
560 T3 = 340,
561 RESET = 300
562 };
563};
564
565// ============================================================================
566// UCS7604 Special 16-Bit RGBW Controller
567// ============================================================================
568
573 enum : u32 {
574 T1 = 400,
575 T2 = 400,
576 T3 = 450,
577 RESET = 280
578 };
580};
581
586 enum : u32 {
587 T1 = 200,
588 T2 = 200,
589 T3 = 225,
590 RESET = 280
591 };
593};
594
599 enum : u32 {
600 T1 = 400,
601 T2 = 400,
602 T3 = 450,
603 RESET = 280
604 };
606};
607
608// ============================================================================
609// Helper Functions
610// ============================================================================
611
615template <typename TIMING>
617 return {TIMING::T1, TIMING::T2, TIMING::T3, TIMING::RESET, "timing"};
618}
619
623constexpr u32 get_bit_period_ns(const ChipsetTiming& timing) FL_NO_EXCEPT {
624 return timing.T1 + timing.T2 + timing.T3;
625}
626
630constexpr u32 get_timing_t1(const ChipsetTiming& timing) FL_NO_EXCEPT {
631 return timing.T1;
632}
633
637constexpr u32 get_timing_t2(const ChipsetTiming& timing) FL_NO_EXCEPT {
638 return timing.T2;
639}
640
644constexpr u32 get_timing_t3(const ChipsetTiming& timing) FL_NO_EXCEPT {
645 return timing.T3;
646}
647
653
654} // namespace fl
Encoding pipeline selector for clockless LED chipsets.
#define FASTLED_WS2812B_V5_T1
Definition led_timing.h:142
#define FASTLED_WS2812_T3
Definition led_timing.h:120
#define FASTLED_WS2812B_V5_T2
Definition led_timing.h:146
#define FASTLED_WS2812_T1
Definition led_timing.h:112
#define FASTLED_WS2812B_V5_T3
Definition led_timing.h:150
#define FASTLED_WS2812_T2
Definition led_timing.h:116
constexpr ChipsetTiming to_runtime_timing() FL_NO_EXCEPT
Convert enum-based timing type to runtime ChipsetTiming struct.
Definition led_timing.h:616
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
ClocklessEncoder
Identifies which encoder to use for clockless chipsets in the Channel API.
@ CLOCKLESS_ENCODER_UCS7604_8BIT
UCS7604 8-bit 800KHz.
@ CLOCKLESS_ENCODER_TM1812_RGBWW
TM1812: two 5-byte RGBWW pixels in each 12-byte IC frame.
@ CLOCKLESS_ENCODER_UCS7604_16BIT
UCS7604 16-bit 800KHz.
@ CLOCKLESS_ENCODER_UCS7604_16BIT_1600
UCS7604 16-bit 1600KHz.
@ CLOCKLESS_ENCODER_TM1908
TM1908: command prefix followed by RGB pixels.
constexpr u32 get_timing_t1(const ChipsetTiming &timing) FL_NO_EXCEPT
Extract T1 (high time for bit 0) from timing constant.
Definition led_timing.h:630
constexpr u32 get_timing_t2(const ChipsetTiming &timing) FL_NO_EXCEPT
Extract T2 (additional high time for bit 1) from timing constant.
Definition led_timing.h:637
const ChipsetTiming * get_timing_by_name(const char *name) FL_NO_EXCEPT
Get timing by name (for dynamic lookup if needed)
constexpr u32 get_bit_period_ns(const ChipsetTiming &timing) FL_NO_EXCEPT
Get total bit period (T1 + T2 + T3) in nanoseconds.
Definition led_timing.h:623
TIMING_WS2812B_MINI_V3 TIMING_WS2812B_V5
Convenience alias - WS2812B-V5 uses identical timing to Mini-V3.
Definition led_timing.h:172
constexpr u32 get_timing_t3(const ChipsetTiming &timing) FL_NO_EXCEPT
Extract T3 (low tail duration) from timing constant.
Definition led_timing.h:644
TIMING_WS2812_800KHZ WS2812ChipsetTiming
Convenience alias for WS2812 timing (commonly used name)
Definition led_timing.h:137
Base definition for an LED controller.
Definition crgb.hpp:179
u32 RESET
Reset/latch time (microseconds)
Definition led_timing.h:90
const char * name
Human-readable chipset name.
Definition led_timing.h:91
u32 T2
Additional high time for bit 1 (nanoseconds)
Definition led_timing.h:88
u32 T3
Low tail duration (nanoseconds)
Definition led_timing.h:89
u32 T1
High time for bit 0 (nanoseconds)
Definition led_timing.h:87
Generic chipset timing entry Provides T1, T2, T3 timing parameters in nanoseconds for any LED protoco...
Definition led_timing.h:86
DP1903 controller @ 400 kHz Four-phase: TH0=800ns, TH1=2400ns, TL0=2400ns, TL1=800ns.
Definition led_timing.h:467
DP1903 controller @ 800 kHz Four-phase: TH0=400ns, TH1=1400ns, TL0=1400ns, TL1=400ns.
Definition led_timing.h:541
GE8822 RGB controller @ 800 kHz Four-phase: TH0=350ns, TH1=1010ns, TL0=1010ns, TL1=350ns.
Definition led_timing.h:100
GS1903 RGB controller @ 800 kHz (12 V) Four-phase: TH0=300ns, TH1=900ns, TL0=900ns,...
Definition led_timing.h:399
GW6205 controller @ 400 kHz Four-phase: TH0=800ns, TH1=1600ns, TL0=1600ns, TL1=800ns.
Definition led_timing.h:489
GW6205 controller @ 800 kHz (fast variant) Four-phase: TH0=400ns, TH1=800ns, TL0=800ns,...
Definition led_timing.h:530
LC8816E RGBW controller @ 800 kHz Four-phase: TH0=300ns, TH1=900ns, TL0=900ns, TL1=300ns.
Definition led_timing.h:238
LPD1886 RGB controller @ 1250 kHz Four-phase: TH0=200ns, TH1=600ns, TL0=600ns, TL1=200ns.
Definition led_timing.h:359
PL9823 RGB controller @ 800 kHz Four-phase: TH0=350ns, TH1=1360ns, TL0=1360ns, TL1=350ns.
Definition led_timing.h:370
SK6812 RGBW controller @ 800 kHz Four-phase: TH0=300ns, TH1=900ns, TL0=900ns, TL1=300ns.
Definition led_timing.h:225
SK6822 RGB controller @ 800 kHz Four-phase: TH0=375ns, TH1=1375ns, TL0=1375ns, TL1=375ns.
Definition led_timing.h:249
SM16703 RGB controller @ 800 kHz Four-phase: TH0=300ns, TH1=900ns, TL0=900ns, TL1=300ns.
Definition led_timing.h:381
SM16824E RGBW controller @ 800 kHz Four-phase: TH0=300ns, TH1=900ns, TL0=900ns, TL1=300ns,...
Definition led_timing.h:414
TM1803 controller @ 400 kHz Four-phase: TH0=700ns, TH1=1800ns, TL0=1800ns, TL1=700ns.
Definition led_timing.h:478
TM1809 RGB controller @ 800 kHz Four-phase: TH0=350ns, TH1=700ns, TL0=800ns, TL1=450ns.
Definition led_timing.h:293
static constexpr ClocklessEncoder ENCODER
Definition led_timing.h:331
TM1812 RGBCCT controller @ 800 kHz (issue #995)
Definition led_timing.h:324
TM1814 RGBW controller @ 800 kHz Four-phase: TH0=360ns, TH1=960ns, TL0=940ns, TL1=340ns.
Definition led_timing.h:556
TM1829 RGB controller @ 1600 kHz (high-speed variant) Four-phase: TH0=100ns, TH1=400ns,...
Definition led_timing.h:348
TM1829 RGB controller @ 800 kHz Four-phase: TH0=340ns, TH1=680ns, TL0=890ns, TL1=550ns.
Definition led_timing.h:337
static constexpr ClocklessEncoder ENCODER
Definition led_timing.h:314
TM1908 RGB controller @ 1.2 MHz.
Definition led_timing.h:307
UCS1903 controller @ 400 kHz Four-phase: TH0=500ns, TH1=2000ns, TL0=2000ns, TL1=500ns.
Definition led_timing.h:456
UCS1903B controller @ 800 kHz Four-phase: TH0=400ns, TH1=850ns, TL0=900ns, TL1=450ns.
Definition led_timing.h:260
UCS1904 controller @ 800 kHz Four-phase: TH0=400ns, TH1=800ns, TL0=850ns, TL1=450ns.
Definition led_timing.h:271
UCS1912 controller @ 800 kHz Four-phase: TH0=250ns, TH1=1250ns, TL0=1350ns, TL1=350ns.
Definition led_timing.h:500
UCS2903 controller @ 800 kHz Four-phase: TH0=250ns, TH1=1000ns, TL0=1000ns, TL1=250ns.
Definition led_timing.h:282
static constexpr ClocklessEncoder ENCODER
Definition led_timing.h:592
UCS7604 RGBW controller @ 1600 kHz (16-bit color depth, high-speed) Four-phase: TH0=200ns,...
Definition led_timing.h:585
static constexpr ClocklessEncoder ENCODER
Definition led_timing.h:579
UCS7604 RGBW controller @ 800 kHz (16-bit color depth) Four-phase: TH0=400ns, TH1=800ns,...
Definition led_timing.h:572
static constexpr ClocklessEncoder ENCODER
Definition led_timing.h:605
UCS7604 RGBW controller @ 800 kHz (8-bit color depth) Same wire timing as 16-bit 800KHz,...
Definition led_timing.h:598
WS2811 @ 400kHz (standard mode, datasheet specification)
Definition led_timing.h:433
WS2811 @ 800kHz (fast mode, half the timing of 400kHz mode)
Definition led_timing.h:519
WS2812 RGB controller @ 800 kHz legacy variant Four-phase: TH0=320ns, TH1=640ns, TL0=960ns,...
Definition led_timing.h:176
static constexpr const char * name() FL_NO_EXCEPT
Definition led_timing.h:133
WS2812 RGB controller @ 800 kHz (most common, overclockable) Four-phase: TH0=250ns,...
Definition led_timing.h:126
WS2812B-Mini-V3 / WS2812B-V5 RGB controller @ 800 kHz Four-phase: TH0=225ns, TH1=580ns,...
Definition led_timing.h:162
WS2813 RGB controller (same timing as WS2812) Four-phase: TH0=320ns, TH1=640ns, TL0=960ns,...
Definition led_timing.h:187
WS2814 RGBW controller @ 800 kHz Four-phase: TH0=320ns, TH1=640ns, TL0=960ns, TL1=640ns.
Definition led_timing.h:200
WS2815 RGB controller @ 400 kHz Four-phase: TH0=250ns, TH1=1340ns, TL0=1640ns, TL1=550ns.
Definition led_timing.h:445
WS2818 RGB controller @ approximately 833 kHz Four-phase: TH0=300ns, TH1=600ns, TL0=900ns,...
Definition led_timing.h:214