How to use the inky.InkyWHAT function in inky

To help you get started, we’ve selected a few inky examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pimoroni / inky / examples / logo-what.py View on Github external
print("""Inky wHAT: Logo

Displays the Inky wHAT logo.

""")

if len(sys.argv) < 2:
    print("""Usage: {} 
       Valid colours: red, yellow, black
""".format(sys.argv[0]))
    sys.exit(0)

colour = sys.argv[1].lower()

inkywhat = InkyWHAT(colour)

inkywhat.set_border(inkywhat.BLACK)

if colour == 'black':
    img = Image.open("InkyPhat-212x104-bw.png")
else:
    img = Image.open("InkyPhat-212x104.png")

inkywhat.set_image(img)

inkywhat.show()
github pimoroni / inky / examples / clean.py View on Github external
# Command line arguments to set display type and colour, and number of cycles to run

parser = argparse.ArgumentParser()
parser.add_argument('--type', '-t', type=str, required=True, choices=["what", "phat"], help="type of display")
parser.add_argument('--colour', '-c', type=str, required=True, choices=["red", "black", "yellow"], help="ePaper display colour")
parser.add_argument('--number', '-n', type=int, required=False, help="number of cycles")
args = parser.parse_args()

colour = args.colour

# Set up the correct display and scaling factors

if args.type == "phat":
    inky_display = InkyPHAT(colour)
elif args.type == "what":
    inky_display = InkyWHAT(colour)

# The number of red / black / white refreshes to run

if args.number:
    cycles = args.number
else:
    cycles = 3

colours = (inky_display.RED, inky_display.BLACK, inky_display.WHITE)
colour_names = (colour, "black", "white")

# Create a new canvas to draw on

img = Image.new("P", (inky_display.WIDTH, inky_display.HEIGHT))

# Loop through the specified number of cycles and completely
github pimoroni / inky / examples / what / quotes-what.py View on Github external
word_length = font.getsize(word)[0]
        line_length += word_length

        if line_length < width:
            reflowed += word
        else:
            line_length = word_length
            reflowed = reflowed[:-1] + "\n  " + word

    reflowed = reflowed.rstrip() + '"'

    return reflowed


# Set up the correct display and scaling factors
inky_display = InkyWHAT(colour)
inky_display.set_border(inky_display.WHITE)
# inky_display.set_rotation(180)

w = inky_display.WIDTH
h = inky_display.HEIGHT

# Create a new canvas to draw on

img = Image.new("P", (inky_display.WIDTH, inky_display.HEIGHT))
draw = ImageDraw.Draw(img)

# Load the fonts

font_size = 24

author_font = ImageFont.truetype(SourceSerifProSemibold, font_size)
github pimoroni / inky / examples / what / dither-image-what.py View on Github external
Converts and displays dithered images on Inky wHAT.
""")

# Command line arguments to set display type and colour, and enter your name

parser = argparse.ArgumentParser()
parser.add_argument('--colour', '-c', type=str, required=True, choices=["red", "black", "yellow"], help="ePaper display colour")
parser.add_argument('--image', '-i', type=str, required=True, help="Input image to be converted/displayed")
args = parser.parse_args()

colour = args.colour
img_file = args.image

# Set up the inky wHAT display and border colour

inky_display = InkyWHAT(colour)
inky_display.set_border(inky_display.WHITE)

# Open our image file that was passed in from the command line

img = Image.open(img_file)

# Get the width and height of the image

w, h = img.size

# Calculate the new height and width of the image

h_new = 300
w_new = int((float(w) / h) * h_new)
w_cropped = 400

inky

Inky pHAT Driver

MIT
Latest version published 1 year ago

Package Health Score

54 / 100
Full package analysis

Similar packages