Skip to content

Added param to disable image converter #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions adafruit_pyportal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -174,6 +176,7 @@ def __init__(
headers=None,
json_path=None,
regexp_path=None,
convert_image=True,
default_bg=0x000000,
status_neopixel=None,
text_font=None,
Expand All @@ -199,6 +202,7 @@ def __init__(
):

self._debug = debug
self._convert_image = convert_image

try:
if hasattr(board, "TFT_BACKLIGHT"):
Expand Down Expand Up @@ -944,21 +948,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"
Expand Down