@@ -171,9 +171,9 @@ def decode_bits(pulses: List) -> NamedTuple:
171171 # convert marks/spaces to 0 and 1
172172 for i , pulse_length in enumerate (pulses ):
173173 if (space * 0.75 ) <= pulse_length <= (space * 1.25 ):
174- pulses [i ] = False
175- elif (mark * 0.75 ) <= pulse_length <= (mark * 1.25 ):
176174 pulses [i ] = True
175+ elif (mark * 0.75 ) <= pulse_length <= (mark * 1.25 ):
176+ pulses [i ] = False
177177 else :
178178 msg = UnparseableIRMessage (input_pulses , reason = "Pulses outside mark/space" )
179179 raise FailedToDecode (msg )
@@ -342,15 +342,15 @@ def read_pulses(
342342class GenericTransmit :
343343 """Generic infrared transmit class that handles encoding.
344344
345- :param int header: The length of header in microseconds
346- :param int one: The length of a one in microseconds
347- :param int zero: The length of a zero in microseconds
345+ :param List[ int] header: The length of header in microseconds, the length should be even
346+ :param List[ int] one: The length of a one in microseconds
347+ :param List[ int] zero: The length of a zero in microseconds
348348 :param int trail: The length of the trail in microseconds, set to None to disable
349349 :param bool debug: Enable debug output, default False
350350 """
351351
352352 def __init__ (
353- self , header : int , one : int , zero : int , trail : int , * , debug : bool = False
353+ self , header : List [ int ] , one : List [ int ] , zero : List [ int ] , trail : int , * , debug : bool = False
354354 ) -> None :
355355 self .header = header
356356 self .one = one
@@ -381,14 +381,15 @@ def transmit(
381381 bits_to_send = nbits
382382
383383 durations = array .array (
384- "H" , [0 ] * (2 + bits_to_send * 2 + (0 if self .trail is None else 1 ))
384+ "H" , [0 ] * (len ( self . header ) + bits_to_send * 2 + (0 if self .trail is None else 1 ))
385385 )
386-
387- durations [0 ] = self .header [0 ]
388- durations [1 ] = self .header [1 ]
386+
387+ for i , _ in enumerate (self .header ):
388+ durations [i ] = self .header [i ]
389+
389390 if self .trail is not None :
390391 durations [- 1 ] = self .trail
391- out = 2
392+ out = len ( self . header )
392393 bit_count = 0
393394 for byte_index , _ in enumerate (data ):
394395 for i in range (7 , - 1 , - 1 ):
0 commit comments