From fd706b63bcc7e42b54822a227d79b5e6d7ccbccc Mon Sep 17 00:00:00 2001 From: yunyaobaihong <896458252@qq.com> Date: Mon, 15 May 2023 17:22:01 +0800 Subject: [PATCH] decoder repair : rgb_led_ws281x can't decoder last bit --- .../decoders/rgb_led_ws281x/pd.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libsigrokdecode4DSL/decoders/rgb_led_ws281x/pd.py b/libsigrokdecode4DSL/decoders/rgb_led_ws281x/pd.py index 17ccf047..92793ec8 100644 --- a/libsigrokdecode4DSL/decoders/rgb_led_ws281x/pd.py +++ b/libsigrokdecode4DSL/decoders/rgb_led_ws281x/pd.py @@ -162,6 +162,14 @@ class Decoder(srd.Decoder): # Ideal duty for T0H: 33%, T1H: 66%. self.bit_ = (tH_samples / period) > 0.5 + def end(self): + if self.state == 'BIT FALLING': + self.check_bit_(self.last_samplenum) + self.put(self.ss, self.es, self.out_ann, + [0, ['%d' % self.bit_]]) + self.bits.append(self.bit_) + self.handle_bits(self.es) + def decode(self): if not self.samplerate: @@ -185,7 +193,9 @@ class Decoder(srd.Decoder): self.ss = self.samplenum self.ss_packet = self.samplenum self.wait({0: 'e'}) + self.state = 'BIT FALLING' + elif self.state == 'RESET': self.put(self.ss, self.es, self.out_ann, [1, ['RESET', 'RST', 'R']]) self.bits = [] @@ -193,13 +203,17 @@ class Decoder(srd.Decoder): self.ss_packet = self.samplenum self.wait({0: 'e'}) self.state = 'BIT FALLING' + elif self.state == 'BIT FALLING': self.es = self.samplenum self.wait({0: 'e'}) + if ((self.samplenum - self.es) / self.samplerate > 50e-6): self.check_bit_(self.samplenum) + self.put(self.ss, self.es, self.out_ann, - [0, ['%d' % self.bit_]]) + [0, ['%d' % self.bit_]]) + self.bits.append(self.bit_) self.handle_bits(self.es) @@ -208,6 +222,7 @@ class Decoder(srd.Decoder): self.state = 'RESET' else: self.state = 'BIT RISING' + elif self.state == 'BIT RISING': self.check_bit_(self.samplenum) self.put(self.ss, self.samplenum, self.out_ann,