summaryrefslogtreecommitdiff
path: root/decoders/counter
diff options
context:
space:
mode:
authorSoeren Apel <soeren@apelpie.net>2018-08-11 23:14:45 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2018-08-30 11:56:35 +0200
commitd52bd4f2ca95cf9e19e7a2a18543dacb0dd2edfe (patch)
tree5ab46f28d778dd93af2452c908aaf44af8c8ee77 /decoders/counter
parent547b79f4b936b35285aed6e3e051ff5d55ffc40a (diff)
downloadlibsigrokdecode-d52bd4f2ca95cf9e19e7a2a18543dacb0dd2edfe.tar.gz
libsigrokdecode-d52bd4f2ca95cf9e19e7a2a18543dacb0dd2edfe.zip
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.
Diffstat (limited to 'decoders/counter')
-rw-r--r--decoders/counter/pd.py9
1 files changed, 8 insertions, 1 deletions
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