]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/nunchuk.py
srd: Remove decode() docstrings.
[libsigrokdecode.git] / decoders / nunchuk.py
index 635a7143a4159b33542b3013c94ef83630e066a6..d33074740eb50b4fb1fdea8137e89cbb3cffd947 100644 (file)
@@ -66,7 +66,7 @@ class Sample():
     def __init__(self, data):
         self.data = data
     def probe(self, probe):
-        s = ord(self.data[probe / 8]) & (1 << (probe % 8))
+        s = self.data[int(probe / 8)] & (1 << (probe % 8))
         return True if s else False
 
 def sampleiter(data, unitsize):
@@ -89,6 +89,8 @@ class Decoder(sigrok.Decoder):
 
     def __init__(self, **kwargs):
         self.probes = Decoder.probes.copy()
+        self.output_protocol = None
+        self.output_annotation = None
 
         # TODO: Don't hardcode the number of channels.
         self.channels = 8
@@ -101,13 +103,13 @@ class Decoder(sigrok.Decoder):
 
     def start(self, metadata):
         self.unitsize = metadata['unitsize']
+        # self.output_protocol = self.output_new(2)
+        self.output_annotation = self.output_new(1)
 
     def report(self):
         pass
 
-    def decode(self, data):
-        """Nintendo Wii Nunchuk decoder"""
-
+    def decode(self, timeoffset, duration, data):
         out = []
         o = {}
 
@@ -186,5 +188,7 @@ class Decoder(sigrok.Decoder):
                 self.state = INITIALIZED
                 self.databytecount = 0
 
-        self.put(out)
+        if out != []:
+            # self.put(self.output_protocol, 0, 0, out_proto)
+            self.put(self.output_annotation, 0, 0, out)