LED timing in datasheet format (standard LED specification). Attributes: T0H: Time HIGH when sending a '0' bit (nanoseconds) T0L: Time LOW when sending a '0' bit (nanoseconds) T1H: Time HIGH when sending a '1' bit (nanoseconds) T1L: Time LOW when sending a '1' bi
| 80 | |
| 81 | |
| 82 | class TimingDatasheet: |
| 83 | """LED timing in datasheet format (standard LED specification). |
| 84 | |
| 85 | Attributes: |
| 86 | T0H: Time HIGH when sending a '0' bit (nanoseconds) |
| 87 | T0L: Time LOW when sending a '0' bit (nanoseconds) |
| 88 | T1H: Time HIGH when sending a '1' bit (nanoseconds) |
| 89 | T1L: Time LOW when sending a '1' bit (nanoseconds) |
| 90 | name: Human-readable chipset name |
| 91 | """ |
| 92 | |
| 93 | def __init__(self, T0H: int, T0L: int, T1H: int, T1L: int, name: str = "") -> None: |
| 94 | """Initialize TimingDatasheet.""" |
| 95 | self.T0H = T0H |
| 96 | self.T0L = T0L |
| 97 | self.T1H = T1H |
| 98 | self.T1L = T1L |
| 99 | self.name = name |
| 100 | |
| 101 | @property |
| 102 | def cycle_0(self) -> int: |
| 103 | """Total cycle time for '0' bit (T0H + T0L).""" |
| 104 | return self.T0H + self.T0L |
| 105 | |
| 106 | @property |
| 107 | def cycle_1(self) -> int: |
| 108 | """Total cycle time for '1' bit (T1H + T1L).""" |
| 109 | return self.T1H + self.T1L |
| 110 | |
| 111 | @property |
| 112 | def duration(self) -> int: |
| 113 | """Maximum cycle duration (max of cycle_0 and cycle_1).""" |
| 114 | return max(self.cycle_0, self.cycle_1) |
| 115 | |
| 116 | def __repr__(self) -> str: |
| 117 | """Return detailed representation.""" |
| 118 | if self.name: |
| 119 | return ( |
| 120 | f"TimingDatasheet({self.name}: " |
| 121 | f"T0H={self.T0H}ns, T0L={self.T0L}ns, " |
| 122 | f"T1H={self.T1H}ns, T1L={self.T1L}ns)" |
| 123 | ) |
| 124 | return ( |
| 125 | f"TimingDatasheet(T0H={self.T0H}ns, T0L={self.T0L}ns, " |
| 126 | f"T1H={self.T1H}ns, T1L={self.T1L}ns)" |
| 127 | ) |
| 128 | |
| 129 | def __str__(self) -> str: |
| 130 | """Return human-readable string.""" |
| 131 | return ( |
| 132 | f"T0H={self.T0H}ns, T0L={self.T0L}ns, " |
| 133 | f"T1H={self.T1H}ns, T1L={self.T1L}ns (cycle={self.duration}ns)" |
| 134 | ) |
| 135 | |
| 136 | |
| 137 | class Timing3Phase: |
no outgoing calls