> As I'm currently facing unrelated problems ([2] and somethign more) with
> my Hantek oscilloscope, I'd appreciate if this were tested on known-good
> data before merging.

With most of that resolved, I could finally test this, and things do
look fine. especially in the presence of artificail delays between bits
(which the SK6812 manage to decode, sources say the same is true for
WS2812, and with the patch also sigrok manages).

Seeing that also the timings produced by the LEDs vary a great deal,
this second patch adds a timing parameter that can be configured (and
defaults to what was hard-coded in the first patch). It is also pushed
to [1] as before.

BR
chrysn

[1]: https://codeberg.org/chrysn-pull-requests/libsigrokdecode

---

From aeea278dac6b17170a5628871d323ed39fa757c1 Mon Sep 17 00:00:00 2001
From: chrysn <chr...@fsfe.org>
Date: Thu, 17 Aug 2023 12:52:38 +0200
Subject: [PATCH] rgb_led_ws281x: Introduce timing parameter

Different LED strips have different timing requirements. While the
default is likely good for perfectly to-spec generators, this allows
decoding signals the way a particular LED would decode them.
---
 decoders/rgb_led_ws281x/pd.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/decoders/rgb_led_ws281x/pd.py b/decoders/rgb_led_ws281x/pd.py
index 486834e..33d8cf1 100644
--- a/decoders/rgb_led_ws281x/pd.py
+++ b/decoders/rgb_led_ws281x/pd.py
@@ -92,6 +92,9 @@ class Decoder(srd.Decoder):
          'values': ('BGR', 'BRG', 'GBR', 'GRB', 'RBG', 'RGB', 'RWBG', 'RGBW')},
         {'id': 'textorder', 'desc': 'components output order (text)',
          'default': 'RGB[W]', 'values': ('wire', 'RGB[W]', 'RGB', 'RGBW', 
'RGWB')},
+        {'id': 't01h', 'desc': 'Minimum length of bit 1 (in ns)',
+         # 480 is between the T0H upper bound (380ns) and the T1H lower bound 
(580ns)
+         'default': 480},
     )
 
     def __init__(self):
@@ -107,8 +110,7 @@ def start(self):
     def metadata(self, key, value):
         if key == srd.SRD_CONF_SAMPLERATE:
             self.samplerate = value
-            # Number of ticks that represent 480ns, which is a value between 
the T0H upper bound (380ns) and the T1H lower bound (580ns)
-            self.t1h_threshold = 480e-9 * self.samplerate
+            self.t1h_threshold = self.options['t01h'] * 1e-9 * self.samplerate
 
     def putg(self, ss, es, cls, text):
         self.put(ss, es, self.out_ann, [cls, text])
-- 
2.40.1

Attachment: signature.asc
Description: PGP signature

_______________________________________________
sigrok-devel mailing list
sigrok-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to