diff options
author | BenediktO <benedikt_o@web.de> | 2020-07-27 08:32:52 +0200 |
---|---|---|
committer | Gerhard Sittig <gerhard.sittig@gmx.net> | 2020-08-30 10:24:08 +0200 |
commit | f9818294d09ba8b7dd3614357ce185f79c8c45a1 (patch) | |
tree | 89b5f28269fe74b1f44093414fa83081c83a7999 /decoders | |
parent | 85f616edfa157ae6ed8ea9ea4a72b930816e4dc9 (diff) | |
download | libsigrokdecode-f9818294d09ba8b7dd3614357ce185f79c8c45a1.tar.gz libsigrokdecode-f9818294d09ba8b7dd3614357ce185f79c8c45a1.zip |
ir_nec: Make the tolerance configurable
Provide an option to adjust the IR NEC decoder's tolerance. Which makes
signals accessible that are generated by cheap remotes which would not
decode at all with the previous implementation and its fixed limit.
[ gsi: rephrased commit message and implementation ]
Diffstat (limited to 'decoders')
-rw-r--r-- | decoders/ir_nec/pd.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/decoders/ir_nec/pd.py b/decoders/ir_nec/pd.py index 05c8c00..0d79865 100644 --- a/decoders/ir_nec/pd.py +++ b/decoders/ir_nec/pd.py @@ -48,6 +48,7 @@ class Decoder(srd.Decoder): options = ( {'id': 'polarity', 'desc': 'Polarity', 'default': 'active-low', 'values': ('active-low', 'active-high')}, + {'id': 'tolerance', 'desc': 'Timing tolerance (%)', 'default': 5}, {'id': 'cd_freq', 'desc': 'Carrier Frequency', 'default': 0}, {'id': 'extended', 'desc': 'Extended NEC Protocol', 'default': 'no', 'values': ('yes', 'no')}, @@ -136,7 +137,7 @@ class Decoder(srd.Decoder): self.samplerate = value def calc_rate(self): - self.tolerance = 0.05 # +/-5% + self.tolerance = self.options['tolerance'] / 100 # 5% by default self.lc = int(self.samplerate * 0.0135) - 1 # 13.5ms self.rc = int(self.samplerate * 0.01125) - 1 # 11.25ms self.dazero = int(self.samplerate * 0.001125) - 1 # 1.125ms |