From: BenediktO Date: Sat, 30 Nov 2019 17:57:32 +0000 (+0100) Subject: ir_rc5: improved performance X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=681bad2a4da0ba8c0c5fb76980cf8515e381750d;p=libsigrokdecode.git ir_rc5: improved performance --- diff --git a/decoders/ir_rc5/pd.py b/decoders/ir_rc5/pd.py index e18a90b..e1c47b6 100644 --- a/decoders/ir_rc5/pd.py +++ b/decoders/ir_rc5/pd.py @@ -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'