qr.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:ClockBlocker 作者: pinheadmz 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号