Repository navigation
extmod/modframebuf: Add attributes for width, height, format and stride. - #17328
andrewleech wants to merge 1 commit into
Conversation
70af7a8 to
92b5a0b
Compare
|
Code size report: |
73a8cf9 to
5b0456f
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #17328 +/- ##
=======================================
Coverage 98.46% 98.46%
=======================================
Files 176 176
Lines 22784 22796 +12
=======================================
+ Hits 22435 22447 +12
Misses 349 349 ☔ 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 |
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]>
5b0456f to
63acb87
Compare
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