Skip to content

ssd1681: Fix OverflowError for displays larger than 255x255. #90

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AJMansfield
Copy link

When trying to use this driver with a display with dimensions larger than 255x255, the arithmetic operations that attempt to format the width and height into a pair of bytes in the ssd1681 driver's power_up function leaves extra overflowing high-order bits in the low-order byte, resulting in an error: OverflowError: value must fit in 1 byte(s), originating from line 146 (for widths larger than 255) or 153 (for heights larger than 255).

This PR fixes this by explicitly masking out just the low byte; it also fixes another instance of this pattern in set_ram_address (though I've not gone into detail trying to figure out inputs to actually trigger an error from this instance).

I've tested this change using an 400x300 HINK-E042A88 SSD1683 display, connected via an Adafruit eInk Feather Friend to my Adafruit Feather RP2040.

Based on my tests I can confirm that this PR addresses the above issue; display operations appear to run correctly with it.

Need to explicitly truncate to just the low-order byte; otherwise, creating these bytearrays results in `OverflowError: value must fit in 1 byte(s)`.
@AJMansfield
Copy link
Author

Also: if I have the time I'll see if this pattern occurs in other drivers too and add fixes for them as well.

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.

1 participant