robweber / omni-epd

An EPD (electronic paper display) class abstraction to simplify communications across multiple display types.
GNU General Public License v3.0
75 stars 16 forks source link

clear() results in TypeError for WaveShare epd2in13_V2 #73

Closed ThatIsAPseudo closed 2 years ago

ThatIsAPseudo commented 2 years ago

Display Type: waveshare_epd.epd2in13_V2 Version pulled: 2022.03.29 Main Branch

> from omni_epd import displayfactory
> epd = displayfactory.load_display_driver("waveshare_epd.epd2in13_V2")
> epd.prepare()
> epd.clear()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "$CONDA_PATH/lib/python3.9/site-packages/omni_epd/displays/waveshare_display.py", line 139, in clear
    self._device.Clear()
TypeError: Clear() missing 1 required positional argument: 'color'

I read the issue #19 about this error, and could not solve it. The epd2in13_V2 display is not declared as a device that needs an alternate clear() function, but it should.

I tried to fix this by changing the following line https://github.com/robweber/omni-epd/blob/dfd02669686f573f8215792a8690df77ba3df1fc/src/omni_epd/displays/waveshare_display.py#L92

to

"epd2in13_V2": {"alt_init": True, "lut_init": True, "alt_clear": True, "version": 2},

but it did not work and I got the same error.

robweber commented 2 years ago

Thanks for the all the information on this. Changing the alt_clear field should have triggered the correct clear method. How did you test after the change? Did you uninstall and rebuild the module if installed on your system?

leetdavid commented 2 years ago

I found a workaround for this to make it work. If you want to clear the screen, use:

epd._device.Clear(0xFF)
robweber commented 2 years ago

How is that any different than this line? https://github.com/robweber/omni-epd/blob/main/src/omni_epd/displays/waveshare_display.py#L137

By changing the alt_clear parameter to True it should trigger that as part of the normal epd.clear() method. The above definitely works but kind of ruins the point of having an abstraction that works for other EPD devices by having to access the device directly.

leetdavid commented 2 years ago

I agree that it's essentially the same; it's just what I did to make it work for my device. I'll try the suggested above fix to see if it works (as it should, as they are equivalent).

leetdavid commented 2 years ago

So I tested it, and the below modification mentioned works.

"epd2in13_V2": {"alt_init": True, "lut_init": True, "alt_clear": True, "version": 2},

It cleared my screen blank. Maybe the author of the issue didn't reinstall the changed library.

robweber commented 2 years ago

Thank you for testing that. I wondered if that was the case as well with the re-install. I'll mark this accordingly and make the change in the main branch directly since it's a pretty simple fix. Thank you for confirming!