Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/opendisplay/display_palettes.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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(
{
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/opendisplay/encoding/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down