diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2012-05-28 14:17:55 +0200 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2012-05-31 00:55:38 +0200 |
commit | d628cdb521159d600cb19a3cd04eec28e07d9220 (patch) | |
tree | 6acba48fc1ca7b8c860ab2fbb7d4c1b66675c529 | |
parent | 11860e5a81b1bf5e02b0a4f698b41cac5ede7a3e (diff) | |
download | libsigrokdecode-d628cdb521159d600cb19a3cd04eec28e07d9220.tar.gz libsigrokdecode-d628cdb521159d600cb19a3cd04eec28e07d9220.zip |
srd: nunchuk: Add verbose summary annotation.
-rw-r--r-- | decoders/nunchuk/nunchuk.py | 19 |
1 files changed, 12 insertions, 7 deletions
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)]]) |