#!/usr/bin/python # -*- coding:utf-8 -*- import sys import os picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'img') libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib') if os.path.exists(libdir): sys.path.append(libdir) from waveshare_epd import epd2in7 import time from PIL import Image,ImageDraw,ImageFont, ImageOps import traceback try: epd = epd2in7.EPD() '''2Gray(Black and white) display''' ## init and Clear epd.init() epd.Clear(0xFF) ## 3.read bmp file Himage = Image.open(os.path.join(picdir, 'monImage.bmp')) epd.display(epd.getbuffer(Himage)) time.sleep(4) '''4Gray display''' ##4Gray display epd.Init_4Gray() #display 4Gra bmp Himage = ImageOps.mirror(Image.open(os.path.join(picdir, 'monImage4.bmp'))) epd.display_4Gray(epd.getbuffer_4Gray(Himage)) time.sleep(3) ## Clear... epd.Clear(0xFF) ##Goto Sleep... epd.sleep() except KeyboardInterrupt: epd2in7.epdconfig.module_exit() exit()