Run interactive mode for timing conversion.
()
| 347 | |
| 348 | |
| 349 | def 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() |
no test coverage detected