summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerhard Sittig <gerhard.sittig@gmx.net>2017-01-15 11:09:45 +0100
committerUwe Hermann <uwe@hermann-uwe.de>2017-01-18 12:38:23 +0100
commitd9135fe1d8982160e2b8283120a07ade7b9e0566 (patch)
treec0f05e10b8a740deebef4c117901f1a4a567c7d3
parent6c0a0f6177b3de5df9d8a21549f2702d2d04733a (diff)
downloadlibsigrokdecode-d9135fe1d8982160e2b8283120a07ade7b9e0566.tar.gz
libsigrokdecode-d9135fe1d8982160e2b8283120a07ade7b9e0566.zip
qi: Convert to PD API version 3
-rw-r--r--decoders/qi/pd.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/decoders/qi/pd.py b/decoders/qi/pd.py
index 1f7659d..9782ee5 100644
--- a/decoders/qi/pd.py
+++ b/decoders/qi/pd.py
@@ -45,7 +45,7 @@ def bits_to_uint(bits):
return reduce(lambda i, v: (i >> 1) | (v << (len(bits) - 1)), bits, 0)
class Decoder(srd.Decoder):
- api_version = 2
+ api_version = 3
id = 'qi'
name = 'Qi'
longname = 'Qi charger protocol'
@@ -228,16 +228,13 @@ class Decoder(srd.Decoder):
self.bits.clear()
self.bitsi.clear()
- def next_sample(self, s):
- if s == self.prev:
- self.counter += 1
- else:
- self.handle_transition(self.counter, s == 0)
- self.prev = s
- self.counter = 1
-
- def decode(self, ss, es, data):
+ def decode(self):
if not self.samplerate:
raise SamplerateError('Cannot decode without samplerate.')
- for (self.samplenum, (qi,)) in data:
- self.next_sample(qi)
+
+ (qi,) = self.wait({'skip': 1})
+ self.handle_transition(self.samplenum, qi == 0)
+ while True:
+ prev = self.samplenum
+ (qi,) = self.wait({0: 'e'})
+ self.handle_transition(self.samplenum - prev, qi == 0)