diff options
author | Gerhard Sittig <gerhard.sittig@gmx.net> | 2018-06-12 19:06:15 +0200 |
---|---|---|
committer | Soeren Apel <soeren@apelpie.net> | 2018-08-11 23:17:22 +0200 |
commit | e663ab183cc55fbff23da01c0fda06d366b7130b (patch) | |
tree | 41dcb82d028198d6c008513b16386755f98cf9d3 | |
parent | 389d21d222a503b9f5f43404ced4b10813008b3a (diff) | |
download | libsigrokdecode-e663ab183cc55fbff23da01c0fda06d366b7130b.tar.gz libsigrokdecode-e663ab183cc55fbff23da01c0fda06d366b7130b.zip |
counter: add support for user specified initial counter values
Introduce options for the initial edge and word counter values. Default
to 0 for compatibility with the previous implementation. This fixes
bug #1229.
-rw-r--r-- | decoders/counter/pd.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/decoders/counter/pd.py b/decoders/counter/pd.py index 798fb3a..b8811e5 100644 --- a/decoders/counter/pd.py +++ b/decoders/counter/pd.py @@ -53,6 +53,8 @@ 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': 'Initial edge counter value', 'default': 0}, + {'id': 'word_off', 'desc': 'Initial word counter value', 'default': 0}, ) def __init__(self): @@ -86,9 +88,9 @@ 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 while True: self.wait(condition) |