|
25 | 25 | encode_image, |
26 | 26 | fit_image, |
27 | 27 | ) |
28 | | -from .exceptions import AuthenticationRequiredError, AuthenticationSessionExistsError, ProtocolError |
| 28 | +from .exceptions import AuthenticationRequiredError, AuthenticationSessionExistsError, ImageEncodingError, ProtocolError |
29 | 29 | from .models.capabilities import DeviceCapabilities |
30 | 30 | from .models.config import GlobalConfig |
31 | 31 | from .models.enums import BoardManufacturer, FitMode, RefreshMode, Rotation |
@@ -1118,9 +1118,16 @@ def _extract_capabilities_from_config(self) -> DeviceCapabilities: |
1118 | 1118 | display = self._config.displays[0] # Primary display |
1119 | 1119 |
|
1120 | 1120 | r = display.rotation_enum |
| 1121 | + try: |
| 1122 | + color_scheme = ColorScheme.from_value(display.color_scheme) |
| 1123 | + except ValueError as exc: |
| 1124 | + raise ImageEncodingError( |
| 1125 | + f"Device uses unsupported color scheme value {display.color_scheme}. " |
| 1126 | + "Reconfigure the device to a supported color scheme (0–5)." |
| 1127 | + ) from exc |
1121 | 1128 | return DeviceCapabilities( |
1122 | 1129 | width=display.pixel_width, |
1123 | 1130 | height=display.pixel_height, |
1124 | | - color_scheme=ColorScheme.from_value(display.color_scheme), |
| 1131 | + color_scheme=color_scheme, |
1125 | 1132 | rotation=r.value if isinstance(r, Rotation) else 0, |
1126 | 1133 | ) |
0 commit comments