Skip to content

Commit b819091

Browse files
committed
use the position we passed in
1 parent 6086ce3 commit b819091

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

adafruit_pyportal.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def __init__(self, *, url=None, json_path=None, regexp_path=None,
318318

319319
gc.collect()
320320

321-
def set_background(self, file_or_color):
321+
def set_background(self, file_or_color, position=None):
322322
"""The background image to a bitmap file.
323323
324324
: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):
328328
while self._bg_group:
329329
self._bg_group.pop()
330330

331+
if not position:
332+
position = (0, 0) # default in top corner
333+
331334
if not file_or_color:
332335
return # we're done, no background desired
333336
if self._bg_file:
@@ -337,7 +340,7 @@ def set_background(self, file_or_color):
337340
background = displayio.OnDiskBitmap(self._bg_file)
338341
self._bg_sprite = displayio.TileGrid(background,
339342
pixel_shader=displayio.ColorConverter(),
340-
position=(0, 0))
343+
position=position)
341344
elif isinstance(file_or_color, int):
342345
# Make a background color fill
343346
color_bitmap = displayio.Bitmap(320, 240, 1)
@@ -678,7 +681,7 @@ def fetch(self):
678681
except OSError as error:
679682
print(error)
680683
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
681-
self.set_background(filename)
684+
self.set_background(filename, self._image_position)
682685
except ValueError as error:
683686
print("Error displaying cached image. " + error.args[0])
684687
self.set_background(self._default_bg)

0 commit comments

Comments
 (0)