Skip to content

Commit 445767e

Browse files
committed
DM: add IL91874 support
1 parent 5b8af3a commit 445767e

File tree

4 files changed

+70
-68
lines changed

4 files changed

+70
-68
lines changed

Adafruit_EPD.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,11 @@ def begin(self, reset=True):
4545
self._rst.value = True
4646
time.sleep(.1)
4747

48-
while self._busy.value == True:
49-
pass
50-
5148
def command(self, c, data=None, end=True):
5249
"""Send command byte to display."""
5350
self._cs.value = True
5451
self._dc.value = False
55-
self._cs.value = False
52+
self._cs.value = False
5653
with self.spi_device as spi:
5754
spi.write(bytearray([c]))
5855

Adafruit_IL0376F.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def __init__(self, width, height, rst, dc, busy, srcs=None, cs=None, spi=None):
3434
def begin(self, reset=True):
3535
super(Adafruit_IL0376F_base, self).begin(reset)
3636

37+
while self._busy.value == True:
38+
pass
39+
3740
self.command(IL0376F_POWER_SETTING, bytearray([0x07, 0x00, 0x0D, 0x00]))
3841
self.command(IL0376F_BOOSTER_SOFT_START, bytearray([0x07, 0x07, 0x07]))
3942

@@ -65,11 +68,20 @@ def power_up(self):
6568
def display(self):
6669
self.power_up()
6770

71+
#TODO: we need to do duplex transfers.
72+
c = 0x00
73+
74+
with self.spi_device as spi:
75+
spi.write(bytearray(SRAM_READ, 0x00, 0x00)) #should be duplex
76+
6877
self.command(IL0376F_DTM1, end=False)
6978
self._dc.value = True
7079
with self.spi_device as spi:
71-
for i in range(10000):
72-
spi.write(bytearray([0xff]))#TODO actual data
80+
spi.write(bytearray(SRAM_READ, 0x00, 0x00))
81+
82+
for i in range(int(self.width*self.height / 4)):
83+
c = spi.write(bytearray([c])) #should be duplex
84+
7385
self._cs.value = True
7486

7587
self.command(IL0376F_DTM2, end=False)

Adafruit_IL91874.py

Lines changed: 52 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,82 @@
11
from Adafruit_EPD import *
2+
from micropython import const
3+
4+
IL91874_PANEL_SETTING = const(0x00)
5+
IL91874_POWER_SETTING = const(0x01)
6+
IL91874_POWER_OFF = const(0x02)
7+
IL91874_POWER_OFF_SEQUENCE = const(0x03)
8+
IL91874_POWER_ON = const(0x04)
9+
IL91874_POWER_ON_MEASURE = const(0x05)
10+
IL91874_BOOSTER_SOFT_START = const(0x06)
11+
IL91874_DEEP_SLEEP = const(0x07)
12+
IL91874_DTM1 = const(0x10)
13+
IL91874_DATA_STOP = const(0x11)
14+
IL91874_DISPLAY_REFRESH = const(0x12)
15+
IL91874_DTM2 = const(0x13)
16+
IL91874_PDTM1 = const(0x14)
17+
IL91874_PDTM2 = const(0x15)
18+
IL91874_PDRF = const(0x16)
19+
IL91874_LUT1 = const(0x20)
20+
IL91874_LUTWW = const(0x21)
21+
IL91874_LUTBW = const(0x22)
22+
IL91874_LUTWB = const(0x23)
23+
IL91874_LUTBB = const(0x24)
24+
IL91874_PLL = const(0x30)
25+
IL91874_CDI = const(0x50)
26+
IL91874_RESOLUTION = const(0x61)
27+
IL91874_VCM_DC_SETTING = const(0x82)
228

329
class Adafruit_IL91874_base(Adafruit_EPD):
4-
IL91874_PANEL_SETTING = 0x00
5-
IL91874_POWER_SETTING = 0x01
6-
IL91874_POWER_OFF = 0x02
7-
IL91874_POWER_OFF_SEQUENCE =0x03
8-
IL91874_POWER_ON = 0x04
9-
IL91874_POWER_ON_MEASURE = 0x05
10-
IL91874_BOOSTER_SOFT_START = 0x06
11-
IL91874_DEEP_SLEEP = 0x07
12-
IL91874_DTM1 = 0x10
13-
IL91874_DATA_STOP = 0x11
14-
IL91874_DISPLAY_REFRESH = 0x12
15-
IL91874_DTM2 = 0x13
16-
IL91874_PDTM1 = 0x14
17-
IL91874_PDTM2 = 0x15
18-
IL91874_PDRF = 0x16
19-
IL91874_LUT1 = 0x20
20-
IL91874_LUTWW = 0x21
21-
IL91874_LUTBW = 0x22
22-
IL91874_LUTWB = 0x23
23-
IL91874_LUTBB = 0x24
24-
IL91874_PLL = 0x30
25-
IL91874_CDI = 0x50
26-
IL91874_RESOLUTION = 0x61
27-
IL91874_VCM_DC_SETTING = 0x82
2830

29-
def __init__(self, width, height, rst, dc, busy, sclk=None, mosi=None, cs=None, gpio=None, spi=None):
31+
def __init__(self, width, height, rst, dc, busy, srcs=None, cs=None, spi=None):
3032

31-
super(Adafruit_IL91874_base, self).__init__(width, height, rst, dc, busy, sclk, mosi, cs, gpio, spi)
32-
33-
self.bw_buffer = [0xFF]* (width*height >> 3)
34-
self.red_buffer = [0xFF]* (width*height >> 3)
33+
super(Adafruit_IL91874_base, self).__init__(width, height, rst, dc, busy, srcs, cs, spi)
3534

3635
def begin(self, reset=True):
3736
super(Adafruit_IL91874_base, self).begin(reset)
3837

39-
self.command(self.IL91874_POWER_SETTING, [0x07, 0x00, 0x0A, 0x00])
40-
self.command(self.IL91874_BOOSTER_SOFT_START, [0x07, 0x07, 0x07])
41-
4238
def update(self):
43-
self.command(self.IL91874_DISPLAY_REFRESH)
39+
self.command(IL91874_DISPLAY_REFRESH)
4440

45-
while self._gpio.is_high(self._busy):
41+
while self._busy.value == True:
4642
pass
4743

4844
time.sleep(10)
4945

50-
self.command(self.IL91874_CDI, [0x17])
51-
self.command(self.IL91874_VCM_DC_SETTING, [0x00])
52-
self.command(self.IL91874_POWER_SETTING, [0x02, 0x00, 0x00, 0x00])
53-
self.command(self.IL91874_POWER_OFF)
46+
self.command(IL91874_CDI, bytearray([0x17]))
47+
self.command(IL91874_VCM_DC_SETTING, bytearray([0x00]))
48+
self.command(IL91874_POWER_SETTING, bytearray([0x02, 0x00, 0x00, 0x00]))
49+
self.command(IL91874_POWER_OFF)
5450

5551
time.sleep(10)
5652

5753
def power_up(self):
58-
self.command(self.IL91874_POWER_ON)
59-
while self._gpio.is_high(self._busy):
54+
self.command(IL91874_BOOSTER_SOFT_START, bytearray([0x07, 0x07, 0x07]))
55+
self.command(IL91874_POWER_SETTING, bytearray([0x07, 0x00, 0x0A, 0x00]))
56+
self.command(IL91874_POWER_ON)
57+
58+
while self._busy.value == True:
6059
pass
6160

6261
time.sleep(.2)
6362

64-
self.command(self.IL91874_PANEL_SETTING, [0xCF])
65-
self.command(self.IL91874_CDI, [0x37])
66-
self.command(self.IL91874_PLL, [0x29])
67-
self.command(self.IL91874_VCM_DC_SETTING, [0x0A])
63+
self.command(IL91874_PANEL_SETTING, bytearray([0xCF]))
64+
self.command(IL91874_CDI, bytearray([0x37]))
65+
self.command(IL91874_PLL, bytearray([0x29]))
66+
self.command(IL91874_VCM_DC_SETTING, bytearray([0x0A]))
6867

6968
def display(self):
7069
self.power_up()
7170

72-
self.command(self.IL91874_DTM1, end=False)
73-
self._gpio.set_high(self._dc)
74-
for i in range(len(self.bw_buffer)):
75-
self._spi.write([self.bw_buffer[i]])
76-
self._gpio.set_high(self._cs)
77-
78-
self.command(self.IL91874_DTM2, end=False)
79-
self._gpio.set_high(self._dc)
80-
for i in range(len(self.red_buffer)):
81-
self._spi.write([self.red_buffer[i]])
82-
self._gpio.set_high(self._cs)
71+
#TODO: write data when we get duplex transfer support
72+
8373
self.update()
8474

75+
"""
8576
def image(self, image):
86-
"""Set buffer to value of Python Imaging Library image. The image should
77+
'''Set buffer to value of Python Imaging Library image. The image should
8778
be in RGB mode and a size equal to the display size.
88-
"""
79+
'''
8980
if image.mode != 'RGB':
9081
raise ValueError('Image must be in mode RGB.')
9182
imwidth, imheight = image.size
@@ -110,7 +101,9 @@ def image(self, image):
110101
else:
111102
#WHITE
112103
self.bw_buffer[addr] |= (1 << (7 - (y%8)))
104+
"""
113105

114106
def clear_buffer(self):
115-
self.bw_buffer = [0xFF]* (width*height >> 3)
116-
self.red_buffer = [0xFF]* (width*height >> 3)
107+
#self.bw_buffer = [0xFF]* (width*height >> 3)
108+
#self.red_buffer = [0xFF]* (width*height >> 3)
109+
pass

Adafruit_IL91874_212_104.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from Adafruit_IL91874 import *
22

33
class Adafruit_IL91874_212_104(Adafruit_IL91874_base):
4-
def __init__(self, rst, dc, busy, sclk=None, mosi=None, cs=None, gpio=None, spi=None):
4+
def __init__(self, rst, dc, busy, srcs=None, cs=None, spi=None):
55

6-
super(Adafruit_IL91874_212_104, self).__init__(212, 104, rst, dc, busy, sclk, mosi, cs, gpio, spi)
6+
super(Adafruit_IL91874_212_104, self).__init__(212, 104, rst, dc, busy, srcs, cs, spi)
77

88
def power_up(self):
99
super(Adafruit_IL91874_212_104, self).power_up()
10-
self.command(self.IL91874_RESOLUTION, [0x68, 0x00, 0xD4])
10+
self.command(IL91874_RESOLUTION, bytearray([0x68, 0x00, 0xD4]))
1111
time.sleep(.02)

0 commit comments

Comments
 (0)