summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2018-01-03 17:20:49 +0100
committerUwe Hermann <uwe@hermann-uwe.de>2018-01-03 17:35:26 +0100
commit42dcd8ef08cadaa870efa71f2df7650d4e4c24a6 (patch)
tree32f37aeee96fc6deea99bdbddec0cdb5aa1426b6 /decoders
parent6ca7aa50829904240ea07bcb7594c838ec467b98 (diff)
downloadlibsigrokdecode-42dcd8ef08cadaa870efa71f2df7650d4e4c24a6.tar.gz
libsigrokdecode-42dcd8ef08cadaa870efa71f2df7650d4e4c24a6.zip
counter: Make "word reset" an explicit annotation class+row.
Also, add long and short annotation string versions.
Diffstat (limited to 'decoders')
-rw-r--r--decoders/counter/pd.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/decoders/counter/pd.py b/decoders/counter/pd.py
index e32dabd..a028765 100644
--- a/decoders/counter/pd.py
+++ b/decoders/counter/pd.py
@@ -37,10 +37,12 @@ class Decoder(srd.Decoder):
annotations = (
('edge_count', 'Edge count'),
('word_count', 'Word count'),
+ ('word_reset', 'Word reset'),
)
annotation_rows = (
('edge_counts', 'Edges', (0,)),
('word_counts', 'Words', (1,)),
+ ('word_resets', 'Word resets', (2,)),
)
options = (
{'id': 'edge', 'desc': 'Edges to check', 'default': 'any', 'values': ('any', 'rising', 'falling')},
@@ -66,9 +68,8 @@ class Decoder(srd.Decoder):
if self.divider < 0:
self.divider = 0
- def put_count(self, ann_class, count):
- self.put(self.samplenum, self.samplenum, self.out_ann,
- [ann_class, [str(count)]])
+ def putc(self, cls, annlist):
+ self.put(self.samplenum, self.samplenum, self.out_ann, [cls, annlist])
def decode(self):
condition = [{'rising': {0: 'r'},
@@ -84,12 +85,12 @@ class Decoder(srd.Decoder):
if self.have_reset and self.matched[1]:
self.edge_count = 0
self.word_count = 0
- self.put_count(1, 'R')
+ self.putc(2, ['Word reset', 'Reset', 'Rst', 'R'])
continue
self.edge_count += 1
- self.put_count(0, self.edge_count)
+ self.putc(0, [str(self.edge_count)])
if self.divider > 0 and (self.edge_count % self.divider) == 0:
self.word_count += 1
- self.put_count(1, self.word_count)
+ self.putc(1, [str(self.word_count)])