def decode(self):
- # Get the first rising edge.
- pin, = self.wait({0: 'e'})
- if pin != self.startedge:
- pin, = self.wait({0: 'e'})
+ # Wait for an "active" edge (depends on config).
+ self.wait({0: 'f' if self.startedge == 0 else 'r'})
self.first_samplenum = self.samplenum
self.start_samplenum = self.samplenum
pin, = self.wait({0: 'e'})
if pin == self.startedge:
- # Rising edge
+ # Active edge
# We are on a full cycle we can calculate
# the period, the duty cycle and its ratio.
period = self.samplenum - self.start_samplenum
self.put(self.first_samplenum, self.es_block, self.out_average,
float(self.average / self.num_cycles))
else:
- # Falling edge
+ # Non-active edge
self.end_samplenum = self.ss_block = self.samplenum