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

Function datasheet_to_phase3

ci/tools/led_timing_conversions.py:191–221  ·  view source on GitHub ↗

Convert LED timing from datasheet format to 3-phase format. This is the CORRECTED algorithm that fixes bugs in the original chipsets.h embedded Python script. Algorithm: duration = max(T0H + T0L, T1H + T1L) T1 = T0H # High time for '0' bit T2 = T1H

(ds: TimingDatasheet)

Source from the content-addressed store, hash-verified

189
190
191def datasheet_to_phase3(ds: TimingDatasheet) -> Timing3Phase:
192 """Convert LED timing from datasheet format to 3-phase format.
193
194 This is the CORRECTED algorithm that fixes bugs in the original
195 chipsets.h embedded Python script.
196
197 Algorithm:
198 duration = max(T0H + T0L, T1H + T1L)
199 T1 = T0H # High time for '0' bit
200 T2 = T1H - T0H # Additional time for '1' bit
201 T3 = duration - T1H # Tail time after '1' bit drops
202
203 Args:
204 ds: LED timing in datasheet format
205
206 Returns:
207 LED timing in 3-phase format
208
209 Example:
210 >>> ds = TimingDatasheet(T0H=400, T0L=850, T1H=850, T1L=400, name="WS2812B")
211 >>> fl = datasheet_to_phase3(ds)
212 >>> print(fl)
213 T1=400ns, T2=450ns, T3=400ns (cycle=1250ns)
214 """
215 duration = max(ds.T0H + ds.T0L, ds.T1H + ds.T1L)
216
217 T1 = ds.T0H # High time for '0' bit
218 T2 = ds.T1H - ds.T0H # Additional time for '1' bit
219 T3 = duration - ds.T1H # Tail time after '1' bit
220
221 return Timing3Phase(T1, T2, T3, ds.name)
222
223
224def optimize_datasheet_timing(

Callers 7

test_ws2812_variantsMethod · 0.90
handle_interactiveFunction · 0.85
handle_datasheetFunction · 0.85

Calls 2

maxFunction · 0.85
Timing3PhaseClass · 0.85