MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / display_partial

Method display_partial

epd_helper.py:70–98  ·  view source on GitHub ↗
(self, image)

Source from the content-addressed store, hash-verified

68 logger.error(f"Error initializing EPD for partial update: {e}")
69 raise
70
71 def display_partial(self, image):
72 try:
73 imw, imh = image.size
74 epd_w, epd_h = self.epd.width, self.epd.height
75
76 # Ensure image matches EPD dimensions before sending to driver
77 # Allow swapped dimensions (90°/270° rotation) — getbuffer handles both orientations
78 if (imw != epd_w or imh != epd_h) and (imw != epd_h or imh != epd_w):
79 logger.warning(f"Image size {imw}x{imh} != EPD size {epd_w}x{epd_h}, resizing")
80 image = image.resize((epd_w, epd_h))
81
82 buf = self.epd.getbuffer(image)
83
84 if hasattr(self.epd, 'displayPartial'):
85 self.epd.displayPartial(buf)
86 elif hasattr(self.epd, 'display_Partial'):
87 import inspect
88 sig = inspect.signature(self.epd.display_Partial)
89 if len(sig.parameters) >= 5:
90 # V2-style: display_Partial(image, Xstart, Ystart, Xend, Yend)
91 self.epd.display_Partial(buf, 0, 0, epd_w, epd_h)
92 else:
93 self.epd.display_Partial(buf)
94 else:
95 self.epd.display(buf)
96 logger.info("Partial display update complete.")
97 except Exception as e:
98 logger.error(f"Error during partial display update: {e} (image={image.size if hasattr(image,'size') else '?'}, epd={self.epd.width}x{self.epd.height}, buf_len={len(buf) if 'buf' in dir() else '?'})")
99 raise
100
101 def clear(self):

Callers 2

_run_gc9a01Method · 0.80
runMethod · 0.80

Calls 8

warningMethod · 0.80
resizeMethod · 0.80
infoMethod · 0.80
errorMethod · 0.80
getbufferMethod · 0.45
displayPartialMethod · 0.45
display_PartialMethod · 0.45
displayMethod · 0.45

Tested by

no test coverage detected