Skip to content

fix error from board.DISPLAY not existing #12

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
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
7 changes: 6 additions & 1 deletion adafruit_bitmapsaver.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _write_pixels(output_file, pixel_source, palette):
# pylint:enable=too-many-locals


def save_pixels(file_or_filename, pixel_source=board.DISPLAY, palette=None):
def save_pixels(file_or_filename, pixel_source=None, palette=None):
"""Save pixels to a 24 bit per pixel BMP file.
If pixel_source if a displayio.Bitmap, save it's pixels through palette.
If it's a displayio.Display, a palette isn't required.
Expand All @@ -130,6 +130,11 @@ def save_pixels(file_or_filename, pixel_source=board.DISPLAY, palette=None):
:param pixel_source: the Bitmap or Display to save
:param palette: the Palette to use for looking up colors in the bitmap
"""
if not pixel_source:
if "DISPLAY" in dir(board):
pixel_source = board.DISPLAY
else:
raise ValueError("Second argument must be a Bitmap or Display")
if isinstance(pixel_source, Bitmap):
if not isinstance(palette, Palette):
raise ValueError("Third argument must be a Palette for a Bitmap save")
Expand Down