| 
									
										
										
										
											2019-02-03 16:26:30 +01:00
										 |  |  | #!/usr/bin/python3 | 
					
						
							|  |  |  | # -*- coding: utf-8 -*- | 
					
						
							| 
									
										
										
										
											2019-02-25 22:20:55 +01:00
										 |  |  | """
 | 
					
						
							|  |  |  | 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. | 
					
						
							|  |  |  | """
 | 
					
						
							| 
									
										
										
										
											2019-02-03 16:26:30 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-25 22:20:55 +01:00
										 |  |  | from __future__ import print_function | 
					
						
							|  |  |  | import time | 
					
						
							|  |  |  | from settings import display_colours | 
					
						
							|  |  |  | from icon_positions_locations import black, white, red | 
					
						
							| 
									
										
										
										
											2019-02-03 16:26:30 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | def calibration(): | 
					
						
							| 
									
										
										
										
											2019-02-25 22:20:55 +01:00
										 |  |  |     """Function for Calibration""" | 
					
						
							| 
									
										
										
										
											2019-02-03 16:26:30 +01:00
										 |  |  |     if display_colours == "bwr": | 
					
						
							|  |  |  |         import epd7in5b | 
					
						
							|  |  |  |         epd = epd7in5b.EPD() | 
					
						
							| 
									
										
										
										
											2019-02-25 22:20:55 +01:00
										 |  |  |         print('_________Calibration for 3-Colour E-Paper started_________'+'\n') | 
					
						
							| 
									
										
										
										
											2019-02-03 16:26:30 +01:00
										 |  |  |     if display_colours == "bw": | 
					
						
							|  |  |  |         import epd7in5 | 
					
						
							|  |  |  |         epd = epd7in5.EPD() | 
					
						
							| 
									
										
										
										
											2019-02-25 22:20:55 +01:00
										 |  |  |         print('_________Calibration for 2-Colour E-Paper started_________'+'\n') | 
					
						
							| 
									
										
										
										
											2019-02-03 16:26:30 +01:00
										 |  |  |     for i in range(2): | 
					
						
							|  |  |  |         epd.init() | 
					
						
							| 
									
										
										
										
											2019-02-25 22:20:55 +01:00
										 |  |  |         print('Calibrating black...') | 
					
						
							| 
									
										
										
										
											2019-02-03 16:26:30 +01:00
										 |  |  |         epd.display_frame(epd.get_frame_buffer(black)) | 
					
						
							|  |  |  |         if display_colours == "bwr": | 
					
						
							|  |  |  |             print('calibrating red...') | 
					
						
							| 
									
										
										
										
											2019-02-12 08:46:52 +01:00
										 |  |  |             epd.display_frame(epd.get_frame_buffer(red)) | 
					
						
							| 
									
										
										
										
											2019-02-25 22:20:55 +01:00
										 |  |  |         print('Calibrating white...') | 
					
						
							| 
									
										
										
										
											2019-02-03 16:26:30 +01:00
										 |  |  |         epd.display_frame(epd.get_frame_buffer(white)) | 
					
						
							|  |  |  |         epd.sleep() | 
					
						
							| 
									
										
										
										
											2019-02-25 22:20:55 +01:00
										 |  |  |         print('Cycle', str(i+1)+'/2', 'complete'+'\n') | 
					
						
							|  |  |  |         print('Calibration complete') | 
					
						
							| 
									
										
										
										
											2019-02-03 16:26:30 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | def main(): | 
					
						
							| 
									
										
										
										
											2019-02-25 22:20:55 +01:00
										 |  |  |     """Added timer""" | 
					
						
							|  |  |  |     start = time.time() | 
					
						
							|  |  |  |     calibration() | 
					
						
							|  |  |  |     end = time.time() | 
					
						
							|  |  |  |     print('Calibration complete in', int(end - start), 'seconds') | 
					
						
							| 
									
										
										
										
											2019-02-03 16:26:30 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | if __name__ == '__main__': | 
					
						
							|  |  |  |     main() |