Skip to content

fix #196 - Saturated Palette in InkyMockImpression not reachable #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
28 changes: 26 additions & 2 deletions library/inky/inky_ac073tc1a.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,28 @@
ORANGE = 6
CLEAN = 7

DESATURATED_PALETTE = [
[0, 0, 0], # Black
[255, 255, 255], # White
[0, 255, 0], # Green
[0, 0, 255], # Blue
[255, 0, 0], # Red
[255, 255, 0], # Yellow
[255, 140, 0], # Orange
[255, 255, 255] # Clear
]

SATURATED_PALETTE = [
[0, 0, 0], # Black
[217, 242, 255], # White
[3, 124, 76], # Green
[27, 46, 198], # Blue
[245, 80, 34], # Red
[255, 255, 68], # Yellow
[239, 121, 44], # Orange
[255, 255, 255] # Clear
]

RESET_PIN = 27
BUSY_PIN = 17
DC_PIN = 22
Expand Down Expand Up @@ -175,9 +197,11 @@ def __init__(self, resolution=None, colour='multi', cs_pin=CS0_PIN, dc_pin=DC_PI
def _palette_blend(self, saturation, dtype='uint8'):
saturation = float(saturation)
palette = []
saturated_palette = getattr(self, "SATURATED_PALETTE", SATURATED_PALETTE)
desaturated_palette = getattr(self, "DESATURATED_PALETTE", DESATURATED_PALETTE)
for i in range(7):
rs, gs, bs = [c * saturation for c in self.SATURATED_PALETTE[i]]
rd, gd, bd = [c * (1.0 - saturation) for c in self.DESATURATED_PALETTE[i]]
rs, gs, bs = [c * saturation for c in saturated_palette[i]]
rd, gd, bd = [c * (1.0 - saturation) for c in desaturated_palette[i]]
if dtype == 'uint8':
palette += [int(rs + rd), int(gs + gd), int(bs + bd)]
if dtype == 'uint24':
Expand Down
6 changes: 4 additions & 2 deletions library/inky/inky_uc8159.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,11 @@ def __init__(self, resolution=None, colour='multi', cs_pin=CS0_PIN, dc_pin=DC_PI
def _palette_blend(self, saturation, dtype='uint8'):
saturation = float(saturation)
palette = []
saturated_palette = getattr(self, "SATURATED_PALETTE", SATURATED_PALETTE)
desaturated_palette = getattr(self, "DESATURATED_PALETTE", DESATURATED_PALETTE)
for i in range(7):
rs, gs, bs = [c * saturation for c in self.SATURATED_PALETTE[i]]
rd, gd, bd = [c * (1.0 - saturation) for c in self.DESATURATED_PALETTE[i]]
rs, gs, bs = [c * saturation for c in saturated_palette[i]]
rd, gd, bd = [c * (1.0 - saturation) for c in desaturated_palette[i]]
if dtype == 'uint8':
palette += [int(rs + rd), int(gs + gd), int(bs + bd)]
if dtype == 'uint24':
Expand Down