]> sigrok.org Git - libsigrokdecode.git/commitdiff
stepper_motor: Convert to PD API version 3.
authorUwe Hermann <redacted>
Fri, 26 Aug 2016 13:19:54 +0000 (15:19 +0200)
committerUwe Hermann <redacted>
Wed, 7 Dec 2016 21:45:47 +0000 (22:45 +0100)
decoders/stepper_motor/pd.py

index 7664fc4290bc1836343ff633dc924af070acc37d..b6ff9b105960c0a269de6818970f7a6cb8ac2fc2 100644 (file)
@@ -24,7 +24,7 @@ class SamplerateError(Exception):
     pass
 
 class Decoder(srd.Decoder):
-    api_version = 2
+    api_version = 3
     id = 'stepper_motor'
     name = 'Stepper motor'
     longname = 'Stepper motor position / speed'
@@ -87,11 +87,9 @@ class Decoder(srd.Decoder):
         if key == srd.SRD_CONF_SAMPLERATE:
             self.samplerate = value
 
-    def decode(self, ss, es, data):
+    def decode(self):
         if not self.samplerate:
             raise SamplerateError('Cannot decode without samplerate.')
-
-        for (self.samplenum, (step, direction)) in data:
-            if step == 1 and self.oldstep == 0:
-                self.step(self.samplenum, direction)
-            self.oldstep = step
+        while True:
+            step, direction = self.wait({0: 'r'})
+            self.step(self.samplenum, direction)