]> sigrok.org Git - libsigrokdecode.git/commitdiff
ir_rc5: improved performance
authorBenediktO <redacted>
Sat, 30 Nov 2019 17:57:32 +0000 (18:57 +0100)
committerUwe Hermann <redacted>
Sun, 1 Dec 2019 17:36:50 +0000 (18:36 +0100)
decoders/ir_rc5/pd.py

index e18a90bfae273be8de9d5cba7308734d26397856..e1c47b6b4eaef937676173250d774681cb9f1c04 100644 (file)
@@ -67,7 +67,7 @@ class Decoder(srd.Decoder):
 
     def start(self):
         self.out_ann = self.register(srd.OUTPUT_ANN)
-        self.old_ir = 1 if self.options['polarity'] == 'active-low' else 0
+        self.next_edge = 'l' if self.options['polarity'] == 'active-low' else 'h'
 
     def metadata(self, key, value):
         if key == srd.SRD_CONF_SAMPLERATE:
@@ -143,11 +143,7 @@ class Decoder(srd.Decoder):
             raise SamplerateError('Cannot decode without samplerate.')
         while True:
 
-            (self.ir,) = self.wait()
-
-            # Wait for any edge (rising or falling).
-            if self.old_ir == self.ir:
-                continue
+            (self.ir,) = self.wait({0: self.next_edge})
 
             # State machine.
             if self.state == 'IDLE':
@@ -155,7 +151,7 @@ class Decoder(srd.Decoder):
                 self.edges.append(self.samplenum)
                 self.bits.append([self.samplenum, bit])
                 self.state = 'MID1'
-                self.old_ir = self.ir
+                self.next_edge = 'l' if self.ir else 'h'
                 continue
             edge = self.edge_type()
             if edge == 'e':
@@ -184,4 +180,4 @@ class Decoder(srd.Decoder):
                 self.handle_bits()
                 self.reset_decoder_state()
 
-            self.old_ir = self.ir
+            self.next_edge = 'l' if self.ir else 'h'