Esempio n. 1
0
def main():
    epd = epd7in5.EPD()
    epd.init()

    # For simplicity, the arguments are explicit numerical coordinates
    # image = Image.new('1', (EPD_WIDTH, EPD_HEIGHT), 1)    # 1: clear the frame
    # draw = ImageDraw.Draw(image)
    # font = ImageFont.truetype('/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 24)
    # draw.rectangle((0, 6, 640, 30), fill = 0)
    # draw.text((200, 10), 'e-Paper demo', font = font, fill = 255)
    # draw.rectangle((200, 80, 600, 280), fill = 0)
    # draw.arc((240, 120, 580, 220), 0, 360, fill = 255)
    # draw.rectangle((0, 80, 160, 280), fill = 255)
    # draw.arc((40, 80, 180, 220), 0, 360, fill = 0)
    # epd.display_frame(epd.get_frame_buffer(image))

    image = Image.open('black.png')
    image = PIL.ImageOps.invert(image.convert("RGB"))
    draw = ImageDraw.Draw(image)
    font = ImageFont.truetype(
        '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 59)
    draw.text((200, 10), getTime(), font=font, fill=255)
    draw.text((0, 10), getDate(), font=font, fill=255)

    epd.display_frame(epd.get_frame_buffer(image))
Esempio n. 2
0
def render():
    video_path = sys.argv[1]
    frame_number = int(sys.argv[2])

    cap = cv2.VideoCapture(video_path)
    frame_count = int(cap.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT))

    if frame_number > frame_count:
        print("This video only has {0} frames".format(frame_count))
        exit(1)

    cap.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, frame_number - 1)
    ret, cv_frame = cap.read()
    if not ret:
        print("Could not read frame {0} from video".format(frame_number))
        exit(1)

    image = Image.fromarray(cv_frame)
    image.thumbnail(SIZE, Image.ANTIALIAS)

    padded_image = Image.new('RGB', SIZE)
    x_offset = int((SIZE[0] - image.size[0]) / 2)
    y_offset = int((SIZE[1] - image.size[1]) / 2)
    padded_image.paste(image, (x_offset, y_offset))

    epd = epd7in5.EPD()
    epd.init()
    epd.display(epd.getbuffer(padded_image))
    epd.sleep()
Esempio n. 3
0
def main():

    lineWidth = 37
    fontSize = 16
    lineSpacing = 18
    fontPath = '/home/pi/.fonts/AnonymousPro-Regular.ttf'
    pdfPath = '/home/pi/test.pdf'

    epd = epd7in5.EPD()
    epd.init()

    size = epd7in5.EPD_WIDTH, epd7in5.EPD_HEIGHT

    image = Image.new('1', (epd7in5.EPD_HEIGHT, epd7in5.EPD_WIDTH), 255)

    draw = ImageDraw.Draw(image)

    font = ImageFont.truetype(fontPath, fontSize)

    margin = offset = 10

    text = textract.process(pdfPath)

    text = text.replace('‘', '\'')
    text = text.replace('’', '\'')

    for line in textwrap.wrap(text, width=lineWidth):
        print(line)
        draw.text((margin, offset), line, font=font)
        offset += lineSpacing

    new_image = image.rotate(180)

    epd.display(epd.getbuffer(new_image))
Esempio n. 4
0
def playlyrics(inp):
    parsinp = inp.split(' by ')
    lyricfull = (PyLyrics.getLyrics(parsinp[1], parsinp[0]))
    lyriclist = lyricfull.split('\n')
    try:
        epd = epd7in5.EPD()
        epd.init()
        print("Clear")
        epd.Clear(0xFF)

        print("Drawing")
        Himage = Image.new('1', (epd7in5.EPD_WIDTH, epd7in5.EPD_HEIGHT), 255)
        draw = ImageDraw.Draw(Himage)
        font24 = ImageFont.truetype(
            '/usr/share/fonts/truetype/freefont/FreeMono.ttf', 24)
        for x in range(0, 4, len(lyriclist) - 1):
            draw.text((10, x * 20), lyriclist[x], font=font24, fill=0)
            draw.text((10, (x + 1) * 20),
                      lyriclist[x + 1],
                      font=font24,
                      fill=0)
            draw.text((10, (x + 2) * 20),
                      lyriclist[x + 2],
                      font=font24,
                      fill=0)
            epd.display(epd.getbuffer(Himage))
            sleep(1)
        epd.display(epd.getbuffer(Himage))
        sleep(2)

        epd.sleep()
    except:
        print('traceback.format_exc():\n%s', traceback.format_exc())
        exit()
Esempio n. 5
0
def main():
    epd = epd7in5.EPD()
    epd.init()

    # For simplicity, the arguments are explicit numerical coordinates
    image = Image.new('1', (EPD_WIDTH, EPD_HEIGHT), 1)  # 1: clear the frame
    draw = ImageDraw.Draw(image)
    font = ImageFont.truetype(
        '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 24)
    # draw.text((200, 10), 'e-Paper demo', font = font, fill = 255)
    # draw the horizontal lines
    draw.line((0, 0, 640, 0), fill=0, width=2)
    draw.line((0, 128, 640, 128), fill=0, width=2)
    draw.line((0, 256, 640, 256), fill=0, width=2)
    draw.line((0, 381, 640, 381), fill=0, width=2)
    # draw the vertical lines
    draw.line((0, 0, 0, 384), fill=0, width=2)
    draw.line((160, 0, 160, 384), fill=0, width=2)
    draw.line((320, 0, 320, 384), fill=0, width=2)
    draw.line((480, 0, 480, 384), fill=0, width=2)
    draw.line((638, 0, 638, 384), fill=0, width=2)
    # draw.arc((240, 120, 580, 220), 0, 360, fill = 255)
    # draw.rectangle((0, 80, 160, 280), fill = 255)
    # draw.arc((40, 80, 180, 220), 0, 360, fill = 0)
    logger.debug('Going to send to screen')
    image2 = Image.open('monocolor.bmp')
    epd.display_frame(epd.get_frame_buffer(image2),
                      epd.get_frame_buffer(image))
    logger.debug('Frame displayed')
Esempio n. 6
0
def main():

    try:
        Himage = draw_image()
        Himage.save('debug.bmp')
        print('image produced')

        if not debug:
            now = datetime.datetime.now().time()
            if now >= r1_start or now <= r1_end or (now >= r2_start
                                                    and now <= r2_end):
                print("sleeping until Ryan is around")
                return

            epd = epd7in5.EPD()
            epd.init()
            # print("Clear")
            # epd.Clear(0xFF)

            epd.display(epd.getbuffer(Himage))
            time.sleep(2)

            # bmp = Image.open('100x100.bmp')
            # Himage2.paste(bmp, (50,10))
            # epd.display(epd.getbuffer(Himage2))
            # time.sleep(2)

            epd.sleep()
    except:
        return
Esempio n. 7
0
def show_img(filename):
    print('Updating display with ', filename)
    img = Image.open(filename)
    epd = epd7in5.EPD()
    epd.init()
    epd.display(epd.getbuffer(img))
    return ()
Esempio n. 8
0
def main():
    epd = epd7in5.EPD()
    epd.init()

    # For simplicity, the arguments are explicit numerical coordinates
    image = Image.new('1', (EPD_WIDTH, EPD_HEIGHT), 0)  # 1: clear the frame

    epd.display_frame(epd.get_frame_buffer(image))
    epd.sleep()
def takeScreenShot():
    subprocess.call('import -window root ' + SCREENSHOT, shell=True)
    epd = epd7in5.EPD()
    epd.init()
    epd.Clear(0xff)
    image = Image.open(SCREENSHOT)
    epd.display(epd.getbuffer(image))
    time.sleep(2)
    epd.sleep()
Esempio n. 10
0
def main():

    lineWidth = 37
    fontSize = 16
    lineSpacing = 18
    linesPerPage = 18

    bookDir = "/home/pi/Books/TXT"
    fontPath = "/home/pi/.fonts/AnonymousPro-Regular.ttf"

    epd = epd7in5.EPD()
    epd.init()
    size = epd7in5.EPD_WIDTH, epd7in5.EPD_HEIGHT
    image = Image.new('1', (epd7in5.EPD_HEIGHT, epd7in5.EPD_WIDTH), 255)
    draw = ImageDraw.Draw(image)

    font = ImageFont.truetype(fontPath, fontSize)

    margin = offset = 10

    books = []

    for r, d, f in os.walk(bookDir):
        for file in f:
            if '.txt' in file:
                books.append(os.path.join(r, file))

    book = open(books[0], "r")
    booklines = book.readlines()

    bookmark = booklines[0]

    for i in range(len(booklines)):
        if (booklines[i] == bookmark):
            pageIndex = i

    pageStop = False
    counter = 1

    while (pageStop == False):
        if ("\f" in booklines[pageIndex - counter]):
            printLines = counter
            pageStop = True
        else:
            counter += 1

    for x in range(printLines - 1):
        draw.text((margin, offset),
                  booklines[pageIndex - (printLines - x) + 1],
                  font=font)
        print(booklines[pageIndex - (printLines - x) + 1])
        offset += lineSpacing

    epd.display(epd.getbuffer(image))

    book.close()
Esempio n. 11
0
def main():
    epd = epd7in5.EPD()
    epd.init()
    # For simplicity, the arguments are explicit numerical coordinates
    image = Image.new('1', (EPD_WIDTH, EPD_HEIGHT), 1)    # 1: clear the frame
    draw = ImageDraw.Draw(image)
    image = Image.open(choose_random_loading_image('bmp/'))
    epd.display_frame(epd.get_frame_buffer(image))
    time.sleep(60)  # change the image every minute
    main()
Esempio n. 12
0
def main():
    epd = epd7in5.EPD()
    epd.init()

    fileIn = "fromServer.png"
    img = Image.open(fileIn)

    img.save("imageForEPaper.bmp", "BMP")
    epd.display_frame(epd.get_frame_buffer(img))
    epd.sleep()
def display_loop():
    """Display the weather data in a loop."""
    import epd7in5

    epd = epd7in5.EPD()
    epd.init()

    while 1:
        # display the image on the epaper display
        epd.display_frame(epd.get_frame_buffer(draw_image()))
        time.sleep(SLEEP_TIME_S)
Esempio n. 14
0
def main():
    epd = epd7in5.EPD()
    epd.init()

    # For simplicity, the arguments are explicit numerical coordinates
    font = ImageFont.truetype(
        '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 124)
    image = Image.new('1', (EPD_WIDTH, EPD_HEIGHT), 1)  # 1: clear the frame
    draw = ImageDraw.Draw(image)
    image = Image.open('bmp/mrwhite2.bmp')
    draw.text((200, 10), 'e-Paper demo', font=font, fill=255)
    epd.display_frame(epd.get_frame_buffer(image))
def main():
    os.chdir(os.path.dirname(os.path.abspath(__file__)))

    epd = epd7in5.EPD()
    epd.init()

    # select a random image file
    filename = random.choice(os.listdir('./images'))
    #filename = 'test3.bmp'

    image = Image.open('./images/' + filename)
    epd.display_frame(epd.get_frame_buffer(image))
Esempio n. 16
0
def simple(f):
    print('start')
    size = (640, 384)
    im1 = brighten(Image.open(f))
    print('opened')
    im2 = check_size(im1)
    print('checked size')
    im3 = im2.convert('1')
    print('converted')

    epd = epd7in5.EPD()
    epd.init()
    epd.display(epd.getbuffer(im3))
    return ()
Esempio n. 17
0
def main():
    epd = epd7in5.EPD()
    epd.init()
    
    fileObj = open("base64bwExample.txt", mode="r", encoding="utf-8")
    imgAsString = fileObj.read()
    imgAsString = re.sub('^data:image/.+;base64,', '', imgAsString)
    #missing_padding = len(imgAsString) % 4
    #if missing_padding != 0:
    #    imgAsString += '=' * (4 - missing_padding)

    imgdata = BytesIO(base64.b64decode(imgAsString))
    img = Image.open(imgdata)
    img.save("imageForEPaper.bmp", "BMP")
    epd.display_frame(epd.get_frame_buffer(img))
Esempio n. 18
0
def main():
    global OldState
    epd = epd7in5.EPD()
    epd.init()
    font = ImageFont.truetype('/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 88)
    font2 = ImageFont.truetype('/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 65)
    font3 = ImageFont.truetype('/usr/share/fonts/dejavu/DejaVuSansMono-Bold.ttf', 35)
    image = Image.new('1', (EPD_WIDTH, EPD_HEIGHT), 1)    # 1: clear the frame
    draw = ImageDraw.Draw(image)
    draw.text((0, 0), u'LÖSUNGSRAUM', font = font, fill = 0)
    newState= foo.getAll()
    draw.text((10,150),newState,font=font3,fill = 0)
    if OldState!=newState:
        print "Draw image"
        epd.display_frame(epd.get_frame_buffer(image))
    OldState=newState
Esempio n. 19
0
def display_frames():
    try:

        epd = epd7in5.EPD()
        logging.info("init and Clear")
        epd.init()
        epd.Clear()
        #time.sleep(1)

        frame_num = 0

        #opens frame and resizes to epaper dimensions, converts image to 1 bit and sleeps for 2.5 minutes
        while frame_num < 206800:

            logging.info("frames in shining frames: %d" %
                         len(os.listdir('shining_frames')))

            logging.info("Frame # %d" % frame_num)
            print("Frame # %d" % frame_num)
            logging.info("Total frames: 206800")
            im = Image.open(
                os.path.join('shining_frames/out_img%d.png' % frame_num))

            sized = im.resize((640, 384), Image.ANTIALIAS)

            converted = sized.convert(mode='1')

            epd.display(epd.getbuffer(sized))

            time.sleep(150)

            os.remove('shining_frames/out_img%d.png' % (frame_num))

            frame_num += 1

        print("finished")
        epd.Clear()
        epd.sleep()

    except IOError as e:
        logging.info(e)

    except KeyboardInterrupt:
        logging.info("ctrl + c:")
        epd7in5bc.epdconfig.module_exit()
        exit()
Esempio n. 20
0
def main():
	if isPi:
		epd = epd7in5.EPD()
		epd.init()

	# For simplicity, the arguments are explicit numerical coordinates
	img = Image.new('1', (EPD_HEIGHT, EPD_WIDTH), 1)    # 1: clear the frame
	draw = ImageDraw.Draw(img)

	renderTime(draw)
	renderTodos(draw)

	if isPi:
		img = img.transpose(Image.ROTATE_270)
		epd.display_frame(epd.get_frame_buffer(img))
	else:
		img.save('monocolor.bmp')
Esempio n. 21
0
def main():
    epd = epd7in5.EPD()
    epd.init()

    # For simplicity, the arguments are explicit numerical coordinates
    image = Image.new('1', (EPD_WIDTH, EPD_HEIGHT), 1)  # 1: clear the frame
    draw = ImageDraw.Draw(image)
    font = ImageFont.truetype("arial.ttf", 15)
    draw.rectangle((0, 6, 640, 30), fill=0)
    draw.text((200, 10), 'e-Paper demo', font=font, fill=255)
    draw.rectangle((200, 80, 600, 280), fill=0)
    draw.arc((240, 120, 580, 220), 0, 360, fill=255)
    draw.rectangle((0, 80, 160, 280), fill=255)
    draw.arc((40, 80, 180, 220), 0, 360, fill=0)
    epd.display_frame(epd.get_frame_buffer(image))

    image = Image.open('monocolor.bmp')
    epd.display_frame(epd.get_frame_buffer(image))
Esempio n. 22
0
def main():
    epd = epd7in5.EPD()
    epd.init()

    # For simplicity, the arguments are explicit numerical coordinates
    # image = Image.new('1', (EPD_WIDTH, EPD_HEIGHT), 1)    # 1: clear the frame
    # draw = ImageDraw.Draw(image)
    # font = ImageFont.truetype('/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 24)
    # draw.rectangle((0, 6, 640, 30), fill = 0)
    # draw.text((200, 10), 'e-Paper demo', font = font, fill = 255)
    # draw.rectangle((200, 80, 600, 280), fill = 0)
    # draw.arc((240, 120, 580, 220), 0, 360, fill = 255)
    # draw.rectangle((0, 80, 160, 280), fill = 255)
    # draw.arc((40, 80, 180, 220), 0, 360, fill = 0)
    # epd.display_frame(epd.get_frame_buffer(image))

    image = Image.open('/home/pi/paper-pi/build/monocolor.bmp')
    epd.display_frame(epd.get_frame_buffer(image))
Esempio n. 23
0
def initializeEPaper():
    global epaperDisplay

    if not debugEnableEPaperDisplay:
        return

    try:
        epaperDisplay = epd7in5.EPD()
        epaperDisplay.init()
        print("E-Paper: Clear")
        epaperDisplay.Clear()

        # If you sleep here, it won't respond to commands
        # epaperDisplay.sleep()
    except:
        print('traceback.format_exc():\n%s', traceback.format_exc())
        exit()

    print("E-paper initialized")
Esempio n. 24
0
    def drawDisplayWithoutEngagements(self):
        try:
            epd = epd7in5.EPD()
            epd.init()
            # epd.Clear(0xFF)

            HImage = Image.new('1', (epd7in5.EPD_WIDTH, epd7in5.EPD_HEIGHT),
                               255)  # 255: Clear the frame
            draw = ImageDraw.Draw(HImage)

            # Draw frame
            draw.line((0, 90, 640, 90), fill=0)
            draw.line((0, 91, 640, 91), fill=0)
            draw.line((0, 92, 640, 92), fill=0)
            draw.line((0, 93, 640, 93), fill=0)
            draw.line((0, 94, 640, 94), fill=0)
            draw.line((0, 286, 640, 286), fill=0)
            draw.line((0, 287, 640, 287), fill=0)
            draw.line((0, 288, 640, 288), fill=0)
            draw.line((0, 289, 640, 289), fill=0)
            draw.line((0, 290, 640, 290), fill=0)

            # Draw logo
            png = Image.open(LOGOPATH)
            HImage.paste(png, (520, 20))
            pngSt = Image.open(STATEPATH)
            HImage.paste(pngSt, (520, 320))

            # Draw title room
            draw.text((20, 30), self.roomTitle, font=FONT30, fill=0)

            # Draw time
            draw.text((5, 305),
                      datetime.now().strftime(self.formatTime),
                      font=FONT46,
                      fill=0)

            epd.display(epd.getbuffer(HImage))
            time.sleep(2)
            epd.sleep()
        except:
            print('traceback.format_exc():\n%s', traceback.format_exc())
            exit()
Esempio n. 25
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--simulate',
                        help='Simulate e-ink display',
                        action='store_true')
    args = parser.parse_args()

    if args.simulate:
        epd = None
    else:
        import epd7in5
        epd = epd7in5.EPD()
        epd.init()

    config = yaml.load(open('config.yml'))
    yr = Yr(config['weather']['url'])
    cal = Readcal(config['calendar']['url'], config['calendar']['username'],
                  config['calendar']['password'])
    while (True):
        display_info(epd, yr, cal)
        time.sleep(60)
        yr.refresh()
Esempio n. 26
0
def main():
    epd = epd7in5.EPD()
    epd.init()

    # For simplicity, the arguments are explicit numerical coordinates
    image = Image.new('1', (EPD_WIDTH, EPD_HEIGHT), 1)  # 1: clear the frame
    draw = ImageDraw.Draw(image)
    font = ImageFont.truetype(
        '/usr/share/fonts/truetype/freefont/FreeMonoBold.ttf', 24)
    draw.rectangle((0, 6, 640, 30), fill=0)
    draw.text((200, 10), 'e-Paper demo', font=font, fill=255)
    draw.rectangle((200, 80, 600, 280), fill=0)
    draw.arc((240, 120, 580, 220), 0, 360, fill=255)
    draw.rectangle((0, 80, 160, 280), fill=255)
    draw.arc((40, 80, 180, 220), 0, 360, fill=0)
    epd.display_frame(epd.get_frame_buffer(image))

    image = Image.open('screenshot.png')
    epd.display_frame(epd.get_frame_buffer(image))

    # You can get frame buffer from an image or import the buffer directly:
    epd.display_frame(imagedata.MONOCOLOR_BITMAP)
Esempio n. 27
0
def main():
    epd = epd7in5.EPD()
    epd.init()

    projects = [
        ('blog', fetch_circle_build_status('blog')),
        ('crytic', dash.BuildStatus.passed),
        ('danger-todoist', fetch_travis_build_status('danger-todoist')),
        ('danger-plugin-mentor',
         fetch_travis_build_status('danger-plugin-mentor')),  # noqa
        ('pitbuddy-ios',
         fetch_bitrise_build_status(os.getenv('PB_IOS_APP'),
                                    os.getenv('PB_IOS_TOKEN'))),  # noqa
        ('pitbuddy-android',
         fetch_bitrise_build_status(os.getenv('PB_ANDROID_APP'),
                                    os.getenv('PB_ANDROID_TOKEN')))  # noqa
    ]

    image = (dash.Dash(projects, os.getenv('DASH_FONTS_DIR')).render(
        datetime.datetime.now()))

    epd.display_frame(epd.get_frame_buffer(image))
Esempio n. 28
0
def main():
    epd = epd7in5.EPD()
    epd.init()
#    epd.Clear()

    # For simplicity, the arguments are explicit numerical coordinates
 
    image = Image.new('1', (EPD_WIDTH, EPD_HEIGHT), 255)    # 1: clear the frame
    image.paste(face, (420,150))
    image.paste(swim, (260,17))
    image.paste(temp, (260,75))
    image.paste(house, (12,150))
    image.paste(sun, (225,150))
    image.paste(paige, (15,230))
#    image.paste(thumb, (40,230))
#    image.paste(month, (12,300))
    draw = ImageDraw.Draw(image)
    draw.rectangle((10, 10, 630, 374), outline = 0) # outside
    draw.rectangle((10, 10, 250, 70), outline = 0)
    draw.rectangle((250, 10, 630, 70), outline = 0)
    draw.rectangle((250, 70, 630, 130), outline = 0)
    draw.rectangle((10, 70, 250, 130), outline = 0)
    draw.rectangle((10, 130, 630, 210), outline = 0) # house sun face
    draw.text((300, 140),"%s" % tassolar, font = font5, fill = 0) # House Solar
    draw.text((90, 140), "%s" % tashouse, font = font5, fill = 0) # House Watts
    draw.text((490, 140), "%s" % solardelta, font = font5, fill = 0) # Gain
    draw.text((12, 11), "Stamp: %s" % current_time, font = font4, fill = 0)
    draw.text((12, 25), "Solar Today       : %s" % tassolartoday, font = font3, fill = 0) # solar today
    draw.text((12, 45), "Solar Yesterday: %s" % tassolarYesterday, font = font3, fill = 0) # solar Yesterday
    draw.text((320, 15), "%s" % pooltemp, font = font1, fill = 0)
    draw.text((320, 75), "%s" % outsidetemp, font = font1, fill = 0)
    draw.text((12, 70), "%s" % dollar , font = font3, fill = 0)
    draw.text((260, 220), "%s" % my_date , font = font1, fill = 0)
    draw.text((260, 270), "Pool Pump is %s" % poolpumppower , font = font1, fill = 0)
    draw.text((260, 320), "Pool Heater is %s" % poolheatpower , font = font1, fill = 0)
    epd.display(epd.getbuffer(image))
    epd.sleep()
Esempio n. 29
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("screen")
    parser.add_argument("--invert", help="invert screen", action="store_true")
    args = parser.parse_args()
    if args.screen == "epd7in5":
        imagecount = 1
        epd = epd7in5.EPD()
    elif args.screen == "epd4in2b":
        imagecount = 2
        epd = epd4in2b.EPD()
    else:
        raise Exception("Unsupported screen, please submit a code patch")
    epd.init()

    image = Image.open('black.png')
    if args.invert:
        image = invert(image)

    if imagecount == 1:
        epd.display_frame(epd.get_frame_buffer(image))
    elif imagecount == 2:
        epd.display_frame(epd.get_frame_buffer(image),
                          epd.get_frame_buffer(image))
Esempio n. 30
0
def calibration():
    """Function for Calibration"""
    if display_colours == "bwr":
        import epd7in5b
        epd = epd7in5b.EPD()
        print('_________Calibration for 3-Colour E-Paper started_________' +
              '\n')
    if display_colours == "bw":
        import epd7in5
        epd = epd7in5.EPD()
        print('_________Calibration for 2-Colour E-Paper started_________' +
              '\n')
    for i in range(2):
        epd.init()
        print('Calibrating black...')
        epd.display_frame(epd.get_frame_buffer(black))
        if display_colours == "bwr":
            print('calibrating red...')
            epd.display_frame(epd.get_frame_buffer(red))
        print('Calibrating white...')
        epd.display_frame(epd.get_frame_buffer(white))
        epd.sleep()
        print('Cycle', str(i + 1) + '/2', 'complete' + '\n')
        print('Calibration complete')