From: Soeren Apel Date: Sat, 11 Aug 2018 21:14:45 +0000 (+0200) Subject: counter: Let user decide how to handle the initial dead_cycles state X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=commitdiff_plain;h=d52bd4f2ca95cf9e19e7a2a18543dacb0dd2edfe counter: Let user decide how to handle the initial dead_cycles state edge_off and word_off are not included in the if block because a user may want to use edge_off to dismiss unwanted clocks instead of dead_cycles. --- diff --git a/decoders/counter/pd.py b/decoders/counter/pd.py index c6eac0e..27a2be8 100644 --- a/decoders/counter/pd.py +++ b/decoders/counter/pd.py @@ -56,6 +56,8 @@ class Decoder(srd.Decoder): {'id': 'edge_off', 'desc': 'Edge counter value after start/reset', 'default': 0}, {'id': 'word_off', 'desc': 'Word counter value after start/reset', 'default': 0}, {'id': 'dead_cycles', 'desc': 'Ignore this many edges after reset', 'default': 0}, + {'id': 'start_with_reset', 'desc': 'Assume decode starts with reset', + 'default': 'no', 'values': ('no', 'yes')}, ) def __init__(self): @@ -93,7 +95,12 @@ class Decoder(srd.Decoder): edge_start = None word_count = int(self.options['word_off']) word_start = None - dead_count = 0 + + if self.options['start_with_reset'] == 'yes': + dead_count = int(self.options['dead_cycles']) + else: + dead_count = 0 + while True: self.wait(condition) now = self.samplenum