Skip to content

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

Merged
merged 8 commits into from
Mar 4, 2023
Merged

Add 2bit grayscale support #50

merged 8 commits into from
Mar 4, 2023

Conversation

jedahan
Copy link

@jedahan jedahan commented Feb 4, 2023

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:

Screenshot 2023-02-04 at 2 11 36 PM

Screenshot 2023-02-04 at 2 11 25 PM

Screen.Recording.2023-02-04.at.2.13.09.PM.mov

Jonathan Dahan added 4 commits February 4, 2023 14:03
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.
@jedahan jedahan marked this pull request as draft February 4, 2023 19:31
Comment on lines +49 to +54
index = (y * framebuf.stride + x) >> 2
pixel = framebuf.buf[index]

shift = (x & 0b11) << 1
mask = 0b11 << shift
color = (color & 0b11) << shift
Copy link
Author

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.

@jedahan jedahan marked this pull request as ready for review February 5, 2023 04:07
@tekktrik tekktrik requested a review from a team February 5, 2023 22:09
@jedahan
Copy link
Author

jedahan commented Mar 3, 2023

ping

@jposada202020
Copy link

Hello :). Thank you for your first PR in CircuitPython, as discussed in discord an example will help the test,
For new functionalities, it will be a good idea to add an example, this way people would use the new functionality.

Copy link
Contributor

@FoamyGuy FoamyGuy left a 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.

@FoamyGuy
Copy link
Contributor

FoamyGuy commented Mar 4, 2023

@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.

@FoamyGuy FoamyGuy merged commit 9d05e34 into adafruit:main Mar 4, 2023
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Mar 4, 2023
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
@jedahan
Copy link
Author

jedahan commented Oct 18, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants