diff --git a/src/opendisplay/display_palettes.py b/src/opendisplay/display_palettes.py index e687803..698b538 100644 --- a/src/opendisplay/display_palettes.py +++ b/src/opendisplay/display_palettes.py @@ -1,5 +1,8 @@ """Automatic measured palette selection and panel capability data for e-paper displays.""" +from typing import cast + +import epaper_dithering as _epaper_dithering from epaper_dithering import ( BWRY_3_97, MONO_4_26, @@ -9,6 +12,7 @@ ColorScheme, ) +INKPLATE_6COLOR = cast(ColorPalette | None, getattr(_epaper_dithering, "INKPLATE_6COLOR", None)) # Panel IDs that support 4-gray mode (from firmware mapEpd) PANELS_4GRAY: frozenset[int] = frozenset( { @@ -59,6 +63,11 @@ def get_gray4_codes(panel_ic_type: int | None) -> tuple[int, int, int, int]: # (?, ColorScheme.BWY): HANSHOW_BWY, } +_BWGBRYO = cast(ColorScheme | None, getattr(ColorScheme, "BWGBRYO", None)) +if _BWGBRYO is not None and INKPLATE_6COLOR is not None: + # Inkplate 6COLOR 7-color ACeP (EP585C_600x448 / panel_ic_type 0x0043) + DISPLAY_PALETTE_MAP[(0x0043, _BWGBRYO)] = INKPLATE_6COLOR + def get_palette_for_display( panel_ic_type: int | None, diff --git a/src/opendisplay/encoding/images.py b/src/opendisplay/encoding/images.py index bbf6b4e..adfae08 100644 --- a/src/opendisplay/encoding/images.py +++ b/src/opendisplay/encoding/images.py @@ -87,6 +87,10 @@ def encode_image( # 6-color Spectra 6 display uses 4bpp with special firmware values # Palette indices 0-5 map to firmware values 0,1,2,3,5,6 (4 is skipped!) return encode_4bpp(image, bwgbry_mapping=True) + if color_scheme == getattr(ColorScheme, "BWGBRYO", None): + # 7-color ACeP (Inkplate 6COLOR) uses 4bpp. The BWGBRYO palette is already + # ordered to the panel's native nibble codes (0..6), so indices map directly. + return encode_4bpp(image) if color_scheme == ColorScheme.GRAYSCALE_4: return encode_2bpp(image) if color_scheme == ColorScheme.GRAYSCALE_16: