summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2017-06-15 21:33:56 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2017-06-15 21:34:35 +0200
commit2dda726be82e97887b8c3958d5a54dd9125265ad (patch)
tree568f99fb51a793d90bd3e14ef30b4d86724fdc4c
parent23e806c21e6e01999163c892635c6dea9d788daa (diff)
downloadlibsigrokdecode-2dda726be82e97887b8c3958d5a54dd9125265ad.tar.gz
libsigrokdecode-2dda726be82e97887b8c3958d5a54dd9125265ad.zip
pwm: Simplify waiting for initial edge.
-rw-r--r--decoders/pwm/pd.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/decoders/pwm/pd.py b/decoders/pwm/pd.py
index 0b7be45..5822f32 100644
--- a/decoders/pwm/pd.py
+++ b/decoders/pwm/pd.py
@@ -93,10 +93,8 @@ class Decoder(srd.Decoder):
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
@@ -105,7 +103,7 @@ class Decoder(srd.Decoder):
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
@@ -135,5 +133,5 @@ class Decoder(srd.Decoder):
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