summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authorKarl Palsson <karlp@etactica.com>2017-01-20 16:23:50 +0000
committerUwe Hermann <uwe@hermann-uwe.de>2017-05-13 16:11:33 +0200
commita93601346b535c48c18d03e0d67c3d8f7243f313 (patch)
tree4391330472dbed21a44e239c3402e8f81f3ae160 /decoders
parentb8c44f69b0f12c2cee2b9765abca8e0b3e751b43 (diff)
downloadlibsigrokdecode-a93601346b535c48c18d03e0d67c3d8f7243f313.tar.gz
libsigrokdecode-a93601346b535c48c18d03e0d67c3d8f7243f313.zip
timing: "normalize" negative times too
Use the same scale. Signed-off-by: Karl Palsson <karlp@etactica.com>
Diffstat (limited to 'decoders')
-rw-r--r--decoders/timing/pd.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/decoders/timing/pd.py b/decoders/timing/pd.py
index b694c1d..c88b8b5 100644
--- a/decoders/timing/pd.py
+++ b/decoders/timing/pd.py
@@ -25,19 +25,19 @@ class SamplerateError(Exception):
pass
def normalize_time(t):
- if t >= 1.0:
+ if abs(t) >= 1.0:
return '%.3f s (%.3f Hz)' % (t, (1/t))
- elif t >= 0.001:
+ elif abs(t) >= 0.001:
if 1/t/1000 < 1:
return '%.3f ms (%.3f Hz)' % (t * 1000.0, (1/t))
else:
return '%.3f ms (%.3f kHz)' % (t * 1000.0, (1/t)/1000)
- elif t >= 0.000001:
+ elif abs(t) >= 0.000001:
if 1/t/1000/1000 < 1:
return '%.3f μs (%.3f kHz)' % (t * 1000.0 * 1000.0, (1/t)/1000)
else:
return '%.3f μs (%.3f MHz)' % (t * 1000.0 * 1000.0, (1/t)/1000/1000)
- elif t >= 0.000000001:
+ elif abs(t) >= 0.000000001:
if 1/t/1000/1000/1000:
return '%.3f ns (%.3f MHz)' % (t * 1000.0 * 1000.0 * 1000.0, (1/t)/1000/1000)
else: