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

Function phase3_to_datasheet

ci/tools/led_timing_conversions.py:290–327  ·  view source on GitHub ↗

Convert LED timing from 3-phase format to datasheet format. This conversion is UNDERDETERMINED because: - We have 3 input values (T1, T2, T3) - We need 4 output values (T0H, T0L, T1H, T1L) Assumption: Symmetric cycle times (T0H+T0L = T1H+T1L = duration) This gives us: T

(
    fl: Timing3Phase, duration: Optional[int] = None
)

Source from the content-addressed store, hash-verified

288
289
290def phase3_to_datasheet(
291 fl: Timing3Phase, duration: Optional[int] = None
292) -> Optional[TimingDatasheet]:
293 """Convert LED timing from 3-phase format to datasheet format.
294
295 This conversion is UNDERDETERMINED because:
296 - We have 3 input values (T1, T2, T3)
297 - We need 4 output values (T0H, T0L, T1H, T1L)
298
299 Assumption: Symmetric cycle times (T0H+T0L = T1H+T1L = duration)
300 This gives us: T0L = duration - T0H, T1L = duration - T1H
301
302 Args:
303 fl: LED timing in 3-phase format
304 duration: Optional total cycle duration (if None, computed as T1+T2+T3)
305
306 Returns:
307 LED timing in datasheet format, or None if conversion fails
308
309 Example:
310 >>> fl = Timing3Phase(T1=250, T2=625, T3=375, name="WS2812")
311 >>> ds = phase3_to_datasheet(fl)
312 >>> print(ds)
313 T0H=250ns, T0L=1000ns, T1H=875ns, T1L=375ns (cycle=1250ns)
314 """
315 if duration is None:
316 duration = fl.T1 + fl.T2 + fl.T3
317
318 T0H = fl.T1
319 T1H = fl.T1 + fl.T2
320 T0L = duration - T0H
321 T1L = duration - T1H
322
323 # Validate results
324 if T0L < 0 or T1L < 0:
325 return None # Invalid timing
326
327 return TimingDatasheet(T0H, T0L, T1H, T1L, fl.name)
328
329
330def print_phase3_cpp_definition(fl: Timing3Phase, name: str = "CUSTOM") -> None:

Callers 7

handle_interactiveFunction · 0.85
handle_fastledFunction · 0.85

Calls 1

TimingDatasheetClass · 0.85