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)
| 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 |