Skip to content

Use numpy for bulk pixel data conversion #47

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 1 commit into from
Nov 20, 2019
Merged

Use numpy for bulk pixel data conversion #47

merged 1 commit into from
Nov 20, 2019

Conversation

Johennes
Copy link
Contributor

This brings back the Numpy approach to converting pixel data for the SPI
interface from the original Adafruit_Python_ILI9341 library. The use of
Numpy instead of the previous double loop results in a performance boost
of a factor >10 when testing on a Raspberry Pi Zero.

Fixes #46

@ladyada
Copy link
Member

ladyada commented Nov 17, 2019

ok cool - small request - put the numpy import into image_to_data so that this code will still run on circuitpyboards that don't have numpy available!

This brings back the Numpy approach to converting pixel data for the SPI
interface from the original Adafruit_Python_ILI9341 library. The use of
Numpy instead of the previous double loop results in a performance boost
of a factor >10 when testing on a Raspberry Pi Zero.

When Numpy is not available at runtime, the previous double loop is
used.

Fixes #46
@Johennes
Copy link
Contributor Author

Ah sorry, didn't realize that was a requirement. I wasn't able to put the import inside of image_to_data since that is used as a generator for list. Instead I made the top-level import conditional and changed image to use the old double loop when Numpy was not imported.

@ladyada ladyada requested a review from makermelissa November 17, 2019 17:49
@ladyada
Copy link
Member

ladyada commented Nov 17, 2019

rad thanks!

@makermelissa
Copy link
Collaborator

I should be able to test in the next couple of days after I get back.

Copy link
Collaborator

@makermelissa makermelissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested successfully using Raspberry Pi 4, 2.8" PiTFT, and Pillow Image example.

@makermelissa makermelissa merged commit 1d74be2 into adafruit:master Nov 20, 2019
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Nov 20, 2019
Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SSD1305 to 1.0.3 from 1.0.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_SSD1305#5 from makermelissa/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_RGB_Display to 3.6.0 from 3.5.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_RGB_Display#51 from makermelissa/master
  > Merge pull request adafruit/Adafruit_CircuitPython_RGB_Display#47 from Johennes/feature/numpy

Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE to 3.0.0 from 1.0.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#34 from dhalbert/check-cpy-version
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#32 from dhalbert/doc-and-cleanup
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#31 from dhalbert/char-fixes-and-float
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#30 from tannewt/api_rework
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#29 from adafruit/dherrada-patch-1
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#25 from kattni/plotter-code
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#23 from kattni/update-color-picker
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#22 from kattni/update-color-picker
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#21 from kattni/cpb-color-picker
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#18 from dhalbert/bleio-api-revamp
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#17 from dhalbert/demo-central
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#16 from dhalbert/pairing
  > Merge pull request adafruit/Adafruit_CircuitPython_BLE#15 from dhalbert/python-advertisement-data
@Johennes Johennes deleted the feature/numpy branch November 20, 2019 20:09
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.

Image drawing is incredibly slow
3 participants