]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/nunchuk/pd.py
Probes, optional probes and annotations now take a tuple.
[libsigrokdecode.git] / decoders / nunchuk / pd.py
index b272338571eab45d0bd6722050b7fbcc4700476c..dfe9abe4e0a0d78a0fc4e03ccabc64a1f3ab0eee 100644 (file)
@@ -18,8 +18,6 @@
 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 ##
 
-# Nintendo Wii Nunchuk protocol decoder
-
 import sigrokdecode as srd
 
 class Decoder(srd.Decoder):
@@ -31,14 +29,11 @@ class Decoder(srd.Decoder):
     license = 'gplv2+'
     inputs = ['i2c']
     outputs = ['nunchuck']
-    probes = []
-    optional_probes = []
-    options = {}
-    annotations = [
-        ['Text (verbose)', 'Human-readable text (verbose)'],
-        ['Text', 'Human-readable text'],
-        ['Warnings', 'Human-readable warnings'],
-    ]
+    annotations = (
+        ('text-verbose', 'Human-readable text (verbose)'),
+        ('text', 'Human-readable text'),
+        ('warnings', 'Human-readable warnings'),
+    )
 
     def __init__(self, **kwargs):
         self.state = 'IDLE'
@@ -48,18 +43,15 @@ class Decoder(srd.Decoder):
         self.init_seq = []
 
     def start(self):
-        # self.out_proto = self.add(srd.OUTPUT_PROTO, 'nunchuk')
-        self.out_ann = self.add(srd.OUTPUT_ANN, 'nunchuk')
-
-    def report(self):
-        pass
+        # self.out_python = self.register(srd.OUTPUT_PYTHON)
+        self.out_ann = self.register(srd.OUTPUT_ANN)
 
     def putx(self, data):
-        # Helper for annotations which span exactly one I2C packet.
+        # Helper for annotations which span exactly one I²C packet.
         self.put(self.ss, self.es, self.out_ann, data)
 
     def putb(self, data):
-        # Helper for annotations which span a block of I2C packets.
+        # Helper for annotations which span a block of I²C packets.
         self.put(self.block_start_sample, self.block_end_sample,
                  self.out_ann, data)
 
@@ -160,12 +152,12 @@ class Decoder(srd.Decoder):
     def decode(self, ss, es, data):
         cmd, databyte = data
 
-        # Store the start/end samples of this I2C packet.
+        # Store the start/end samples of this I²C packet.
         self.ss, self.es = ss, es
 
         # State machine.
         if self.state == 'IDLE':
-            # Wait for an I2C START condition.
+            # Wait for an I²C START condition.
             if cmd != 'START':
                 return
             self.state = 'GET SLAVE ADDR'