The previous implementation used the fact that libsigrok's internal API
happens to use the first letter of the user visible English option text.
Two locations mapped edge choices to API literals in different ways.
Unify them, introduce an explicit option text to literal value mapping.
(Many if not all decoder implementations do that. More adjustment to use
common code could be beneficial.)
self.put(self.samplenum, self.samplenum, self.out_ann, [cls, annlist])
def decode(self):
- condition = [{'rising': {0: 'r'},
- 'falling': {0: 'f'},
- 'any': {0: 'e'},}[self.edge]]
+ opt_edge_map = {'rising': 'r', 'falling': 'f', 'any': 'e'}
+
+ condition = [{0: opt_edge_map[self.edge]}]
if self.has_channel(1):
self.have_reset = True
- condition.append({1: self.options['reset_edge'][0]})
+ condition.append({1: opt_edge_map[self.options['reset_edge']]})
while True:
self.wait(condition)