X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoders%2Fcounter%2Fpd.py;h=27a2be88dc07934f9eed9a33a90ddc121c5d7c70;hp=bb55fa7d060ae4efdaa533ce6630b6176f6aadfa;hb=d52bd4f2ca95cf9e19e7a2a18543dacb0dd2edfe;hpb=17869208b8cc79e1ff6bd003b9a64e1b6f07a140 diff --git a/decoders/counter/pd.py b/decoders/counter/pd.py index bb55fa7..27a2be8 100644 --- a/decoders/counter/pd.py +++ b/decoders/counter/pd.py @@ -19,8 +19,8 @@ import sigrokdecode as srd -(PIN_DATA, PIN_RESET) = range(2) -(ROW_EDGE, ROW_WORD, ROW_RESET) = range(3) +PIN_DATA, PIN_RESET = range(2) +ROW_EDGE, ROW_WORD, ROW_RESET = range(3) class Decoder(srd.Decoder): api_version = 3 @@ -53,6 +53,11 @@ class Decoder(srd.Decoder): {'id': 'divider', 'desc': 'Count divider (word width)', 'default': 0}, {'id': 'reset_edge', 'desc': 'Edge which clears counters (reset)', 'default': 'falling', 'values': ('rising', 'falling')}, + {'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): @@ -86,20 +91,33 @@ class Decoder(srd.Decoder): cond_reset = len(condition) condition.append({PIN_RESET: opt_edge_map[reset_edge]}) - edge_count = 0 + edge_count = int(self.options['edge_off']) edge_start = None - word_count = 0 + word_count = int(self.options['word_off']) word_start = None + + 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 if have_reset and self.matched[cond_reset]: - edge_count = 0 + edge_count = int(self.options['edge_off']) edge_start = now - word_count = 0 + word_count = int(self.options['word_off']) word_start = now self.putc(ROW_RESET, now, ['Word reset', 'Reset', 'Rst', 'R']) + dead_count = int(self.options['dead_cycles']) + continue + + if dead_count: + dead_count -= 1 + edge_start = now + word_start = now continue # Implementation note: In the absence of a RESET condition