X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoders%2Fnunchuk.py;h=bda374522e43bce637597b98a67dceaff659c055;hp=d3ae8714d17c42e82481f70d9d871fc8aa6f30f3;hb=2b9837d9fc5f9b4eca52327527e18db4bfb730ff;hpb=2fd89a85c4a1131ca259d794a43b26b8bd84b6a0 diff --git a/decoders/nunchuk.py b/decoders/nunchuk.py index d3ae871..bda3745 100644 --- a/decoders/nunchuk.py +++ b/decoders/nunchuk.py @@ -30,7 +30,7 @@ # https://www.sparkfun.com/products/9281 # -import sigrokdecode +import sigrokdecode as srd # States IDLE = 0 @@ -62,7 +62,7 @@ example_packets = [ {'type': 'P', 'range': (32, 33), 'data': None, 'ann': ''}, ] -class Decoder(sigrokdecode.Decoder): +class Decoder(srd.Decoder): id = 'nunchuk' name = 'Nunchuk' longname = 'Nintendo Wii Nunchuk decoder' @@ -75,11 +75,9 @@ class Decoder(sigrokdecode.Decoder): outputs = ['nunchuck'] probes = [] # TODO options = {} + annotations = [] def __init__(self, **kwargs): - self.output_protocol = None - self.output_annotation = None - self.state = IDLE # TODO: Can we assume a certain initial state? self.sx = self.sy = self.ax = self.ay = self.az = self.bz = self.bc = 0 @@ -87,13 +85,13 @@ class Decoder(sigrokdecode.Decoder): self.databytecount = 0 def start(self, metadata): - # self.output_protocol = self.add(2) - self.output_annotation = self.add(1) + # self.out_proto = self.add(srd.OUTPUT_PROTO, 'nunchuk') + self.out_ann = self.add(srd.OUTPUT_ANN, 'nunchuk') def report(self): pass - def decode(self, timeoffset, duration, data): + def decode(self, ss, es, data): out = [] o = {} @@ -172,6 +170,6 @@ class Decoder(sigrokdecode.Decoder): self.databytecount = 0 if out != []: - # self.put(0, 0, self.output_protocol, out_proto) - self.put(0, 0, self.output_annotation, out) + # self.put(0, 0, self.out_proto, out_proto) + self.put(0, 0, self.out_ann, out)