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

Method auto_detect

epd_helper.py:127–157  ·  view source on GitHub ↗

Try each known EPD driver and return the first that initializes successfully. Returns: tuple: (epd_type_string, width, height) on success, or None if no display detected.

(known_types=None)

Source from the content-addressed store, hash-verified

125 raise
126
127 @staticmethod
128 def auto_detect(known_types=None):
129 """Try each known EPD driver and return the first that initializes successfully.
130
131 Returns:
132 tuple: (epd_type_string, width, height) on success, or None if no display detected.
133 """
134 if known_types is None:
135 known_types = KNOWN_EPD_TYPES
136
137 for epd_type in known_types:
138 try:
139 logger.info(f"Auto-detect: trying {epd_type}...")
140 helper = EPDHelper(epd_type)
141 helper.epd.init()
142 w, h = helper.epd.width, helper.epd.height
143 try:
144 helper.epd.sleep()
145 except Exception:
146 pass
147 time.sleep(0.3)
148 logger.info(f"Auto-detect: found {epd_type} ({w}x{h})")
149 return (epd_type, w, h)
150 except Exception as e:
151 logger.debug(f"Auto-detect: {epd_type} failed: {e}")
152 try:
153 helper.epd.sleep()
154 except Exception:
155 pass
156 time.sleep(0.3)
157 logger.warning("Auto-detect: no e-paper display detected")
158 return None

Callers 1

Calls 6

EPDHelperClass · 0.85
infoMethod · 0.80
debugMethod · 0.80
warningMethod · 0.80
initMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected