adafruit / Adafruit_CircuitPython_SharpMemoryDisplay

CircuitPython library for SHARP Memory monochrome displays
MIT License
9 stars 12 forks source link

Added image function that uses numpy if available #19

Closed ilikecake closed 2 years ago

ilikecake commented 2 years ago

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 commented 2 years ago

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

ilikecake commented 2 years ago

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 commented 2 years ago

did it work on the trinket m0 before this change?

ilikecake commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 :)