]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/graycode/pd.py
modbus: Make C->S and S->C configurable, add framegap option.
[libsigrokdecode.git] / decoders / graycode / pd.py
index f500c8393bc77013ddc141e2d825be741b5fdfbf..055908c8a4f3bfac7fbf1a31c3419b246581312f 100644 (file)
@@ -77,10 +77,11 @@ class Decoder(srd.Decoder):
     id = 'graycode'
     name = 'Gray code'
     longname = 'Gray code and rotary encoder'
-    desc = 'Accumulate rotary encoder increments, provide timing statistics.'
+    desc = 'Accumulate rotary encoder increments, provide statistics.'
     license = 'gplv2+'
     inputs = ['logic']
-    outputs = ['graycode']
+    outputs = []
+    tags = ['Encoding']
     optional_channels = tuple(
         {'id': 'd{}'.format(i), 'name': 'D{}'.format(i), 'desc': 'Data line {}'.format(i)}
         for i in range(MAX_CHANNELS)
@@ -101,6 +102,9 @@ class Decoder(srd.Decoder):
     annotation_rows = tuple((u, v, (i,)) for i, (u, v) in enumerate(annotations))
 
     def __init__(self):
+        self.reset()
+
+    def reset(self):
         self.num_channels = 0
         self.samplerate = None
         self.last_n = deque()
@@ -172,7 +176,7 @@ class Decoder(srd.Decoder):
             if self.options['edges']:
                 self.turns.set(self.samplenum, self.count.get() // self.options['edges'])
 
-            if self.samplerate is not None:
+            if self.samplerate:
                 period = (curtime - prevtime) / self.samplerate
                 freq = abs(phasedelta_raw) / period