MCPcopy Create free account
hub / github.com/FastLED/FastLED / canUseWave3

Function canUseWave3

src/fl/channels/wave3.cpp.hpp:24–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22// ============================================================================
23
24FL_OPTIMIZE_FUNCTION
25bool canUseWave3(const ChipsetTiming& timing) {
26 const u32 period = timing.T1 + timing.T2 + timing.T3;
27 if (period == 0) {
28 return false;
29 }
30
31 // T0H = T1, T1H = T1 + T2
32 const float t0h_norm = static_cast<float>(timing.T1) / period;
33 const float t1h_norm = static_cast<float>(timing.T1 + timing.T2) / period;
34
35 // Round to nearest integer tick count out of 3
36 u32 ticks_bit0 = static_cast<u32>(t0h_norm * 3.0f + 0.5f);
37 u32 ticks_bit1 = static_cast<u32>(t1h_norm * 3.0f + 0.5f);
38
39 // Both must be in [1, 2] (need at least 1 high tick and 1 low tick)
40 if (ticks_bit0 < 1 || ticks_bit0 > 2) return false;
41 if (ticks_bit1 < 1 || ticks_bit1 > 2) return false;
42
43 // Must be different (one is 1-tick, other is 2-tick)
44 if (ticks_bit0 == ticks_bit1) return false;
45
46 return true;
47}
48
49// ============================================================================
50// Wave3 Clock Frequency

Callers 5

initializeMethod · 0.85
beginTransmissionMethod · 0.85
FL_TEST_FILEFunction · 0.85
FL_TEST_FILEFunction · 0.85
captureFunction · 0.85

Calls

no outgoing calls

Tested by 1

captureFunction · 0.68