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

Function handle_interactive

ci/tools/led_timing_conversions.py:349–563  ·  view source on GitHub ↗

Run interactive mode for timing conversion.

()

Source from the content-addressed store, hash-verified

347
348
349def handle_interactive() -> None:
350 """Run interactive mode for timing conversion."""
351 print("LED Chipset Timing Conversion Tool")
352 print("=" * 50)
353 print()
354 print("Which conversion would you like to perform?")
355 print()
356 print("[1] Datasheet format (T0H, T0L, T1H, T1L) → 3-phase format (T1, T2, T3)")
357 print("[2] 3-phase format (T1, T2, T3) → Datasheet format (T0H, T0L, T1H, T1L)")
358 print()
359
360 try:
361 choice = input("Enter choice [1 or 2]: ").strip()
362
363 if choice not in ["1", "2"]:
364 print("\nERROR: Invalid choice. Please enter 1 or 2.")
365 sys.exit(1)
366
367 print()
368
369 if choice == "1":
370 # Datasheet → 3-phase conversion
371 print(
372 "Do you want to optimize for datasheet specifications? [y/N]: ", end=""
373 )
374 optimize = input().strip().lower() in ["y", "yes"]
375 print()
376
377 if optimize:
378 print("Enter datasheet SPECIFICATIONS (min-max ranges in nanoseconds):")
379 print(" Example: For WS2812B-V5, T0H range is 220-380ns")
380 print()
381 T0H_min = int(input(" T0H min: "))
382 T0H_max = int(input(" T0H max: "))
383 T0L_min = int(input(" T0L min: "))
384 T0L_max = int(input(" T0L max: "))
385 T1H_min = int(input(" T1H min: "))
386 T1H_max = int(input(" T1H max: "))
387 T1L_min = int(input(" T1L min: "))
388 T1L_max = int(input(" T1L max: "))
389 print()
390
391 spec = TimingSpec(
392 T0H_min,
393 T0H_max,
394 T0L_min,
395 T0L_max,
396 T1H_min,
397 T1H_max,
398 T1L_min,
399 T1L_max,
400 )
401
402 # Generate initial timing from spec midpoints
403 # Use minimum values for high times (safest for signal integrity)
404 # This avoids requiring oscilloscope measurements
405 print("Generating optimal timing from specification ranges...")
406 print()

Callers 1

mainFunction · 0.85

Calls 10

validateMethod · 0.95
TimingSpecClass · 0.85
TimingDatasheetClass · 0.85
datasheet_to_phase3Function · 0.85
Timing3PhaseClass · 0.85
phase3_to_datasheetFunction · 0.85
printFunction · 0.50

Tested by

no test coverage detected