## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
##
-def sigrokdecode_count_transitions(inbuf):
+def decode(inbuf):
"""Counts the low->high and high->low transitions in the specified
channel(s) of the signal."""
rising = [0] * channels
falling = [0] * channels
- # print len(inbuf)
- # print type(inbuf)
-
- # Presets...
+ # Initial values.
oldbyte = inbuf[0]
for i in range(channels):
oldbit[i] = (oldbyte & (1 << i)) >> i
elif (oldbit[i] == 1 and curbit == 0):
falling[i] += 1
oldbit[i] = curbit
+ oldbyte = s
# Total number of transitions is the sum of rising and falling edges.
for i in range(channels):
return outbuf
+def register():
+ return {
+ 'id': 'transitioncounter',
+ 'name': 'Transition counter',
+ 'desc': 'Count rising/falling edges',
+ 'inputformats': ['raw'],
+ 'signalnames': {}, # FIXME
+ 'outputformats': ['transitioncounts'],
+ }
+
# Use psyco (if available) as it results in huge performance improvements.
try:
import psyco
- psyco.bind(sigrokdecode_count_transitions)
+ psyco.bind(decode)
except ImportError:
pass