#!/usr/bin/python # -*- coding:utf-8 -*- import sys import os picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic') 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() ## init and Clear epd.init() epd.Clear(0xFF) font24 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 24) font18 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18) font35 = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 35) # Drawing on the Horizontal image Himage = Image.new('1', (epd.height, epd.width), 255) # 255: clear the frame draw = ImageDraw.Draw(Himage) draw.text((10, 0), 'hello world', font = font24, fill = 0) draw.text((150, 5), 'hello world', font = font18, fill = epd.GRAY2) draw.line((140, 75, 190, 75), fill = 0) draw.arc((140, 50, 190, 100), 0, 360, fill = 0) draw.rectangle((80, 50, 130, 100), fill = 0) draw.chord((200, 50, 250, 100), 0, 360, fill = 0) epd.display(epd.getbuffer(Himage)) time.sleep(2) ##4Gray display epd.Init_4Gray() ### problème : l'image est inversée et je n'arrive pas le corriger. # Drawing on the Horizontal image Himage = Image.new('L', (epd.height, epd.width), 0) # 0: écran noir draw = ImageDraw.Draw(Himage) draw.text((10, 0), 'ligne 01', font = font35, fill = epd.GRAY1) draw.text((10, 35), 'ligne 02', font = font24, fill = epd.GRAY2) draw.text((10, 70), 'ligne 03', font = font35, fill = epd.GRAY3) draw.line((10, 140, 260, 140), fill = epd.GRAY1) epd.display_4Gray(epd.getbuffer_4Gray(Himage)) time.sleep(8) ## Clear... epd.Clear(0xFF) ##Goto Sleep... epd.sleep() except KeyboardInterrupt: epd2in7.epdconfig.module_exit() exit()