← index #7844PR #17328
Related · high · value 0.275
QUERY · ISSUE

Framebuffer Tests: Parameter stride is never tested

openby volkerjaenischopened 2021-09-22updated 2025-10-04
tests

Dear Micropython developers!

One of the most mystic but also widespread used parameter in the framebuffer code is the "stride".

IMHO the stride is meant to gives a solution to displays with hidden pixels.
@all Can anybody longer in the project please elaborate on this parameter or give a pointer, please.

Nevertheless, there is not a single test that covers the stride, while it's value contributes in nearly any function of the module.

If we expose a parameter it should be tested.

I volunteer to write tests for the stride parameter.

Cheers,
Volker

CANDIDATE · PULL REQUEST

extmod/modframebuf: Add attributes for width, height, format and stride.

openby andrewleechopened 2025-05-20updated 2026-01-22
extmod

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:

  • MONO_VLSB, MONO_HLSB, MONO_HMSB
  • RGB565
  • GS2_HMSB, GS4_HMSB, GS8

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

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied