FastLED 3.10.8
Loading...
Searching...
No Matches
fl::channels::rx::Ws2812StreamDecoder Class Reference

Detailed Description

Streaming decoder over (rise, fall) capture pairs.

Not thread-safe: the owner feeds it from one context at a time (the DMA ISR during the frame, then the thread after the ISR is masked).

Definition at line 110 of file ws2812_stream_decoder.h.

#include <ws2812_stream_decoder.h>

+ Collaboration diagram for fl::channels::rx::Ws2812StreamDecoder:

Classes

struct  Exception
 
struct  Pending
 
struct  Stats
 

Public Member Functions

fl::result< u32, DecodeError > copyTo (fl::span< u8 > out) const FL_NO_EXCEPT
 Copy the decoded frame into out with the batch decoder's result rules (overflow, >10% error rate, partial final byte).
 
size_t diagEdgeCount () const FL_NO_EXCEPT
 
void finish (const ChipsetTiming4Phase &timing) FL_NO_EXCEPT
 Re-classify the recorded bits with the decode-time timing and write the partial final byte.
 
void flush () FL_NO_EXCEPT
 End of capture: decode the final pair (HIGH only; its LOW is the reset) and fix the calibration.
 
void markOverrun () FL_NO_EXCEPT
 Captures were lost (ring overwritten before decode).
 
void push (fl::span< const u16 > captures) FL_NO_EXCEPT
 Consume capture pairs laid out as [rise0, fall0, rise1, fall1...].
 
void reset (const ChipsetTiming4Phase &stream_timing, u32 ns_per_tick_q16, fl::span< u8 > out, fl::span< EdgeTime > diag_edges) FL_NO_EXCEPT
 Start a frame.
 
const Stats & stats () const FL_NO_EXCEPT
 

Static Public Attributes

static constexpr u32 kCalibrationBits = 64
 Bits classified before the threshold is fixed. 64 bits = 8 bytes.
 
static constexpr u32 kExceptionBandNs = 150
 Bits within this distance of the calibrated threshold are recorded for re-classification against the whole-frame threshold.
 
static constexpr u32 kMaxExceptions = 32
 

Private Types

enum class  Mode : u8 { Midpoint , FromHigh }
 

Private Member Functions

void appendBit (int bit) FL_NO_EXCEPT
 
void calibrate () FL_NO_EXCEPT
 
void classify (u32 high_ns, Mode mode) FL_NO_EXCEPT
 
void emitEdge (bool high, u32 ns) FL_NO_EXCEPT
 
void emitPair (u16 rise, u16 fall, bool has_low, u32 low_ns) FL_NO_EXCEPT
 
void pushBit (u32 high_ns, Mode mode) FL_NO_EXCEPT
 
void record (u32 high_ns, Mode mode, bool stream_valid) FL_NO_EXCEPT
 

Private Attributes

u32 mBitCount = 0
 
u32 mBitPos = 0
 
bool mCalibrated = false
 
u8 mCurByte = 0
 
fl::span< EdgeTime > mDiag
 
size_t mDiagCount = 0
 
u32 mEdgeIndex = 0
 
u32 mExceptionCount = 0
 
Exception mExceptions [kMaxExceptions]
 
bool mFlushed = false
 
bool mHavePrev = false
 
u32 mHighMax = 0
 
u32 mHighMin = 0xFFFFFFFFu
 
u32 mHighSamples = 0
 
u32 mMidpoint = 0
 
u32 mNsPerTickQ16 = 0
 
fl::span< u8 > mOut
 
bool mPartialWritten = false
 
Pending mPending [kCalibrationBits]
 
u32 mPendingCount = 0
 
u16 mPrevFall = 0
 
u16 mPrevRise = 0
 
bool mStarted = false
 
Stats mStats
 
ChipsetTiming4Phase mTiming = {}
 

The documentation for this class was generated from the following files: