summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authorGerhard Sittig <gerhard.sittig@gmx.net>2020-07-03 11:22:03 +0200
committerGerhard Sittig <gerhard.sittig@gmx.net>2020-07-07 22:50:46 +0200
commitc945a82d3217da1a7c651ba2404070e00287c87b (patch)
treec79e537ed230f5153cebd57c7fd5c2deebb2a54e /decoders
parent3e962c2f5914300d63ccd5c135e4554c4314517f (diff)
downloadlibsigrokdecode-c945a82d3217da1a7c651ba2404070e00287c87b.tar.gz
libsigrokdecode-c945a82d3217da1a7c651ba2404070e00287c87b.zip
timing: use ss/es for consistency
Consistently use ss and es identifiers for annotation emission to match other decoders, as well as counting distances between sample points to increase readability. This also dramatically reduces text line length.
Diffstat (limited to 'decoders')
-rw-r--r--decoders/timing/pd.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/decoders/timing/pd.py b/decoders/timing/pd.py
index e687562..f14b64f 100644
--- a/decoders/timing/pd.py
+++ b/decoders/timing/pd.py
@@ -98,7 +98,7 @@ class Decoder(srd.Decoder):
raise SamplerateError('Cannot decode without samplerate.')
edge = self.options['edge']
avg_period = self.options['avg_period']
- last_samplenum = None
+ ss = None
last_n = deque()
last_t = None
while True:
@@ -109,10 +109,11 @@ class Decoder(srd.Decoder):
else:
pin = self.wait({Pin.DATA: 'e'})
- if not last_samplenum:
- last_samplenum = self.samplenum
+ if not ss:
+ ss = self.samplenum
continue
- samples = self.samplenum - last_samplenum
+ es = self.samplenum
+ samples = es - ss
t = samples / self.samplerate
if t > 0:
@@ -120,14 +121,14 @@ class Decoder(srd.Decoder):
if len(last_n) > avg_period:
last_n.popleft()
- self.put(last_samplenum, self.samplenum, self.out_ann,
+ self.put(ss, es, self.out_ann,
[Ann.TIME, [normalize_time(t)]])
if avg_period > 0:
- self.put(last_samplenum, self.samplenum, self.out_ann,
+ self.put(ss, es, self.out_ann,
[Ann.AVG, [normalize_time(sum(last_n) / len(last_n))]])
if last_t and self.options['delta'] == 'yes':
- self.put(last_samplenum, self.samplenum, self.out_ann,
+ self.put(ss, es, self.out_ann,
[Ann.DELTA, [normalize_time(t - last_t)]])
last_t = t
- last_samplenum = self.samplenum
+ ss = es