diff --git a/.gitignore b/.gitignore index 036203b..9bfb3f6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ keys.py *.pyc .image-cache/ -test.png \ No newline at end of file +test.png +*.j2 \ No newline at end of file diff --git a/deploy/deploy.playbook.yml b/deploy/deploy.playbook.yml index 2e47f20..41c4ccd 100644 --- a/deploy/deploy.playbook.yml +++ b/deploy/deploy.playbook.yml @@ -13,7 +13,7 @@ version: main - name: Install from the pipenv-file - command: "pipenv install --system --deploy" + command: "pipenv install --system --deploy --categories=\"packages prod-packages\"" args: chdir: "{{ code_dest }}" diff --git a/deploy/setup.playbook.yml b/deploy/setup.playbook.yml index 29c389d..37ac297 100644 --- a/deploy/setup.playbook.yml +++ b/deploy/setup.playbook.yml @@ -8,7 +8,6 @@ user: "{{ ansible_user }}" state: present # copy file present on the controller to the remote host - # https://docs.ansible.com/ansible/latest/collections/ansible/builtin/copy_module.html key: "{{ lookup('file', '~/.ssh/default.pub') }}" - name: apt update all packages @@ -48,7 +47,7 @@ delay: 5 timeout: 300 - - name: Add wifi networks from secrets + - name: Add wifi networks from template template: src: templates/wpa_supplicant.conf.j2 dest: /etc/wpa_supplicant/wpa_supplicant.conf diff --git a/deploy/templates/eink-show.timer.j2 b/deploy/templates/eink-show.timer.j2 index 5909751..26be874 100644 --- a/deploy/templates/eink-show.timer.j2 +++ b/deploy/templates/eink-show.timer.j2 @@ -2,7 +2,8 @@ Description=Run photo update regularly [Timer] -OnCalendar=Tue 11:00 +OnCalendar=08:00 +OnCalendar=16:00 Persistent=true [Install] diff --git a/image_convert.py b/image_convert.py index 3f9c8b1..0829440 100644 --- a/image_convert.py +++ b/image_convert.py @@ -1,4 +1,4 @@ -from PIL import Image +from PIL import Image, ImageOps import io import os @@ -24,7 +24,6 @@ oranges = [int_mult(orange_base, x/42) for x in range(1,43)] palette_unflat = [black_base, *whites, *greens, *blues, *reds, *yellows, *oranges] palette = [item for sublist in palette_unflat for item in sublist] -# print(len(palette)) ref_image = Image.new("P", (1,1)) ref_image.putpalette(palette) @@ -49,7 +48,12 @@ class ImageShrink: def shrink(self, image: Image) -> Image: """"Shrinks a given image (bytearray) to a given resolution (width, height)""" - image.thumbnail(self.resolution) + # image = ImageOps.contain(image, self.resolution) + # maintains the aspect ratio of the original image and leaves empty space + image = ImageOps.fit(image, self.resolution, centering=(0.5, 0.5)) + # crops the image to the given resolution from the center on + + # image.thumbnail(self.resolution) return image diff --git a/image_show.py b/image_show.py index db9ef28..b7de130 100644 --- a/image_show.py +++ b/image_show.py @@ -1,5 +1,5 @@ from PIL import Image, ImageDraw -from waveshare-epaper import epd7in3f +from waveshare_epaper import epd7in3f # BLACK = 0x000000 # 0000 BGR # WHITE = 0xffffff # 0001