Whitney Knitter
Published © GPL3+

Harry Potter Newspaper Powered by Raspberry Pi Zero

In this project, I use eInk displays in a custom PCB layout with a RPi Zero to create my own Harry Potter newspaper with magic photos.

IntermediateFull instructions provided2 hours9,848
Harry Potter Newspaper Powered by Raspberry Pi Zero

Things used in this project

Hardware components

Raspberry Pi Zero Wireless
Raspberry Pi Zero Wireless
×1
Adafruit eInk Breakout Friend with 32KB SRAM
×1
Adafruit 2.9" Flexible 296x128 Monochrome eInk / ePaper Display - UC8151D Chipset
×1
Adafruit SMT GPIO Header for Raspberry Pi HAT - 2x20 Short Female Header
×1
M20-8771246-ND CONN HEADER SMD 12POS 2.54MM
×1

Software apps and online services

Raspbian
Raspberry Pi Raspbian

Story

Read more

Custom parts and enclosures

KiCad PCB

Schematics

Adafruit eInk Friend Schematic

Code

epd_pillow_hp_newspaper.py

Python
# SPDX-FileCopyrightText: 2019 Melissa LeBlanc-Williams for Adafruit Industries
# SPDX-License-Identifier: MIT

"""
Image resizing and drawing using the Pillow Library. For the image, check out the
associated Adafruit Learn guide at:
https://learn.adafruit.com/adafruit-eink-display-breakouts/python-code

"""
import time
import digitalio
import busio
import board
from PIL import Image
from adafruit_epd.uc8151d import Adafruit_UC8151D  # pylint: disable=unused-import


# create the spi device and pins we will need
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
ecs = digitalio.DigitalInOut(board.CE1)
dc = digitalio.DigitalInOut(board.D22)
srcs = None
rst = digitalio.DigitalInOut(board.D27)
busy = None #digitalio.DigitalInOut(board.D17)

display = Adafruit_UC8151D(128, 296,        # 2.9" mono flexible display
    spi,
    cs_pin=ecs,
    dc_pin=dc,
    sramcs_pin=srcs,
    rst_pin=rst,
    busy_pin=busy,
)

# IF YOU HAVE A 2.9" FLEXIBLE DISPLAY uncomment these lines!
display.set_black_buffer(1, True)
display.set_color_buffer(1, True)

display.rotation = 1

while True:

    image = Image.open("chatGPT_logo.png")

    # Scale the image to the smaller screen dimension
    image_ratio = image.width / image.height
    screen_ratio = display.width / display.height
    if screen_ratio < image_ratio:
        scaled_width = image.width * display.height // image.height
        scaled_height = display.height
    else:
        scaled_width = display.width
        scaled_height = image.height * display.width // image.width
    image = image.resize((scaled_width, scaled_height), Image.BICUBIC)

    # Crop and center the image
    x = scaled_width // 2 - display.width // 2
    y = scaled_height // 2 - display.height // 2
    image = image.crop((x, y, x + display.width, y + display.height)).convert("RGB")

    # Convert to Monochrome and Add dithering
    # image = image.convert("1").convert("L")

    # Display image.
    display.image(image)
    display.display()

    #time.sleep(1)

    image = Image.open("lordV.png")

    # Scale the image to the smaller screen dimension
    image_ratio = image.width / image.height
    screen_ratio = display.width / display.height
    if screen_ratio < image_ratio:
        scaled_width = image.width * display.height // image.height
        scaled_height = display.height
    else:
        scaled_width = display.width
        scaled_height = image.height * display.width // image.width
    image = image.resize((scaled_width, scaled_height), Image.BICUBIC)

    # Crop and center the image
    x = scaled_width // 2 - display.width // 2
    y = scaled_height // 2 - display.height // 2
    image = image.crop((x, y, x + display.width, y + display.height)).convert("RGB")

    # Convert to Monochrome and Add dithering
    # image = image.convert("1").convert("L")

    # Display image.
    display.image(image)
    display.display()

    #time.sleep(1)

Credits

Whitney Knitter

Whitney Knitter

157 projects • 1586 followers
All thoughts/opinions are my own and do not reflect those of any company/entity I currently/previously associate with.

Comments