55
55
b"\x01 \x05 \x03 \x00 \x2b \x2b \x09 " # power setting
56
56
b"\x06 \x03 \x17 \x17 \x17 " # booster soft start
57
57
b"\x04 \x80 \xc8 " # power on and wait 200 ms
58
- b"\x00 \x01 \xcf " # panel setting
58
+ b"\x00 \x01 \x0f " # panel setting. Further filled in below.
59
59
b"\x50 \x01 \x37 " # CDI setting
60
- b"\x30 \x01 \x29 " # PLL
60
+ b"\x30 \x01 \x29 " # PLL set to 150 Hz
61
61
b"\x61 \x03 \x00 \x00 \x00 " # Resolution
62
62
b"\x82 \x81 \x32 \x0a " # VCM DC and delay 50ms
63
63
)
64
64
65
+ _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
+ # 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 "
111
+ )
112
+
65
113
_STOP_SEQUENCE = (
66
114
b"\x50 \x01 \x17 " # CDI setting
67
115
b"\x82 \x01 \x00 " # VCM DC and delay 50ms
@@ -90,7 +138,12 @@ class IL0373(displayio.EPaperDisplay):
90
138
"""
91
139
92
140
def __init__ (self , bus , swap_rams = False , ** kwargs ):
93
- start_sequence = bytearray (_START_SEQUENCE )
141
+ 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
145
+ else :
146
+ start_sequence = bytearray (_START_SEQUENCE )
94
147
95
148
width = kwargs ["width" ]
96
149
height = kwargs ["height" ]
@@ -109,6 +162,25 @@ def __init__(self, bus, swap_rams=False, **kwargs):
109
162
write_color_ram_command = 0x13
110
163
color_bits_inverted = kwargs .pop ("color_bits_inverted" , True )
111
164
black_bits_inverted = kwargs .pop ("black_bits_inverted" , False )
165
+ if "highlight_color" not in kwargs :
166
+ 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)
173
+
174
+ # Set the resolution to scan
175
+ if width > 128 :
176
+ start_sequence [17 ] |= 0b11 << 5 # 160x296
177
+ elif height > 252 or width > 96 :
178
+ start_sequence [17 ] |= 0b10 << 5 # 128x296
179
+ elif height > 230 :
180
+ start_sequence [17 ] |= 0b01 << 5 # 96x252
181
+ else :
182
+ pass # 0b00 is 96x230
183
+
112
184
super ().__init__ (
113
185
bus ,
114
186
start_sequence ,
0 commit comments