projects
/
libsigrokdecode.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
eb7082c
)
srd: i2c: Use short-form if-else Python idiom.
author
Uwe Hermann
<uwe@hermann-uwe.de>
Thu, 12 Jan 2012 20:57:51 +0000
(21:57 +0100)
committer
Uwe Hermann
<uwe@hermann-uwe.de>
Thu, 12 Jan 2012 21:31:11 +0000
(22:31 +0100)
decoders/i2c.py
patch
|
blob
|
history
diff --git
a/decoders/i2c.py
b/decoders/i2c.py
index edaeb9487b7c782c2479c2168ea5028907fd30d1..15ef9c617dfb1526f6baf17914d71f2eca578cd5 100644
(file)
--- a/
decoders/i2c.py
+++ b/
decoders/i2c.py
@@
-183,10
+183,7
@@
class Decoder(srd.Decoder):
return False
def found_start(self, scl, sda):
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]]])
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.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
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).
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'
if self.state == FIND_ADDRESS and self.wr == 1:
cmd = 'ADDRESS_WRITE'