summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authorGerhard Sittig <gerhard.sittig@gmx.net>2020-07-03 12:58:40 +0200
committerGerhard Sittig <gerhard.sittig@gmx.net>2020-07-07 22:50:46 +0200
commit6298af07a39123ddf23ee16efea4f607ef7088e8 (patch)
tree842767dfbf2e00c3efead1a90b34c8d4b3eb8d56 /decoders
parent74c9c926a8936b6e7b781639908d1016e2088307 (diff)
downloadlibsigrokdecode-6298af07a39123ddf23ee16efea4f607ef7088e8.tar.gz
libsigrokdecode-6298af07a39123ddf23ee16efea4f607ef7088e8.zip
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.
Diffstat (limited to 'decoders')
-rw-r--r--decoders/timing/pd.py14
1 files changed, 9 insertions, 5 deletions
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)