-
Notifications
You must be signed in to change notification settings - Fork 23
Reduce the CPU load when waiting for the display #35
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
Conversation
In many places a `pass` instruction is used in loops to wait until we hear back back from the display. This causes the loop to execute continuously which uses all of the available CPU, if we instead sleep for 1ms, we don't lose much time (less than 1ms each wait) and we dramatically reduce the load on the CPU. Before the change (updating a 3-color 2.13" display): ``` time python3 ./update_display real 0m19.664s user 0m17.622s sys 0m1.046s ``` After the change: time python3 ./update_display real 0m19.730s user 0m3.563s sys 0m0.792s1 The total time to run the script is about the same, but the CPU time has reduced dramatically.
@makermelissa maybe check it still works on a feather m4 + wing in the next week or two? :) |
I tried this out with a Feather M4 and both the mono and tri-color and neither worked. So then I tried the original code before this change and it didn't work for either display again, so I'll have to look into it further. |
Ok! I got it working. It tested fine on both the mono and tri-color displays. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good and tested fine.
🙌 thank you so much :) |
Thank you! |
Updating https://github.com/adafruit/Adafruit_CircuitPython_EPD to 2.5.2 from 2.5.1: > Merge pull request adafruit/Adafruit_CircuitPython_EPD#35 from mariovisic/nice_to_cpu
In many places a
pass
instruction is used in loops to wait until we hear backback from the display. This causes the loop to execute continuously which uses
all of the available CPU, if we instead sleep for 1ms, we don't lose much time
(less than 1ms each wait) and we dramatically reduce the load on the CPU.
Before the change (updating a 3-color 2.13" display):
After the change:
The total time to run the script is about the same, but the CPU time has reduced dramatically.