From: Uwe Hermann Date: Mon, 28 May 2012 12:17:55 +0000 (+0200) Subject: srd: nunchuk: Add verbose summary annotation. X-Git-Tag: libsigrokdecode-0.1.1~97 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d628cdb521159d600cb19a3cd04eec28e07d9220;p=libsigrokdecode.git srd: nunchuk: Add verbose summary annotation. --- diff --git a/decoders/nunchuk/nunchuk.py b/decoders/nunchuk/nunchuk.py index 8472a3d..a3fdf77 100644 --- a/decoders/nunchuk/nunchuk.py +++ b/decoders/nunchuk/nunchuk.py @@ -110,18 +110,26 @@ class Decoder(srd.Decoder): self.putx([1, ['AZ[1:0]: 0x%x' % az_rest]]) def output_full_block_if_possible(self): - # For now, only output summary annotation if all values are available. t = (self.sx, self.sy, self.ax, self.ay, self.az, self.bz, self.bc) if -1 in t: return - # Note: Only works if host reads _all_ regs (0x00 - 0x05). - d = 'SX = 0x%02x, SY = 0x%02x, AX = 0x%02x, AY = 0x%02x, ' \ + s = 'Analog stick X position: 0x%02x\n' % self.sx + s += 'Analog stick Y position: 0x%02x\n' % self.sy + s += 'Z button: %spressed\n' % ('' if (self.bz == 0) else 'not ') + s += 'C button: %spressed\n' % ('' if (self.bc == 0) else 'not ') + s += 'Accelerometer X value: 0x%03x\n' % self.ax + s += 'Accelerometer Y value: 0x%03x\n' % self.ay + s += 'Accelerometer Z value: 0x%03x\n' % self.az + self.put(self.block_start_sample, self.block_end_sample, + self.out_ann, [0, [s]]) + + s = 'SX = 0x%02x, SY = 0x%02x, AX = 0x%02x, AY = 0x%02x, ' \ 'AZ = 0x%02x, BZ = 0x%02x, BC = 0x%02x' % (self.sx, \ self.sy, self.ax, self.ay, self.az, self.bz, self.bc) self.put(self.block_start_sample, self.block_end_sample, - self.out_ann, [0, [d]]) + self.out_ann, [1, [s]]) def decode(self, ss, es, data): cmd, databyte = data @@ -148,12 +156,9 @@ class Decoder(srd.Decoder): self.reg += 1 elif cmd == 'STOP': self.block_end_sample = es - self.output_full_block_if_possible() - self.sx = self.sy = self.ax = self.ay = self.az = -1 self.bz = self.bc = -1 - self.state = 'IDLE' else: # self.putx([0, ['Ignoring: %s (data=%s)' % (cmd, databyte)]])