Skip to content

Fix grayscale to match Arduino #14

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

Merged
merged 1 commit into from
Nov 10, 2020
Merged
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
24 changes: 12 additions & 12 deletions adafruit_il0373.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,18 @@
b"\x50\x01\x37" # CDI setting
b"\x30\x01\x29" # PLL set to 150 Hz
b"\x61\x03\x00\x00\x00" # Resolution
b"\x82\x81\x32\x0a" # VCM DC and delay 50ms
b"\x82\x81\x12\x32" # VCM DC and delay 50ms
)

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

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

def __init__(self, bus, swap_rams=False, **kwargs):
if kwargs.get("grayscale", False):
start_sequence = bytearray(len(_START_SEQUENCE) + len(_GRAYSCALE_LUT))
start_sequence[: len(_START_SEQUENCE)] = _START_SEQUENCE
start_sequence[len(_START_SEQUENCE) :] = _GRAYSCALE_LUT
start_sequence = bytearray(_GRAYSCALE_START_SEQUENCE)
else:
start_sequence = bytearray(_START_SEQUENCE)

Expand All @@ -164,12 +170,6 @@ def __init__(self, bus, swap_rams=False, **kwargs):
black_bits_inverted = kwargs.pop("black_bits_inverted", False)
if "highlight_color" not in kwargs:
start_sequence[17] |= 1 << 4 # Set BWR to only do black and white.
if kwargs.get("grayscale", False):
start_sequence[17] |= (
1 << 5
) # Set REG_EN to use the LUT sequence from the registers.
start_sequence[6] = 0x13 # Boost the voltage
start_sequence[23] = 0x3C # PLL set to 50 Hz (M = 7, N = 4)

# Set the resolution to scan
if width > 128:
Expand Down