]>
vault307.fbx.one Git - micorpython_ir.git/blob - ir_tx/mce.py
1 # mce.py Encoder for IR remote control using synchronous code
2 # Supports Microsoft MCE edition remote protocol.
5 # Copyright Peter Hinch 2020 Released under the MIT license
7 # WARNING: This is experimental and subject to change.
9 from micropython
import const
12 _TBIT
= const(500) # Time (μs) for pulse of carrier
16 init_cs
= 4 # http://www.hifi-remote.com/johnsfine/DecodeIR.html#OrtekMCE says 3
18 def __init__(self
, pin
, freq
=38000, verbose
=False):
19 super().__init
__(pin
, freq
, 34, 30, verbose
)
21 def tx(self
, addr
, data
, toggle
):
30 self
.append(2000, 1000, _TBIT
)
31 d
= ((data
& 0x3f) << 6) |
(addr
& 0xf) |
((toggle
& 3) << 4)
32 d |
= checksum(d
) << 12
33 self
.verbose
and print(bin(d
))
38 if bit ^ self
.carrier
:
42 self
.append(_TBIT
, _TBIT
)