From: Karl Palsson Date: Fri, 20 Jan 2017 16:03:21 +0000 (+0000) Subject: timing: disable averaging if set to zero X-Git-Tag: libsigrokdecode-0.5.0~25 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=82738302754039cffb4ee84b2fa9b1450612a5e3;p=libsigrokdecode.git timing: disable averaging if set to zero The extra row of the average isn't always useful. Allow it to be disabled by setting the average window to zero. Signed-off-by: Karl Palsson --- diff --git a/decoders/timing/pd.py b/decoders/timing/pd.py index 19836b0..01e3b01 100644 --- a/decoders/timing/pd.py +++ b/decoders/timing/pd.py @@ -116,8 +116,9 @@ class Decoder(srd.Decoder): # Report the timing normalized. self.put(self.last_samplenum, self.samplenum, self.out_ann, [0, [normalize_time(t)]]) - self.put(self.last_samplenum, self.samplenum, self.out_ann, - [1, [normalize_time(sum(self.last_n) / len(self.last_n))]]) + if self.options['avg_period'] > 0: + self.put(self.last_samplenum, self.samplenum, self.out_ann, + [1, [normalize_time(sum(self.last_n) / len(self.last_n))]]) # Store data for next round. self.last_samplenum = self.samplenum