X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoders%2Fmorse%2Fpd.py;h=47a641c18e63015d4133d13d5f55c526bd091fc4;hp=3048332354f4a86585ef3fc55fc16796cf2c39fb;hb=d6d8a8a440ea2a81e6ddde33d16bc84d01cdb432;hpb=15a8a05595c72d328abdea8e3b23f1b558cc46bf diff --git a/decoders/morse/pd.py b/decoders/morse/pd.py index 3048332..47a641c 100644 --- a/decoders/morse/pd.py +++ b/decoders/morse/pd.py @@ -121,6 +121,7 @@ class Decoder(srd.Decoder): license = 'gplv2+' inputs = ['logic'] outputs = ['morse'] + tags = ['Encoding'] channels = ( {'id': 'data', 'name': 'Data', 'desc': 'Data line'}, ) @@ -165,7 +166,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 +176,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.