From b819091230a1a1e631b44186ed3b03312091ba54 Mon Sep 17 00:00:00 2001 From: ladyada Date: Fri, 1 Mar 2019 13:42:11 -0500 Subject: [PATCH 1/3] use the position we passed in --- adafruit_pyportal.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index f01313f..b96bce1 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -318,7 +318,7 @@ def __init__(self, *, url=None, json_path=None, regexp_path=None, gc.collect() - def set_background(self, file_or_color): + def set_background(self, file_or_color, position=None): """The background image to a bitmap file. :param file_or_color: The filename of the chosen background image, or a hex color. @@ -328,6 +328,9 @@ def set_background(self, file_or_color): while self._bg_group: self._bg_group.pop() + if not position: + position = (0, 0) # default in top corner + if not file_or_color: return # we're done, no background desired if self._bg_file: @@ -337,7 +340,7 @@ def set_background(self, file_or_color): background = displayio.OnDiskBitmap(self._bg_file) self._bg_sprite = displayio.TileGrid(background, pixel_shader=displayio.ColorConverter(), - position=(0, 0)) + position=position) elif isinstance(file_or_color, int): # Make a background color fill color_bitmap = displayio.Bitmap(320, 240, 1) @@ -678,7 +681,7 @@ def fetch(self): except OSError as error: print(error) raise OSError("""\n\nNo writable filesystem found for saving datastream. Insert an SD card or set internal filesystem to be unsafe by setting 'disable_concurrent_write_protection' in the mount options in boot.py""") # pylint: disable=line-too-long - self.set_background(filename) + self.set_background(filename, self._image_position) except ValueError as error: print("Error displaying cached image. " + error.args[0]) self.set_background(self._default_bg) From ab7fa0e11454a9596a9aefd2bedf66eacae712db Mon Sep 17 00:00:00 2001 From: ladyada Date: Tue, 5 Mar 2019 23:04:11 -0500 Subject: [PATCH 2/3] fix word wrap helper, allow use without a URL (no internet usage), touchscreen pins --- adafruit_pyportal.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index b96bce1..d672cc4 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -189,7 +189,7 @@ def __init__(self, *, url=None, json_path=None, regexp_path=None, esp32_cs = DigitalInOut(board.ESP_CS) spi = busio.SPI(board.SCK, board.MOSI, board.MISO) - if not self._uselocal: + if url and not self._uselocal: self._esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset, esp32_gpio0) #self._esp._debug = 1 @@ -229,7 +229,7 @@ def __init__(self, *, url=None, json_path=None, regexp_path=None, if self._debug: print("Init display") - self.splash = displayio.Group(max_size=5) + self.splash = displayio.Group(max_size=15) board.DISPLAY.show(self.splash) if self._debug: @@ -305,10 +305,8 @@ def __init__(self, *, url=None, json_path=None, regexp_path=None, if self._debug: print("Init touchscreen") # pylint: disable=no-member - self.touchscreen = adafruit_touchscreen.Touchscreen(microcontroller.pin.PB01, - microcontroller.pin.PB08, - microcontroller.pin.PA06, - microcontroller.pin.PB00, + self.touchscreen = adafruit_touchscreen.Touchscreen(board.TOUCH_XL, board.TOUCH_XR, + board.TOUCH_YD, board.TOUCH_YU, calibration=((5200, 59000), (5800, 57000)), size=(320, 240)) @@ -805,7 +803,9 @@ def wrap_nicely(string, max_chars): the_line = "" for w in words: if len(the_line+' '+w) <= max_chars: - the_line += ' '+w + if the_lines: + the_line += ' ' + the_line += w else: the_lines.append(the_line) the_line = ''+w From 407780c61fc9de0087d963b34b5ab9229927b41c Mon Sep 17 00:00:00 2001 From: ladyada Date: Tue, 5 Mar 2019 23:26:53 -0500 Subject: [PATCH 3/3] fix travis and re-fix linewrap --- adafruit_pyportal.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/adafruit_pyportal.py b/adafruit_pyportal.py index ead49a8..ab81dfa 100644 --- a/adafruit_pyportal.py +++ b/adafruit_pyportal.py @@ -48,7 +48,6 @@ import gc import board import busio -import microcontroller from digitalio import DigitalInOut import pulseio import adafruit_touchscreen @@ -834,9 +833,7 @@ def wrap_nicely(string, max_chars): the_line = "" for w in words: if len(the_line+' '+w) <= max_chars: - if the_lines: - the_line += ' ' - the_line += w + the_line += ' '+w else: the_lines.append(the_line) the_line = ''+w