Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added image function that uses numpy if available #19

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 2 commits into from
Apr 25, 2022

Conversation

ilikecake
Copy link
Contributor

Using the display.image(image) function to convert a PIL image to the proper format to display is very slow. See here for a thread with information on the issue. Using numpy to convert the image data is quite a bit faster. I measured the time to call the display.image(image) with the current method, and with numpy. The execution time decreased from ~7.1sec to .014sec on a Raspberry Pi Zero W.

Similar to this function, I added a check for numpy to the code, and if it is available, numpy is used to generate the frame data. If numpy is not available, the function should work the same way as before.

@ladyada
Copy link
Member

ladyada commented Feb 21, 2022

nice! could you by chance test this on a non-raspi?

@ilikecake
Copy link
Contributor Author

The only other circuitpython device I have is the Trinket M0. Would that device work to test this? How would I get my modified version of the software on that device?

@ladyada
Copy link
Member

ladyada commented Feb 21, 2022

did it work on the trinket m0 before this change?

@ilikecake
Copy link
Contributor Author

I have not tried with the trinket m0. I got this display to work with a project I am building with the Raspberry Pi. I don't have much time to work on it during the week, but I will try to wire up the trinket and see if I can get it to work.

@ilikecake
Copy link
Contributor Author

I was going to wire up the Trinket M0, and realized that it would not work the way I thought. The Trinket M0 does not have access to the PIL library, right? This change only affects the image() function, which requires a PIL frame to decode. The only change that would affect a normal circuitpython device is the check for numpy. I guess I could try to test that bit, but it is a direct copy-paste from another of your repos. I do not have any other Linux SBCs that I can test this on. Let me know what you want me to do here.

@ladyada
Copy link
Member

ladyada commented Mar 6, 2022

kk not sure when we'll get to testing this but we'll have to do a hardware test before merge since it could break existing projects! for now ya can just keep using it on raspi :)

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.

I tested the simpletest example with this branch on a Feather RP2040 with https://www.adafruit.com/product/3502

Adafruit CircuitPython 7.3.0-beta.1 on 2022-04-07; Adafruit Feather RP2040 with rp2040
Board ID:adafruit_feather_rp2040

It does seem to function as expected.

I didn't test Raspberry Pi or the image() function but those changes do seem good to me as well.

@FoamyGuy FoamyGuy merged commit 1e77578 into adafruit:main Apr 25, 2022
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Apr 26, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_SD to 3.3.9 from 3.3.8:
  > Merge pull request adafruit/Adafruit_CircuitPython_SD#48 from tekktrik/doc/add-typing
  > change discord badge
  > Patch: Replaced discord badge image
  > Updated gitignore
  > Update Black to latest.

Updating https://github.com/adafruit/Adafruit_CircuitPython_SharpMemoryDisplay to 1.4.0 from 1.2.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_SharpMemoryDisplay#21 from tekktrik/dev/switch-bus-device
  > Merge pull request adafruit/Adafruit_CircuitPython_SharpMemoryDisplay#19 from ilikecake/image-function-numpy
  > change discord badge
  > Patch: Replaced discord badge image
  > Updated gitignore
  > Update Black to latest.
  > Fixed readthedocs build
  > Consolidate Documentation sections of README

Updating https://github.com/adafruit/Adafruit_CircuitPython_PortalBase to 1.13.0 from 1.12.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_PortalBase#70 from FoamyGuy/dont_require_secrets_if_no_network
  > change discord badge
  > Patch: Replaced discord badge image
  > Updated gitignore
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