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'),
self.put(ss_block, es_block, self.out_ann, data)
def pins_to_hex(self, pins):
- if pins in digits:
- return digits[pins]
- else:
- return None
+ return digits.get(pins, None)
def decode(self):
oldpins = self.wait()
# 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]
# Check if decimal point is present and active.
- if self.have_dp:
- if dp == 1:
- digit = digit + '.'
+ if self.have_dp and dp == 1:
+ digit += '.'
self.putb(lastpos, self.samplenum, [0, [digit]])