-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
extmod/modframebuf: Add attributes for width, height, format and stride. #17328
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
base: master
Are you sure you want to change the base?
Conversation
70af7a8 to
92b5a0b
Compare
|
Code size report: |
f691ae9 to
73a8cf9
Compare
Implement an attr handler for FrameBuffer objects to allow direct access to the width, height, format and stride properties, which makes it easier to reuse framebuffers without needing to track their properties separately. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Andrew Leech <[email protected]>
73a8cf9 to
5b0456f
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #17328 +/- ##
=======================================
Coverage 98.54% 98.54%
=======================================
Files 169 169
Lines 21898 21909 +11
=======================================
+ Hits 21580 21591 +11
Misses 318 318 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Some display drivers enable rotation where width and height may be transposed. My subclasses maintain To expand on this, where rotation is done in code there may be no problem if the framebuf is instantiated with Arguably no action is required here with such subclasses overriding the base class attributes, but comments are welcome. |
Rotation feels like a problem best solved at a layer above Or at least right now |
Summary
This PR adds direct attribute access to the FrameBuffer class by implementing an attribute handler in the C code. Users can now access the width, height, format, and stride properties directly from
framebuffer objects using standard attribute syntax (e.g., fb.width, fb.height, etc.).
This makes it easier to work with framebuffers in applications where these properties need to be accessed frequently, eliminating the need to store and track these values separately. It's particularly
useful when passing framebuffers between different functions or modules.
Prompted by https://github.com/orgs/micropython/discussions/17266
Testing
I've added a comprehensive test suite in tests/extmod/framebuf_attr.py that validates all the framebuffer attributes with all supported formats:
The test also checks various dimensions (8x4, 16x8, 128x64) and verifies that attempting to access non-existent attributes raises an AttributeError as expected.
The implementation was tested on the Unix port, and since this change is contained within the framebuf module and doesn't interact with hardware-specific features, it should work consistently across all
ports that support the framebuf module.
🤖 Generated with Claude Code