From: Gerhard Sittig Date: Fri, 3 Jul 2020 10:58:40 +0000 (+0200) Subject: timing: break long options lines, rename samples identifier X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6298af07a39123ddf23ee16efea4f607ef7088e8;p=libsigrokdecode.git 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. --- 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)