Skip to content

Conversation

@deshipu
Copy link

@deshipu deshipu commented Mar 20, 2019

No description provided.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you for the fix!

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

After thinking about this I don't think this is the right fix. Bitmap only handles 1, 2, 4 or 8 bits. It can't do number of bits that don't fit evenly into a byte.

@deshipu
Copy link
Author

deshipu commented Mar 20, 2019

Hmm, in that case, the original code was correct up to 8 bits, be just need a special case for multiples of 8.

@deshipu
Copy link
Author

deshipu commented Mar 20, 2019

We probably should also have a check for a maximum value — what that would be?

@deshipu deshipu requested a review from tannewt March 20, 2019 19:11
@deshipu
Copy link
Author

deshipu commented Mar 20, 2019

Actually we don't need to check for max value, because 2ⁿ is always going to be larger than n, so we can't get a number so large that we can't handle, now that we increase bits slower.

@tannewt
Copy link
Member

tannewt commented Mar 20, 2019

The implementation caps at 8 bit color: https://github.com/adafruit/circuitpython/blob/master/shared-module/displayio/Bitmap.c#L48

I think this implementation may still infinite loop for value counts > 0x80000000 because the minimum value based on bits will wrap around. Do we want to support 32 bit color in the future or is 24 enough? We can cap the number for the API here and leave the above check for the implementation.

@dhalbert dhalbert added this to the 4.0.0 - Bluetooth milestone Mar 20, 2019
@deshipu
Copy link
Author

deshipu commented Mar 20, 2019

Oh, you mean the 1U << bits will wrap around with bits >= 32?
I wonder if we could do value_counts >> bits instead...

@deshipu
Copy link
Author

deshipu commented Mar 20, 2019

I suppose we now need to add a check that value_counts > 0...

tannewt
tannewt previously approved these changes Mar 21, 2019
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Looks good! Unfortunately the translation check isn't happy because make translate wasn't run after adding it.

@dhalbert
Copy link
Collaborator

@deshipu Can you fix the translation conflicts and resubmit? (Maybe after your other PR's are cleared.)

@deshipu deshipu requested a review from dhalbert March 25, 2019 20:42
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Travis is happy. Thank you!

@tannewt tannewt merged commit 3f42a49 into adafruit:master Mar 26, 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