]>
vault307.fbx.one Git - micorpython_ir.git/blob - ir_tx/nec.py
1 # nec.py Encoder for IR remote control using synchronous code
5 # Copyright Peter Hinch 2020 Released under the MIT license
7 from micropython
import const
8 from ir_tx
import IR
, STOP
15 def __init__(self
, pin
, freq
=38000, verbose
=False): # NEC specifies 38KHz
16 super().__init
__(pin
, freq
, 68, 50, verbose
)
19 self
.append(_TBURST
, _T_ONE
if b
else _TBURST
)
21 def tx(self
, addr
, data
, _
): # Ignore toggle
22 self
.append(9000, 4500)
23 if addr
< 256: # Short address: append complement
24 addr |
= ((addr ^
0xff) << 8)
28 data |
= ((data ^
0xff) << 8)
36 self
.append(9000, 2250, _TBURST
, STOP
)
37 self
.aptr
= 0 # Reset pointer
38 self
.cb(self
._tim
) # Initiate physical transmission.