Create a gist now

Instantly share code, notes, and snippets.

Embed
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

This comment has been minimized.

Show comment
Hide comment
@segfaultlabs

segfaultlabs Aug 29, 2017

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?

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

This comment has been minimized.

Show comment
Hide comment
@Akkiesoft

Akkiesoft Sep 18, 2017

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

Owner

Akkiesoft commented Sep 18, 2017

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