From: Gerhard Sittig Date: Sun, 27 May 2018 07:06:48 +0000 (+0200) Subject: counter: explicit option text to .wait() edge mapping X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d11290fef0450c4f9b1c0f14d7c203de6ee02695;p=libsigrokdecode.git 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.) --- 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)