]> sigrok.org Git - libsigrokdecode.git/blobdiff - scripts/transitioncounter.py
Python: Bugfixes (True/False != 1/0).
[libsigrokdecode.git] / scripts / transitioncounter.py
index 7c9c6a3e3d05bef37be6a57f399226968c034e4d..c16ce46aacc67a90cb5c00bec11a66ba6416dbf5 100644 (file)
@@ -41,7 +41,7 @@ def sigrokdecode_count_transitions(inbuf):
        # Presets...
        oldbyte = inbuf[0]
        for i in range(channels):
-               oldbit[i] = (oldbyte & (1 << i)) != 0
+               oldbit[i] = (oldbyte & (1 << i)) >> i
 
        # Loop over all samples.
        # TODO: Handle LAs with more/less than 8 channels.
@@ -50,7 +50,7 @@ def sigrokdecode_count_transitions(inbuf):
                if oldbyte == s:
                        continue
                for i in range(channels):
-                       curbit = (s & (1 << i) != 0)
+                       curbit = (s & (1 << i)) >> i
                        # Optimization: Skip identical bits (no transitions).
                        if oldbit[i] == curbit:
                                continue