From: Karl Palsson Date: Fri, 20 Jan 2017 16:23:50 +0000 (+0000) Subject: timing: "normalize" negative times too X-Git-Tag: libsigrokdecode-0.5.0~23 X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=a93601346b535c48c18d03e0d67c3d8f7243f313;hp=b8c44f69b0f12c2cee2b9765abca8e0b3e751b43;p=libsigrokdecode.git timing: "normalize" negative times too Use the same scale. Signed-off-by: Karl Palsson --- 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: