Fix typos
This commit is contained in:
parent
2965f4f218
commit
2c06a2f979
@ -137,11 +137,8 @@ class Inkycal:
|
|||||||
except:
|
except:
|
||||||
logger.exception(f"Exception: {traceback.format_exc()}.")
|
logger.exception(f"Exception: {traceback.format_exc()}.")
|
||||||
|
|
||||||
# Path to store images
|
|
||||||
self.image_folder = settings.IMAGE_FOLDER
|
|
||||||
|
|
||||||
# Remove old hashes
|
# Remove old hashes
|
||||||
self._remove_hashes(self.image_folder)
|
self._remove_hashes(settings.IMAGE_FOLDER)
|
||||||
|
|
||||||
# set up cache
|
# set up cache
|
||||||
if not os.path.exists(os.path.join(settings.CACHE_PATH, CACHE_NAME)):
|
if not os.path.exists(os.path.join(settings.CACHE_PATH, CACHE_NAME)):
|
||||||
@ -352,11 +349,11 @@ class Inkycal:
|
|||||||
self._calibration_check()
|
self._calibration_check()
|
||||||
if self._calibration_state:
|
if self._calibration_state:
|
||||||
# After calibration, we have to forcefully rewrite the screen
|
# After calibration, we have to forcefully rewrite the screen
|
||||||
self._remove_hashes(self.image_folder)
|
self._remove_hashes(settings.IMAGE_FOLDER)
|
||||||
|
|
||||||
if self.supports_colour:
|
if self.supports_colour:
|
||||||
im_black = Image.open(f"{self.image_folder}canvas.png")
|
im_black = Image.open(os.path.join(settings.IMAGE_FOLDER, "canvas.png"))
|
||||||
im_colour = Image.open(f"{self.image_folder}canvas_colour.png")
|
im_colour = Image.open(os.path.join(settings.IMAGE_FOLDER, "canvas_colour.png"))
|
||||||
|
|
||||||
# Flip the image by 180° if required
|
# Flip the image by 180° if required
|
||||||
if self.settings['orientation'] == 180:
|
if self.settings['orientation'] == 180:
|
||||||
@ -365,8 +362,8 @@ class Inkycal:
|
|||||||
|
|
||||||
# Render the image on the display
|
# Render the image on the display
|
||||||
if not self.settings.get('image_hash', False) or self._needs_image_update([
|
if not self.settings.get('image_hash', False) or self._needs_image_update([
|
||||||
(f"{self.image_folder}/canvas.png.hash", im_black),
|
(f"{settings.IMAGE_FOLDER}/canvas.png.hash", im_black),
|
||||||
(f"{self.image_folder}/canvas_colour.png.hash", im_colour)
|
(f"{settings.IMAGE_FOLDER}/canvas_colour.png.hash", im_colour)
|
||||||
]):
|
]):
|
||||||
display.render(im_black, im_colour)
|
display.render(im_black, im_colour)
|
||||||
|
|
||||||
@ -379,7 +376,7 @@ class Inkycal:
|
|||||||
im_black = upside_down(im_black)
|
im_black = upside_down(im_black)
|
||||||
|
|
||||||
if not self.settings.get('image_hash', False) or self._needs_image_update([
|
if not self.settings.get('image_hash', False) or self._needs_image_update([
|
||||||
(f"{self.image_folder}/canvas.png.hash", im_black), ]):
|
(f"{settings.IMAGE_FOLDER}/canvas.png.hash", im_black), ]):
|
||||||
display.render(im_black)
|
display.render(im_black)
|
||||||
|
|
||||||
logger.info(f'\nNo errors since {self.counter} display updates')
|
logger.info(f'\nNo errors since {self.counter} display updates')
|
||||||
@ -415,8 +412,8 @@ class Inkycal:
|
|||||||
returns the merged image
|
returns the merged image
|
||||||
"""
|
"""
|
||||||
|
|
||||||
im1_path = os.path.join(settings.image_folder, "canvas.png")
|
im1_path = os.path.join(settings.IMAGE_FOLDER, "canvas.png")
|
||||||
im2_path = os.path.join(settings.image_folder, "canvas_colour.png")
|
im2_path = os.path.join(settings.IMAGE_FOLDER, "canvas_colour.png")
|
||||||
|
|
||||||
# If there is an image for black and colour, merge them
|
# If there is an image for black and colour, merge them
|
||||||
if os.path.exists(im1_path) and os.path.exists(im2_path):
|
if os.path.exists(im1_path) and os.path.exists(im2_path):
|
||||||
@ -454,8 +451,8 @@ class Inkycal:
|
|||||||
for number in range(1, self._module_number):
|
for number in range(1, self._module_number):
|
||||||
|
|
||||||
# get the path of the current module's generated images
|
# get the path of the current module's generated images
|
||||||
im1_path = f"{self.image_folder}module{number}_black.png"
|
im1_path = os.path.join(settings.IMAGE_FOLDER, f"module{number}_black.png")
|
||||||
im2_path = f"{self.image_folder}module{number}_colour.png"
|
im2_path = os.path.join(settings.IMAGE_FOLDER, f"module{number}_colour.png")
|
||||||
|
|
||||||
# Check if there is an image for the black band
|
# Check if there is an image for the black band
|
||||||
if os.path.exists(im1_path):
|
if os.path.exists(im1_path):
|
||||||
@ -525,8 +522,8 @@ class Inkycal:
|
|||||||
im_black = self._optimize_im(im_black)
|
im_black = self._optimize_im(im_black)
|
||||||
im_colour = self._optimize_im(im_colour)
|
im_colour = self._optimize_im(im_colour)
|
||||||
|
|
||||||
im_black.save(self.image_folder + 'canvas.png', 'PNG')
|
im_black.save(os.path.join(settings.IMAGE_FOLDER, "canvas.png"), "PNG")
|
||||||
im_colour.save(self.image_folder + 'canvas_colour.png', 'PNG')
|
im_colour.save(os.path.join(settings.IMAGE_FOLDER, "canvas_colour.png"), 'PNG')
|
||||||
|
|
||||||
# Additionally, combine the two images with color
|
# Additionally, combine the two images with color
|
||||||
def clear_white(img):
|
def clear_white(img):
|
||||||
@ -614,8 +611,8 @@ class Inkycal:
|
|||||||
black, colour = module.generate_image()
|
black, colour = module.generate_image()
|
||||||
if self.show_border:
|
if self.show_border:
|
||||||
draw_border_2(im=black, xy=(1, 1), size=(black.width - 2, black.height - 2), radius=5)
|
draw_border_2(im=black, xy=(1, 1), size=(black.width - 2, black.height - 2), radius=5)
|
||||||
black.save(f"{self.image_folder}module{number}_black.png", "PNG")
|
black.save(os.path.join(settings.IMAGE_FOLDER, f"module{number}_black.png"), "PNG")
|
||||||
colour.save(f"{self.image_folder}module{number}_colour.png", "PNG")
|
colour.save(os.path.join(settings.IMAGE_FOLDER, f"module{number}_colour.png"), "PNG")
|
||||||
return True
|
return True
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception(f"Error in module {number}!")
|
logger.exception(f"Error in module {number}!")
|
||||||
|
Loading…
Reference in New Issue
Block a user