]>
vault307.fbx.one Git - micorpython_ir.git/blob - ir_tx/sony.py
1 # sony.py Encoder for IR remote control using synchronous code
5 # Copyright Peter Hinch 2020 Released under the MIT license
7 from micropython
import const
12 def __init__(self
, pin
, bits
, freq
, verbose
):
13 super().__init
__(pin
, freq
, 3 + bits
* 2, 30, verbose
)
14 if bits
not in (12, 15, 20):
15 raise ValueError('bits must be 12, 15 or 20.')
18 def tx(self
, addr
, data
, ext
):
19 self
.append(2400, 600)
23 v |
= (addr
& 0x1f) << 7
25 v |
= (addr
& 0xff) << 7
27 v |
= (addr
& 0x1f) << 7
28 v |
= (ext
& 0xff) << 12
30 self
.append(1200 if v
& 1 else 600, 600)
33 # Sony specifies 40KHz
34 class SONY_12(SONY_ABC
):
35 valid
= (0x1f, 0x7f, 0) # Max addr, data, toggle
36 def __init__(self
, pin
, freq
=40000, verbose
=False):
37 super().__init
__(pin
, 12, freq
, verbose
)
39 class SONY_15(SONY_ABC
):
40 valid
= (0xff, 0x7f, 0) # Max addr, data, toggle
41 def __init__(self
, pin
, freq
=40000, verbose
=False):
42 super().__init
__(pin
, 15, freq
, verbose
)
44 class SONY_20(SONY_ABC
):
45 valid
= (0x1f, 0x7f, 0xff) # Max addr, data, toggle
46 def __init__(self
, pin
, freq
=40000, verbose
=False):
47 super().__init
__(pin
, 20, freq
, verbose
)