Skip to content

Commit 043f614

Browse files
authored
Merge pull request #12 from FoamyGuy/fix_for_board_without_display
fix error from board.DISPLAY not existing
2 parents 112d72f + 3fb0d56 commit 043f614

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

adafruit_bitmapsaver.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def _write_pixels(output_file, pixel_source, palette):
121121
# pylint:enable=too-many-locals
122122

123123

124-
def save_pixels(file_or_filename, pixel_source=board.DISPLAY, palette=None):
124+
def save_pixels(file_or_filename, pixel_source=None, palette=None):
125125
"""Save pixels to a 24 bit per pixel BMP file.
126126
If pixel_source if a displayio.Bitmap, save it's pixels through palette.
127127
If it's a displayio.Display, a palette isn't required.
@@ -130,6 +130,11 @@ def save_pixels(file_or_filename, pixel_source=board.DISPLAY, palette=None):
130130
:param pixel_source: the Bitmap or Display to save
131131
:param palette: the Palette to use for looking up colors in the bitmap
132132
"""
133+
if not pixel_source:
134+
if "DISPLAY" in dir(board):
135+
pixel_source = board.DISPLAY
136+
else:
137+
raise ValueError("Second argument must be a Bitmap or Display")
133138
if isinstance(pixel_source, Bitmap):
134139
if not isinstance(palette, Palette):
135140
raise ValueError("Third argument must be a Palette for a Bitmap save")

0 commit comments

Comments
 (0)