From: Uwe Hermann Date: Sun, 8 Apr 2018 16:55:08 +0000 (+0200) Subject: rc_encode: Add self.putx() helper. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3a843174bf6d0d178f39a7cd0d443a051f4e9a95;p=libsigrokdecode.git rc_encode: Add self.putx() helper. --- diff --git a/decoders/rc_encode/pd.py b/decoders/rc_encode/pd.py index b0dda1f..1c1f579 100644 --- a/decoders/rc_encode/pd.py +++ b/decoders/rc_encode/pd.py @@ -113,6 +113,9 @@ class Decoder(srd.Decoder): self.out_ann = self.register(srd.OUTPUT_ANN) self.model = self.options['remote'] + def putx(self, data): + self.put(self.ss, self.es, self.out_ann, data) + def decode(self): while True: pin = self.wait({0: 'e'}) @@ -134,10 +137,8 @@ class Decoder(srd.Decoder): self.es = self.samplenum self.bits.append([decode_bit(self.pulses), self.ss, self.es]) # Save states and times. - self.put(self.ss, self.es, self.out_ann, - [0, [decode_bit(self.pulses)]]) # Write decoded bit. - self.put(self.ss, self.es, self.out_ann, - [1, [pinlabels(self.bit_count)]]) # Write pin labels. + self.putx([0, [decode_bit(self.pulses)]]) # Write decoded bit. + self.putx([1, [pinlabels(self.bit_count)]]) # Write pin labels. self.pulses = [] self.ss = self.samplenum else: @@ -150,8 +151,7 @@ class Decoder(srd.Decoder): samples = self.samplenum - self.samplenumber_last pin = self.wait({'skip': 8 * samples}) # Wait for end of sync bit. self.es = self.samplenum - self.put(self.ss, self.es, self.out_ann, - [0, ['Sync']]) # Write sync label. + self.putx([0, ['Sync']]) # Write sync label. self.reset() # Reset and wait for next set of pulses. self.state = 'DECODE_TIMEOUT' if not self.state == 'DECODE_TIMEOUT':