| 
									
										
										
										
											2022-04-14 06:38:22 +02:00
										 |  |  | """
 | 
					
						
							|  |  |  | 10.3" driver class | 
					
						
							| 
									
										
										
										
											2023-06-03 16:16:07 +02:00
										 |  |  | Copyright by aceinnolab | 
					
						
							| 
									
										
										
										
											2022-04-14 06:38:22 +02:00
										 |  |  | """
 | 
					
						
							| 
									
										
										
										
											2024-05-12 02:00:26 +02:00
										 |  |  | import os | 
					
						
							| 
									
										
										
										
											2022-04-14 06:38:22 +02:00
										 |  |  | from subprocess import run | 
					
						
							| 
									
										
										
										
											2023-12-14 22:29:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 06:38:22 +02:00
										 |  |  | from PIL import Image | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-12 02:00:26 +02:00
										 |  |  | from inkycal.settings import Settings | 
					
						
							| 
									
										
										
										
											2023-12-14 22:29:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 06:38:22 +02:00
										 |  |  | # Display resolution | 
					
						
							|  |  |  | EPD_WIDTH = 1872 | 
					
						
							|  |  |  | EPD_HEIGHT = 1404 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-12 02:00:26 +02:00
										 |  |  | settings = Settings() | 
					
						
							| 
									
										
										
										
											2022-04-14 06:38:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-14 22:29:22 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-14 06:38:22 +02:00
										 |  |  | class EPD: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def __init__(self): | 
					
						
							|  |  |  |         """10.3" epaper class""" | 
					
						
							|  |  |  |         pass | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def init(self): | 
					
						
							|  |  |  |         pass | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def display(self, command): | 
					
						
							|  |  |  |         """displays an image""" | 
					
						
							|  |  |  |         try: | 
					
						
							|  |  |  |             run_command = command.split() | 
					
						
							|  |  |  |             run(run_command) | 
					
						
							|  |  |  |         except: | 
					
						
							|  |  |  |             print("oops, something didn't work right :/") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def getbuffer(self, image): | 
					
						
							|  |  |  |         """ad-hoc""" | 
					
						
							| 
									
										
										
										
											2023-12-14 22:29:22 +01:00
										 |  |  |         image = image.rotate(90, expand=True).transpose(Image.FLIP_LEFT_RIGHT) | 
					
						
							| 
									
										
										
										
											2024-07-05 13:20:57 +02:00
										 |  |  |         image.convert("RGB").save(os.path.join(settings.IMAGE_FOLDER, "canvas.bmp"), "BMP") | 
					
						
							|  |  |  |         command = f'sudo {settings.PARALLEL_DRIVER_PATH}/epd -{settings.VCOM} 0 {os.path.join(settings.IMAGE_FOLDER, "canvas.bmp")}' | 
					
						
							| 
									
										
										
										
											2022-04-14 06:38:22 +02:00
										 |  |  |         print(command) | 
					
						
							|  |  |  |         return command | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def sleep(self): | 
					
						
							|  |  |  |         pass |