Skip to content

Commit 2aca2d2

Browse files
BreadMakesYouFullBreadMakesYouFull
BreadMakesYouFull
authored and
BreadMakesYouFull
committed
fix #196
1 parent 6162b5f commit 2aca2d2

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

library/inky/inky_ac073tc1a.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,28 @@
2323
ORANGE = 6
2424
CLEAN = 7
2525

26+
DESATURATED_PALETTE = [
27+
[0, 0, 0], # Black
28+
[255, 255, 255], # White
29+
[0, 255, 0], # Green
30+
[0, 0, 255], # Blue
31+
[255, 0, 0], # Red
32+
[255, 255, 0], # Yellow
33+
[255, 140, 0], # Orange
34+
[255, 255, 255] # Clear
35+
]
36+
37+
SATURATED_PALETTE = [
38+
[0, 0, 0], # Black
39+
[217, 242, 255], # White
40+
[3, 124, 76], # Green
41+
[27, 46, 198], # Blue
42+
[245, 80, 34], # Red
43+
[255, 255, 68], # Yellow
44+
[239, 121, 44], # Orange
45+
[255, 255, 255] # Clear
46+
]
47+
2648
RESET_PIN = 27
2749
BUSY_PIN = 17
2850
DC_PIN = 22
@@ -175,9 +197,11 @@ def __init__(self, resolution=None, colour='multi', cs_pin=CS0_PIN, dc_pin=DC_PI
175197
def _palette_blend(self, saturation, dtype='uint8'):
176198
saturation = float(saturation)
177199
palette = []
200+
saturated_palette = getattr(self, "SATURATED_PALETTE", SATURATED_PALETTE)
201+
desaturated_palette = getattr(self, "DESATURATED_PALETTE", DESATURATED_PALETTE)
178202
for i in range(7):
179-
rs, gs, bs = [c * saturation for c in self.SATURATED_PALETTE[i]]
180-
rd, gd, bd = [c * (1.0 - saturation) for c in self.DESATURATED_PALETTE[i]]
203+
rs, gs, bs = [c * saturation for c in saturated_palette[i]]
204+
rd, gd, bd = [c * (1.0 - saturation) for c in desaturated_palette[i]]
181205
if dtype == 'uint8':
182206
palette += [int(rs + rd), int(gs + gd), int(bs + bd)]
183207
if dtype == 'uint24':

library/inky/inky_uc8159.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,11 @@ def __init__(self, resolution=None, colour='multi', cs_pin=CS0_PIN, dc_pin=DC_PI
192192
def _palette_blend(self, saturation, dtype='uint8'):
193193
saturation = float(saturation)
194194
palette = []
195+
saturated_palette = getattr(self, "SATURATED_PALETTE", SATURATED_PALETTE)
196+
desaturated_palette = getattr(self, "DESATURATED_PALETTE", DESATURATED_PALETTE)
195197
for i in range(7):
196-
rs, gs, bs = [c * saturation for c in self.SATURATED_PALETTE[i]]
197-
rd, gd, bd = [c * (1.0 - saturation) for c in self.DESATURATED_PALETTE[i]]
198+
rs, gs, bs = [c * saturation for c in saturated_palette[i]]
199+
rd, gd, bd = [c * (1.0 - saturation) for c in desaturated_palette[i]]
198200
if dtype == 'uint8':
199201
palette += [int(rs + rd), int(gs + gd), int(bs + bd)]
200202
if dtype == 'uint24':

0 commit comments

Comments
 (0)