Skip to content

Commit d3597b3

Browse files
committed
Black
1 parent 6bede34 commit d3597b3

File tree

2 files changed

+65
-62
lines changed

2 files changed

+65
-62
lines changed

adafruit_il0373.py

Lines changed: 57 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -63,55 +63,51 @@
6363
)
6464

6565
_GRAYSCALE_LUT = (
66-
# Common voltage
67-
b"\x20\x2a"
68-
b"\x00\x0A\x00\x00\x00\x01"
69-
b"\x60\x14\x14\x00\x00\x01"
70-
b"\x00\x14\x00\x00\x00\x01"
71-
b"\x00\x13\x0A\x01\x00\x01"
72-
b"\x00\x00\x00\x00\x00\x00"
73-
b"\x00\x00\x00\x00\x00\x00"
74-
b"\x00\x00\x00\x00\x00\x00"
75-
76-
# White to White
77-
b"\x21\x2a"
78-
b"\x40\x0A\x00\x00\x00\x01"
79-
b"\x90\x14\x14\x00\x00\x01"
80-
b"\x10\x14\x0A\x00\x00\x01"
81-
b"\xA0\x13\x01\x00\x00\x01"
82-
b"\x00\x00\x00\x00\x00\x00"
83-
b"\x00\x00\x00\x00\x00\x00"
84-
b"\x00\x00\x00\x00\x00\x00"
85-
86-
# Black to White
87-
b"\x22\x2a"
88-
b"\x40\x0A\x00\x00\x00\x01"
89-
b"\x90\x14\x14\x00\x00\x01"
90-
b"\x00\x14\x0A\x00\x00\x01"
91-
b"\x99\x0C\x01\x03\x04\x01"
92-
b"\x00\x00\x00\x00\x00\x00"
93-
b"\x00\x00\x00\x00\x00\x00"
94-
b"\x00\x00\x00\x00\x00\x00"
95-
96-
# White to Black
97-
b"\x23\x2a"
98-
b"\x40\x0A\x00\x00\x00\x01"
99-
b"\x90\x14\x14\x00\x00\x01"
100-
b"\x00\x14\x0A\x00\x00\x01"
101-
b"\x99\x0B\x04\x04\x01\x01"
102-
b"\x00\x00\x00\x00\x00\x00"
103-
b"\x00\x00\x00\x00\x00\x00"
104-
b"\x00\x00\x00\x00\x00\x00"
105-
106-
# Black to Black
107-
b"\x24\x2a"
108-
b"\x80\x0A\x00\x00\x00\x01"
109-
b"\x90\x14\x14\x00\x00\x01"
110-
b"\x20\x14\x0A\x00\x00\x01"
111-
b"\x50\x13\x01\x00\x00\x01"
112-
b"\x00\x00\x00\x00\x00\x00"
113-
b"\x00\x00\x00\x00\x00\x00"
114-
b"\x00\x00\x00\x00\x00\x00"
66+
# Common voltage
67+
b"\x20\x2a"
68+
b"\x00\x0A\x00\x00\x00\x01"
69+
b"\x60\x14\x14\x00\x00\x01"
70+
b"\x00\x14\x00\x00\x00\x01"
71+
b"\x00\x13\x0A\x01\x00\x01"
72+
b"\x00\x00\x00\x00\x00\x00"
73+
b"\x00\x00\x00\x00\x00\x00"
74+
b"\x00\x00\x00\x00\x00\x00"
75+
# White to White
76+
b"\x21\x2a"
77+
b"\x40\x0A\x00\x00\x00\x01"
78+
b"\x90\x14\x14\x00\x00\x01"
79+
b"\x10\x14\x0A\x00\x00\x01"
80+
b"\xA0\x13\x01\x00\x00\x01"
81+
b"\x00\x00\x00\x00\x00\x00"
82+
b"\x00\x00\x00\x00\x00\x00"
83+
b"\x00\x00\x00\x00\x00\x00"
84+
# Black to White
85+
b"\x22\x2a"
86+
b"\x40\x0A\x00\x00\x00\x01"
87+
b"\x90\x14\x14\x00\x00\x01"
88+
b"\x00\x14\x0A\x00\x00\x01"
89+
b"\x99\x0C\x01\x03\x04\x01"
90+
b"\x00\x00\x00\x00\x00\x00"
91+
b"\x00\x00\x00\x00\x00\x00"
92+
b"\x00\x00\x00\x00\x00\x00"
93+
# White to Black
94+
b"\x23\x2a"
95+
b"\x40\x0A\x00\x00\x00\x01"
96+
b"\x90\x14\x14\x00\x00\x01"
97+
b"\x00\x14\x0A\x00\x00\x01"
98+
b"\x99\x0B\x04\x04\x01\x01"
99+
b"\x00\x00\x00\x00\x00\x00"
100+
b"\x00\x00\x00\x00\x00\x00"
101+
b"\x00\x00\x00\x00\x00\x00"
102+
# Black to Black
103+
b"\x24\x2a"
104+
b"\x80\x0A\x00\x00\x00\x01"
105+
b"\x90\x14\x14\x00\x00\x01"
106+
b"\x20\x14\x0A\x00\x00\x01"
107+
b"\x50\x13\x01\x00\x00\x01"
108+
b"\x00\x00\x00\x00\x00\x00"
109+
b"\x00\x00\x00\x00\x00\x00"
110+
b"\x00\x00\x00\x00\x00\x00"
115111
)
116112

117113
_STOP_SEQUENCE = (
@@ -144,8 +140,8 @@ class IL0373(displayio.EPaperDisplay):
144140
def __init__(self, bus, swap_rams=False, **kwargs):
145141
if kwargs.get("grayscale", False):
146142
start_sequence = bytearray(len(_START_SEQUENCE) + len(_GRAYSCALE_LUT))
147-
start_sequence[:len(_START_SEQUENCE)] = _START_SEQUENCE
148-
start_sequence[len(_START_SEQUENCE):] = _GRAYSCALE_LUT
143+
start_sequence[: len(_START_SEQUENCE)] = _START_SEQUENCE
144+
start_sequence[len(_START_SEQUENCE) :] = _GRAYSCALE_LUT
149145
else:
150146
start_sequence = bytearray(_START_SEQUENCE)
151147

@@ -167,21 +163,23 @@ def __init__(self, bus, swap_rams=False, **kwargs):
167163
color_bits_inverted = kwargs.pop("color_bits_inverted", True)
168164
black_bits_inverted = kwargs.pop("black_bits_inverted", False)
169165
if "highlight_color" not in kwargs:
170-
start_sequence[17] |= 1 << 4 # Set BWR to only do black and white.
166+
start_sequence[17] |= 1 << 4 # Set BWR to only do black and white.
171167
if kwargs.get("grayscale", False):
172-
start_sequence[17] |= 1 << 5 # Set REG_EN to use the LUT sequence from the registers.
173-
start_sequence[6] = 0x13 # Boost the voltage
174-
start_sequence[23] = 0x3C # PLL set to 50 Hz (M = 7, N = 4)
168+
start_sequence[17] |= (
169+
1 << 5
170+
) # Set REG_EN to use the LUT sequence from the registers.
171+
start_sequence[6] = 0x13 # Boost the voltage
172+
start_sequence[23] = 0x3C # PLL set to 50 Hz (M = 7, N = 4)
175173

176174
# Set the resolution to scan
177175
if width > 128:
178-
start_sequence[17] |= 0b11 << 5 # 160x296
176+
start_sequence[17] |= 0b11 << 5 # 160x296
179177
elif height > 252 or width > 96:
180-
start_sequence[17] |= 0b10 << 5 # 128x296
178+
start_sequence[17] |= 0b10 << 5 # 128x296
181179
elif height > 230:
182-
start_sequence[17] |= 0b01 << 5 # 96x252
180+
start_sequence[17] |= 0b01 << 5 # 96x252
183181
else:
184-
pass # 0b00 is 96x230
182+
pass # 0b00 is 96x230
185183

186184
super().__init__(
187185
bus,

examples/il0373_2.9_grayscale.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@
2424
time.sleep(1)
2525

2626
display = adafruit_il0373.IL0373(
27-
display_bus, width=296, height=128, rotation=270,
28-
black_bits_inverted=False, color_bits_inverted=False, grayscale=True,
29-
refresh_time=1
27+
display_bus,
28+
width=296,
29+
height=128,
30+
rotation=270,
31+
black_bits_inverted=False,
32+
color_bits_inverted=False,
33+
grayscale=True,
34+
refresh_time=1,
3035
)
3136

3237
g = displayio.Group()

0 commit comments

Comments
 (0)