diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2012-01-12 21:57:51 +0100 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2012-01-12 22:31:11 +0100 |
commit | bf1c3f4db0ffbc05f29f81541c551c691ccd2ba7 (patch) | |
tree | c992cf229fdfa2d4f7df9bb07b90bbfa3f945c0d /decoders | |
parent | eb7082c98efad727d88e3ebeadcd496fa948475b (diff) | |
download | libsigrokdecode-bf1c3f4db0ffbc05f29f81541c551c691ccd2ba7.tar.gz libsigrokdecode-bf1c3f4db0ffbc05f29f81541c551c691ccd2ba7.zip |
srd: i2c: Use short-form if-else Python idiom.
Diffstat (limited to 'decoders')
-rw-r--r-- | decoders/i2c.py | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/decoders/i2c.py b/decoders/i2c.py index edaeb94..15ef9c6 100644 --- a/decoders/i2c.py +++ b/decoders/i2c.py @@ -183,10 +183,7 @@ class Decoder(srd.Decoder): return False def found_start(self, scl, sda): - if self.is_repeat_start == 1: - cmd = 'START_REPEAT' - else: - cmd = 'START' + cmd = 'START_REPEAT' if (self.is_repeat_start == 1) else 'START' self.put(self.out_proto, [cmd, None, None]) self.put(self.out_ann, [ANN_SHIFTED, [protocol[cmd][0]]]) @@ -222,10 +219,7 @@ class Decoder(srd.Decoder): if self.state == FIND_ADDRESS: # The READ/WRITE bit is only in address bytes, not data bytes. - if self.databyte & 1: - self.wr = 0 - else: - self.wr = 1 + self.wr = 0 if (self.databyte & 1) else 1 d = self.databyte >> 1 elif self.state == FIND_DATA: d = self.databyte @@ -234,10 +228,7 @@ class Decoder(srd.Decoder): pass # Last bit that came in was the ACK/NACK bit (1 = NACK). - if sda == 1: - ack_bit = 'NACK' - else: - ack_bit = 'ACK' + ack_bit = 'NACK' if (sda == 1) else 'ACK' if self.state == FIND_ADDRESS and self.wr == 1: cmd = 'ADDRESS_WRITE' |