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

Function isResetPulse

src/platforms/esp/32/drivers/rmt_rx/rmt_rx_channel.cpp.hpp:96–126  ·  view source on GitHub ↗

* @brief Check if symbol is a reset pulse * @param symbol RMT symbol to check * @param timing Timing thresholds * @param ns_per_tick Cached nanoseconds per tick * @return true if symbol is reset pulse (long low duration) */

Source from the content-addressed store, hash-verified

94 * @return true if symbol is reset pulse (long low duration)
95 */
96inline bool isResetPulse(RmtSymbol symbol, const ChipsetTiming4Phase &timing,
97 u32 ns_per_tick) {
98 // Cast RmtSymbol to rmt_symbol_word_t to access bitfields
99 const auto rmt_sym = fl::bit_cast<rmt_symbol_word_t>(symbol);
100
101 // Reset pulse characteristics:
102 // - Long low duration (>50us)
103 // - Either duration0 or duration1 can be the low period
104
105 // Convert durations to nanoseconds
106 u32 duration0_ns = ticksToNs(rmt_sym.duration0, ns_per_tick);
107 u32 duration1_ns = ticksToNs(rmt_sym.duration1, ns_per_tick);
108
109 // Check if either duration exceeds reset threshold
110 u32 reset_min_ns = timing.reset_min_us * 1000;
111
112 // Reset pulse should have level=0 (low) for the long duration
113 // Check duration0 with level0=0, or duration1 with level1=0
114 if (rmt_sym.level0 == 0 && duration0_ns >= reset_min_ns) {
115 FL_WARN("isResetPulse DETECTED: duration0=" << duration0_ns << "ns (level0=0), reset_min="
116 << reset_min_ns << "ns (" << timing.reset_min_us << "us)");
117 return true;
118 }
119 if (rmt_sym.level1 == 0 && duration1_ns >= reset_min_ns) {
120 FL_WARN("isResetPulse DETECTED: duration1=" << duration1_ns << "ns (level1=0), reset_min="
121 << reset_min_ns << "ns (" << timing.reset_min_us << "us)");
122 return true;
123 }
124
125 return false;
126}
127
128/**
129 * @brief Check if symbol is a gap pulse (transmission gap like PARLIO DMA gap)

Callers 1

decodeRmtSymbolsFunction · 0.70

Calls 1

ticksToNsFunction · 0.70

Tested by

no test coverage detected