def showQR():
global rpc_connection
print "Loading 2nd bitcoin address..."
# connect to node and get new wallet address
try:
addr = rpc_connection.getnewaddress()
except (socket.error, httplib.CannotSendRequest):
print "showQR Timeout"
initRPC()
return False
# bypass rpc for testing
#addr = '1CepbXDXPeJTsk9PUUKkXwfqcyDgmo1qoE'
# generate QR code and display on LED grid
code = pyqrcode.create(addr, error='M', version=3)
t = code.text(1)
print addr
# print the actual QR code to terminal with 1's and 0's
print t
row = 31
col = 0
matrix.Clear()
for i in t:
if i != '\n':
matrix.SetPixel(row, col, 255-int(i)*255, 255-int(i)*255, 255-int(i)*255)
col += 1
else:
row -= 1
col = 0
time.sleep(0.001)
# give us a chance to scan it
time.sleep(5)
return True
评论列表
文章目录