Skip to content

Support multi-byte values with Bitmap #1746

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 2 commits into from
Apr 4, 2019

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Apr 4, 2019

It also corrects the behavior of single byte values.

Fixes #1744

It also corrects the behavior of single byte values.

Fixes micropython#1744
@tannewt tannewt added this to the 4.0.0 - Bluetooth milestone Apr 4, 2019
@dhalbert dhalbert self-requested a review April 4, 2019 22:16
Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

I looked over the logic and it looks good from here!

@dhalbert dhalbert merged commit 35cfc61 into adafruit:master Apr 4, 2019
self->read_only = false;
self->bits_per_value = bits_per_value;

if (bits_per_value > 8) {
mp_raise_NotImplementedError(translate("Only bit maps of 8 bit color or less are supported"));
if (bits_per_value > 8 && bits_per_value != 16 && bits_per_value != 32) {
Copy link

Choose a reason for hiding this comment

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

Doesn't this assume that size_t is uint32_t?

Copy link

Choose a reason for hiding this comment

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

Also, shouldn't we also be checking that it's a power of two when < 8?

Copy link
Member Author

Choose a reason for hiding this comment

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

How does it assume uint32_t is size_t?

It's probably better to modify this check to check for 24 bit and fail. We can rely on shared-bindings to do power of two below 8 and multiple of 8 above. I just didn't want to support packing/unpacking 24-bit values.

Copy link

Choose a reason for hiding this comment

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

Well, it actually assumes 32 <= size_t <= 40. I guess I'm trying to understand why you replaced uint32_t with size_t earlier on, when you still hard-code the supported sizes.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed it because I was in there and better understand size_t can be used to support 64 bit in the future. Perhaps I should have left it to reduce the diff size.

Copy link

Choose a reason for hiding this comment

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

I see, sorry, I thought it's related.

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