X-Git-Url: https://vault307.fbx.one/gitweb/micorpython_ir.git/blobdiff_plain/8ac6c4b0b81221439541db8f7bdbab29913da9bb..cfb4d7a37f2dbe06dd118dffb943308bed3c6e09:/ir_tx/nec.py diff --git a/ir_tx/nec.py b/ir_tx/nec.py index da1af24..807ec68 100644 --- a/ir_tx/nec.py +++ b/ir_tx/nec.py @@ -2,8 +2,9 @@ # NEC protocol. # Author: Peter Hinch -# Copyright Peter Hinch 2020 Released under the MIT license +# Copyright Peter Hinch 2020-2022 Released under the MIT license +# With thanks to J.E. Tannenbaum for information re Samsung protocol from micropython import const from ir_tx import IR, STOP @@ -12,15 +13,19 @@ _T_ONE = const(1687) class NEC(IR): valid = (0xffff, 0xff, 0) # Max addr, data, toggle + samsung = False - def __init__(self, pin, freq=38000, verbose=False): # NEC specifies 38KHz + def __init__(self, pin, freq=38000, verbose=False): # NEC specifies 38KHz also Samsung super().__init__(pin, freq, 68, 33, verbose) # Measured duty ratio 33% def _bit(self, b): self.append(_TBURST, _T_ONE if b else _TBURST) def tx(self, addr, data, _): # Ignore toggle - self.append(9000, 4500) + if self.samsung: + self.append(4500, 4500) + else: + self.append(9000, 4500) if addr < 256: # Short address: append complement addr |= ((addr ^ 0xff) << 8) for _ in range(16):