]>
vault307.fbx.one Git - micorpython_ir.git/blob - ir_tx/philips.py
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
8 from sys
import platform
11 # Philips RC5 protocol
12 _T_RC5
= const(889) # Time for pulse of carrier
13 ermsg
= 'ESP32 does not support Philips protocols'
16 def __init__(self
, pin
, freq
=36000, verbose
=False):
17 super().__init
__(pin
, freq
, 28, 30, verbose
)
19 def tx(self
, addr
, data
, toggle
):
20 d
= (data
& 0x3f) |
((addr
& 0x1f) << 6) |
((data
& 0x40) << 6) |
((toggle
& 1) << 11)
21 self
.verbose
and print(bin(d
))
28 if bit ^ self
.carrier
:
32 self
.append(_T_RC5
, _T_RC5
)
35 # Philips RC6 mode 0 protocol
41 def __init__(self
, pin
, freq
=36000, verbose
=False):
42 super().__init
__(pin
, freq
, 44, 30, verbose
)
44 def tx(self
, addr
, data
, toggle
):
46 self
.append(2666, _T2_RC6
, _T_RC6
, _T2_RC6
, _T_RC6
, _T_RC6
, _T_RC6
, _T_RC6
, _T_RC6
)
47 # Append a single bit of twice duration
52 self
.append(_T2_RC6
, _T2_RC6
)
53 d
= (data
& 0xff) |
((addr
& 0xff) << 8)
55 self
.verbose
and print('toggle', toggle
, self
.carrier
, bool(d
& mask
))
58 if bit ^ self
.carrier
:
59 self
.append(_T_RC6
, _T_RC6
)