From 6298af07a39123ddf23ee16efea4f607ef7088e8 Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Fri, 3 Jul 2020 12:58:40 +0200 Subject: timing: break long options lines, rename samples identifier Break text lines in the options declarations which have become rather long. Rename 'samples' in the main loop to just 'sa', which better matches the other 'ss', 'es', 't', etc identifers. Separate the code for unconditional 'time' classes from optional averaging and deltas. --- decoders/timing/pd.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'decoders') diff --git a/decoders/timing/pd.py b/decoders/timing/pd.py index 1295477..b179ed6 100644 --- a/decoders/timing/pd.py +++ b/decoders/timing/pd.py @@ -92,9 +92,12 @@ class Decoder(srd.Decoder): ) options = ( { 'id': 'avg_period', 'desc': 'Averaging period', 'default': 100 }, - { 'id': 'edge', 'desc': 'Edges to check', 'default': 'any', 'values': ('any', 'rising', 'falling') }, - { 'id': 'delta', 'desc': 'Show delta from last', 'default': 'no', 'values': ('yes', 'no') }, - { 'id': 'terse', 'desc': 'Show periods in terse format', 'default': 'no', 'values': ('yes', 'no') }, + { 'id': 'edge', 'desc': 'Edges to check', + 'default': 'any', 'values': ('any', 'rising', 'falling') }, + { 'id': 'delta', 'desc': 'Show delta from last', + 'default': 'no', 'values': ('yes', 'no') }, + { 'id': 'terse', 'desc': 'Show periods in terse format', + 'default': 'no', 'values': ('yes', 'no') }, ) def __init__(self): @@ -132,8 +135,8 @@ class Decoder(srd.Decoder): ss = self.samplenum continue es = self.samplenum - samples = es - ss - t = samples / self.samplerate + sa = es - ss + t = sa / self.samplerate if terse: cls, txt = Ann.TERSE, terse_times(t) @@ -141,6 +144,7 @@ class Decoder(srd.Decoder): else: cls, txt = Ann.TIME, [normalize_time(t)] self.put(ss, es, self.out_ann, [cls, txt]) + if avg_period > 0: if t > 0: last_n.append(t) -- cgit v1.2.3-70-g09d2