From: Uwe Hermann Date: Wed, 3 Jan 2018 16:20:49 +0000 (+0100) Subject: counter: Make "word reset" an explicit annotation class+row. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=42dcd8ef08cadaa870efa71f2df7650d4e4c24a6;p=libsigrokdecode.git counter: Make "word reset" an explicit annotation class+row. Also, add long and short annotation string versions. --- 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)])