Some improvements
Added info about the module and a 'timer' to time the time taken for calibration. Improved some output messages for easier understanding. Switched form generating images to opening images, hence allowing a slightly faster calibration.
This commit is contained in:
parent
a10da655e5
commit
271c18467a
@ -1,40 +1,45 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
Calibration module for the Black-White and Black-White-Red E-Paper display
|
||||||
|
Calibration refers to flushing all pixels in a single colour to prevent
|
||||||
|
ghosting.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
import time
|
||||||
from settings import display_colours
|
from settings import display_colours
|
||||||
from PIL import Image, ImageDraw
|
from icon_positions_locations import black, white, red
|
||||||
|
|
||||||
|
|
||||||
EPD_WIDTH = 640
|
|
||||||
EPD_HEIGHT = 384
|
|
||||||
|
|
||||||
def calibration():
|
def calibration():
|
||||||
|
"""Function for Calibration"""
|
||||||
if display_colours == "bwr":
|
if display_colours == "bwr":
|
||||||
import epd7in5b
|
import epd7in5b
|
||||||
epd = epd7in5b.EPD()
|
epd = epd7in5b.EPD()
|
||||||
|
print('_________Calibration for 3-Colour E-Paper started_________'+'\n')
|
||||||
if display_colours == "bw":
|
if display_colours == "bw":
|
||||||
import epd7in5
|
import epd7in5
|
||||||
epd = epd7in5.EPD()
|
epd = epd7in5.EPD()
|
||||||
|
print('_________Calibration for 2-Colour E-Paper started_________'+'\n')
|
||||||
for i in range(2):
|
for i in range(2):
|
||||||
epd.init()
|
epd.init()
|
||||||
black = Image.new('1', (EPD_WIDTH, EPD_HEIGHT), 'black')
|
print('Calibrating black...')
|
||||||
print('calibrating black...')
|
|
||||||
ImageDraw.Draw(black)
|
|
||||||
epd.display_frame(epd.get_frame_buffer(black))
|
epd.display_frame(epd.get_frame_buffer(black))
|
||||||
if display_colours == "bwr":
|
if display_colours == "bwr":
|
||||||
red = Image.new('L', (EPD_WIDTH, EPD_HEIGHT), 'red')
|
|
||||||
ImageDraw.Draw(red)
|
|
||||||
print('calibrating red...')
|
print('calibrating red...')
|
||||||
epd.display_frame(epd.get_frame_buffer(red))
|
epd.display_frame(epd.get_frame_buffer(red))
|
||||||
white = Image.new('1', (EPD_WIDTH, EPD_HEIGHT), 'white')
|
print('Calibrating white...')
|
||||||
ImageDraw.Draw(white)
|
|
||||||
print('calibrating white...')
|
|
||||||
epd.display_frame(epd.get_frame_buffer(white))
|
epd.display_frame(epd.get_frame_buffer(white))
|
||||||
epd.sleep()
|
epd.sleep()
|
||||||
print('Calibration complete')
|
print('Cycle', str(i+1)+'/2', 'complete'+'\n')
|
||||||
|
print('Calibration complete')
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
for i in range(1):
|
"""Added timer"""
|
||||||
calibration()
|
start = time.time()
|
||||||
|
calibration()
|
||||||
|
end = time.time()
|
||||||
|
print('Calibration complete in', int(end - start), 'seconds')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user