]>
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 valid
= (0xf, 0x3f, 3) # Max addr, data, toggle
17 init_cs
= 4 # http://www.hifi-remote.com/johnsfine/DecodeIR.html#OrtekMCE says 3
19 def __init__(self
, pin
, freq
=38000, verbose
=False):
20 super().__init
__(pin
, freq
, 34, 30, verbose
)
22 def tx(self
, addr
, data
, toggle
):
31 self
.append(2000, 1000, _TBIT
)
32 d
= ((data
& 0x3f) << 6) |
(addr
& 0xf) |
((toggle
& 3) << 4)
33 d |
= checksum(d
) << 12
34 self
.verbose
and print(bin(d
))
39 if bit ^ self
.carrier
:
43 self
.append(_TBIT
, _TBIT
)