From aae79541e1f93170e114dc5d4725a79df30668c6 Mon Sep 17 00:00:00 2001 From: Moheeb Zara Date: Mon, 27 Apr 2020 17:14:52 -0700 Subject: [PATCH 1/4] Add param to disable image converter In some cases your image may already be the correct format. --- adafruit_pyportal.py | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index f8e96a1..7e2db9b 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -126,6 +126,8 @@ class PyPortal: :param regexp_path: The list of regexp strings to get data out (use a single regexp group). Can be list of regexps for multiple data points. Defaults to ``None`` to not use regexp. + :param convert_image: Determine whether or not to use the AdafruitIO image converter service. + Set as False if your image is already resized. Defaults to True. :param default_bg: The path to your default background image file or a hex color. Defaults to 0x000000. :param status_neopixel: The pin for the status NeoPixel. Use ``board.NEOPIXEL`` for the on-board @@ -174,6 +176,7 @@ def __init__( headers=None, json_path=None, regexp_path=None, + convert_image=False, default_bg=0x000000, status_neopixel=None, text_font=None, @@ -944,21 +947,23 @@ def fetch(self, refresh_url=None, timeout=10): if image_url: try: print("original URL:", image_url) - if iwidth < iheight: - image_url = self.image_converter_url( - image_url, - int( - self._image_resize[1] - * self._image_resize[1] - / self._image_resize[0] - ), - self._image_resize[1], - ) - else: - image_url = self.image_converter_url( - image_url, self._image_resize[0], self._image_resize[1] - ) - print("convert URL:", image_url) + if self._convert_image: + if iwidth < iheight: + image_url = self.image_converter_url( + image_url, + int( + self._image_resize[1] + * self._image_resize[1] + / self._image_resize[0] + ), + self._image_resize[1], + ) + else: + image_url = self.image_converter_url( + image_url, self._image_resize[0], self._image_resize[1] + ) + + print("convert URL:", image_url) # convert image to bitmap and cache # print("**not actually wgetting**") filename = "/cache.bmp" From 1005a9a1ad695d9b51a2e90a1c3b934131344419 Mon Sep 17 00:00:00 2001 From: Moheeb Zara Date: Mon, 27 Apr 2020 17:23:04 -0700 Subject: [PATCH 2/4] Update adafruit_pyportal.py --- adafruit_pyportal.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index 7e2db9b..cf94aa3 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -176,7 +176,7 @@ def __init__( headers=None, json_path=None, regexp_path=None, - convert_image=False, + convert_image=True, default_bg=0x000000, status_neopixel=None, text_font=None, @@ -202,6 +202,7 @@ def __init__( ): self._debug = debug + self._convert_image= convert_image try: if hasattr(board, "TFT_BACKLIGHT"): From 5439e51cfa8f68fb7be6b4c6452022eed7e0b08d Mon Sep 17 00:00:00 2001 From: FoamyGuy Date: Wed, 6 May 2020 13:16:17 -0500 Subject: [PATCH 3/4] black formatting --- adafruit_pyportal.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index cf94aa3..0f78116 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -202,7 +202,7 @@ def __init__( ): self._debug = debug - self._convert_image= convert_image + self._convert_image = convert_image try: if hasattr(board, "TFT_BACKLIGHT"): @@ -949,22 +949,22 @@ def fetch(self, refresh_url=None, timeout=10): try: print("original URL:", image_url) if self._convert_image: - if iwidth < iheight: - image_url = self.image_converter_url( - image_url, - int( - self._image_resize[1] - * self._image_resize[1] - / self._image_resize[0] - ), - self._image_resize[1], - ) - else: - image_url = self.image_converter_url( - image_url, self._image_resize[0], self._image_resize[1] - ) - - print("convert URL:", image_url) + if iwidth < iheight: + image_url = self.image_converter_url( + image_url, + int( + self._image_resize[1] + * self._image_resize[1] + / self._image_resize[0] + ), + self._image_resize[1], + ) + else: + image_url = self.image_converter_url( + image_url, self._image_resize[0], self._image_resize[1] + ) + + print("convert URL:", image_url) # convert image to bitmap and cache # print("**not actually wgetting**") filename = "/cache.bmp" From ceaedff15717c746da86b4d9b08453fc39927de0 Mon Sep 17 00:00:00 2001 From: FoamyGuy Date: Wed, 6 May 2020 13:18:40 -0500 Subject: [PATCH 4/4] remove trailing whitespace --- adafruit_pyportal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index 0f78116..34583fa 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -126,8 +126,8 @@ class PyPortal: :param regexp_path: The list of regexp strings to get data out (use a single regexp group). Can be list of regexps for multiple data points. Defaults to ``None`` to not use regexp. - :param convert_image: Determine whether or not to use the AdafruitIO image converter service. - Set as False if your image is already resized. Defaults to True. + :param convert_image: Determine whether or not to use the AdafruitIO image converter service. + Set as False if your image is already resized. Defaults to True. :param default_bg: The path to your default background image file or a hex color. Defaults to 0x000000. :param status_neopixel: The pin for the status NeoPixel. Use ``board.NEOPIXEL`` for the on-board