Skip to content

Instantly share code, notes, and snippets.

@Akkiesoft
Created August 2, 2017 15:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Akkiesoft/f3ba94af42138a3756bac426982f57d9 to your computer and use it in GitHub Desktop.
Save Akkiesoft/f3ba94af42138a3756bac426982f57d9 to your computer and use it in GitHub Desktop.
The script that showing PNG image for waveshare 2.13 Inch e-Paper module.
# The script that showing PNG image for waveshare 2.13 Inch e-Paper module.
import time
import spidev as SPI
import EPD_driver
import datetime
from PIL import Image
xDot = 122
yDot = 250
DELAYTIME = 4
bus = 0
device = 0
# PNG image must be palette mode. Image size is 250x122.
# Palette 0: white, 1: black
image = Image.open("image.png")
size = image.size
data = []
for x in range(size[0]):
for by in range(size[1] / 8 + 1):
block = 0
for y in range(8):
block = block << 1
try:
pixel = 1 - image.getpixel((x, by * 8 + y))
block = block | pixel
except:
pass
data.append(int(block))
disp = EPD_driver.EPD_driver(spi=SPI.SpiDev(bus, device))
disp.Dis_Clear_full()
disp.Dis_full_pic(data)
@segfaultlabs
Copy link

Hi,
I am trying to use your script with images generated with ImageMagik on Linux, for my own project using this Hat.
When displaying the images, there are horizontal lines on the waveshare hat and the image / text is not solid, I am using black and white png, would you be able to provide any advice?

@Akkiesoft
Copy link
Author

Is your PNG image generated with index color mode?
My image show correctly and created with gimp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment