Files
Paperwall/display/epd4in0e_driver.py
T
Honey 7c197e20a5 fix: correct waveshare_epd import path
Was importing 'waveshare_epd' as a top-level package, but it's nested
under display/waveshare_epd/ -- caused ModuleNotFoundError on the Pi
since only display/ is on sys.path via main.py's imports, not
display/waveshare_epd/ itself. Verified the corrected import resolves
by exercising it directly; the only error left is the driver's own
platform check falling through to its Jetson Nano path on this non-Pi
dev machine, which is expected here and won't happen on the real
Raspberry Pi (it checks /proc/cpuinfo for "Raspberry").
2026-07-21 22:38:48 +02:00

55 lines
1.7 KiB
Python

"""Driver for the Waveshare epd4in0e (4", 6-color Spectra) panel.
Thin wrapper around the vendored `waveshare_epd.epd4in0e` module -- the exact
driver already proven working under the InkyPi install on this Pi. That
driver only exposes `Clear()` and `display()`, both of which do a full
`TurnOnDisplay()` flash cycle; there is no partial-refresh path for this
panel at the hardware/SDK level, confirmed by reading the driver itself.
"""
import logging
from display import Display
logger = logging.getLogger(__name__)
RESOLUTION = (400, 600)
class EPD4in0eDisplay(Display):
def __init__(self):
self.resolution = RESOLUTION
self._epd = None
def init(self) -> None:
from display.waveshare_epd import epd4in0e
self._epd = epd4in0e.EPD()
self._epd.init()
logger.info("epd4in0e initialized")
def show(self, image) -> None:
if self._epd is None:
self.init()
width, height = self.resolution
if image.size != (width, height):
raise ValueError(
f"Image size {image.size} does not match panel resolution {self.resolution}"
)
# Re-init: the panel goes to sleep after every show(), and needs a
# fresh init() before it will accept commands again.
self._epd.init()
# Clear first to avoid ghosting from the previous image -- also a
# full flash, there's no way around it on this panel.
self._epd.Clear()
self._epd.display(self._epd.getbuffer(image.convert("RGB")))
def sleep(self) -> None:
if self._epd is not None:
self._epd.sleep()
logger.info("epd4in0e put to sleep")