Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.2k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
andrewleech wants to merge1 commit intomicropython:masterChoose a base branch fromandrewleech:framebuf_attr
base:master
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletionsdocs/library/framebuf.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
15 changes: 13 additions & 2 deletionsexamples/natmod/framebuf/framebuf.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletionsextmod/modframebuf.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletionstests/extmod/framebuf_attr.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
try: | ||
importframebuf | ||
exceptImportError: | ||
print("SKIP") | ||
raiseSystemExit | ||
# Test different formats | ||
formats= [ | ||
(framebuf.MONO_VLSB,"MONO_VLSB"), | ||
(framebuf.MONO_HLSB,"MONO_HLSB"), | ||
(framebuf.MONO_HMSB,"MONO_HMSB"), | ||
(framebuf.RGB565,"RGB565"), | ||
(framebuf.GS2_HMSB,"GS2_HMSB"), | ||
(framebuf.GS4_HMSB,"GS4_HMSB"), | ||
(framebuf.GS8,"GS8"), | ||
] | ||
# Test with different dimensions | ||
dimensions= [(8,4), (16,8), (128,64)] | ||
forwidth,heightindimensions: | ||
forfmt,nameinformats: | ||
# Create appropriate buffer size based on format | ||
iffmt==framebuf.MONO_VLSB: | ||
size= ((height+7)//8)*width | ||
eliffmt==framebuf.MONO_HLSBorfmt==framebuf.MONO_HMSB: | ||
size= ((width+7)//8)*height | ||
eliffmt==framebuf.RGB565: | ||
size=width*height*2 | ||
eliffmt==framebuf.GS2_HMSB: | ||
size= ((width+3)//4)*height | ||
eliffmt==framebuf.GS4_HMSB: | ||
size= ((width+1)//2)*height | ||
eliffmt==framebuf.GS8: | ||
size=width*height | ||
else: | ||
continue | ||
buf=bytearray(size) | ||
fb=framebuf.FrameBuffer(buf,width,height,fmt) | ||
print(name,"{}x{}:".format(width,height)) | ||
print("width:",fb.width) | ||
print("height:",fb.height) | ||
print("format:",fb.format) | ||
print("stride:",fb.stride) | ||
print("format == {}: {}".format(name,fb.format==fmt)) | ||
# Try accessing a non-existent attribute (should fail) | ||
try: | ||
print(fb.non_existent) | ||
print("ERROR: should have raised AttributeError") | ||
exceptAttributeError: | ||
print("Raised AttributeError correctly") | ||
print() |
168 changes: 168 additions & 0 deletionstests/extmod/framebuf_attr.py.exp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
MONO_VLSB 8x4: | ||
width: 8 | ||
height: 4 | ||
format: 0 | ||
stride: 8 | ||
format == MONO_VLSB: True | ||
Raised AttributeError correctly | ||
MONO_HLSB 8x4: | ||
width: 8 | ||
height: 4 | ||
format: 3 | ||
stride: 8 | ||
format == MONO_HLSB: True | ||
Raised AttributeError correctly | ||
MONO_HMSB 8x4: | ||
width: 8 | ||
height: 4 | ||
format: 4 | ||
stride: 8 | ||
format == MONO_HMSB: True | ||
Raised AttributeError correctly | ||
RGB565 8x4: | ||
width: 8 | ||
height: 4 | ||
format: 1 | ||
stride: 8 | ||
format == RGB565: True | ||
Raised AttributeError correctly | ||
GS2_HMSB 8x4: | ||
width: 8 | ||
height: 4 | ||
format: 5 | ||
stride: 8 | ||
format == GS2_HMSB: True | ||
Raised AttributeError correctly | ||
GS4_HMSB 8x4: | ||
width: 8 | ||
height: 4 | ||
format: 2 | ||
stride: 8 | ||
format == GS4_HMSB: True | ||
Raised AttributeError correctly | ||
GS8 8x4: | ||
width: 8 | ||
height: 4 | ||
format: 6 | ||
stride: 8 | ||
format == GS8: True | ||
Raised AttributeError correctly | ||
MONO_VLSB 16x8: | ||
width: 16 | ||
height: 8 | ||
format: 0 | ||
stride: 16 | ||
format == MONO_VLSB: True | ||
Raised AttributeError correctly | ||
MONO_HLSB 16x8: | ||
width: 16 | ||
height: 8 | ||
format: 3 | ||
stride: 16 | ||
format == MONO_HLSB: True | ||
Raised AttributeError correctly | ||
MONO_HMSB 16x8: | ||
width: 16 | ||
height: 8 | ||
format: 4 | ||
stride: 16 | ||
format == MONO_HMSB: True | ||
Raised AttributeError correctly | ||
RGB565 16x8: | ||
width: 16 | ||
height: 8 | ||
format: 1 | ||
stride: 16 | ||
format == RGB565: True | ||
Raised AttributeError correctly | ||
GS2_HMSB 16x8: | ||
width: 16 | ||
height: 8 | ||
format: 5 | ||
stride: 16 | ||
format == GS2_HMSB: True | ||
Raised AttributeError correctly | ||
GS4_HMSB 16x8: | ||
width: 16 | ||
height: 8 | ||
format: 2 | ||
stride: 16 | ||
format == GS4_HMSB: True | ||
Raised AttributeError correctly | ||
GS8 16x8: | ||
width: 16 | ||
height: 8 | ||
format: 6 | ||
stride: 16 | ||
format == GS8: True | ||
Raised AttributeError correctly | ||
MONO_VLSB 128x64: | ||
width: 128 | ||
height: 64 | ||
format: 0 | ||
stride: 128 | ||
format == MONO_VLSB: True | ||
Raised AttributeError correctly | ||
MONO_HLSB 128x64: | ||
width: 128 | ||
height: 64 | ||
format: 3 | ||
stride: 128 | ||
format == MONO_HLSB: True | ||
Raised AttributeError correctly | ||
MONO_HMSB 128x64: | ||
width: 128 | ||
height: 64 | ||
format: 4 | ||
stride: 128 | ||
format == MONO_HMSB: True | ||
Raised AttributeError correctly | ||
RGB565 128x64: | ||
width: 128 | ||
height: 64 | ||
format: 1 | ||
stride: 128 | ||
format == RGB565: True | ||
Raised AttributeError correctly | ||
GS2_HMSB 128x64: | ||
width: 128 | ||
height: 64 | ||
format: 5 | ||
stride: 128 | ||
format == GS2_HMSB: True | ||
Raised AttributeError correctly | ||
GS4_HMSB 128x64: | ||
width: 128 | ||
height: 64 | ||
format: 2 | ||
stride: 128 | ||
format == GS4_HMSB: True | ||
Raised AttributeError correctly | ||
GS8 128x64: | ||
width: 128 | ||
height: 64 | ||
format: 6 | ||
stride: 128 | ||
format == GS8: True | ||
Raised AttributeError correctly | ||
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.