File tree Expand file tree Collapse file tree
custom_components/rav311_remote Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44PIONEER_FREQUENCY_HZ = 40_000
55
6- _HEADER_HIGH = 9000
7- _HEADER_LOW = 4500
8- _BIT_HIGH = 560
9- _ONE_LOW = 1690
10- _ZERO_LOW = 560
11- _TRAILER_HIGH = 560
6+ _HEADER_HIGH = 9000
7+ _HEADER_LOW = 4500
8+ _BIT_HIGH = 560
9+ _ONE_LOW = 1690
10+ _ZERO_LOW = 560
11+ _TRAILER_HIGH = 560
1212_TRAILER_LOW = 25500
1313
1414
@@ -21,10 +21,11 @@ def _reverse_bits(b: int) -> int:
2121
2222
2323def _encode_uint16_lsb (value : int ) -> list [int ]:
24+ """Encode 16 bits LSB-first as alternating +mark / -space integers."""
2425 result = []
2526 for _ in range (16 ):
26- result .append (_BIT_HIGH )
27- result .append (_ONE_LOW if (value & 1 ) else _ZERO_LOW )
27+ result .append (_BIT_HIGH ) # positive = pulse
28+ result .append (- ( _ONE_LOW if (value & 1 ) else _ZERO_LOW )) # negative = space
2829 value >>= 1
2930 return result
3031
@@ -44,10 +45,12 @@ def get_raw_timings(self) -> list[int]:
4445 address = ((~ rev_high & 0xFF ) << 8 ) | rev_high
4546 command = ((~ low_byte & 0xFF ) << 8 ) | low_byte
4647
47- frame : list [int ] = [_HEADER_HIGH , _HEADER_LOW ]
48+ frame : list [int ] = [
49+ _HEADER_HIGH , - _HEADER_LOW , # header: +pulse / -space
50+ ]
4851 frame .extend (_encode_uint16_lsb (address ))
4952 frame .extend (_encode_uint16_lsb (command ))
50- frame .extend ([ _TRAILER_HIGH , _TRAILER_LOW ])
53+ frame .append ( _TRAILER_HIGH ) # trailing pulse only
5154
5255 timings : list [int ] = []
5356 for _ in range (self ._repeat ):
You can’t perform that action at this time.
0 commit comments