Created
August 30, 2019 18:37
-
-
Save RaneWallin/339e3644018d11ef9d6e33960059c433 to your computer and use it in GitHub Desktop.
A demo project for the 2.7" ePaper HAT from Waveshare, using the display and the buttons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
sys.path.insert(1, "./lib") | |
import epd2in7b | |
from PIL import Image, ImageDraw, ImageFont | |
from gpiozero import Button | |
btn = Button(5) | |
epd = epd2in7b.EPD() | |
epd.init() | |
print("Clear...") | |
epd.Clear(0xFF) | |
def printToDisplay(string): | |
HBlackImage = Image.new('1', (epd2in7b.EPD_HEIGHT, epd2in7b.EPD_WIDTH), 255) | |
HRedImage = Image.new('1', (epd2in7b.EPD_HEIGHT, epd2in7b.EPD_WIDTH), 255) | |
draw = ImageDraw.Draw(HBlackImage) # Create draw object and pass in the image layer we want to work with (HBlackImage) | |
font = ImageFont.truetype('/usr/share/fonts/truetype/google/Bangers-Regular.ttf', 30) # Create our font, passing in the font file and font size | |
draw.text((25, 65), string, font = font, fill = 0) | |
epd.display(epd.getbuffer(HBlackImage), epd.getbuffer(HRedImage)) | |
def handleBtnPress(): | |
printToDisplay("Hello, World!") | |
btn.when_pressed = handleBtnPress | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment