]> sigrok.org Git - libsigrokdecode.git/commitdiff
counter: add support for user specified initial counter values
authorGerhard Sittig <redacted>
Tue, 12 Jun 2018 17:06:15 +0000 (19:06 +0200)
committerSoeren Apel <redacted>
Sat, 11 Aug 2018 21:17:22 +0000 (23:17 +0200)
Introduce options for the initial edge and word counter values. Default
to 0 for compatibility with the previous implementation. This fixes
bug #1229.

decoders/counter/pd.py

index 798fb3a7fc8aa2b4cbc15cc1bed26949ac37c975..b8811e589bdf89e58ae8748435b536016f490be9 100644 (file)
@@ -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': '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):
     )
 
     def __init__(self):
@@ -86,9 +88,9 @@ class Decoder(srd.Decoder):
             cond_reset = len(condition)
             condition.append({PIN_RESET: opt_edge_map[reset_edge]})
 
             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
         edge_start = None
-        word_count = 0
+        word_count = int(self.options['word_off'])
         word_start = None
         while True:
             self.wait(condition)
         word_start = None
         while True:
             self.wait(condition)