-
Notifications
You must be signed in to change notification settings - Fork 36
Add 2bit grayscale support #50
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
Conversation
This lets people use framebuf for 2 color displays like the 8x8x2 matrix. It is a mostly mechanical port of the circuitpython GS2_HMSB code.
index = (y * framebuf.stride + x) >> 2 | ||
pixel = framebuf.buf[index] | ||
|
||
shift = (x & 0b11) << 1 | ||
mask = 0b11 << shift | ||
color = (color & 0b11) << shift |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't actually understand why we right shift 2, then left shift 1 and then left shift by shift
. I wonder if there is a conceptually simpler way to write this.
ping |
Hello :). Thank you for your first PR in CircuitPython, as discussed in discord an example will help the test, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks good to me.
I tested successfully with the given "emulator" CPython script that outputs to the terminal and pared it down to a very basic simpletest-like script to validate the basic usage of framebuf, everything appears to be working as expected as far as I can tell.
I do not have the bicolor 8x8 matrix to test the new functionality on the actual hardware it was meant for, but don't think we need to hold this PR up for that reason.
I did regression testing with a 7x15 LED charliewing feather wing, a 16x8 LED Matrix featherwing, and a SSD1306 featherwing all of which utilized the frambuf repo (albeit not the new functionality) and confirmed all of those are functioning as expected. All testing was carred out on FEather RP2040 with version 8.0.3
.
Thanks for adding this new functionality @jedahan. Sorry that it took us a while to get feedback here.
Going to merge this now, if someone gets hardware in the future to test it and finds problems we can create a new issue / PR as needed to resolve.
@jedahan your terminal emulation utility is nice for testing this without access to the real hardware. If you're up to it and willing to share that in this repo under the appropriate license I would say go ahead and make a new PR that adds that script, or perhaps a modified one that is terminal only. I noticed yours runs on Raspberry pi with real hardware or terminal without. But it might be nice to have terminal only for an example / test in this repo I think. |
Updating https://github.com/adafruit/Adafruit_CircuitPython_framebuf to 1.6.0 from 1.5.0: > Merge pull request adafruit/Adafruit_CircuitPython_framebuf#50 from jedahan/gs2_hmsb > Add upload url to release action Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Updated download stats for the libraries
I just noticed this got merged, thank you! I quickly updated the terminal framebuffer example to be a little bit more minimal, would you want a PR for something like this? https://gist.github.com/jedahan/92adc7242e20376bbad64bcbf5ace72c |
This lets people use framebuf for 2 color displays like the 8x8x2 matrix. It is a mostly mechanical port of the circuitpython GS2_HMSB code.
You can see how I use this code in https://github.com/jedahan/alarmclock , attached are terminal visualizations of
python3 blinkenlights.py
using some of this framebuf api:Screen.Recording.2023-02-04.at.2.13.09.PM.mov