Exemplo n.º 1
0
inkyphat.set_border(inkyphat.RED)
inkyphat.set_image("resources/hello-badge.png")

# Partial update if using Inky pHAT display v1

if inkyphat.get_version() == 1:
    inkyphat.show()

# Add the text

font = ImageFont.truetype(inkyphat.fonts.AmaticSCBold, 38)

name = sys.argv[1]

w, h = font.getsize(name)

# Center the text and align it with the name strip

x = (inkyphat.WIDTH / 2) - (w / 2)
y = 71 - (h / 2)

inkyphat.text((x, y), name, inkyphat.BLACK, font)

# Partial update if using Inky pHAT display v1

if inkyphat.get_version() == 1:
    inkyphat.set_partial_mode(56, 96, 0, inkyphat.WIDTH)

inkyphat.show()
Exemplo n.º 2
0
# Refresh the text strip
#
# Partial updates are snapped to 8 pixel boundaries vertically,
# so the name strip is carefully aligned to an 8 pixel grid
#
# Generally you should refresh only whole horizontal rows.
# Colours either side of the update area will be washed out!
#
# Your refreshed area may have a white border
# which could cut into surrounding colours.
#
# Remember:
# Art smartly to update partly!

inkyphat.set_partial_mode(0, 64, 0, inkyphat.WIDTH)
inkyphat.show()

if line_1_status_code != 10:
    inkyphat.rectangle((0, 0, 212, 104), inkyphat.RED)
    inkyphat.text((4, 60), line_1_name, inkyphat.WHITE, BOOKBOLD_MEDIUM)
    inkyphat.text((inkyphat.WIDTH - line_1_status_w, 60), line_1_status_text,
                  inkyphat.WHITE, BOOK_MEDIUM)
else:
    inkyphat.rectangle((0, 0, 212, 104), inkyphat.WHITE)
    inkyphat.text((4, 56), line_1_name, inkyphat.BLACK, BOOKBOLD_MEDIUM)
    inkyphat.text((inkyphat.WIDTH - line_1_status_w, 56), line_1_status_text,
                  inkyphat.BLACK, BOOK_MEDIUM)

inkyphat.set_partial_mode(56, 80, 0, inkyphat.WIDTH)
inkyphat.show()