]> sigrok.org Git - libsigrokdecode.git/commitdiff
seven_segment: add option to display unknown characters
authorBen Gardiner <redacted>
Sun, 22 Nov 2020 20:40:44 +0000 (20:40 +0000)
committerBen Gardiner <redacted>
Sun, 22 Nov 2020 20:40:57 +0000 (20:40 +0000)
option show_unknown=yes will display unknown 7-segment characters as
an octothorpe ('#').

Signed-off-by: Ben Gardiner <redacted>
decoders/seven_segment/pd.py

index 87714bbcd81483df06817f9aa374c0b31d2bd293..eedacf93e3b2d7a9460fae3405036f64484cfb97 100644 (file)
@@ -67,6 +67,8 @@ class Decoder(srd.Decoder):
     options = (
         {'id': 'polarity', 'desc': 'Expected polarity',
             'default': 'common-cathode', 'values': ('common-cathode', 'common-anode')},
     options = (
         {'id': 'polarity', 'desc': 'Expected polarity',
             'default': 'common-cathode', 'values': ('common-cathode', 'common-anode')},
+        {'id': 'show_unknown', 'desc': 'Display Unknown characters as #',
+            'default': 'no', 'values': ('yes', 'no')},
     )
     annotations = (
         ('decoded-digit', 'Decoded digit'),
     )
     annotations = (
         ('decoded-digit', 'Decoded digit'),
@@ -120,6 +122,9 @@ class Decoder(srd.Decoder):
             # Convert to character string.
             digit = self.pins_to_hex(oldpins[:7])
 
             # Convert to character string.
             digit = self.pins_to_hex(oldpins[:7])
 
+            if digit is None and self.options['show_unknown'] == 'yes':
+                digit = '#'
+
             if digit is not None:
                 dp = oldpins[7]
 
             if digit is not None:
                 dp = oldpins[7]