DM: add IL91874 support

This commit is contained in:
dean 2017-10-09 16:09:53 -04:00
parent 5b8af3ad77
commit 445767efb8
4 changed files with 69 additions and 67 deletions

View file

@ -45,9 +45,6 @@ class Adafruit_EPD(object):
self._rst.value = True
time.sleep(.1)
while self._busy.value == True:
pass
def command(self, c, data=None, end=True):
"""Send command byte to display."""
self._cs.value = True

View file

@ -34,6 +34,9 @@ class Adafruit_IL0376F_base(Adafruit_EPD):
def begin(self, reset=True):
super(Adafruit_IL0376F_base, self).begin(reset)
while self._busy.value == True:
pass
self.command(IL0376F_POWER_SETTING, bytearray([0x07, 0x00, 0x0D, 0x00]))
self.command(IL0376F_BOOSTER_SOFT_START, bytearray([0x07, 0x07, 0x07]))
@ -65,11 +68,20 @@ class Adafruit_IL0376F_base(Adafruit_EPD):
def display(self):
self.power_up()
#TODO: we need to do duplex transfers.
c = 0x00
with self.spi_device as spi:
spi.write(bytearray(SRAM_READ, 0x00, 0x00)) #should be duplex
self.command(IL0376F_DTM1, end=False)
self._dc.value = True
with self.spi_device as spi:
for i in range(10000):
spi.write(bytearray([0xff]))#TODO actual data
spi.write(bytearray(SRAM_READ, 0x00, 0x00))
for i in range(int(self.width*self.height / 4)):
c = spi.write(bytearray([c])) #should be duplex
self._cs.value = True
self.command(IL0376F_DTM2, end=False)

View file

@ -1,91 +1,82 @@
from Adafruit_EPD import *
from micropython import const
IL91874_PANEL_SETTING = const(0x00)
IL91874_POWER_SETTING = const(0x01)
IL91874_POWER_OFF = const(0x02)
IL91874_POWER_OFF_SEQUENCE = const(0x03)
IL91874_POWER_ON = const(0x04)
IL91874_POWER_ON_MEASURE = const(0x05)
IL91874_BOOSTER_SOFT_START = const(0x06)
IL91874_DEEP_SLEEP = const(0x07)
IL91874_DTM1 = const(0x10)
IL91874_DATA_STOP = const(0x11)
IL91874_DISPLAY_REFRESH = const(0x12)
IL91874_DTM2 = const(0x13)
IL91874_PDTM1 = const(0x14)
IL91874_PDTM2 = const(0x15)
IL91874_PDRF = const(0x16)
IL91874_LUT1 = const(0x20)
IL91874_LUTWW = const(0x21)
IL91874_LUTBW = const(0x22)
IL91874_LUTWB = const(0x23)
IL91874_LUTBB = const(0x24)
IL91874_PLL = const(0x30)
IL91874_CDI = const(0x50)
IL91874_RESOLUTION = const(0x61)
IL91874_VCM_DC_SETTING = const(0x82)
class Adafruit_IL91874_base(Adafruit_EPD):
IL91874_PANEL_SETTING = 0x00
IL91874_POWER_SETTING = 0x01
IL91874_POWER_OFF = 0x02
IL91874_POWER_OFF_SEQUENCE =0x03
IL91874_POWER_ON = 0x04
IL91874_POWER_ON_MEASURE = 0x05
IL91874_BOOSTER_SOFT_START = 0x06
IL91874_DEEP_SLEEP = 0x07
IL91874_DTM1 = 0x10
IL91874_DATA_STOP = 0x11
IL91874_DISPLAY_REFRESH = 0x12
IL91874_DTM2 = 0x13
IL91874_PDTM1 = 0x14
IL91874_PDTM2 = 0x15
IL91874_PDRF = 0x16
IL91874_LUT1 = 0x20
IL91874_LUTWW = 0x21
IL91874_LUTBW = 0x22
IL91874_LUTWB = 0x23
IL91874_LUTBB = 0x24
IL91874_PLL = 0x30
IL91874_CDI = 0x50
IL91874_RESOLUTION = 0x61
IL91874_VCM_DC_SETTING = 0x82
def __init__(self, width, height, rst, dc, busy, sclk=None, mosi=None, cs=None, gpio=None, spi=None):
def __init__(self, width, height, rst, dc, busy, srcs=None, cs=None, spi=None):
super(Adafruit_IL91874_base, self).__init__(width, height, rst, dc, busy, sclk, mosi, cs, gpio, spi)
self.bw_buffer = [0xFF]* (width*height >> 3)
self.red_buffer = [0xFF]* (width*height >> 3)
super(Adafruit_IL91874_base, self).__init__(width, height, rst, dc, busy, srcs, cs, spi)
def begin(self, reset=True):
super(Adafruit_IL91874_base, self).begin(reset)
self.command(self.IL91874_POWER_SETTING, [0x07, 0x00, 0x0A, 0x00])
self.command(self.IL91874_BOOSTER_SOFT_START, [0x07, 0x07, 0x07])
def update(self):
self.command(self.IL91874_DISPLAY_REFRESH)
self.command(IL91874_DISPLAY_REFRESH)
while self._gpio.is_high(self._busy):
while self._busy.value == True:
pass
time.sleep(10)
self.command(self.IL91874_CDI, [0x17])
self.command(self.IL91874_VCM_DC_SETTING, [0x00])
self.command(self.IL91874_POWER_SETTING, [0x02, 0x00, 0x00, 0x00])
self.command(self.IL91874_POWER_OFF)
self.command(IL91874_CDI, bytearray([0x17]))
self.command(IL91874_VCM_DC_SETTING, bytearray([0x00]))
self.command(IL91874_POWER_SETTING, bytearray([0x02, 0x00, 0x00, 0x00]))
self.command(IL91874_POWER_OFF)
time.sleep(10)
def power_up(self):
self.command(self.IL91874_POWER_ON)
while self._gpio.is_high(self._busy):
self.command(IL91874_BOOSTER_SOFT_START, bytearray([0x07, 0x07, 0x07]))
self.command(IL91874_POWER_SETTING, bytearray([0x07, 0x00, 0x0A, 0x00]))
self.command(IL91874_POWER_ON)
while self._busy.value == True:
pass
time.sleep(.2)
self.command(self.IL91874_PANEL_SETTING, [0xCF])
self.command(self.IL91874_CDI, [0x37])
self.command(self.IL91874_PLL, [0x29])
self.command(self.IL91874_VCM_DC_SETTING, [0x0A])
self.command(IL91874_PANEL_SETTING, bytearray([0xCF]))
self.command(IL91874_CDI, bytearray([0x37]))
self.command(IL91874_PLL, bytearray([0x29]))
self.command(IL91874_VCM_DC_SETTING, bytearray([0x0A]))
def display(self):
self.power_up()
self.command(self.IL91874_DTM1, end=False)
self._gpio.set_high(self._dc)
for i in range(len(self.bw_buffer)):
self._spi.write([self.bw_buffer[i]])
self._gpio.set_high(self._cs)
#TODO: write data when we get duplex transfer support
self.command(self.IL91874_DTM2, end=False)
self._gpio.set_high(self._dc)
for i in range(len(self.red_buffer)):
self._spi.write([self.red_buffer[i]])
self._gpio.set_high(self._cs)
self.update()
"""
def image(self, image):
"""Set buffer to value of Python Imaging Library image. The image should
'''Set buffer to value of Python Imaging Library image. The image should
be in RGB mode and a size equal to the display size.
"""
'''
if image.mode != 'RGB':
raise ValueError('Image must be in mode RGB.')
imwidth, imheight = image.size
@ -110,7 +101,9 @@ class Adafruit_IL91874_base(Adafruit_EPD):
else:
#WHITE
self.bw_buffer[addr] |= (1 << (7 - (y%8)))
"""
def clear_buffer(self):
self.bw_buffer = [0xFF]* (width*height >> 3)
self.red_buffer = [0xFF]* (width*height >> 3)
#self.bw_buffer = [0xFF]* (width*height >> 3)
#self.red_buffer = [0xFF]* (width*height >> 3)
pass

View file

@ -1,11 +1,11 @@
from Adafruit_IL91874 import *
class Adafruit_IL91874_212_104(Adafruit_IL91874_base):
def __init__(self, rst, dc, busy, sclk=None, mosi=None, cs=None, gpio=None, spi=None):
def __init__(self, rst, dc, busy, srcs=None, cs=None, spi=None):
super(Adafruit_IL91874_212_104, self).__init__(212, 104, rst, dc, busy, sclk, mosi, cs, gpio, spi)
super(Adafruit_IL91874_212_104, self).__init__(212, 104, rst, dc, busy, srcs, cs, spi)
def power_up(self):
super(Adafruit_IL91874_212_104, self).power_up()
self.command(self.IL91874_RESOLUTION, [0x68, 0x00, 0xD4])
self.command(IL91874_RESOLUTION, bytearray([0x68, 0x00, 0xD4]))
time.sleep(.02)