所以我对并行端口很陌生,我一直在这里研究这段代码->> http://pyserial.svn.sourceforge.net/viewvc/pyserial/trunk/pyparallel/examples/lcd.py?revision=49&view =标记
我对这里发生的事情感到困惑
def reveseout(self, x):
r = ((x & (1<<0) and 1) << 7) |\
((x & (1<<1) and 1) << 6) |\
((x & (1<<2) and 1) << 5) |\
((x & (1<<3) and 1) << 4) |\
((x & (1<<4) and 1) << 3) |\
((x & (1<<5) and 1) << 2) |\
((x & (1<<6) and 1) << 1) |\
((x & (1<<7) and 1) << 0)
#print "%02x" % r, "%02x" %x
self.p.setData(r)
我知道这是反转引脚,但我不理解语法本身以及它的字面意思。
任何帮助将不胜感激谢谢!