Skip to content

Conversation

@dastels
Copy link
Collaborator

@dastels dastels commented Jul 19, 2019

No description provided.

@dastels dastels requested a review from a team July 19, 2019 22:01
@dastels
Copy link
Collaborator Author

dastels commented Jul 19, 2019

Um... why isn't travis running checks on this?

@ladyada
Copy link
Member

ladyada commented Jul 19, 2019

there's no code you commited?

@dastels
Copy link
Collaborator Author

dastels commented Jul 19, 2019

OK... I've had some git weirdness happening with the one. I think it's good now (and it's checking).

@brentru
Copy link
Member

brentru commented Jul 25, 2019

@dastels Ran into an error with a PyGamer running CircuitPython 4.1.0-beta and the simpletest example in this PR.

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Setting up SD card
Building sample bitmap and palette
Saving bitmap
Error saving bitmap
Traceback (most recent call last):
  File "code.py", line 50, in <module>
  File "/lib/adafruit_bitmapsaver.py", line 115, in save_bitmap
  File "/lib/adafruit_bitmapsaver.py", line 112, in save_bitmap
  File "/lib/adafruit_bitmapsaver.py", line 84, in _write_pixels
TypeError: 'Palette' object is not subscriptable
OSError

@dastels
Copy link
Collaborator Author

dastels commented Jul 25, 2019

Yes. It requires 5.0

@brentru
Copy link
Member

brentru commented Jul 25, 2019

@dastels Ok, could you update the README.rst to reflect the requirement for CircuitPython 5.0?

:param bitmap: the displayio.Bitmap to save
:param palette: the displayio.Palette to use for looking up colors in the bitmap
"""
print("Saving bitmap")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Library should not print.

output_file = file_or_filename

filesize = 54 + bitmap.height * _bytes_per_row(bitmap)
# print('Bitmap height: ', bitmap.height)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove or add a debug kwarg

_write_dib_header(output_file, bitmap)
_write_pixels(output_file, bitmap, palette)
except Exception:
print('Error saving bitmap')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you raise instead of printing here?

raise
else:
output_file.close()
print("Finished saving bitmap")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print used again. Possibly return if bitmap was saved successfully.

"""
print("Saving bitmap")
if not isinstance(bitmap, Bitmap):
raise ValueError('bitmap')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make these exceptions more verbose as to why the file is not accepted?

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BitmapSaver.git"

#pylint:disable=line-too-long,broad-except,redefined-outer-name,invalid-name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hiya don't disable these, they're there for a reason! please lint the code so these errors don't come up.

@ladyada ladyada merged commit ab737ac into adafruit:master Aug 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants