Пример #1
0
def update_amount_screen():
    """Update the amount screen to reflect new coins inserted
    """
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle(
        (2, 2, width - 2, height - 2), fill=config.WHITE, outline=config.BLACK
    )
    draw.text(
        (13, 10),
        str(round(config.SATS)) + " sats",
        fill=config.BLACK,
        font=utils.create_font("freemono", 28),
    )
    draw.text(
        (11, 37),
        "(" + "%.2f" % round(config.FIAT, 2) + " " + config.CURRENCY + ")",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )
    draw.text(
        (11, 70),
        "(1 cent = " + str(round(config.SATPRICE)) + " sats)",
        fill=config.BLACK,
        font=utils.create_font("freemono", 14),
    )

    config.PAPIRUS.display(image)
    config.PAPIRUS.partial_update()
Пример #2
0
def update_payout_screen():
    """Update the payout screen to reflect balance of deposited coins.
    Scan the invoice??? I don't think so!
    Handle the invoice??? I also don't think so!
    """
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle(
        (2, 2, width - 2, height - 2), fill=config.WHITE, outline=config.BLACK
    )
    draw.text(
        (15, 30),
        str(round(config.SATS)) + " sats",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )
    draw.text(
        (15, 50),
        "on the way!",
        fill=config.BLACK,
        font=utils.create_font("freemono", 15),
    )

    config.PAPIRUS.display(image)
    config.PAPIRUS.update()

    # scan the invoice
    # TODO: I notice this is commented out, I presume this function should _not_ be
    #   scanning a QR code on each update?
    # config.INVOICE = qr.scan()

    # handle the invoice
    handle_invoice(draw, image)
Пример #3
0
def update_wallet_scan():
    # initially set all white background
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle(
        (2, 2, width - 2, height - 2), fill=config.WHITE, outline=config.BLACK
    )
    draw.text(
        (35, 20),
        "Please scan",
        fill=config.BLACK,
        font=utils.create_font("freemono", 18),
    )
    draw.text(
        (33, 40),
        "your wallet",
        fill=config.BLACK,
        font=utils.create_font("freemono", 18),
    )
    draw.text(
        (35, 60),
        "credentials.",
        fill=config.BLACK,
        font=utils.create_font("freemono", 18),
    )

    config.PAPIRUS.display(image)
    config.PAPIRUS.update()
    time.sleep(2)
Пример #4
0
def update_qr_failed():
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle((2, 2, width - 2, height - 2),
                   fill=config.WHITE,
                   outline=config.BLACK)
    draw.text(
        (25, 10),
        "Scanning...",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )
    draw.text(
        (25, 30),
        "Scan failed.",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )
    draw.text(
        (25, 50),
        "Try again.",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )

    display_image(image, True)
Пример #5
0
def update_startup_screen():
    """Show startup screen on eInk Display
    """
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.text(
        (20, 10),
        "Welcome to the",
        fill=config.BLACK,
        font=utils.create_font("freemono", 18),
    )
    draw.text(
        (10, 20),
        "LightningATM",
        fill=config.BLACK,
        font=utils.create_font("sawasdee", 30),
    )
    draw.text(
        (7, 75),
        "- please insert coins -",
        fill=config.BLACK,
        font=utils.create_font("freemono", 14),
    )

    display_image(image, True)
Пример #6
0
def update_lntxbot_balance(balance):
    # initially set all white background
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle((2, 2, width - 2, height - 2),
                   fill=config.WHITE,
                   outline=config.BLACK)
    draw.text(
        (50, 15),
        messages.lntxbot_balance_1,
        fill=config.BLACK,
        font=utils.create_font("freemonobold", 26),
    )
    draw.text(
        (10, 55),
        messages.lntxbot_balance_2,
        fill=config.BLACK,
        font=utils.create_font("freemono", 18),
    )
    draw.text(
        (45, 75),
        str("{:,}".format(balance)) + messages.lntxbot_balance_3,
        fill=config.BLACK,
        font=utils.create_font("freemono", 24),
    )

    config.WAVESHARE.init(config.WAVESHARE.FULL_UPDATE)
    config.WAVESHARE.display(config.WAVESHARE.getbuffer(image))
    time.sleep(3)
Пример #7
0
def update_lntxbot_balance(balance):
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle((2, 2, width - 2, height - 2),
                   fill=config.WHITE,
                   outline=config.BLACK)
    draw.text(
        (45, 15),
        "Success!!",
        fill=config.BLACK,
        font=utils.create_font("freemonobold", 20),
    )
    draw.text(
        (10, 45),
        "Your current balance:",
        fill=config.BLACK,
        font=utils.create_font("freemono", 15),
    )
    draw.text(
        (45, 65),
        str("{:,}".format(balance)) + " sats",
        fill=config.BLACK,
        font=utils.create_font("freemono", 18),
    )

    display_image(image, True)
    time.sleep(3)
Пример #8
0
def update_btcpay_lnd():
    # initially set all white background
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle(
        (2, 2, width - 2, height - 2), fill=config.WHITE, outline=config.BLACK
    )
    draw.text(
        (45, 15),
        "Success!!",
        fill=config.BLACK,
        font=utils.create_font("freemonobold", 20),
    )
    draw.text(
        (10, 45),
        "Successfuly scanned",
        fill=config.BLACK,
        font=utils.create_font("freemono", 15),
    )
    draw.text(
        (15, 65),
        "BTCPay LND Wallet.",
        fill=config.BLACK,
        font=utils.create_font("freemono", 16),
    )

    config.PAPIRUS.display(image)
    config.PAPIRUS.update()
    time.sleep(3)
Пример #9
0
def update_qr_request():
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle((2, 2, width - 2, height - 2),
                   fill=config.WHITE,
                   outline=config.BLACK)
    draw.text(
        (25, 10),
        "Please scan",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )
    draw.text(
        (10, 30),
        "your invoice in",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )

    for i in range(0, 3):
        draw.text(
            (80, 45),
            str(3 - i),
            fill=config.BLACK,
            font=utils.create_font("freemono", 50),
        )

        display_image(image)
        draw.rectangle((75, 50, 115, 90),
                       fill=config.WHITE,
                       outline=config.WHITE)
        time.sleep(1)
Пример #10
0
def update_btcpay_lnd():
    # initially set all white background
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle((2, 2, width - 2, height - 2),
                   fill=config.WHITE,
                   outline=config.BLACK)
    draw.text(
        (50, 20),
        messages.btcpay_lnd_1,
        fill=config.BLACK,
        font=utils.create_font("freemonobold", 26),
    )
    draw.text(
        (10, 55),
        messages.btcpay_lnd_2,
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )
    draw.text(
        (15, 80),
        messages.btcpay_lnd_3,
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )

    config.WAVESHARE.init(config.WAVESHARE.FULL_UPDATE)
    config.WAVESHARE.display(config.WAVESHARE.getbuffer(image))
    time.sleep(3)
Пример #11
0
def menu_screen():
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle((2, 2, width - 2, height - 2),
                   fill=config.WHITE,
                   outline=config.BLACK)
    draw.text(
        (20, 16),
        "►",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )
    draw.text(
        (40, 20),
        "Menu 1",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )
    draw.text(
        (40, 40),
        "Menu 2",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )

    display_image(image)

    while config.PUSHES <= 2:
        print(config.PUSHES)
        time.sleep(2)
Пример #12
0
def update_wallet_scan():
    # initially set all white background
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle((2, 2, width - 2, height - 2),
                   fill=config.WHITE,
                   outline=config.BLACK)
    draw.text(
        (40, 20),
        messages.wallet_scan_1,
        fill=config.BLACK,
        font=utils.create_font("freemono", 25),
    )
    draw.text(
        (40, 45),
        messages.wallet_scan_2,
        fill=config.BLACK,
        font=utils.create_font("freemono", 25),
    )
    draw.text(
        (40, 70),
        messages.wallet_scan_3,
        fill=config.BLACK,
        font=utils.create_font("freemono", 25),
    )

    config.WAVESHARE.init(config.WAVESHARE.FULL_UPDATE)
    config.WAVESHARE.display(config.WAVESHARE.getbuffer(image))
    time.sleep(2)
Пример #13
0
def update_thankyou_screen():
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.text(
        (15, 15),
        messages.thankyou_screen_1,
        fill=config.BLACK,
        font=utils.create_font("freemono", 26),
    )
    draw.text(
        (40, 45),
        messages.thankyou_screen_2,
        fill=config.BLACK,
        font=utils.create_font("freemono", 26),
    )
    draw.text(
        (15, 80),
        messages.thankyou_screen_3,
        fill=config.BLACK,
        font=utils.create_font("freemono", 18),
    )

    config.WAVESHARE.init(config.WAVESHARE.FULL_UPDATE)
    config.WAVESHARE.display(config.WAVESHARE.getbuffer(image))
    time.sleep(5)
Пример #14
0
def update_startup_screen():
    """Show startup screen on eInk Display
    """
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.text(
        (18, 13),
        messages.startup_screen_1,
        fill=config.BLACK,
        font=utils.create_font("freemono", 25),
    )
    draw.text(
        (12, 30),
        messages.startup_screen_2,
        fill=config.BLACK,
        font=utils.create_font("sawasdee", 37),
    )
    draw.text(
        (9, 92),
        messages.startup_screen_3,
        fill=config.BLACK,
        font=utils.create_font("freemono", 16),
    )

    config.WAVESHARE.init(config.WAVESHARE.FULL_UPDATE)
    config.WAVESHARE.display(config.WAVESHARE.getbuffer(image))
Пример #15
0
def update_qr_failed():
    # initially set all white background
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle((2, 2, width - 2, height - 2),
                   fill=config.WHITE,
                   outline=config.BLACK)
    draw.text(
        (25, 10),
        "Scanning...",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )
    draw.text(
        (25, 30),
        "Scan failed.",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )
    draw.text(
        (25, 50),
        "Try again.",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )

    config.PAPIRUS.display(image)
    config.PAPIRUS.partial_update()
Пример #16
0
def update_lntxbot_scan():
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle((2, 2, width - 2, height - 2),
                   fill=config.WHITE,
                   outline=config.BLACK)
    draw.text(
        (35, 20),
        "Please scan",
        fill=config.BLACK,
        font=utils.create_font("freemono", 18),
    )
    draw.text(
        (33, 40),
        "your lntxbot",
        fill=config.BLACK,
        font=utils.create_font("freemono", 18),
    )
    draw.text(
        (35, 60),
        "credentials.",
        fill=config.BLACK,
        font=utils.create_font("freemono", 18),
    )

    display_image(image, True)
    time.sleep(2)
Пример #17
0
def update_qr_request():
    # initially set all white background
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle((2, 2, width - 2, height - 2),
                   fill=config.WHITE,
                   outline=config.BLACK)
    draw.text(
        (34, 10),
        messages.qr_request_1,
        fill=config.BLACK,
        font=utils.create_font("freemono", 25),
    )
    draw.text(
        (10, 30),
        messages.qr_request_2,
        fill=config.BLACK,
        font=utils.create_font("freemono", 25),
    )

    config.WAVESHARE.init(config.WAVESHARE.FULL_UPDATE)
    config.WAVESHARE.displayPartBaseImage(config.WAVESHARE.getbuffer(image))

    for i in range(0, 3):
        draw.text(
            (90, 55),
            str(3 - i),
            fill=config.BLACK,
            font=utils.create_font("freemono", 58),
        )
        config.WAVESHARE.init(config.WAVESHARE.PART_UPDATE)
        config.WAVESHARE.displayPartial(config.WAVESHARE.getbuffer(image))
        draw.rectangle((75, 50, 115, 90),
                       fill=config.WHITE,
                       outline=config.WHITE)
        time.sleep(0.5)

    draw.rectangle((2, 2, width - 2, height - 2),
                   fill=config.WHITE,
                   outline=config.BLACK)
    draw.text(
        (32, 15),
        messages.qr_request_3,
        fill=config.BLACK,
        font=utils.create_font("freemono", 28),
    )
    draw.text(
        (22, 40),
        messages.qr_request_4 + str(math.floor(config.SATS)) +
        messages.qr_request_5,
        fill=config.BLACK,
        font=utils.create_font("freemono", 28),
    )
    config.WAVESHARE.init(config.WAVESHARE.PART_UPDATE)
    config.WAVESHARE.displayPartial(config.WAVESHARE.getbuffer(image))
Пример #18
0
def update_qr_request():
    # initially set all white background
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle((2, 2, width - 2, height - 2),
                   fill=config.WHITE,
                   outline=config.BLACK)
    draw.text(
        (25, 10),
        "Please scan",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )
    draw.text(
        (10, 30),
        "your invoice in",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )

    config.PAPIRUS.display(image)
    config.PAPIRUS.update()

    for i in range(0, 3):
        draw.text(
            (80, 45),
            str(3 - i),
            fill=config.BLACK,
            font=utils.create_font("freemono", 50),
        )
        config.PAPIRUS.display(image)
        config.PAPIRUS.partial_update()
        draw.rectangle((75, 50, 115, 90),
                       fill=config.WHITE,
                       outline=config.WHITE)
        time.sleep(1)

    draw.rectangle((2, 2, width - 2, height - 2),
                   fill=config.WHITE,
                   outline=config.BLACK)
    draw.text(
        (25, 10),
        "Scanning...",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )
    draw.text(
        (15, 35),
        "for " + str(math.floor(config.SATS)) + " sats.",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )
    config.PAPIRUS.display(image)
    config.PAPIRUS.partial_update()
Пример #19
0
def handle_invoice(draw, image):
    """Decode a BOLT11 invoice. Ensure that amount is correct or 0, then attempt to
    make the payment.
    """
    decode_req = lightning.decode_request(config.INVOICE)
    if decode_req == str(round(config.SATS)) or str(0):
        lightning.payout(config.SATS, config.INVOICE)
        result = lightning.last_payment(config.INVOICE)

        draw.text(
            (15, 70),
            str(result),
            fill=config.BLACK,
            font=utils.create_font("freemono", 15),
        )

        config.PAPIRUS.display(image)
        config.PAPIRUS.partial_update()
        time.sleep(1)

        if result is True:
            display.update_thankyou_screen()
        else:
            display.update_payment_failed()
            time.sleep(120)

        logger.info("Initiating restart...")
        os.execv("/home/pi/LightningATM/app.py", [""])
    else:
        print("Please show correct invoice")
Пример #20
0
def error_screen(message="ERROR"):
    """Error screen
    """
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.text(
        (18, 13),
        messages.error_screen_1,
        fill=config.BLACK,
        font=utils.create_font("freemono", 25),
    )
    draw.text(
        (12, 30),
        message,
        fill=config.BLACK,
        font=utils.create_font("freemono", 16),
    )

    config.WAVESHARE.init(config.WAVESHARE.FULL_UPDATE)
    config.WAVESHARE.display(config.WAVESHARE.getbuffer(image))
Пример #21
0
def error_screen(message="ERROR"):
    """Error screen
    """
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.text(
        (20, 10),
        messages.error_screen_1,
        fill=config.BLACK,
        font=utils.create_font("freemono", 18),
    )
    draw.text(
        (10, 20),
        message,
        fill=config.BLACK,
        font=utils.create_font("freemono", 14),
    )

    config.PAPIRUS.display(image)
    config.PAPIRUS.update()
Пример #22
0
def update_lnurl_generation():
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle((2, 2, width - 2, height - 2),
                   fill=config.WHITE,
                   outline=config.BLACK)
    draw.text(
        (30, 20),
        "Generating",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )
    draw.text(
        (10, 40),
        "QR code to scan",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )

    display_image(image)
Пример #23
0
def update_lnurl_generation():
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle((2, 2, width - 2, height - 2),
                   fill=config.WHITE,
                   outline=config.BLACK)
    draw.text(
        (40, 35),
        messages.lnurl_generation_1,
        fill=config.BLACK,
        font=utils.create_font("freemono", 24),
    )
    draw.text(
        (20, 60),
        messages.lnurl_generation_2,
        fill=config.BLACK,
        font=utils.create_font("freemono", 24),
    )

    config.WAVESHARE.init(config.WAVESHARE.FULL_UPDATE)
    config.WAVESHARE.display(config.WAVESHARE.getbuffer(image))
Пример #24
0
def draw_lnurl_qr(qr_img):
    """draw a lnurl qr code on the e-ink screen
    """
    image = Image.new("1", config.PAPIRUS.size, config.BLACK)
    draw = ImageDraw.Draw(image)
    draw.bitmap((0, 0), qr_img, fill=config.WHITE)
    draw.text(
        (110, 25),
        "Scan to",
        fill=config.WHITE,
        font=utils.create_font("freemonobold", 16),
    )
    draw.text(
        (110, 45),
        "receive",
        fill=config.WHITE,
        font=utils.create_font("freemonobold", 16),
    )

    config.PAPIRUS.display(image)
    config.PAPIRUS.update()
Пример #25
0
def update_shutdown_screen():
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.text(
        (20, 10),
        "ATM turned off!",
        fill=config.BLACK,
        font=utils.create_font("freemono", 18),
    )
    draw.text(
        (25, 45),
        "Please contact",
        fill=config.BLACK,
        font=utils.create_font("freemono", 17),
    )
    draw.text((45, 65),
              "operator.",
              fill=config.BLACK,
              font=utils.create_font("freemono", 17))

    display_image(image, True)
Пример #26
0
def update_payment_failed():
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.text(
        (15, 10),
        "Payment failed!",
        fill=config.BLACK,
        font=utils.create_font("freemono", 19),
    )
    draw.text(
        (25, 45),
        "Please contact",
        fill=config.BLACK,
        font=utils.create_font("freemono", 17),
    )
    draw.text((45, 65),
              "operator.",
              fill=config.BLACK,
              font=utils.create_font("freemono", 17))

    display_image(image, True)
Пример #27
0
def update_amount_screen():
    """Update the amount screen to reflect new coins inserted
    """
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle(
        (2, 2, width - 2, height - 2), fill=config.WHITE, outline=config.BLACK
    )
    draw.text(
        (11, 15),
        str("{:,}".format(math.floor(config.SATS))) + messages.amount_screen_1,
        fill=config.BLACK,
        font=utils.create_font("dotmbold", 30),
    )
    draw.text(
        (12, 45),
        "%.2f" % round(config.FIAT, 2) + " " + config.conf["atm"]["cur"].upper(),
        fill=config.BLACK,
        font=utils.create_font("dotmbold", 25),
    )
    draw.text(
        (11, 70),
        messages.amount_screen_2,
        fill=config.BLACK,
        font=utils.create_font("freemono", 18),
    )
    draw.text(
        (60, 70),
        messages.amount_screen_3
        + str(math.floor(config.SATPRICE))
        + messages.amount_screen_4
        + config.conf["atm"]["centname"],
        fill=config.BLACK,
        font=utils.create_font("freemono", 18),
    )
    draw.text(
        (11, 85),
        messages.amount_screen_5,
        fill=config.BLACK,
        font=utils.create_font("freemono", 18),
    )
    draw.text(
        (60, 85),
        messages.amount_screen_6
        + config.conf["atm"]["fee"]
        + messages.amount_screen_7
        + str(math.floor(config.SATSFEE))
        + messages.amount_screen_8,
        fill=config.BLACK,
        font=utils.create_font("freemono", 18),
    )

    if config.COINCOUNT == 1:
        config.WAVESHARE.init(config.WAVESHARE.FULL_UPDATE)
        config.WAVESHARE.displayPartBaseImage(config.WAVESHARE.getbuffer(image))
    else:
        config.WAVESHARE.init(config.WAVESHARE.PART_UPDATE)
        config.WAVESHARE.displayPartial(config.WAVESHARE.getbuffer(image))
Пример #28
0
def update_qr_failed():
    # initially set all white background
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle((2, 2, width - 2, height - 2),
                   fill=config.WHITE,
                   outline=config.BLACK)

    draw.text(
        (25, 30),
        messages.qr_failed_1,
        fill=config.BLACK,
        font=utils.create_font("freemono", 28),
    )
    draw.text(
        (30, 57),
        messages.qr_failed_2,
        fill=config.BLACK,
        font=utils.create_font("freemono", 28),
    )

    config.WAVESHARE.init(config.WAVESHARE.FULL_UPDATE)
    config.WAVESHARE.display(config.WAVESHARE.getbuffer(image))
Пример #29
0
def update_payout_screen():
    """Update the payout screen to reflect balance of deposited coins.
    Scan the invoice??? I don't think so!
    """
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.rectangle((2, 2, width - 2, height - 2),
                   fill=config.WHITE,
                   outline=config.BLACK)
    draw.text(
        (15, 30),
        str(math.floor(config.SATS)) + " sats",
        fill=config.BLACK,
        font=utils.create_font("freemono", 20),
    )
    draw.text(
        (15, 50),
        "on the way!",
        fill=config.BLACK,
        font=utils.create_font("freemono", 15),
    )

    display_image(image, True)
Пример #30
0
def update_nocoin_screen():
    image, width, height, draw = init_screen(color=config.WHITE)

    draw.text(
        (15, 10),
        "No coins added!",
        fill=config.BLACK,
        font=utils.create_font("freemono", 19),
    )
    draw.text(
        (25, 45),
        "Please add",
        fill=config.BLACK,
        font=utils.create_font("freemono", 17),
    )
    draw.text(
        (45, 65),
        "coins first.",
        fill=config.BLACK,
        font=utils.create_font("freemono", 17),
    )

    display_image(image, True)