-
Notifications
You must be signed in to change notification settings - Fork 11
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
Performance improvements using spidev to update the 12.48inch e-Paper Module with Python #7
base: master
Are you sure you want to change the base?
Performance improvements using spidev to update the 12.48inch e-Paper Module with Python #7
Conversation
Use SPI.writebytes2() to send pixel data in builk.
…a significant performance improvement. Use PIL to convert incoming images to 1-bit color and directly access the pixel data to send, which saves a lot of time on slower platforms.
… to see if it's really needed.
…Black/White to draw using ImageDraw.
Am I right in understanding this removes the dependency on |
Yes, I left it in there since I didn’t update the 3-color version of the panel. It’s on my todo list to get one to finish the job.
Thanks! |
Ah, I didn't catch that this doesn't update the B model as well. I just ordered that product today. Once it arrives I would be happy to test the code. I'll admit I don't really understand what you've done, but maybe I could learn. Would the approach to speeding up the 3-color display be very different? I'd imagine it's just the same ideas applied to another part of the code. If you apply them and code it up I can test it for you. |
It's about the same, the difference being that the black/white image and red image are written separately. I'll get those changes added in over the next few days. Keep in mind, that's software engineer's estimate, so it might be longer. ;-)
Thanks for the offer, I'll take you up on that. |
@makeworld-the-better-one I just pushed the initial pass at supporting the B version (black/white/red) of the panel with Python on the Raspberry Pi. Let me know if it works for you, I can't test it. Happy Pi Day! |
That's great! My display hasn't arrived yet, it could be a week, could be longer. Once it does I'll try it out and let you know here. 𝜋 |
Could you also update the example |
…EBUG logger, and handle any exceptions when drawing to the panel.
Good catch @makeworld-the-better-one, the |
@MediumFidelity Thank you for this hugely improved version. I also tried to create a version without the dependency to the Tested on the red/white/black version. |
@fpammer Cool to see it works! I don't think you should need |
Sorry my wording was not very clear. The version in this pull request is great because it works without the |
You're welcome, I'm happy to help!
Thank you very much for testing it on that panel. If mounting the panel in an IKEA frame isn't too complicated (I ordered a custom matte board), I'll probably pick up the red/white/black panel as well. |
Just wondering, does this improve the advertised 8s (16s for color) refresh time? Or is that a minimum time sort of, and this just gets closer to it. |
That's the minimum time of a full panel refresh, so as it stands, this PR just gets closer to that. |
Deleted my earlier comments since they were resolved. However, I noticed a weird situation when running the improved code. It's best seen from the image below, but somehow the colors came out inverted in the new code, when running the same example file provided. I'm not sure how @fpammer managed to display the image correctly, but when I tried to display any image, the red color always came out incorrectly inverted. Any thoughts, @MediumFidelity? |
Hi @speedyg0nz, Sorry about the delay, missed the notification. I didn't have a tri-color display to test with, but it looks like the red channel bits are flipped. Agreed that I don't know how it'd work with others. Let me check the data sheet. I still waiting for Waveshare to restock these displays (the red looks great!), but they say the semiconductor industry madness is causing them issues, so it might be a long time. |
@MediumFidelity , thanks for getting getting back! Just wanted to say that this is amazing work and the display refresh time is indeed significantly shorter when running it on my RPi0. The inverted red channel is the only issue I encountered but otherwise it was simply a drop-in replacement.
Yeah, I got one around a year back when they still had stock and it was largely sitting around collecting dust until I finally completed my E-Ink desktop calendar project a few weeks back. Since then, I've been looking to optimize the performance and reduce the time needed to refresh the screen, since it runs off a small-ish battery. |
This repo seems to be abandoned. This could probably go in https://github.com/waveshare/e-Paper |
I just received a 12.48inch e-paper Module (B), they are finally back in stock. I'm looking through the changes @SSYYL introduced with the "V2" version of the B (red/black/white) panel. Looks like there were some initialization commands removed (defaults were okay?), but I still need to check the commands themselves to see if there are functional differences. Once I sort that out, I'll get the performance improvements folded in again. I have a black/white version of the panel mounted in a frame, and displaying the "true" phase of the moon, and it looks beautiful. @speedyg0nz I'll take a look at the red channel inversion too. It's easy to flip that stuff. |
@speedyg0nz For the red issue, it was an easy fix to flip the value of the red channel. If you want to make a local edit, in the
There are 4 places to add it, for each of the 4 regions of the display. I'm still going through changes Waveshare introduced to see what's what. |
Hi @MediumFidelity, Sorry it took so long to reply. |
Finally got around to testing this out and adding the bitwise NOT fixed the color inversion! Thanks! |
These changes significantly reduce the time required to process the image to display and update the panel. This is particularly true on less powerful hardware, like the Raspberry Pi Zero W. Highlights of the changes are:
spidev
library to access SPI, instead of a C "bit banged" implementation.SPI.writebytes2()
function.tobytes('raw')
.The following dependencies are needed (similar to other Waveshare E Ink displays):
Using the existing demo code as an example running in the following environment, the runtime is greatly reduced.
Hardware:
Raspberry Pi Zero W
OS:
Raspbian GNU/Linux 10 (buster)
Software:
Python 3.7.3
Original:
Using branch
epd12in48_spidev_python
:Further improvement are possible too, removing or tightening up
sleep()
calls and changing how the busy pin is polled.Also, an initial call to
clear()
probably isn't needed due to how the entire panel is updated.Experimental support for the 12.48inch e-Paper Module (B) has been added, but is untested with a real panel.