]>
vault307.fbx.one Git - micorpython_ir.git/blob - ir_tx/nec.py
807ec68abb220eeead32a1d98cf0b638000308b7
1 # nec.py Encoder for IR remote control using synchronous code
5 # Copyright Peter Hinch 2020-2022 Released under the MIT license
7 # With thanks to J.E. Tannenbaum for information re Samsung protocol
8 from micropython
import const
9 from ir_tx
import IR
, STOP
15 valid
= (0xffff, 0xff, 0) # Max addr, data, toggle
18 def __init__(self
, pin
, freq
=38000, verbose
=False): # NEC specifies 38KHz also Samsung
19 super().__init
__(pin
, freq
, 68, 33, verbose
) # Measured duty ratio 33%
22 self
.append(_TBURST
, _T_ONE
if b
else _TBURST
)
24 def tx(self
, addr
, data
, _
): # Ignore toggle
26 self
.append(4500, 4500)
28 self
.append(9000, 4500)
29 if addr
< 256: # Short address: append complement
30 addr |
= ((addr ^
0xff) << 8)
34 data |
= ((data ^
0xff) << 8)
42 self
.append(9000, 2250, _TBURST
)
43 self
.trigger() # Initiate physical transmission.