]>
vault307.fbx.one Git - micorpython_ir.git/blob - ir_tx/philips.py
90b9de941f4d7bc17729fab3e195e9ba1f2a53ef
1 # philips.py Encoder for IR remote control using synchronous code
2 # RC-5 and RC-6 mode 0 protocols.
5 # Copyright Peter Hinch 2020 Released under the MIT license
7 from micropython
import const
10 # Philips RC5 protocol
11 _T_RC5
= const(889) # Time for pulse of carrier
15 valid
= (0x1f, 0x3f, 1) # Max addr, data, toggle
17 def __init__(self
, pin
, freq
=36000, verbose
=False):
18 super().__init
__(pin
, freq
, 28, 30, verbose
)
20 def tx(self
, addr
, data
, toggle
): # Fix RC5X S2 bit polarity
21 d
= (data
& 0x3f) |
((addr
& 0x1f) << 6) |
(((data
& 0x40) ^
0x40) << 6) |
((toggle
& 1) << 11)
22 self
.verbose
and print(bin(d
))
29 if bit ^ self
.carrier
:
33 self
.append(_T_RC5
, _T_RC5
)
36 # Philips RC6 mode 0 protocol
41 valid
= (0xff, 0xff, 1) # Max addr, data, toggle
43 def __init__(self
, pin
, freq
=36000, verbose
=False):
44 super().__init
__(pin
, freq
, 44, 30, verbose
)
46 def tx(self
, addr
, data
, toggle
):
48 self
.append(2666, _T2_RC6
, _T_RC6
, _T2_RC6
, _T_RC6
, _T_RC6
, _T_RC6
, _T_RC6
, _T_RC6
)
49 # Append a single bit of twice duration
54 self
.append(_T2_RC6
, _T2_RC6
)
55 d
= (data
& 0xff) |
((addr
& 0xff) << 8)
57 self
.verbose
and print('toggle', toggle
, self
.carrier
, bool(d
& mask
))
60 if bit ^ self
.carrier
:
61 self
.append(_T_RC6
, _T_RC6
)