Skip to content

Commit 3cddaae

Browse files
committed
Fix grayscale to match Arduino
VCM DC setting was wrong. Part of the problem was that the delay value is after the parameters, not after the count.
1 parent fe0fb74 commit 3cddaae

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

adafruit_il0373.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,18 @@
5959
b"\x50\x01\x37" # CDI setting
6060
b"\x30\x01\x29" # PLL set to 150 Hz
6161
b"\x61\x03\x00\x00\x00" # Resolution
62-
b"\x82\x81\x32\x0a" # VCM DC and delay 50ms
62+
b"\x82\x81\x12\x32" # VCM DC and delay 50ms
6363
)
6464

65-
_GRAYSCALE_LUT = (
65+
_GRAYSCALE_START_SEQUENCE = (
66+
b"\x01\x05\x03\x00\x2b\x2b\x13" # power setting
67+
b"\x06\x03\x17\x17\x17" # booster soft start
68+
b"\x04\x80\xc8" # power on and wait 200 ms
69+
b"\x00\x01\x2f" # panel setting. Further filled in below.
70+
b"\x50\x01\x97" # CDI setting
71+
b"\x30\x01\x3C" # PLL set to 50 Hz (M = 7, N = 4)
72+
b"\x61\x03\x00\x00\x00" # Resolution
73+
b"\x82\x81\x12\x32" # VCM DC and delay 50ms
6674
# Common voltage
6775
b"\x20\x2a"
6876
b"\x00\x0A\x00\x00\x00\x01"
@@ -112,7 +120,7 @@
112120

113121
_STOP_SEQUENCE = (
114122
b"\x50\x01\x17" # CDI setting
115-
b"\x82\x01\x00" # VCM DC and delay 50ms
123+
b"\x82\x01\x00" # VCM DC to -0.10 V
116124
b"\x02\x00" # Power off
117125
)
118126
# pylint: disable=too-few-public-methods
@@ -139,9 +147,7 @@ class IL0373(displayio.EPaperDisplay):
139147

140148
def __init__(self, bus, swap_rams=False, **kwargs):
141149
if kwargs.get("grayscale", False):
142-
start_sequence = bytearray(len(_START_SEQUENCE) + len(_GRAYSCALE_LUT))
143-
start_sequence[: len(_START_SEQUENCE)] = _START_SEQUENCE
144-
start_sequence[len(_START_SEQUENCE) :] = _GRAYSCALE_LUT
150+
start_sequence = bytearray(_GRAYSCALE_START_SEQUENCE)
145151
else:
146152
start_sequence = bytearray(_START_SEQUENCE)
147153

@@ -164,12 +170,6 @@ def __init__(self, bus, swap_rams=False, **kwargs):
164170
black_bits_inverted = kwargs.pop("black_bits_inverted", False)
165171
if "highlight_color" not in kwargs:
166172
start_sequence[17] |= 1 << 4 # Set BWR to only do black and white.
167-
if kwargs.get("grayscale", False):
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)
173173

174174
# Set the resolution to scan
175175
if width > 128:

0 commit comments

Comments
 (0)