FastLED 3.9.15
Loading...
Searching...
No Matches
timing_traits.h
Go to the documentation of this file.
1
8
9#pragma once
10
11#include "fl/stl/int.h"
12#include "fl/stl/noexcept.h"
13
14namespace fl {
15
16// ============================================================================
17// TimingTraits - Extract timing values from ChipsetTiming at compile-time
18// ============================================================================
19
34template <typename TIMING>
37 static constexpr u32 T1 = TIMING::T1;
38
40 static constexpr u32 T2 = TIMING::T2;
41
43 static constexpr u32 T3 = TIMING::T3;
44
46 static constexpr u32 RESET = TIMING::RESET;
47
49 static constexpr u32 BIT_PERIOD = TIMING::T1 + TIMING::T2 + TIMING::T3;
50};
51
52// ============================================================================
53// C++11/14 Fallback Helpers (if non-reference template parameters needed)
54// ============================================================================
55
62template <u32 T1_NS, u32 T2_NS, u32 T3_NS, u32 RESET_US = 280>
64 static constexpr u32 T1 = T1_NS;
65 static constexpr u32 T2 = T2_NS;
66 static constexpr u32 T3 = T3_NS;
67 static constexpr u32 RESET = RESET_US;
68 static constexpr u32 BIT_PERIOD = T1_NS + T2_NS + T3_NS;
69};
70
71// Conversion from FastLED timings to the type found in datasheets.
72// Note: parameter names avoid T0H/T0L/T1H/T1L which are hardware register
73// macros on ESP8266 (defined in esp8266_peri.h).
74inline void convert_fastled_timings_to_timedeltas(u16 t1_in, u16 t2_in,
75 u16 t3_in, u16 *out_t0h,
76 u16 *out_t0l, u16 *out_t1h,
77 u16 *out_t1l) FL_NOEXCEPT {
78 *out_t0h = t1_in;
79 *out_t0l = t2_in + t3_in;
80 *out_t1h = t1_in + t2_in;
81 *out_t1l = t3_in;
82}
83
84} // namespace fl
void convert_fastled_timings_to_timedeltas(u16 t1_in, u16 t2_in, u16 t3_in, u16 *out_t0h, u16 *out_t0l, u16 *out_t1h, u16 *out_t1l) FL_NOEXCEPT
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_NOEXCEPT
static constexpr u32 BIT_PERIOD
static constexpr u32 T1
static constexpr u32 T2
static constexpr u32 T3
static constexpr u32 RESET
Helper to create timing traits from individual timing values Useful for creating custom timing config...
static constexpr u32 RESET
Reset/latch time (microseconds)
static constexpr u32 T2
Additional high time for bit 1 (nanoseconds)
static constexpr u32 T3
Low tail duration (nanoseconds)
static constexpr u32 BIT_PERIOD
Total bit period (T1 + T2 + T3) in nanoseconds.
static constexpr u32 T1
High time for bit 0 (nanoseconds)
Compile-time trait to extract timing values from timing types.