ssd1681: Fix OverflowError for displays larger than 255x255. #90
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.