txoof / epdlib

Python library for creating and writing modular layouts for e-paper screens
GNU General Public License v3.0
16 stars 8 forks source link

autodetect bicolor displays #2

Closed tmmorin closed 3 years ago

tmmorin commented 3 years ago

This allowed me to successfully use my waveshare bicolor display with epd7in5bc_V2.

This kind of introspection isn't fantastic from a code quality standpoint, but I'm still sharing it with you @txoof .

I also sync'ed the waveshare_epd directory with Waveshares repo at, because I noticed that a change had been made in the sleep() method since you did a copy (see https://github.com/waveshare/e-Paper/commit/751a9fb93fdd486511222777b0070c51bf436386#diff-19259a5328cddb0511e7b66e73c4138fR171). I haven't checked how things work with the older code.

txoof commented 3 years ago

Interesting solution -- I did something similar in the development branch , but using inspect.getfullargspec

My solution is to check how many args the EPD write is expecting and then pass an empty image as the "color" argument. I think this might be slightly more robust than just guessing based on the module name. Some of the older modules only have "b" or "c" in the module name to indicate that it's a color module: 2 color -- epd2in7.py; 3 color -- epd2in7b.py

I haven't merged those changes into the pypi version nor rebuilt slimpi against them yet as I'd like to do some more testing first. Would you be willing to give it a go on your setup to see if it works?

It might also be a good idea if I update the Pipfile in slimpi to point to the waveshare repo rather than using a copy built in as that quickly grows stale.

tmmorin commented 3 years ago

Your solution is better. I used introspect in the past, but yesterday I had 20 minutes before me and was lazy to do the minimal research necessary to use it...

Don't merge my change! :)

About your change: you do epd.getbuffer(self.clearScreen()) each time, and I think that the call to getbuffer (which takes a few seconds on my raspi zero) could be avoided by caching its result as I did in my change.

tmmorin commented 3 years ago

It might also be a good idea if I update the Pipfile in slimpi to point to the waveshare repo rather than using a copy built in as that quickly grows stale.

True, but since it's not a proper python module installable with pip, I'm not sure that it's feasible.

Another possibility would be to just git clone it during build.sh. Yet another one would be to use git submodule, but you'll have to do a manual action each time you want to point to a fresh commit.

txoof commented 3 years ago

@tmmorin Thanks for all the suggestions and the kick in the pants to update this.

I've updated the development branch with the fixes for your issue as well as your suggestion for a cached buffer.

I think the inspection solution is cleaner than guessing based on the module name.

Would you mind taking a look?

txoof commented 3 years ago

Closed see commit: https://github.com/txoof/epdlib/commit/7bf3865969cf1e1840cfd4878e220b7344609b5e