From d11290fef0450c4f9b1c0f14d7c203de6ee02695 Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Sun, 27 May 2018 09:06:48 +0200 Subject: [PATCH] counter: explicit option text to .wait() edge mapping The previous implementation used the fact that libsigrok's internal API happens to use the first letter of the user visible English option text. Two locations mapped edge choices to API literals in different ways. Unify them, introduce an explicit option text to literal value mapping. (Many if not all decoder implementations do that. More adjustment to use common code could be beneficial.) --- decoders/counter/pd.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/decoders/counter/pd.py b/decoders/counter/pd.py index cbb6a5f..6dd8d91 100644 --- a/decoders/counter/pd.py +++ b/decoders/counter/pd.py @@ -75,13 +75,13 @@ class Decoder(srd.Decoder): self.put(self.samplenum, self.samplenum, self.out_ann, [cls, annlist]) def decode(self): - condition = [{'rising': {0: 'r'}, - 'falling': {0: 'f'}, - 'any': {0: 'e'},}[self.edge]] + opt_edge_map = {'rising': 'r', 'falling': 'f', 'any': 'e'} + + condition = [{0: opt_edge_map[self.edge]}] if self.has_channel(1): self.have_reset = True - condition.append({1: self.options['reset_edge'][0]}) + condition.append({1: opt_edge_map[self.options['reset_edge']]}) while True: self.wait(condition) -- 2.30.2