summaryrefslogtreecommitdiff
path: root/decoders/morse
diff options
context:
space:
mode:
authorChristoph Rackwitz <christoph.rackwitz@gmail.com>2018-09-11 21:55:38 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2018-09-12 00:23:37 +0200
commit2d0ef8bdad13fa50dbb9073c0ce4fd0ce4e025b6 (patch)
tree18f2421ad7b50136ed631a77c4da75db91ca28d5 /decoders/morse
parent3d188680d3937eebe9e03ce79d9bbb297426237c (diff)
downloadlibsigrokdecode-2d0ef8bdad13fa50dbb9073c0ce4fd0ce4e025b6.tar.gz
libsigrokdecode-2d0ef8bdad13fa50dbb9073c0ce4fd0ce4e025b6.zip
morse: fix for #1278
Diffstat (limited to 'decoders/morse')
-rw-r--r--decoders/morse/pd.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/decoders/morse/pd.py b/decoders/morse/pd.py
index 3048332..9a83b63 100644
--- a/decoders/morse/pd.py
+++ b/decoders/morse/pd.py
@@ -165,7 +165,7 @@ class Decoder(srd.Decoder):
curtime = self.samplenum
dt = (curtime - prevtime) / self.samplerate
units = dt / timeunit
- iunits = round(units)
+ iunits = int(max(1, round(units)))
error = abs(units - iunits)
symbol = (pval, iunits)
@@ -175,15 +175,17 @@ class Decoder(srd.Decoder):
continue
self.put(prevtime, curtime, self.out_ann, [0, ['{:.3g}'.format(dt)]])
- self.put(prevtime, curtime, self.out_ann, [1, ['{:.1f}*{:.3g}'.format(units, timeunit)]])
if symbol in symbols:
+ self.put(prevtime, curtime, self.out_ann, [1, ['{:.1f}*{:.3g}'.format(units, timeunit)]])
yield (prevtime, curtime, symbol)
+ else:
+ self.put(prevtime, curtime, self.out_ann, [1, ['!! {:.1f}*{:.3g} !!'.format(units, timeunit)]])
prevtime = curtime
thisunit = dt / iunits
- timeunit += (thisunit - timeunit) * 0.02 * iunits # Adapt.
+ timeunit += (thisunit - timeunit) * 0.2 * max(0, 1 - 2*error) # Adapt.
def decode_morse(self):
# Group symbols into letters.