FastLED 3.9.15
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_NOEXCEPT { 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
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
199 enum : u32 {
200 T1 = 300,
201 T2 = 600,
202 T3 = 300,
203 RESET = 80
204 };
205};
206
210 enum : u32 {
211 T1 = 375,
212 T2 = 1000,
213 T3 = 375,
215 };
216};
217
221 enum : u32 {
222 T1 = 400,
223 T2 = 450,
224 T3 = 450,
226 };
227};
228
232 enum : u32 {
233 T1 = 400,
234 T2 = 400,
235 T3 = 450,
237 };
238};
239
243 enum : u32 {
244 T1 = 250,
245 T2 = 750,
246 T3 = 250,
248 };
249};
250
254 enum : u32 {
255 T1 = 350,
256 T2 = 350,
257 T3 = 450,
259 };
260};
261
265 enum : u32 {
266 T1 = 340,
267 T2 = 340,
268 T3 = 550,
269 RESET = 500
270 };
271};
272
276 enum : u32 {
277 T1 = 100,
278 T2 = 300,
279 T3 = 200,
280 RESET = 500
281 };
282};
283
287 enum : u32 {
288 T1 = 200,
289 T2 = 400,
290 T3 = 200,
292 };
293};
294
298 enum : u32 {
299 T1 = 350,
300 T2 = 1010,
301 T3 = 350,
303 };
304};
305
309 enum : u32 {
310 T1 = 300,
311 T2 = 600,
312 T3 = 300,
314 };
315};
316
320 enum : u32 {
321 T1 = 300,
322 T2 = 900,
323 T3 = 100,
324 RESET = 200
325 };
326};
327
328// ============================================================================
329// Medium-Speed Chipsets (400kHz - 600kHz range)
330// ============================================================================
331
339 enum : u32 {
340 T1 = 500, // T0H: 500ns (datasheet: 500ns ±150ns)
341 T2 = 700, // T1H - T0H: 700ns (T1H=1200ns per datasheet)
342 T3 = 1300, // T1L: 1300ns (datasheet: 1300ns ±150ns)
343 RESET = 280 // Reset time: 280µs (>50µs per datasheet)
344 };
345};
346
351 enum : u32 {
352 T1 = 250,
353 T2 = 1090,
354 T3 = 550,
356 };
357};
358
362 enum : u32 {
363 T1 = 500,
364 T2 = 1500,
365 T3 = 500,
367 };
368};
369
373 enum : u32 {
374 T1 = 800,
375 T2 = 1600,
376 T3 = 800,
378 };
379};
380
384 enum : u32 {
385 T1 = 700,
386 T2 = 1100,
387 T3 = 700,
389 };
390};
391
395 enum : u32 {
396 T1 = 800,
397 T2 = 800,
398 T3 = 800,
400 };
401};
402
406 enum : u32 {
407 T1 = 250,
408 T2 = 1000,
409 T3 = 350,
411 };
412};
413
414// ============================================================================
415// Legacy/Special Chipsets
416// ============================================================================
417
425 enum : u32 {
426 T1 = 250, // T0H: 250ns (half of 500ns @ 400kHz)
427 T2 = 350, // T1H - T0H: 350ns (T1H=600ns, half of 1200ns @ 400kHz)
428 T3 = 650, // T1L: 650ns (half of 1300ns @ 400kHz)
429 RESET = 280 // Reset time: 280µs (>50µs per datasheet)
430 };
431};
432
436 enum : u32 {
437 T1 = 400,
438 T2 = 400,
439 T3 = 400,
441 };
442};
443
447 enum : u32 {
448 T1 = 400,
449 T2 = 1000,
450 T3 = 400,
452 };
453};
454
455// ============================================================================
456// RGBW Chipsets (16-bit color depth variants)
457// ============================================================================
458
462 enum : u32 {
463 T1 = 360,
464 T2 = 600,
465 T3 = 340,
466 RESET = 300
467 };
468};
469
470// ============================================================================
471// UCS7604 Special 16-Bit RGBW Controller
472// ============================================================================
473
478 enum : u32 {
479 T1 = 400,
480 T2 = 400,
481 T3 = 450,
482 RESET = 280
483 };
485};
486
491 enum : u32 {
492 T1 = 200,
493 T2 = 200,
494 T3 = 225,
495 RESET = 280
496 };
498};
499
504 enum : u32 {
505 T1 = 400,
506 T2 = 400,
507 T3 = 450,
508 RESET = 280
509 };
511};
512
513// ============================================================================
514// Helper Functions
515// ============================================================================
516
520template <typename TIMING>
522 return {TIMING::T1, TIMING::T2, TIMING::T3, TIMING::RESET, "timing"};
523}
524
528constexpr u32 get_bit_period_ns(const ChipsetTiming& timing) FL_NOEXCEPT {
529 return timing.T1 + timing.T2 + timing.T3;
530}
531
535constexpr u32 get_timing_t1(const ChipsetTiming& timing) FL_NOEXCEPT {
536 return timing.T1;
537}
538
542constexpr u32 get_timing_t2(const ChipsetTiming& timing) FL_NOEXCEPT {
543 return timing.T2;
544}
545
549constexpr u32 get_timing_t3(const ChipsetTiming& timing) FL_NOEXCEPT {
550 return timing.T3;
551}
552
558
559} // 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
ClocklessEncoder
Identifies which encoder to use for clockless chipsets in the Channel API.
@ CLOCKLESS_ENCODER_UCS7604_8BIT
UCS7604 8-bit 800KHz.
@ CLOCKLESS_ENCODER_UCS7604_16BIT
UCS7604 16-bit 800KHz.
@ CLOCKLESS_ENCODER_UCS7604_16BIT_1600
UCS7604 16-bit 1600KHz.
constexpr ChipsetTiming to_runtime_timing() FL_NOEXCEPT
Convert enum-based timing type to runtime ChipsetTiming struct.
Definition led_timing.h:521
const ChipsetTiming * get_timing_by_name(const char *name) FL_NOEXCEPT
Get timing by name (for dynamic lookup if needed)
constexpr u32 get_bit_period_ns(const ChipsetTiming &timing) FL_NOEXCEPT
Get total bit period (T1 + T2 + T3) in nanoseconds.
Definition led_timing.h:528
constexpr u32 get_timing_t2(const ChipsetTiming &timing) FL_NOEXCEPT
Extract T2 (additional high time for bit 1) from timing constant.
Definition led_timing.h:542
constexpr u32 get_timing_t3(const ChipsetTiming &timing) FL_NOEXCEPT
Extract T3 (low tail duration) from timing constant.
Definition led_timing.h:549
constexpr u32 get_timing_t1(const ChipsetTiming &timing) FL_NOEXCEPT
Extract T1 (high time for bit 0) from timing constant.
Definition led_timing.h:535
TIMING_WS2812B_MINI_V3 TIMING_WS2812B_V5
Convenience alias - WS2812B-V5 uses identical timing to Mini-V3.
Definition led_timing.h:172
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
#define FL_NOEXCEPT
DP1903 controller @ 400 kHz Four-phase: TH0=800ns, TH1=2400ns, TL0=2400ns, TL1=800ns.
Definition led_timing.h:372
DP1903 controller @ 800 kHz Four-phase: TH0=400ns, TH1=1400ns, TL0=1400ns, TL1=400ns.
Definition led_timing.h:446
GE8822 RGB controller @ 800 kHz Four-phase: TH0=350ns, TH1=1010ns, TL0=1010ns, TL1=350ns.
Definition led_timing.h:100
GW6205 controller @ 400 kHz Four-phase: TH0=800ns, TH1=1600ns, TL0=1600ns, TL1=800ns.
Definition led_timing.h:394
GW6205 controller @ 800 kHz (fast variant) Four-phase: TH0=400ns, TH1=800ns, TL0=800ns,...
Definition led_timing.h:435
LPD1886 RGB controller @ 1250 kHz Four-phase: TH0=200ns, TH1=600ns, TL0=600ns, TL1=200ns.
Definition led_timing.h:286
PL9823 RGB controller @ 800 kHz Four-phase: TH0=350ns, TH1=1360ns, TL0=1360ns, TL1=350ns.
Definition led_timing.h:297
SK6812 RGBW controller @ 800 kHz Four-phase: TH0=300ns, TH1=900ns, TL0=900ns, TL1=300ns.
Definition led_timing.h:198
SK6822 RGB controller @ 800 kHz Four-phase: TH0=375ns, TH1=1375ns, TL0=1375ns, TL1=375ns.
Definition led_timing.h:209
SM16703 RGB controller @ 800 kHz Four-phase: TH0=300ns, TH1=900ns, TL0=900ns, TL1=300ns.
Definition led_timing.h:308
SM16824E RGB controller (high-speed variant) Four-phase: TH0=300ns, TH1=1200ns, TL0=1000ns,...
Definition led_timing.h:319
TM1803 controller @ 400 kHz Four-phase: TH0=700ns, TH1=1800ns, TL0=1800ns, TL1=700ns.
Definition led_timing.h:383
TM1809 RGB controller @ 800 kHz Four-phase: TH0=350ns, TH1=700ns, TL0=800ns, TL1=450ns.
Definition led_timing.h:253
TM1814 RGBW controller @ 800 kHz Four-phase: TH0=360ns, TH1=960ns, TL0=940ns, TL1=340ns.
Definition led_timing.h:461
TM1829 RGB controller @ 1600 kHz (high-speed variant) Four-phase: TH0=100ns, TH1=400ns,...
Definition led_timing.h:275
TM1829 RGB controller @ 800 kHz Four-phase: TH0=340ns, TH1=680ns, TL0=890ns, TL1=550ns.
Definition led_timing.h:264
UCS1903 controller @ 400 kHz Four-phase: TH0=500ns, TH1=2000ns, TL0=2000ns, TL1=500ns.
Definition led_timing.h:361
UCS1903B controller @ 800 kHz Four-phase: TH0=400ns, TH1=850ns, TL0=900ns, TL1=450ns.
Definition led_timing.h:220
UCS1904 controller @ 800 kHz Four-phase: TH0=400ns, TH1=800ns, TL0=850ns, TL1=450ns.
Definition led_timing.h:231
UCS1912 controller @ 800 kHz Four-phase: TH0=250ns, TH1=1250ns, TL0=1350ns, TL1=350ns.
Definition led_timing.h:405
UCS2903 controller @ 800 kHz Four-phase: TH0=250ns, TH1=1000ns, TL0=1000ns, TL1=250ns.
Definition led_timing.h:242
static constexpr ClocklessEncoder ENCODER
Definition led_timing.h:497
UCS7604 RGBW controller @ 1600 kHz (16-bit color depth, high-speed) Four-phase: TH0=200ns,...
Definition led_timing.h:490
static constexpr ClocklessEncoder ENCODER
Definition led_timing.h:484
UCS7604 RGBW controller @ 800 kHz (16-bit color depth) Four-phase: TH0=400ns, TH1=800ns,...
Definition led_timing.h:477
static constexpr ClocklessEncoder ENCODER
Definition led_timing.h:510
UCS7604 RGBW controller @ 800 kHz (8-bit color depth) Same wire timing as 16-bit 800KHz,...
Definition led_timing.h:503
WS2811 @ 400kHz (standard mode, datasheet specification)
Definition led_timing.h:338
WS2811 @ 800kHz (fast mode, half the timing of 400kHz mode)
Definition led_timing.h:424
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_NOEXCEPT
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
WS2815 RGB controller @ 400 kHz Four-phase: TH0=250ns, TH1=1340ns, TL0=1640ns, TL1=550ns.
Definition led_timing.h:350