From 284c65bfbef6b8483322e4b23bb929da66152506 Mon Sep 17 00:00:00 2001 From: dean Date: Thu, 12 Jul 2018 12:35:19 -0400 Subject: [PATCH] DM: fix for new screen and latest cirpy --- Adafruit_EPD/__init__.py | 0 Adafruit_EPD.py => Adafruit_EPD/epd.py | 32 +++-- Adafruit_EPD/il0373.py | 159 +++++++++++++++++++++++++ Adafruit_EPD/mcp_sram.py | 77 ++++++++++++ Adafruit_IL0376F.py | 129 -------------------- Adafruit_IL0376F_200_200.py | 32 ----- Adafruit_IL91874.py | 109 ----------------- Adafruit_IL91874_212_104.py | 11 -- Adafruit_MCP_SRAM.py | 58 --------- examples/basic_154.py | 35 ++++++ 10 files changed, 292 insertions(+), 350 deletions(-) create mode 100644 Adafruit_EPD/__init__.py rename Adafruit_EPD.py => Adafruit_EPD/epd.py (68%) create mode 100644 Adafruit_EPD/il0373.py create mode 100644 Adafruit_EPD/mcp_sram.py delete mode 100644 Adafruit_IL0376F.py delete mode 100644 Adafruit_IL0376F_200_200.py delete mode 100644 Adafruit_IL91874.py delete mode 100644 Adafruit_IL91874_212_104.py delete mode 100644 Adafruit_MCP_SRAM.py create mode 100644 examples/basic_154.py diff --git a/Adafruit_EPD/__init__.py b/Adafruit_EPD/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Adafruit_EPD.py b/Adafruit_EPD/epd.py similarity index 68% rename from Adafruit_EPD.py rename to Adafruit_EPD/epd.py index 6bee8cf..2ccd994 100644 --- a/Adafruit_EPD.py +++ b/Adafruit_EPD/epd.py @@ -1,17 +1,21 @@ import time -from Adafruit_MCP_SRAM import * +from Adafruit_EPD import mcp_sram import digitalio import busio from board import * -from adafruit_bus_device.spi_device import SPIDevice - class Adafruit_EPD(object): """Base class for EPD displays """ + BLACK = 0 + WHITE = 1 + INVERSE = 2 + RED = 3 + DARK = 4 + LIGHT = 5 - def __init__(self, width, height, rst, dc, busy, srcs=None, cs=None, - spi=None): + def __init__(self, width, height, rst, dc, busy, srcs, cs, + spi): self.width = width self.height = height @@ -33,7 +37,7 @@ class Adafruit_EPD(object): self.spi_device = spi - self.sram = Adafruit_MCP_SRAM(cs=srcs, spi=spi) + self.sram = mcp_sram.Adafruit_MCP_SRAM(srcs, spi) def begin(self, reset=True): self._cs.value = True @@ -50,8 +54,11 @@ class Adafruit_EPD(object): self._cs.value = True self._dc.value = False self._cs.value = False - with self.spi_device as spi: - spi.write(bytearray([c])) + outbuf = bytearray(1) + + while not self.spi_device.try_lock(): + pass + self.spi_device.write_readinto(bytearray([c]), outbuf) if data is not None: self.data(data) @@ -59,9 +66,12 @@ class Adafruit_EPD(object): elif end: self._cs.value = True + self.spi_device.unlock() + return outbuf[0] + def data(self, d): """Send data to display.""" self._dc.value = True - with self.spi_device as spi: - spi.write(d) - self._cs.value = True \ No newline at end of file + self.spi_device.write(d) + self._cs.value = True + self.spi_device.unlock() \ No newline at end of file diff --git a/Adafruit_EPD/il0373.py b/Adafruit_EPD/il0373.py new file mode 100644 index 0000000..a1fc5b3 --- /dev/null +++ b/Adafruit_EPD/il0373.py @@ -0,0 +1,159 @@ +from Adafruit_EPD.epd import Adafruit_EPD +from Adafruit_EPD.mcp_sram import Adafruit_MCP_SRAM +from micropython import const +import time + +IL0373_PANEL_SETTING = const(0x00) +IL0373_POWER_SETTING = const(0x01) +IL0373_POWER_OFF = const(0x02) +IL0373_POWER_OFF_SEQUENCE = const(0x03) +IL0373_POWER_ON = const(0x04) +IL0373_POWER_ON_MEASURE = const(0x05) +IL0373_BOOSTER_SOFT_START = const(0x06) +IL0373_DEEP_SLEEP = const(0x07) +IL0373_DTM1 = const(0x10) +IL0373_DATA_STOP = const(0x11) +IL0373_DISPLAY_REFRESH = const(0x12) +IL0373_DTM2 = const(0x13) +IL0373_PDTM1 = const(0x14) +IL0373_PDTM2 = const(0x15) +IL0373_PDRF = const(0x16) +IL0373_LUT1 = const(0x20) +IL0373_LUTWW = const(0x21) +IL0373_LUTBW = const(0x22) +IL0373_LUTWB = const(0x23) +IL0373_LUTBB = const(0x24) +IL0373_PLL = const(0x30) +IL0373_CDI = const(0x50) +IL0373_RESOLUTION = const(0x61) +IL0373_VCM_DC_SETTING = const(0x82) + +class Adafruit_IL0373(Adafruit_EPD): + def __init__(self, width, height, rst, dc, busy, srcs, cs, spi): + super().__init__(width, height, rst, dc, busy, srcs, cs, spi) + + self.bw_bufsize = int(width * height / 8) + self.red_bufsize = int(width * height / 8) + + self.begin() + + def begin(self, reset=True): + super(Adafruit_IL0373, self).begin(reset) + + while self._busy.value == False: + pass + + self.command(IL0373_POWER_SETTING, bytearray([0x03, 0x00, 0x2b, 0x2b, 0x09])) + self.command(IL0373_BOOSTER_SOFT_START, bytearray([0x17, 0x17, 0x17])) + + def update(self): + self.command(IL0373_DISPLAY_REFRESH) + + while self._busy.value == False: + pass + + self.command(IL0373_CDI, bytearray([0x17])) + self.command(IL0373_VCM_DC_SETTING, bytearray([0x00])) + self.command(IL0373_POWER_OFF) + time.sleep(2) + + def power_up(self): + self.command(IL0373_POWER_ON) + + while self._busy.value == False: + pass + + time.sleep(.2) + + self.command(IL0373_PANEL_SETTING, bytearray([0xCF])) + self.command(IL0373_CDI, bytearray([0x37])) + self.command(IL0373_PLL, bytearray([0x29])) + b1 = self.height & 0xFF + b2 = (self.height >> 8) & 0xFF + b3 = self.width & 0xFF + b4 = (self.width >> 8) & 0xFF + self.command(IL0373_RESOLUTION, bytearray([b1, b2, b3, b4])) + self.command(IL0373_VCM_DC_SETTING, bytearray([0x0A])) + + + def display(self): + self.power_up() + + while not self.spi_device.try_lock(): + pass + self.sram.cs.value = False + #send read command + self.spi_device.write(bytearray([Adafruit_MCP_SRAM.SRAM_READ])) + #send start address + self.spi_device.write(bytearray([0x00, 0x00])) + self.spi_device.unlock() + + #first data byte from SRAM will be transfered in at the same time as the EPD command is transferred out + c = self.command(IL0373_DTM1, end=False) + + while not self.spi_device.try_lock(): + pass + self._dc.value = True + xfer = bytearray([c]) + outbuf = bytearray(1) + for i in range(self.bw_bufsize): + outbuf[0] = xfer[0] + self.spi_device.write_readinto(outbuf, xfer) + self._cs.value = True + self.sram.cs.value = True + + time.sleep(.002) + + self.sram.cs.value = False + #send read command + self.spi_device.write(bytearray([Adafruit_MCP_SRAM.SRAM_READ])) + #send start address + self.spi_device.write(bytearray([(self.bw_bufsize >> 8), (self.bw_bufsize & 0xFF)])) + self.spi_device.unlock() + + #first data byte from SRAM will be transfered in at the same time as the EPD command is transferred out + c = self.command(IL0373_DTM2, end=False) + + while not self.spi_device.try_lock(): + pass + self._dc.value = True + xfer = bytearray([c]) + outbuf = bytearray(1) + for i in range(self.bw_bufsize): + outbuf[0] = xfer[0] + self.spi_device.write_readinto(outbuf, xfer) + self._cs.value = True + self.sram.cs.value = True + self.spi_device.unlock() + + self.update() + + def draw_pixel(self, x, y, color): + if (x < 0) or (x >= self.width) or (y < 0) or (y >= self.height): + return + + if x == 0: + x = 1 + + addr = int(((self.width - x) * self.height + y)/8) + if color == Adafruit_EPD.RED: + addr = addr + self.bw_bufsize + c = self.sram.read8(addr) + + if color == Adafruit_EPD.WHITE: + c = c | (1 << (7 - y%8)) + elif color == Adafruit_EPD.RED or color == Adafruit_EPD.BLACK: + c = c & ~(1 << (7 - y%8)) + elif color == Adafruit_EPD.INVERSE: + c = c ^ (1 << (7 - y%8)) + + self.sram.write8(addr, c) + + def clear_buffer(self): + self.sram.erase(0x00, self.bw_bufsize, 0xFF) + self.sram.erase(self.bw_bufsize, self.red_bufsize, 0xFF) + + def clear_display(self): + self.clear_buffer() + self.display() + diff --git a/Adafruit_EPD/mcp_sram.py b/Adafruit_EPD/mcp_sram.py new file mode 100644 index 0000000..fc2b7a4 --- /dev/null +++ b/Adafruit_EPD/mcp_sram.py @@ -0,0 +1,77 @@ +import time +from micropython import const +import digitalio + +from adafruit_bus_device.spi_device import SPIDevice +import busio +from board import * + +SRAM_SEQUENTIAL_MODE = const(1 << 6) + +class Adafruit_MCP_SRAM: + + SRAM_READ = 0x03 + SRAM_WRITE = 0x02 + SRAM_RDSR = 0x05 + SRAM_WRSR = 0x01 + + def __init__(self, cs, spi): + # Handle hardware SPI + self.spi_device = spi + self.cs = cs + + self.cs.direction = digitalio.Direction.OUTPUT + while not self.spi_device.try_lock(): + pass + self.cs.value = False + self.spi_device.write(bytearray([Adafruit_MCP_SRAM.SRAM_WRSR, 0x43])) + self.cs.value = True + self.spi_device.unlock() + + def write(self, addr, buf, reg=SRAM_WRITE): + c = bytearray([reg, (addr >> 8) & 0xFF, addr & 0xFF] + buf) + + while not self.spi_device.try_lock(): + pass + self.cs.value = False + self.spi_device.write(c) + self.cs.value = True + self.spi_device.unlock() + + def read(self, addr, length, reg=SRAM_READ): + c = bytearray([reg, (addr >> 8) & 0xFF, addr & 0xFF]) + + buf = bytearray(length) + while not self.spi_device.try_lock(): + pass + self.cs.value = False + self.spi_device.write(c) + self.spi_device.readinto(buf) + self.cs.value = True + self.spi_device.unlock() + return buf + + def read8(self, addr, reg=SRAM_READ): + return self.read(addr, 1, reg)[0] + + def read16(self, addr, reg=SRAM_READ): + buf = self.read(addr, 2, reg) + return (buf[0] << 8 | buf[1]) + + def write8(self, addr, value, reg=SRAM_WRITE): + self.write(addr, [value], reg) + + def write16(self, addr, value, reg=SRAM_WRITE): + self.write(addr, [value >> 8, value], reg) + + def erase(self, addr, length, value): + c = bytearray([Adafruit_MCP_SRAM.SRAM_WRITE, (addr >> 8) & 0xFF, addr & 0xFF]) + + while not self.spi_device.try_lock(): + pass + self.cs.value = False + self.spi_device.write(c) + for x in range(length): + self.spi_device.write(bytearray([value])) + self.cs.value = True + self.spi_device.unlock() diff --git a/Adafruit_IL0376F.py b/Adafruit_IL0376F.py deleted file mode 100644 index 6e93eaa..0000000 --- a/Adafruit_IL0376F.py +++ /dev/null @@ -1,129 +0,0 @@ -from Adafruit_EPD import * -from micropython import const - -IL0376F_PANEL_SETTING = const(0x00) -IL0376F_POWER_SETTING = const(0x01) -IL0376F_POWER_OFF = const(0x02) -IL0376F_POWER_OFF_SEQUENCE = const(0x03) -IL0376F_POWER_ON = const(0x04) -IL0376F_POWER_ON_MEASURE = const(0x05) -IL0376F_BOOSTER_SOFT_START = const(0x06) -IL0376F_DTM1 = const(0x10) -IL0376F_DATA_STOP = const(0x11) -IL0376F_DISPLAY_REFRESH = const(0x12) -IL0376F_DTM2 = const(0x13) -IL0376F_VCOM1_LUT = const(0x20) -IL0376F_WHITE_LUT = const(0x21) -IL0376F_BLACK_LUT = const(0x22) -IL0376F_GRAY1_LUT = const(0x23) -IL0376F_GRAY2_LUT = const(0x24) -IL0376F_VCOM2_LUT = const(0x25) -IL0376F_RED0_LUT = const(0x26) -IL0376F_RED1_LUT = const(0x27) -IL0376F_PLL = const(0x30) -IL0376F_CDI = const(0x50) -IL0376F_RESOLUTION = const(0x61) -IL0376F_VCM_DC_SETTING = const(0x82) - -class Adafruit_IL0376F_base(Adafruit_EPD): - - def __init__(self, width, height, rst, dc, busy, srcs=None, cs=None, spi=None): - - super(Adafruit_IL0376F_base, self).__init__(width, height, rst, dc, busy, srcs, cs, spi) - - 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])) - - def update(self): - self.command(IL0376F_DISPLAY_REFRESH) - - while self._busy.value == True: - pass - - time.sleep(10) - - self.command(IL0376F_CDI, bytearray([0x17])) - self.command(IL0376F_VCM_DC_SETTING, bytearray([0x00])) - self.command(IL0376F_POWER_SETTING, bytearray([0x02, 0x00, 0x00, 0x00])) - self.command(IL0376F_POWER_OFF) - - def power_up(self): - self.command(IL0376F_POWER_ON) - while self._busy.value == True: - pass - - time.sleep(.2) - - self.command(IL0376F_PANEL_SETTING, bytearray([0xCF])) - self.command(IL0376F_CDI, bytearray([0x37])) - self.command(IL0376F_PLL, bytearray([0x39])) - self.command(IL0376F_VCM_DC_SETTING, bytearray([0x0E])) - - 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: - 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) - self._dc.value = True - with self.spi_device as spi: - for i in range(5000): - spi.write(bytearray([0xff]))#TODO actual data - self._cs.value = True - - self.update() - - """ - def image(self, image): - 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 - if imwidth != self.width or imheight != self.height: - raise ValueError('Image must be same dimensions as display ({0}x{1}).' \ - .format(self.width, self.height)) - # Grab all the pixels from the image, faster than getpixel. - pix = image.load() - - for y in xrange(image.size[0]): - for x in xrange(image.size[1]): - if x == 0: - x = 1 - p = pix[x, y] - if p == (0xFF, 0, 0): - #RED - addr = ( (self.width - x) * self.height + y) >> 3 - self.red_buffer[addr] &= ~(1 << (7 - (y%8))) - else: - #GS - bits = (6 - y%4 * 2) - addr = ( (self.width - x) * self.height + y) >> 2 - self.bw_buffer[addr] &= ~(0x3 << bits) - if p == (0xFF, 0xFF, 0xFF): #WHITE - self.bw_buffer[addr] |= (0x3 << bits) - - elif p == (0x7F, 0x7F, 0x7F): #GRAY - self.bw_buffer[addr] |= (0x2 << bits) - """ \ No newline at end of file diff --git a/Adafruit_IL0376F_200_200.py b/Adafruit_IL0376F_200_200.py deleted file mode 100644 index 42f5b49..0000000 --- a/Adafruit_IL0376F_200_200.py +++ /dev/null @@ -1,32 +0,0 @@ -from Adafruit_IL0376F import * - -lut_vcom0 = bytearray([ 0x0E ,0x14 ,0x01 ,0x0A ,0x06 ,0x04 ,0x0A ,0x0A ,0x0F ,0x03 ,0x03 ,0x0C ,0x06 ,0x0A ,0x00 ]) -lut_w = bytearray([ 0x0E ,0x14 ,0x01 ,0x0A ,0x46 ,0x04 ,0x8A ,0x4A ,0x0F ,0x83 ,0x43 ,0x0C ,0x86 ,0x0A ,0x04 ]) -lut_b = bytearray([ 0x0E ,0x14 ,0x01 ,0x8A ,0x06 ,0x04 ,0x8A ,0x4A ,0x0F ,0x83 ,0x43 ,0x0C ,0x06 ,0x4A ,0x04 ]) -lut_g1 = bytearray([ 0x8E ,0x94 ,0x01 ,0x8A ,0x06 ,0x04 ,0x8A ,0x4A ,0x0F ,0x83 ,0x43 ,0x0C ,0x06 ,0x0A ,0x04 ]) -lut_g2 = bytearray([ 0x8E ,0x94 ,0x01 ,0x8A ,0x06 ,0x04 ,0x8A ,0x4A ,0x0F ,0x83 ,0x43 ,0x0C ,0x06 ,0x0A ,0x04 ]) -lut_vcom1 = bytearray([ 0x03 ,0x1D ,0x01 ,0x01 ,0x08 ,0x23 ,0x37 ,0x37 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ]) -lut_red0 = bytearray([ 0x83 ,0x5D ,0x01 ,0x81 ,0x48 ,0x23 ,0x77 ,0x77 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ]) -lut_red1 = bytearray([ 0x03 ,0x1D ,0x01 ,0x01 ,0x08 ,0x23 ,0x37 ,0x37 ,0x01 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ]) - -class Adafruit_IL0376F_200_200(Adafruit_IL0376F_base): - - def __init__(self, rst, dc, busy, srcs=None, cs=None, spi=None): - - super(Adafruit_IL0376F_200_200, self).__init__(200, 200, rst, dc, busy, srcs, cs, spi) - - def power_up(self): - super(Adafruit_IL0376F_200_200, self).power_up() - - self.command(IL0376F_RESOLUTION, bytearray([0xC8, 0x00, 0xC8])) - self.write_lut() - - def write_lut(self): - self.command(IL0376F_VCOM1_LUT, lut_vcom0) - self.command(IL0376F_WHITE_LUT, lut_w) - self.command(IL0376F_BLACK_LUT, lut_b) - self.command(IL0376F_GRAY1_LUT, lut_g1) - self.command(IL0376F_GRAY2_LUT, lut_g2) - self.command(IL0376F_VCOM2_LUT, lut_vcom1) - self.command(IL0376F_RED0_LUT, lut_red0) - self.command(IL0376F_RED1_LUT, lut_red1) \ No newline at end of file diff --git a/Adafruit_IL91874.py b/Adafruit_IL91874.py deleted file mode 100644 index 3495b9a..0000000 --- a/Adafruit_IL91874.py +++ /dev/null @@ -1,109 +0,0 @@ -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): - - 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, srcs, cs, spi) - - def begin(self, reset=True): - super(Adafruit_IL91874_base, self).begin(reset) - - def update(self): - self.command(IL91874_DISPLAY_REFRESH) - - while self._busy.value == True: - pass - - time.sleep(10) - - 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(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(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() - - #TODO: write data when we get duplex transfer support - - self.update() - - """ - def image(self, image): - '''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 - if imwidth != self.width or imheight != self.height: - raise ValueError('Image must be same dimensions as display ({0}x{1}).' \ - .format(self.width, self.height)) - # Grab all the pixels from the image, faster than getpixel. - pix = image.load() - - for y in xrange(image.size[1]): - for x in xrange(image.size[0]): - if x == 0: - x = 1 - p = pix[x, y] - addr = ( (self.width - x) * self.height + y) >> 3 - if p == (0xFF, 0, 0): - #RED - self.red_buffer[addr] &= ~(1 << (7 - (y%8))) - elif p == (0, 0, 0): - #BLACK - self.bw_buffer[addr] &= ~(1 << (7 - (y%8))) - 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) - pass \ No newline at end of file diff --git a/Adafruit_IL91874_212_104.py b/Adafruit_IL91874_212_104.py deleted file mode 100644 index 0f98f43..0000000 --- a/Adafruit_IL91874_212_104.py +++ /dev/null @@ -1,11 +0,0 @@ -from Adafruit_IL91874 import * - -class Adafruit_IL91874_212_104(Adafruit_IL91874_base): - def __init__(self, rst, dc, busy, srcs=None, cs=None, spi=None): - - 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(IL91874_RESOLUTION, bytearray([0x68, 0x00, 0xD4])) - time.sleep(.02) \ No newline at end of file diff --git a/Adafruit_MCP_SRAM.py b/Adafruit_MCP_SRAM.py deleted file mode 100644 index 7c008d9..0000000 --- a/Adafruit_MCP_SRAM.py +++ /dev/null @@ -1,58 +0,0 @@ -import time -from micropython import const - -from adafruit_bus_device.spi_device import SPIDevice -import busio -from board import * - -SRAM_READ = const(0x03) -SRAM_WRITE = const(0x02) -SRAM_RDSR = const(0x05) -SRAM_WRSR = const(0x01) - -SRAM_SEQUENTIAL_MODE = const(1 << 6) - -class Adafruit_MCP_SRAM: - - def __init__(self, cs, spi): - # Handle hardware SPI - self.spi_device = spi - - with self.spi_device as spi: - spi.write(bytearray([0xFF, 0xFF, 0xFF])) - - def write(self, addr, buf, reg=SRAM_WRITE): - c = bytearray([reg, (addr >> 16) & 0xFF, (addr >> 8) & 0xFF, addr & 0xFF] + bytearray(buf)) - - with self.spi_device as spi: - spi.write(c) - - def read(self, addr, length, reg=SRAM_READ): - c = bytearray([reg, (addr >> 16) & 0xFF, (addr >> 8) & 0xFF, addr & 0xFF] + bytearray(buf)) - - buf = bytearray(length) - with self.spi_device as spi: - spi.readinto(buf) - - return buf - - def read8(self, addr, reg=SRAM_READ): - return ord(self.read(addr, 1, reg)[0]) - - def read16(self, addr, reg=SRAM_READ): - buf = self.read(addr, 2, reg) - return (buf[0] << 8 | buf[1]) - - def write8(self, addr, value, reg=SRAM_WRITE): - self.write(addr, [value], reg) - - def write16(self, addr, value, reg=SRAM_WRITE): - self.write(addr, [value >> 8, value], reg) - - def erase(self, addr, length, value): - pos = 0 - while pos < length: - buf = [value] * min(64, length - pos) - self.write(addr, buf) - addr = addr + len(buf) - pos = pos + len(buf) diff --git a/examples/basic_154.py b/examples/basic_154.py new file mode 100644 index 0000000..6ef2511 --- /dev/null +++ b/examples/basic_154.py @@ -0,0 +1,35 @@ +import digitalio +import busio +from adafruit_bus_device.spi_device import SPIDevice +from board import * +from Adafruit_EPD.epd import Adafruit_EPD +from Adafruit_EPD.il0373 import Adafruit_IL0373 + +#create the spi device and pins we will need +spi = busio.SPI(SCK, MOSI=MOSI, MISO=MISO) +ecs = digitalio.DigitalInOut(D10) +dc = digitalio.DigitalInOut(D9) +srcs = digitalio.DigitalInOut(D8) +rst = digitalio.DigitalInOut(D7) +busy = digitalio.DigitalInOut(D6) + +#give them all to our driver +display = Adafruit_IL0373(152, 152, rst, dc, busy, srcs, ecs, spi) + +#clear the buffer +display.clear_buffer() + +#draw some lines!! +for i in range(152): + display.draw_pixel(i, i, Adafruit_EPD.RED) + display.draw_pixel(152-i, i, Adafruit_EPD.RED) + display.draw_pixel(10, i, Adafruit_EPD.BLACK) + display.draw_pixel(20, i, Adafruit_EPD.BLACK) + display.draw_pixel(30, i, Adafruit_EPD.BLACK) + display.draw_pixel(40, i, Adafruit_EPD.BLACK) + display.draw_pixel(50, i, Adafruit_EPD.BLACK) + display.draw_pixel(60, i, Adafruit_EPD.BLACK) + display.draw_pixel(70, i, Adafruit_EPD.BLACK) + display.draw_pixel(80, i, Adafruit_EPD.BLACK) + +display.display()