Ran black, updated to pylint 2.x

This commit is contained in:
dherrada 2020-03-16 14:41:40 -04:00
parent faeb1a75d8
commit c13f9f53c1
19 changed files with 553 additions and 362 deletions

View file

@ -40,7 +40,7 @@ jobs:
source actions-ci/install.sh source actions-ci/install.sh
- name: Pip install pylint, black, & Sphinx - name: Pip install pylint, black, & Sphinx
run: | run: |
pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
- name: Library version - name: Library version
run: git describe --dirty --always --tags run: git describe --dirty --always --tags
- name: PyLint - name: PyLint

View file

@ -34,9 +34,11 @@ from adafruit_epd import mcp_sram
__version__ = "0.0.0-auto.0" __version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_EPD.git" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_EPD.git"
class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-public-methods
class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-public-methods
"""Base class for EPD displays """Base class for EPD displays
""" """
BLACK = const(0) BLACK = const(0)
WHITE = const(1) WHITE = const(1)
INVERSE = const(2) INVERSE = const(2)
@ -44,8 +46,9 @@ class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-pub
DARK = const(4) DARK = const(4)
LIGHT = const(5) LIGHT = const(5)
def __init__(
def __init__(self, width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin): # pylint: disable=too-many-arguments self, width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
): # pylint: disable=too-many-arguments
self._width = width self._width = width
self._height = height self._height = height
@ -73,7 +76,7 @@ class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-pub
self.spi_device = spi self.spi_device = spi
while not self.spi_device.try_lock(): while not self.spi_device.try_lock():
time.sleep(0.01) time.sleep(0.01)
self.spi_device.configure(baudrate=1000000) # 1 Mhz self.spi_device.configure(baudrate=1000000) # 1 Mhz
self.spi_device.unlock() self.spi_device.unlock()
self._spibuf = bytearray(1) self._spibuf = bytearray(1)
@ -101,16 +104,16 @@ class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-pub
while not self.spi_device.try_lock(): while not self.spi_device.try_lock():
time.sleep(0.01) time.sleep(0.01)
self.sram.cs_pin.value = False self.sram.cs_pin.value = False
#send read command # send read command
self._buf[0] = mcp_sram.Adafruit_MCP_SRAM.SRAM_READ self._buf[0] = mcp_sram.Adafruit_MCP_SRAM.SRAM_READ
#send start address # send start address
self._buf[1] = 0 self._buf[1] = 0
self._buf[2] = 0 self._buf[2] = 0
self.spi_device.write(self._buf, end=3) self.spi_device.write(self._buf, end=3)
self.spi_device.unlock() self.spi_device.unlock()
#first data byte from SRAM will be transfered in at the # first data byte from SRAM will be transfered in at the
#same time as the EPD command is transferred out # same time as the EPD command is transferred out
databyte = self.write_ram(0) databyte = self.write_ram(0)
while not self.spi_device.try_lock(): while not self.spi_device.try_lock():
@ -127,23 +130,23 @@ class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-pub
self._cs.value = True self._cs.value = True
self.spi_device.unlock() self.spi_device.unlock()
time.sleep(.002) time.sleep(0.002)
if self.sram: if self.sram:
while not self.spi_device.try_lock(): while not self.spi_device.try_lock():
time.sleep(0.01) time.sleep(0.01)
self.sram.cs_pin.value = False self.sram.cs_pin.value = False
#send read command # send read command
self._buf[0] = mcp_sram.Adafruit_MCP_SRAM.SRAM_READ self._buf[0] = mcp_sram.Adafruit_MCP_SRAM.SRAM_READ
#send start address # send start address
self._buf[1] = (self._buffer1_size >> 8) & 0xFF self._buf[1] = (self._buffer1_size >> 8) & 0xFF
self._buf[2] = self._buffer1_size & 0xFF self._buf[2] = self._buffer1_size & 0xFF
self.spi_device.write(self._buf, end=3) self.spi_device.write(self._buf, end=3)
self.spi_device.unlock() self.spi_device.unlock()
if self._buffer2_size != 0: if self._buffer2_size != 0:
#first data byte from SRAM will be transfered in at the # first data byte from SRAM will be transfered in at the
#same time as the EPD command is transferred out # same time as the EPD command is transferred out
databyte = self.write_ram(1) databyte = self.write_ram(1)
while not self.spi_device.try_lock(): while not self.spi_device.try_lock():
@ -166,7 +169,6 @@ class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-pub
self.update() self.update()
def hardware_reset(self): def hardware_reset(self):
"""If we have a reset pin, do a hardware reset by toggling it""" """If we have a reset pin, do a hardware reset by toggling it"""
if self._rst: if self._rst:
@ -251,7 +253,7 @@ class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-pub
def _color_dup(self, func, args, color): def _color_dup(self, func, args, color):
black = getattr(self._blackframebuf, func) black = getattr(self._blackframebuf, func)
red = getattr(self._colorframebuf, func) red = getattr(self._colorframebuf, func)
if self._blackframebuf is self._colorframebuf: # monochrome if self._blackframebuf is self._colorframebuf: # monochrome
black(*args, color=(color != Adafruit_EPD.WHITE) != self._black_inverted) black(*args, color=(color != Adafruit_EPD.WHITE) != self._black_inverted)
else: else:
black(*args, color=(color == Adafruit_EPD.BLACK) != self._black_inverted) black(*args, color=(color == Adafruit_EPD.BLACK) != self._black_inverted)
@ -259,7 +261,7 @@ class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-pub
def pixel(self, x, y, color): def pixel(self, x, y, color):
"""draw a single pixel in the display buffer""" """draw a single pixel in the display buffer"""
self._color_dup('pixel', (x, y), color) self._color_dup("pixel", (x, y), color)
def fill(self, color): def fill(self, color):
"""fill the screen with the passed color""" """fill the screen with the passed color"""
@ -273,28 +275,45 @@ class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-pub
self._blackframebuf.fill(black_fill) self._blackframebuf.fill(black_fill)
self._colorframebuf.fill(red_fill) self._colorframebuf.fill(red_fill)
def rect(self, x, y, width, height, color): # pylint: disable=too-many-arguments def rect(self, x, y, width, height, color): # pylint: disable=too-many-arguments
"""draw a rectangle""" """draw a rectangle"""
self._color_dup('rect', (x, y, width, height), color) self._color_dup("rect", (x, y, width, height), color)
def fill_rect(self, x, y, width, height, color): # pylint: disable=too-many-arguments def fill_rect(
self, x, y, width, height, color
): # pylint: disable=too-many-arguments
"""fill a rectangle with the passed color""" """fill a rectangle with the passed color"""
self._color_dup('fill_rect', (x, y, width, height), color) self._color_dup("fill_rect", (x, y, width, height), color)
def line(self, x_0, y_0, x_1, y_1, color): # pylint: disable=too-many-arguments def line(self, x_0, y_0, x_1, y_1, color): # pylint: disable=too-many-arguments
"""Draw a line from (x_0, y_0) to (x_1, y_1) in passed color""" """Draw a line from (x_0, y_0) to (x_1, y_1) in passed color"""
self._color_dup('line', (x_0, y_0, x_1, y_1), color) self._color_dup("line", (x_0, y_0, x_1, y_1), color)
def text(self, string, x, y, color, *, font_name="font5x8.bin"): def text(self, string, x, y, color, *, font_name="font5x8.bin"):
"""Write text string at location (x, y) in given color, using font file""" """Write text string at location (x, y) in given color, using font file"""
if self._blackframebuf is self._colorframebuf: # monochrome if self._blackframebuf is self._colorframebuf: # monochrome
self._blackframebuf.text(string, x, y, font_name=font_name, self._blackframebuf.text(
color=(color != Adafruit_EPD.WHITE) != self._black_inverted) string,
x,
y,
font_name=font_name,
color=(color != Adafruit_EPD.WHITE) != self._black_inverted,
)
else: else:
self._blackframebuf.text(string, x, y, font_name=font_name, self._blackframebuf.text(
color=(color == Adafruit_EPD.BLACK) != self._black_inverted) string,
self._colorframebuf.text(string, x, y, font_name=font_name, x,
color=(color == Adafruit_EPD.RED) != self._color_inverted) y,
font_name=font_name,
color=(color == Adafruit_EPD.BLACK) != self._black_inverted,
)
self._colorframebuf.text(
string,
x,
y,
font_name=font_name,
color=(color == Adafruit_EPD.RED) != self._color_inverted,
)
@property @property
def width(self): def width(self):
@ -329,17 +348,19 @@ class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-pub
"""draw a vertical line""" """draw a vertical line"""
self.fill_rect(x, y, 1, height, color) self.fill_rect(x, y, 1, height, color)
def image(self, image): 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. be in RGB mode and a size equal to the display size.
""" """
if image.mode != 'RGB': if image.mode != "RGB":
raise ValueError('Image must be in mode RGB.') raise ValueError("Image must be in mode RGB.")
imwidth, imheight = image.size imwidth, imheight = image.size
if imwidth != self.width or imheight != self.height: if imwidth != self.width or imheight != self.height:
raise ValueError('Image must be same dimensions as display ({0}x{1}).' \ raise ValueError(
.format(self.width, self.height)) "Image must be same dimensions as display ({0}x{1}).".format(
self.width, self.height
)
)
if self.sram: if self.sram:
raise RuntimeError("PIL image is not for use with SRAM assist") raise RuntimeError("PIL image is not for use with SRAM assist")
# Grab all the pixels from the image, faster than getpixel. # Grab all the pixels from the image, faster than getpixel.
@ -350,7 +371,7 @@ class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-pub
for y in range(image.size[1]): for y in range(image.size[1]):
for x in range(image.size[0]): for x in range(image.size[0]):
pixel = pix[x, y] pixel = pix[x, y]
if (pixel[0] >= 0x80) and (pixel[1] < 0x80) and (pixel[2] < 0x80): if (pixel[1] < 0x80 <= pixel[0]) and (pixel[2] < 0x80):
# reddish # reddish
self.pixel(x, y, Adafruit_EPD.RED) self.pixel(x, y, Adafruit_EPD.RED)
elif (pixel[0] < 0x80) and (pixel[1] < 0x80) and (pixel[2] < 0x80): elif (pixel[0] < 0x80) and (pixel[1] < 0x80) and (pixel[2] < 0x80):

View file

@ -59,12 +59,17 @@ _IL0373_CDI = const(0x50)
_IL0373_RESOLUTION = const(0x61) _IL0373_RESOLUTION = const(0x61)
_IL0373_VCM_DC_SETTING = const(0x82) _IL0373_VCM_DC_SETTING = const(0x82)
class Adafruit_IL0373(Adafruit_EPD): class Adafruit_IL0373(Adafruit_EPD):
"""driver class for Adafruit IL0373 ePaper display breakouts""" """driver class for Adafruit IL0373 ePaper display breakouts"""
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin): def __init__(
super(Adafruit_IL0373, self).__init__(width, height, spi, cs_pin, dc_pin, self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
sramcs_pin, rst_pin, busy_pin) ):
super(Adafruit_IL0373, self).__init__(
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
)
self._buffer1_size = int(width * height / 8) self._buffer1_size = int(width * height / 8)
self._buffer2_size = int(width * height / 8) self._buffer2_size = int(width * height / 8)
@ -77,10 +82,12 @@ class Adafruit_IL0373(Adafruit_EPD):
self._buffer2 = bytearray((width * height) // 8) self._buffer2 = bytearray((width * height) // 8)
# since we have *two* framebuffers - one for red and one for black # since we have *two* framebuffers - one for red and one for black
# we dont subclass but manage manually # we dont subclass but manage manually
self._framebuf1 = adafruit_framebuf.FrameBuffer(self._buffer1, width, height, self._framebuf1 = adafruit_framebuf.FrameBuffer(
buf_format=adafruit_framebuf.MHMSB) self._buffer1, width, height, buf_format=adafruit_framebuf.MHMSB
self._framebuf2 = adafruit_framebuf.FrameBuffer(self._buffer2, width, height, )
buf_format=adafruit_framebuf.MHMSB) self._framebuf2 = adafruit_framebuf.FrameBuffer(
self._buffer2, width, height, buf_format=adafruit_framebuf.MHMSB
)
self.set_black_buffer(0, True) self.set_black_buffer(0, True)
self.set_color_buffer(1, True) self.set_color_buffer(1, True)
# pylint: enable=too-many-arguments # pylint: enable=too-many-arguments
@ -105,7 +112,7 @@ class Adafruit_IL0373(Adafruit_EPD):
self.hardware_reset() self.hardware_reset()
self.busy_wait() self.busy_wait()
self.command(_IL0373_POWER_SETTING, bytearray([0x03, 0x00, 0x2b, 0x2b, 0x09])) self.command(_IL0373_POWER_SETTING, bytearray([0x03, 0x00, 0x2B, 0x2B, 0x09]))
self.command(_IL0373_BOOSTER_SOFT_START, bytearray([0x17, 0x17, 0x17])) self.command(_IL0373_BOOSTER_SOFT_START, bytearray([0x17, 0x17, 0x17]))
self.command(_IL0373_POWER_ON) self.command(_IL0373_POWER_ON)
@ -134,7 +141,7 @@ class Adafruit_IL0373(Adafruit_EPD):
time.sleep(0.1) time.sleep(0.1)
self.busy_wait() self.busy_wait()
if not self._busy: if not self._busy:
time.sleep(15) # wait 15 seconds time.sleep(15) # wait 15 seconds
def write_ram(self, index): def write_ram(self, index):
"""Send the one byte command for starting the RAM write process. Returns """Send the one byte command for starting the RAM write process. Returns
@ -146,7 +153,7 @@ class Adafruit_IL0373(Adafruit_EPD):
return self.command(_IL0373_DTM2, end=False) return self.command(_IL0373_DTM2, end=False)
raise RuntimeError("RAM index must be 0 or 1") raise RuntimeError("RAM index must be 0 or 1")
def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
return # on this chip it does nothing return # on this chip it does nothing

View file

@ -60,12 +60,17 @@ _IL0398_RESOLUTION = const(0x61)
_IL0398_GETSTATUS = const(0x71) _IL0398_GETSTATUS = const(0x71)
_IL0398_VCM_DC_SETTING = const(0x82) _IL0398_VCM_DC_SETTING = const(0x82)
class Adafruit_IL0398(Adafruit_EPD): class Adafruit_IL0398(Adafruit_EPD):
"""driver class for Adafruit IL0373 ePaper display breakouts""" """driver class for Adafruit IL0373 ePaper display breakouts"""
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin): def __init__(
super(Adafruit_IL0398, self).__init__(width, height, spi, cs_pin, dc_pin, self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
sramcs_pin, rst_pin, busy_pin) ):
super(Adafruit_IL0398, self).__init__(
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
)
self._buffer1_size = int(width * height / 8) self._buffer1_size = int(width * height / 8)
self._buffer2_size = int(width * height / 8) self._buffer2_size = int(width * height / 8)
@ -78,10 +83,12 @@ class Adafruit_IL0398(Adafruit_EPD):
self._buffer2 = bytearray((width * height) // 8) self._buffer2 = bytearray((width * height) // 8)
# since we have *two* framebuffers - one for red and one for black # since we have *two* framebuffers - one for red and one for black
# we dont subclass but manage manually # we dont subclass but manage manually
self._framebuf1 = adafruit_framebuf.FrameBuffer(self._buffer1, width, height, self._framebuf1 = adafruit_framebuf.FrameBuffer(
buf_format=adafruit_framebuf.MHMSB) self._buffer1, width, height, buf_format=adafruit_framebuf.MHMSB
self._framebuf2 = adafruit_framebuf.FrameBuffer(self._buffer2, width, height, )
buf_format=adafruit_framebuf.MHMSB) self._framebuf2 = adafruit_framebuf.FrameBuffer(
self._buffer2, width, height, buf_format=adafruit_framebuf.MHMSB
)
self.set_black_buffer(0, True) self.set_black_buffer(0, True)
self.set_color_buffer(1, True) self.set_color_buffer(1, True)
# pylint: enable=too-many-arguments # pylint: enable=too-many-arguments
@ -97,7 +104,7 @@ class Adafruit_IL0398(Adafruit_EPD):
busy pin, or pausing""" busy pin, or pausing"""
if self._busy: if self._busy:
while not self._busy.value: while not self._busy.value:
#self.command(_IL0398_GETSTATUS) # self.command(_IL0398_GETSTATUS)
time.sleep(0.01) time.sleep(0.01)
else: else:
time.sleep(0.5) time.sleep(0.5)
@ -134,7 +141,7 @@ class Adafruit_IL0398(Adafruit_EPD):
time.sleep(0.1) time.sleep(0.1)
self.busy_wait() self.busy_wait()
if not self._busy: if not self._busy:
time.sleep(15) # wait 15 seconds time.sleep(15) # wait 15 seconds
def write_ram(self, index): def write_ram(self, index):
"""Send the one byte command for starting the RAM write process. Returns """Send the one byte command for starting the RAM write process. Returns
@ -146,7 +153,7 @@ class Adafruit_IL0398(Adafruit_EPD):
return self.command(_IL0398_DTM2, end=False) return self.command(_IL0398_DTM2, end=False)
raise RuntimeError("RAM index must be 0 or 1") raise RuntimeError("RAM index must be 0 or 1")
def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
return # on this chip it does nothing return # on this chip it does nothing

View file

@ -60,19 +60,24 @@ _IL91874_RESOLUTION = const(0x61)
_IL91874_VCM_DC_SETTING = const(0x82) _IL91874_VCM_DC_SETTING = const(0x82)
# pylint: disable=line-too-long # pylint: disable=line-too-long
_LUT_VCOMDC = b'\x00\x00\x00\x1a\x1a\x00\x00\x01\x00\n\n\x00\x00\x08\x00\x0e\x01\x0e\x01\x10\x00\n\n\x00\x00\x08\x00\x04\x10\x00\x00\x05\x00\x03\x0e\x00\x00\n\x00#\x00\x00\x00\x01' _LUT_VCOMDC = b"\x00\x00\x00\x1a\x1a\x00\x00\x01\x00\n\n\x00\x00\x08\x00\x0e\x01\x0e\x01\x10\x00\n\n\x00\x00\x08\x00\x04\x10\x00\x00\x05\x00\x03\x0e\x00\x00\n\x00#\x00\x00\x00\x01"
_LUT_WW = b'\x90\x1a\x1a\x00\x00\x01@\n\n\x00\x00\x08\x84\x0e\x01\x0e\x01\x10\x80\n\n\x00\x00\x08\x00\x04\x10\x00\x00\x05\x00\x03\x0e\x00\x00\n\x00#\x00\x00\x00\x01' _LUT_WW = b"\x90\x1a\x1a\x00\x00\x01@\n\n\x00\x00\x08\x84\x0e\x01\x0e\x01\x10\x80\n\n\x00\x00\x08\x00\x04\x10\x00\x00\x05\x00\x03\x0e\x00\x00\n\x00#\x00\x00\x00\x01"
_LUT_BW = b'\xa0\x1a\x1a\x00\x00\x01\x00\n\n\x00\x00\x08\x84\x0e\x01\x0e\x01\x10\x90\n\n\x00\x00\x08\xb0\x04\x10\x00\x00\x05\xb0\x03\x0e\x00\x00\n\xc0#\x00\x00\x00\x01' _LUT_BW = b"\xa0\x1a\x1a\x00\x00\x01\x00\n\n\x00\x00\x08\x84\x0e\x01\x0e\x01\x10\x90\n\n\x00\x00\x08\xb0\x04\x10\x00\x00\x05\xb0\x03\x0e\x00\x00\n\xc0#\x00\x00\x00\x01"
_LUT_BB = b'\x90\x1a\x1a\x00\x00\x01@\n\n\x00\x00\x08\x84\x0e\x01\x0e\x01\x10\x80\n\n\x00\x00\x08\x00\x04\x10\x00\x00\x05\x00\x03\x0e\x00\x00\n\x00#\x00\x00\x00\x01' _LUT_BB = b"\x90\x1a\x1a\x00\x00\x01@\n\n\x00\x00\x08\x84\x0e\x01\x0e\x01\x10\x80\n\n\x00\x00\x08\x00\x04\x10\x00\x00\x05\x00\x03\x0e\x00\x00\n\x00#\x00\x00\x00\x01"
_LUT_WB = b'\x90\x1a\x1a\x00\x00\x01 \n\n\x00\x00\x08\x84\x0e\x01\x0e\x01\x10\x10\n\n\x00\x00\x08\x00\x04\x10\x00\x00\x05\x00\x03\x0e\x00\x00\n\x00#\x00\x00\x00\x01' _LUT_WB = b"\x90\x1a\x1a\x00\x00\x01 \n\n\x00\x00\x08\x84\x0e\x01\x0e\x01\x10\x10\n\n\x00\x00\x08\x00\x04\x10\x00\x00\x05\x00\x03\x0e\x00\x00\n\x00#\x00\x00\x00\x01"
# pylint: enable=line-too-long # pylint: enable=line-too-long
class Adafruit_IL91874(Adafruit_EPD): class Adafruit_IL91874(Adafruit_EPD):
"""driver class for Adafruit IL91874 ePaper display breakouts""" """driver class for Adafruit IL91874 ePaper display breakouts"""
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin): def __init__(
super(Adafruit_IL91874, self).__init__(width, height, spi, cs_pin, dc_pin, self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
sramcs_pin, rst_pin, busy_pin) ):
super(Adafruit_IL91874, self).__init__(
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
)
self._buffer1_size = int(width * height / 8) self._buffer1_size = int(width * height / 8)
self._buffer2_size = int(width * height / 8) self._buffer2_size = int(width * height / 8)
@ -85,10 +90,12 @@ class Adafruit_IL91874(Adafruit_EPD):
self._buffer2 = bytearray((width * height) // 8) self._buffer2 = bytearray((width * height) // 8)
# since we have *two* framebuffers - one for red and one for black # since we have *two* framebuffers - one for red and one for black
# we dont subclass but manage manually # we dont subclass but manage manually
self._framebuf1 = adafruit_framebuf.FrameBuffer(self._buffer1, width, height, self._framebuf1 = adafruit_framebuf.FrameBuffer(
buf_format=adafruit_framebuf.MHMSB) self._buffer1, width, height, buf_format=adafruit_framebuf.MHMSB
self._framebuf2 = adafruit_framebuf.FrameBuffer(self._buffer2, width, height, )
buf_format=adafruit_framebuf.MHMSB) self._framebuf2 = adafruit_framebuf.FrameBuffer(
self._buffer2, width, height, buf_format=adafruit_framebuf.MHMSB
)
self.set_black_buffer(0, True) self.set_black_buffer(0, True)
self.set_color_buffer(1, False) self.set_color_buffer(1, False)
self._single_byte_tx = True self._single_byte_tx = True
@ -118,7 +125,7 @@ class Adafruit_IL91874(Adafruit_EPD):
self.command(_IL91874_PANEL_SETTING, bytearray([0xAF])) self.command(_IL91874_PANEL_SETTING, bytearray([0xAF]))
self.command(_IL91874_PLL, bytearray([0x3A])) self.command(_IL91874_PLL, bytearray([0x3A]))
self.command(_IL91874_POWER_SETTING, bytearray([0x03, 0x00, 0x2b, 0x2b, 0x09])) self.command(_IL91874_POWER_SETTING, bytearray([0x03, 0x00, 0x2B, 0x2B, 0x09]))
self.command(_IL91874_BOOSTER_SOFT_START, bytearray([0x07, 0x07, 0x17])) self.command(_IL91874_BOOSTER_SOFT_START, bytearray([0x07, 0x07, 0x17]))
self.command(0xF8, bytearray([0x60, 0xA5])) # mystery command in example code self.command(0xF8, bytearray([0x60, 0xA5])) # mystery command in example code
@ -157,7 +164,7 @@ class Adafruit_IL91874(Adafruit_EPD):
self.command(_IL91874_DISPLAY_REFRESH) self.command(_IL91874_DISPLAY_REFRESH)
self.busy_wait() self.busy_wait()
if not self._busy: if not self._busy:
time.sleep(16) # wait 16 seconds time.sleep(16) # wait 16 seconds
def write_ram(self, index): def write_ram(self, index):
"""Send the one byte command for starting the RAM write process. Returns """Send the one byte command for starting the RAM write process. Returns
@ -169,7 +176,7 @@ class Adafruit_IL91874(Adafruit_EPD):
return self.command(_IL91874_DTM2, end=False) return self.command(_IL91874_DTM2, end=False)
raise RuntimeError("RAM index must be 0 or 1") raise RuntimeError("RAM index must be 0 or 1")
def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
return # on this chip it does nothing return # on this chip it does nothing

View file

@ -34,23 +34,27 @@ __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_EPD.git"
SRAM_SEQUENTIAL_MODE = const(1 << 6) SRAM_SEQUENTIAL_MODE = const(1 << 6)
class Adafruit_MCP_SRAM_View: class Adafruit_MCP_SRAM_View:
"""A interface class that turns an SRAM chip into something like a memoryview""" """A interface class that turns an SRAM chip into something like a memoryview"""
def __init__(self, sram, offset): def __init__(self, sram, offset):
self._sram = sram self._sram = sram
self._offset = offset self._offset = offset
self._buf = [0] self._buf = [0]
def __getitem__(self, i): def __getitem__(self, i):
return self._sram.read(self._offset+i, 1)[0] return self._sram.read(self._offset + i, 1)[0]
def __setitem__(self, i, val): def __setitem__(self, i, val):
self._buf[0] = val self._buf[0] = val
self._sram.write(self._offset+i, self._buf) self._sram.write(self._offset + i, self._buf)
class Adafruit_MCP_SRAM: class Adafruit_MCP_SRAM:
"""supporting class for communicating with """supporting class for communicating with
Microchip SRAM chips""" Microchip SRAM chips"""
SRAM_READ = 0x03 SRAM_READ = 0x03
SRAM_WRITE = 0x02 SRAM_WRITE = 0x02
SRAM_RDSR = 0x05 SRAM_RDSR = 0x05
@ -65,7 +69,7 @@ class Adafruit_MCP_SRAM:
self._buf[0] = Adafruit_MCP_SRAM.SRAM_WRSR self._buf[0] = Adafruit_MCP_SRAM.SRAM_WRSR
self._buf[1] = 0x43 self._buf[1] = 0x43
with self._spi as spidev: with self._spi as spidev:
spidev.write(self._buf, end=2) # pylint: disable=no-member spidev.write(self._buf, end=2) # pylint: disable=no-member
def get_view(self, offset): def get_view(self, offset):
"""Create an object that can be used as a memoryview, with a given offset""" """Create an object that can be used as a memoryview, with a given offset"""
@ -78,8 +82,8 @@ class Adafruit_MCP_SRAM:
self._buf[2] = addr & 0xFF self._buf[2] = addr & 0xFF
with self._spi as spi: with self._spi as spi:
spi.write(self._buf, end=3) # pylint: disable=no-member spi.write(self._buf, end=3) # pylint: disable=no-member
spi.write(bytearray(buf)) # pylint: disable=no-member spi.write(bytearray(buf)) # pylint: disable=no-member
def read(self, addr, length, reg=SRAM_READ): def read(self, addr, length, reg=SRAM_READ):
"""read passed number of bytes at the passed address""" """read passed number of bytes at the passed address"""
@ -89,8 +93,8 @@ class Adafruit_MCP_SRAM:
buf = bytearray(length) buf = bytearray(length)
with self._spi as spi: with self._spi as spi:
spi.write(self._buf, end=3) # pylint: disable=no-member spi.write(self._buf, end=3) # pylint: disable=no-member
spi.readinto(buf) # pylint: disable=no-member spi.readinto(buf) # pylint: disable=no-member
return buf return buf
def read8(self, addr, reg=SRAM_READ): def read8(self, addr, reg=SRAM_READ):
@ -117,6 +121,6 @@ class Adafruit_MCP_SRAM:
self._buf[2] = addr & 0xFF self._buf[2] = addr & 0xFF
fill = bytearray([value]) fill = bytearray([value])
with self._spi as spi: with self._spi as spi:
spi.write(self._buf, end=3) # pylint: disable=no-member spi.write(self._buf, end=3) # pylint: disable=no-member
for _ in range(length): for _ in range(length):
spi.write(fill) # pylint: disable=no-member spi.write(fill) # pylint: disable=no-member

View file

@ -66,17 +66,22 @@ _SSD1608_SET_RAMYPOS = const(0x45)
_SSD1608_SET_RAMXCOUNT = const(0x4E) _SSD1608_SET_RAMXCOUNT = const(0x4E)
_SSD1608_SET_RAMYCOUNT = const(0x4F) _SSD1608_SET_RAMYCOUNT = const(0x4F)
_SSD1608_NOP = const(0xFF) _SSD1608_NOP = const(0xFF)
_LUT_DATA = b'\x02\x02\x01\x11\x12\x12""fiiYX\x99\x99\x88\x00\x00\x00\x00\xf8\xb4\x13Q5QQ\x19\x01\x00' # pylint: disable=line-too-long _LUT_DATA = b'\x02\x02\x01\x11\x12\x12""fiiYX\x99\x99\x88\x00\x00\x00\x00\xf8\xb4\x13Q5QQ\x19\x01\x00' # pylint: disable=line-too-long
class Adafruit_SSD1608(Adafruit_EPD): class Adafruit_SSD1608(Adafruit_EPD):
"""driver class for Adafruit SSD1608 ePaper display breakouts""" """driver class for Adafruit SSD1608 ePaper display breakouts"""
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin): def __init__(
super(Adafruit_SSD1608, self).__init__(width, height, spi, cs_pin, dc_pin, self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
sramcs_pin, rst_pin, busy_pin) ):
super(Adafruit_SSD1608, self).__init__(
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
)
if height % 8 != 0: if height % 8 != 0:
height += (8 - height % 8) height += 8 - height % 8
self._height = height self._height = height
self._buffer1_size = int(width * height / 8) self._buffer1_size = int(width * height / 8)
@ -85,8 +90,9 @@ class Adafruit_SSD1608(Adafruit_EPD):
self._buffer1 = self.sram.get_view(0) self._buffer1 = self.sram.get_view(0)
else: else:
self._buffer1 = bytearray((width * height) // 8) self._buffer1 = bytearray((width * height) // 8)
self._framebuf1 = adafruit_framebuf.FrameBuffer(self._buffer1, width, height, self._framebuf1 = adafruit_framebuf.FrameBuffer(
buf_format=adafruit_framebuf.MHMSB) self._buffer1, width, height, buf_format=adafruit_framebuf.MHMSB
)
self.set_black_buffer(0, True) self.set_black_buffer(0, True)
self.set_color_buffer(0, True) self.set_color_buffer(0, True)
# pylint: enable=too-many-arguments # pylint: enable=too-many-arguments
@ -113,8 +119,10 @@ class Adafruit_SSD1608(Adafruit_EPD):
self.command(_SSD1608_SW_RESET) self.command(_SSD1608_SW_RESET)
self.busy_wait() self.busy_wait()
# driver output control # driver output control
self.command(_SSD1608_DRIVER_CONTROL, self.command(
bytearray([self._width-1, (self._width-1) >> 8, 0x00])) _SSD1608_DRIVER_CONTROL,
bytearray([self._width - 1, (self._width - 1) >> 8, 0x00]),
)
# Set dummy line period # Set dummy line period
self.command(_SSD1608_WRITE_DUMMY, bytearray([0x1B])) self.command(_SSD1608_WRITE_DUMMY, bytearray([0x1B]))
# Set gate line width # Set gate line width
@ -122,10 +130,12 @@ class Adafruit_SSD1608(Adafruit_EPD):
# Data entry sequence # Data entry sequence
self.command(_SSD1608_DATA_MODE, bytearray([0x03])) self.command(_SSD1608_DATA_MODE, bytearray([0x03]))
# Set ram X start/end postion # Set ram X start/end postion
self.command(_SSD1608_SET_RAMXPOS, bytearray([0x00, self._height//8 - 1])) self.command(_SSD1608_SET_RAMXPOS, bytearray([0x00, self._height // 8 - 1]))
# Set ram Y start/end postion # Set ram Y start/end postion
self.command(_SSD1608_SET_RAMYPOS, self.command(
bytearray([0, 0, self._height - 1, (self._height - 1) >> 8])) _SSD1608_SET_RAMYPOS,
bytearray([0, 0, self._height - 1, (self._height - 1) >> 8]),
)
# Vcom Voltage # Vcom Voltage
self.command(_SSD1608_WRITE_VCOM, bytearray([0x70])) self.command(_SSD1608_WRITE_VCOM, bytearray([0x70]))
# LUT # LUT
@ -143,7 +153,7 @@ class Adafruit_SSD1608(Adafruit_EPD):
self.command(_SSD1608_MASTER_ACTIVATE) self.command(_SSD1608_MASTER_ACTIVATE)
self.busy_wait() self.busy_wait()
if not self._busy: if not self._busy:
time.sleep(3) # wait 3 seconds time.sleep(3) # wait 3 seconds
def write_ram(self, index): def write_ram(self, index):
"""Send the one byte command for starting the RAM write process. Returns """Send the one byte command for starting the RAM write process. Returns
@ -153,10 +163,10 @@ class Adafruit_SSD1608(Adafruit_EPD):
return self.command(_SSD1608_WRITE_RAM, end=False) return self.command(_SSD1608_WRITE_RAM, end=False)
raise RuntimeError("RAM index must be 0") raise RuntimeError("RAM index must be 0")
def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
# Set RAM X address counter # Set RAM X address counter
self.command(_SSD1608_SET_RAMXCOUNT, bytearray([x])) self.command(_SSD1608_SET_RAMXCOUNT, bytearray([x]))
# Set RAM Y address counter # Set RAM Y address counter
self.command(_SSD1608_SET_RAMYCOUNT, bytearray([y>>8, y])) self.command(_SSD1608_SET_RAMYCOUNT, bytearray([y >> 8, y]))

View file

@ -60,17 +60,22 @@ _SSD1675_SET_RAMXCOUNT = const(0x4E)
_SSD1675_SET_RAMYCOUNT = const(0x4F) _SSD1675_SET_RAMYCOUNT = const(0x4F)
_SSD1675_SET_ANALOGBLOCK = const(0x74) _SSD1675_SET_ANALOGBLOCK = const(0x74)
_SSD1675_SET_DIGITALBLOCK = const(0x7E) _SSD1675_SET_DIGITALBLOCK = const(0x7E)
_LUT_DATA = b'\x80`@\x00\x00\x00\x00\x10` \x00\x00\x00\x00\x80`@\x00\x00\x00\x00\x10` \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x02\t\t\x00\x00\x02\x03\x03\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x15A\xa820\n' # pylint: disable=line-too-long _LUT_DATA = b"\x80`@\x00\x00\x00\x00\x10` \x00\x00\x00\x00\x80`@\x00\x00\x00\x00\x10` \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00\x02\t\t\x00\x00\x02\x03\x03\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x15A\xa820\n" # pylint: disable=line-too-long
class Adafruit_SSD1675(Adafruit_EPD): class Adafruit_SSD1675(Adafruit_EPD):
"""driver class for Adafruit SSD1675 ePaper display breakouts""" """driver class for Adafruit SSD1675 ePaper display breakouts"""
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin): def __init__(
super(Adafruit_SSD1675, self).__init__(width, height, spi, cs_pin, dc_pin, self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
sramcs_pin, rst_pin, busy_pin) ):
super(Adafruit_SSD1675, self).__init__(
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
)
stride = width stride = width
if stride % 8 != 0: if stride % 8 != 0:
stride += (8 - stride % 8) stride += 8 - stride % 8
self._buffer1_size = int(stride * height / 8) self._buffer1_size = int(stride * height / 8)
self._buffer2_size = self._buffer1_size self._buffer2_size = self._buffer1_size
@ -83,10 +88,20 @@ class Adafruit_SSD1675(Adafruit_EPD):
self._buffer2 = bytearray(self._buffer2_size) self._buffer2 = bytearray(self._buffer2_size)
# since we have *two* framebuffers - one for red and one for black # since we have *two* framebuffers - one for red and one for black
# we dont subclass but manage manually # we dont subclass but manage manually
self._framebuf1 = adafruit_framebuf.FrameBuffer(self._buffer1, width, height, stride=stride, self._framebuf1 = adafruit_framebuf.FrameBuffer(
buf_format=adafruit_framebuf.MHMSB) self._buffer1,
self._framebuf2 = adafruit_framebuf.FrameBuffer(self._buffer2, width, height, stride=stride, width,
buf_format=adafruit_framebuf.MHMSB) height,
stride=stride,
buf_format=adafruit_framebuf.MHMSB,
)
self._framebuf2 = adafruit_framebuf.FrameBuffer(
self._buffer2,
width,
height,
stride=stride,
buf_format=adafruit_framebuf.MHMSB,
)
self.set_black_buffer(0, True) self.set_black_buffer(0, True)
self.set_color_buffer(0, True) self.set_color_buffer(0, True)
# pylint: enable=too-many-arguments # pylint: enable=too-many-arguments
@ -121,8 +136,7 @@ class Adafruit_SSD1675(Adafruit_EPD):
self.command(_SSD1675_SET_DIGITALBLOCK, bytearray([0x3B])) self.command(_SSD1675_SET_DIGITALBLOCK, bytearray([0x3B]))
# driver output control # driver output control
self.command(_SSD1675_DRIVER_CONTROL, self.command(_SSD1675_DRIVER_CONTROL, bytearray([0xFA, 0x01, 0x00]))
bytearray([0xFA, 0x01, 0x00]))
# Data entry sequence # Data entry sequence
self.command(_SSD1675_DATA_MODE, bytearray([0x03])) self.command(_SSD1675_DATA_MODE, bytearray([0x03]))
# Set ram X start/end postion # Set ram X start/end postion
@ -161,7 +175,7 @@ class Adafruit_SSD1675(Adafruit_EPD):
self.command(_SSD1675_MASTER_ACTIVATE) self.command(_SSD1675_MASTER_ACTIVATE)
self.busy_wait() self.busy_wait()
if not self._busy: if not self._busy:
time.sleep(3) # wait 3 seconds time.sleep(3) # wait 3 seconds
def write_ram(self, index): def write_ram(self, index):
"""Send the one byte command for starting the RAM write process. Returns """Send the one byte command for starting the RAM write process. Returns
@ -173,8 +187,8 @@ class Adafruit_SSD1675(Adafruit_EPD):
return self.command(_SSD1675_WRITE_RAM2, end=False) return self.command(_SSD1675_WRITE_RAM2, end=False)
raise RuntimeError("RAM index must be 0 or 1") raise RuntimeError("RAM index must be 0 or 1")
def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
self.command(_SSD1675_SET_RAMXCOUNT, bytearray([x])) self.command(_SSD1675_SET_RAMXCOUNT, bytearray([x]))
self.command(_SSD1675_SET_RAMYCOUNT, bytearray([y, y>>8])) self.command(_SSD1675_SET_RAMYCOUNT, bytearray([y, y >> 8]))

View file

@ -86,17 +86,22 @@ _SSD1675B_SET_RAMYCOUNT = const(0x4F)
_SSD1675B_SET_ANALOGBLOCK = const(0x74) _SSD1675B_SET_ANALOGBLOCK = const(0x74)
_SSD1675B_SET_DIGITALBLOCK = const(0x7E) _SSD1675B_SET_DIGITALBLOCK = const(0x7E)
_SSD1675B_NOP = const(0xFF) _SSD1675B_NOP = const(0xFF)
_LUT_DATA = b'\xa0\x90P\x00\x00\x00\x00\x00\x00\x00P\x90\xa0\x00\x00\x00\x00\x00\x00\x00\xa0\x90P\x00\x00\x00\x00\x00\x00\x00P\x90\xa0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x0f\x00\x00\x00\x0f\x0f\x00\x00\x03\x0f\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x15A\xa82P,\x0b' # pylint: disable=line-too-long _LUT_DATA = b"\xa0\x90P\x00\x00\x00\x00\x00\x00\x00P\x90\xa0\x00\x00\x00\x00\x00\x00\x00\xa0\x90P\x00\x00\x00\x00\x00\x00\x00P\x90\xa0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f\x0f\x00\x00\x00\x0f\x0f\x00\x00\x03\x0f\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x15A\xa82P,\x0b" # pylint: disable=line-too-long
class Adafruit_SSD1675B(Adafruit_EPD): class Adafruit_SSD1675B(Adafruit_EPD):
"""driver class for Adafruit SSD1675B ePaper display breakouts""" """driver class for Adafruit SSD1675B ePaper display breakouts"""
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin): def __init__(
super(Adafruit_SSD1675B, self).__init__(width, height, spi, cs_pin, dc_pin, self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
sramcs_pin, rst_pin, busy_pin) ):
super(Adafruit_SSD1675B, self).__init__(
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
)
stride = width stride = width
if stride % 8 != 0: if stride % 8 != 0:
stride += (8 - stride % 8) stride += 8 - stride % 8
self._buffer1_size = int(stride * height / 8) self._buffer1_size = int(stride * height / 8)
self._buffer2_size = self._buffer1_size self._buffer2_size = self._buffer1_size
@ -109,10 +114,20 @@ class Adafruit_SSD1675B(Adafruit_EPD):
self._buffer2 = bytearray(self._buffer2_size) self._buffer2 = bytearray(self._buffer2_size)
# since we have *two* framebuffers - one for red and one for black # since we have *two* framebuffers - one for red and one for black
# we dont subclass but manage manually # we dont subclass but manage manually
self._framebuf1 = adafruit_framebuf.FrameBuffer(self._buffer1, width, height, stride=stride, self._framebuf1 = adafruit_framebuf.FrameBuffer(
buf_format=adafruit_framebuf.MHMSB) self._buffer1,
self._framebuf2 = adafruit_framebuf.FrameBuffer(self._buffer2, width, height, stride=stride, width,
buf_format=adafruit_framebuf.MHMSB) height,
stride=stride,
buf_format=adafruit_framebuf.MHMSB,
)
self._framebuf2 = adafruit_framebuf.FrameBuffer(
self._buffer2,
width,
height,
stride=stride,
buf_format=adafruit_framebuf.MHMSB,
)
self.set_black_buffer(0, True) self.set_black_buffer(0, True)
self.set_color_buffer(0, True) self.set_color_buffer(0, True)
# pylint: enable=too-many-arguments # pylint: enable=too-many-arguments
@ -146,8 +161,10 @@ class Adafruit_SSD1675B(Adafruit_EPD):
# set digital block control # set digital block control
self.command(_SSD1675B_SET_DIGITALBLOCK, bytearray([0x3B])) self.command(_SSD1675B_SET_DIGITALBLOCK, bytearray([0x3B]))
self.command(_SSD1675B_DRIVER_CONTROL, self.command(
bytearray([self._height-1, (self._height-1) >> 8, 0x00])) _SSD1675B_DRIVER_CONTROL,
bytearray([self._height - 1, (self._height - 1) >> 8, 0x00]),
)
# Data entry sequence # Data entry sequence
self.command(_SSD1675B_DATA_MODE, bytearray([0x03])) self.command(_SSD1675B_DATA_MODE, bytearray([0x03]))
@ -155,8 +172,10 @@ class Adafruit_SSD1675B(Adafruit_EPD):
# Set ram X start/end postion # Set ram X start/end postion
self.command(_SSD1675B_SET_RAMXPOS, bytearray([0x00, self._width // 8])) self.command(_SSD1675B_SET_RAMXPOS, bytearray([0x00, self._width // 8]))
# Set ram Y start/end postion # Set ram Y start/end postion
self.command(_SSD1675B_SET_RAMYPOS, self.command(
bytearray([0x0, 0x0, self._height-1, (self._height-1) >> 8])) _SSD1675B_SET_RAMYPOS,
bytearray([0x0, 0x0, self._height - 1, (self._height - 1) >> 8]),
)
# Border color # Border color
self.command(_SSD1675B_WRITE_BORDER, bytearray([0x03])) self.command(_SSD1675B_WRITE_BORDER, bytearray([0x03]))
@ -175,12 +194,15 @@ class Adafruit_SSD1675B(Adafruit_EPD):
self.command(_SSD1675B_WRITE_LUT, _LUT_DATA[0:100]) self.command(_SSD1675B_WRITE_LUT, _LUT_DATA[0:100])
# Set temperature control # Set temperature control
#self.command(_SSD1675B_TEMP_CONTROL, bytearray([0x80])) # self.command(_SSD1675B_TEMP_CONTROL, bytearray([0x80]))
# Set RAM X address counter # Set RAM X address counter
self.command(_SSD1675B_SET_RAMXCOUNT, bytearray([0])) self.command(_SSD1675B_SET_RAMXCOUNT, bytearray([0]))
# Set RAM Y address counter # Set RAM Y address counter
self.command(_SSD1675B_SET_RAMYCOUNT, bytearray([self._height-1, (self._height-1) >> 8])) self.command(
_SSD1675B_SET_RAMYCOUNT,
bytearray([self._height - 1, (self._height - 1) >> 8]),
)
self.busy_wait() self.busy_wait()
@ -195,7 +217,7 @@ class Adafruit_SSD1675B(Adafruit_EPD):
self.command(_SSD1675B_MASTER_ACTIVATE) self.command(_SSD1675B_MASTER_ACTIVATE)
self.busy_wait() self.busy_wait()
if not self._busy: if not self._busy:
time.sleep(3) # wait 3 seconds time.sleep(3) # wait 3 seconds
def write_ram(self, index): def write_ram(self, index):
"""Send the one byte command for starting the RAM write process. Returns """Send the one byte command for starting the RAM write process. Returns
@ -207,8 +229,8 @@ class Adafruit_SSD1675B(Adafruit_EPD):
return self.command(_SSD1675B_WRITE_RAM2, end=False) return self.command(_SSD1675B_WRITE_RAM2, end=False)
raise RuntimeError("RAM index must be 0 or 1") raise RuntimeError("RAM index must be 0 or 1")
def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
self.command(_SSD1675B_SET_RAMXCOUNT, bytearray([x])) self.command(_SSD1675B_SET_RAMXCOUNT, bytearray([x]))
self.command(_SSD1675B_SET_RAMYCOUNT, bytearray([y, y>>8])) self.command(_SSD1675B_SET_RAMYCOUNT, bytearray([y, y >> 8]))

View file

@ -83,17 +83,22 @@ _SSD1681_SET_RAMXCOUNT = const(0x4E)
_SSD1681_SET_RAMYCOUNT = const(0x4F) _SSD1681_SET_RAMYCOUNT = const(0x4F)
_SSD1681_NOP = const(0xFF) _SSD1681_NOP = const(0xFF)
_LUT_DATA = b'\x02\x02\x01\x11\x12\x12""fiiYX\x99\x99\x88\x00\x00\x00\x00\xf8\xb4\x13Q5QQ\x19\x01\x00' # pylint: disable=line-too-long _LUT_DATA = b'\x02\x02\x01\x11\x12\x12""fiiYX\x99\x99\x88\x00\x00\x00\x00\xf8\xb4\x13Q5QQ\x19\x01\x00' # pylint: disable=line-too-long
class Adafruit_SSD1681(Adafruit_EPD): class Adafruit_SSD1681(Adafruit_EPD):
"""driver class for Adafruit SSD1681 ePaper display breakouts""" """driver class for Adafruit SSD1681 ePaper display breakouts"""
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments
def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin): def __init__(
super(Adafruit_SSD1681, self).__init__(width, height, spi, cs_pin, dc_pin, self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
sramcs_pin, rst_pin, busy_pin) ):
super(Adafruit_SSD1681, self).__init__(
width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin
)
if height % 8 != 0: if height % 8 != 0:
height += (8 - height % 8) height += 8 - height % 8
self._height = height self._height = height
self._buffer1_size = int(width * height / 8) self._buffer1_size = int(width * height / 8)
@ -102,8 +107,9 @@ class Adafruit_SSD1681(Adafruit_EPD):
self._buffer1 = self.sram.get_view(0) self._buffer1 = self.sram.get_view(0)
else: else:
self._buffer1 = bytearray((width * height) // 8) self._buffer1 = bytearray((width * height) // 8)
self._framebuf1 = adafruit_framebuf.FrameBuffer(self._buffer1, width, height, self._framebuf1 = adafruit_framebuf.FrameBuffer(
buf_format=adafruit_framebuf.MHMSB) self._buffer1, width, height, buf_format=adafruit_framebuf.MHMSB
)
self.set_black_buffer(0, True) self.set_black_buffer(0, True)
self.set_color_buffer(0, True) self.set_color_buffer(0, True)
# pylint: enable=too-many-arguments # pylint: enable=too-many-arguments
@ -130,15 +136,19 @@ class Adafruit_SSD1681(Adafruit_EPD):
self.command(_SSD1681_SW_RESET) self.command(_SSD1681_SW_RESET)
self.busy_wait() self.busy_wait()
# driver output control # driver output control
self.command(_SSD1681_DRIVER_CONTROL, self.command(
bytearray([self._width-1, (self._width-1) >> 8, 0x00])) _SSD1681_DRIVER_CONTROL,
bytearray([self._width - 1, (self._width - 1) >> 8, 0x00]),
)
# data entry mode # data entry mode
self.command(_SSD1681_DATA_MODE, bytearray([0x03])) self.command(_SSD1681_DATA_MODE, bytearray([0x03]))
# Set ram X start/end postion # Set ram X start/end postion
self.command(_SSD1681_SET_RAMXPOS, bytearray([0x00, self._height//8 - 1])) self.command(_SSD1681_SET_RAMXPOS, bytearray([0x00, self._height // 8 - 1]))
# Set ram Y start/end postion # Set ram Y start/end postion
self.command(_SSD1681_SET_RAMYPOS, self.command(
bytearray([0, 0, self._height - 1, (self._height - 1) >> 8])) _SSD1681_SET_RAMYPOS,
bytearray([0, 0, self._height - 1, (self._height - 1) >> 8]),
)
# Set border waveform # Set border waveform
self.command(_SSD1681_WRITE_BORDER, bytearray([0x05])) self.command(_SSD1681_WRITE_BORDER, bytearray([0x05]))
# Set temperature control # Set temperature control
@ -157,7 +167,7 @@ class Adafruit_SSD1681(Adafruit_EPD):
self.command(_SSD1681_MASTER_ACTIVATE) self.command(_SSD1681_MASTER_ACTIVATE)
self.busy_wait() self.busy_wait()
if not self._busy: if not self._busy:
time.sleep(3) # wait 3 seconds time.sleep(3) # wait 3 seconds
def write_ram(self, index): def write_ram(self, index):
"""Send the one byte command for starting the RAM write process. Returns """Send the one byte command for starting the RAM write process. Returns
@ -167,10 +177,10 @@ class Adafruit_SSD1681(Adafruit_EPD):
return self.command(_SSD1681_WRITE_BWRAM, end=False) return self.command(_SSD1681_WRITE_BWRAM, end=False)
raise RuntimeError("RAM index must be 0") raise RuntimeError("RAM index must be 0")
def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use def set_ram_address(self, x, y): # pylint: disable=unused-argument, no-self-use
"""Set the RAM address location, not used on this chipset but required by """Set the RAM address location, not used on this chipset but required by
the superclass""" the superclass"""
# Set RAM X address counter # Set RAM X address counter
self.command(_SSD1681_SET_RAMXCOUNT, bytearray([x])) self.command(_SSD1681_SET_RAMXCOUNT, bytearray([x]))
# Set RAM Y address counter # Set RAM Y address counter
self.command(_SSD1681_SET_RAMYCOUNT, bytearray([y>>8, y])) self.command(_SSD1681_SET_RAMYCOUNT, bytearray([y >> 8, y]))

View file

@ -2,7 +2,8 @@
import os import os
import sys import sys
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath(".."))
# -- General configuration ------------------------------------------------ # -- General configuration ------------------------------------------------
@ -10,10 +11,10 @@ sys.path.insert(0, os.path.abspath('..'))
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones. # ones.
extensions = [ extensions = [
'sphinx.ext.autodoc', "sphinx.ext.autodoc",
'sphinx.ext.intersphinx', "sphinx.ext.intersphinx",
'sphinx.ext.napoleon', "sphinx.ext.napoleon",
'sphinx.ext.todo', "sphinx.ext.todo",
] ]
# Uncomment the below if you use native CircuitPython modules such as # Uncomment the below if you use native CircuitPython modules such as
@ -22,29 +23,40 @@ extensions = [
# autodoc_mock_imports = ["digitalio", "busio", "micropython"] # autodoc_mock_imports = ["digitalio", "busio", "micropython"]
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'Register': ('https://circuitpython.readthedocs.io/projects/register/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)} intersphinx_mapping = {
"python": ("https://docs.python.org/3.4", None),
"BusDevice": (
"https://circuitpython.readthedocs.io/projects/busdevice/en/latest/",
None,
),
"Register": (
"https://circuitpython.readthedocs.io/projects/register/en/latest/",
None,
),
"CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None),
}
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates'] templates_path = ["_templates"]
source_suffix = '.rst' source_suffix = ".rst"
# The master toctree document. # The master toctree document.
master_doc = 'index' master_doc = "index"
# General information about the project. # General information about the project.
project = u'Adafruit EPD Library' project = u"Adafruit EPD Library"
copyright = u'2018 Dean Miller' copyright = u"2018 Dean Miller"
author = u'Dean Miller' author = u"Dean Miller"
# The version info for the project you're documenting, acts as replacement for # The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
# built documents. # built documents.
# #
# The short X.Y version. # The short X.Y version.
version = u'1.0' version = u"1.0"
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = u'1.0' release = u"1.0"
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.
@ -56,7 +68,7 @@ language = None
# List of patterns, relative to source directory, that match files and # List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path # This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md'] exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"]
# The reST default role (used for this markup: `text`) to use for all # The reST default role (used for this markup: `text`) to use for all
# documents. # documents.
@ -68,7 +80,7 @@ default_role = "any"
add_function_parentheses = True add_function_parentheses = True
# The name of the Pygments (syntax highlighting) style to use. # The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx' pygments_style = "sphinx"
# If true, `todo` and `todoList` produce output, else they produce nothing. # If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False todo_include_todos = False
@ -83,59 +95,62 @@ napoleon_numpy_docstring = False
# The theme to use for HTML and HTML Help pages. See the documentation for # The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. # a list of builtin themes.
# #
on_rtd = os.environ.get('READTHEDOCS', None) == 'True' on_rtd = os.environ.get("READTHEDOCS", None) == "True"
if not on_rtd: # only import and set the theme if we're building docs locally if not on_rtd: # only import and set the theme if we're building docs locally
try: try:
import sphinx_rtd_theme import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.'] html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."]
except: except:
html_theme = 'default' html_theme = "default"
html_theme_path = ['.'] html_theme_path = ["."]
else: else:
html_theme_path = ['.'] html_theme_path = ["."]
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css". # so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static'] html_static_path = ["_static"]
# The name of an image file (relative to this directory) to use as a favicon of # The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large. # pixels large.
# #
html_favicon = '_static/favicon.ico' html_favicon = "_static/favicon.ico"
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'AdafruitEpdLibrarydoc' htmlhelp_basename = "AdafruitEpdLibrarydoc"
# -- Options for LaTeX output --------------------------------------------- # -- Options for LaTeX output ---------------------------------------------
latex_elements = { latex_elements = {
# The paper size ('letterpaper' or 'a4paper'). # The paper size ('letterpaper' or 'a4paper').
# #
# 'papersize': 'letterpaper', # 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
# The font size ('10pt', '11pt' or '12pt'). #
# # 'pointsize': '10pt',
# 'pointsize': '10pt', # Additional stuff for the LaTeX preamble.
#
# Additional stuff for the LaTeX preamble. # 'preamble': '',
# # Latex figure (float) alignment
# 'preamble': '', #
# 'figure_align': 'htbp',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
} }
# Grouping the document tree into LaTeX files. List of tuples # Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, # (source start file, target name, title,
# author, documentclass [howto, manual, or own class]). # author, documentclass [howto, manual, or own class]).
latex_documents = [ latex_documents = [
(master_doc, 'AdafruitEPDLibrary.tex', u'AdafruitEPD Library Documentation', (
author, 'manual'), master_doc,
"AdafruitEPDLibrary.tex",
u"AdafruitEPD Library Documentation",
author,
"manual",
),
] ]
# -- Options for manual page output --------------------------------------- # -- Options for manual page output ---------------------------------------
@ -143,8 +158,13 @@ latex_documents = [
# One entry per manual page. List of tuples # One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section).
man_pages = [ man_pages = [
(master_doc, 'AdafruitEPDlibrary', u'Adafruit EPD Library Documentation', (
[author], 1) master_doc,
"AdafruitEPDlibrary",
u"Adafruit EPD Library Documentation",
[author],
1,
)
] ]
# -- Options for Texinfo output ------------------------------------------- # -- Options for Texinfo output -------------------------------------------
@ -153,7 +173,13 @@ man_pages = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
(master_doc, 'AdafruitEPDLibrary', u'Adafruit EPD Library Documentation', (
author, 'AdafruitEPDLibrary', 'One line description of project.', master_doc,
'Miscellaneous'), "AdafruitEPDLibrary",
u"Adafruit EPD Library Documentation",
author,
"AdafruitEPDLibrary",
"One line description of project.",
"Miscellaneous",
),
] ]

View file

@ -3,9 +3,9 @@ import busio
import board import board
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
from adafruit_epd.il0373 import Adafruit_IL0373 from adafruit_epd.il0373 import Adafruit_IL0373
from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import
from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import
from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import
from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import
@ -13,30 +13,38 @@ from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-impo
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
ecs = digitalio.DigitalInOut(board.D10) ecs = digitalio.DigitalInOut(board.D10)
dc = digitalio.DigitalInOut(board.D9) dc = digitalio.DigitalInOut(board.D9)
srcs = digitalio.DigitalInOut(board.D7) # can be None to use internal memory srcs = digitalio.DigitalInOut(board.D7) # can be None to use internal memory
rst = digitalio.DigitalInOut(board.D11) # can be None to not use this pin rst = digitalio.DigitalInOut(board.D11) # can be None to not use this pin
busy = digitalio.DigitalInOut(board.D12) # can be None to not use this pin busy = digitalio.DigitalInOut(board.D12) # can be None to not use this pin
# give them all to our driver # give them all to our driver
print("Creating display") print("Creating display")
#display = Adafruit_SSD1608(200, 200, spi, # 1.54" HD mono display # display = Adafruit_SSD1608(200, 200, spi, # 1.54" HD mono display
#display = Adafruit_SSD1675(122, 250, spi, # 2.13" HD mono display # display = Adafruit_SSD1675(122, 250, spi, # 2.13" HD mono display
#display = Adafruit_IL91874(176, 264, spi, # 2.7" Tri-color display # display = Adafruit_IL91874(176, 264, spi, # 2.7" Tri-color display
#display = Adafruit_IL0373(152, 152, spi, # 1.54" Tri-color display # display = Adafruit_IL0373(152, 152, spi, # 1.54" Tri-color display
#display = Adafruit_IL0373(128, 296, spi, # 2.9" Tri-color display # display = Adafruit_IL0373(128, 296, spi, # 2.9" Tri-color display
#display = Adafruit_IL0398(400, 300, spi, # 4.2" Tri-color display # display = Adafruit_IL0398(400, 300, spi, # 4.2" Tri-color display
display = Adafruit_IL0373(104, 212, spi, # 2.13" Tri-color display display = Adafruit_IL0373(
cs_pin=ecs, dc_pin=dc, sramcs_pin=srcs, 104,
rst_pin=rst, busy_pin=busy) 212,
spi, # 2.13" Tri-color display
cs_pin=ecs,
dc_pin=dc,
sramcs_pin=srcs,
rst_pin=rst,
busy_pin=busy,
)
# IF YOU HAVE A FLEXIBLE DISPLAY (2.13" or 2.9") uncomment these lines! # IF YOU HAVE A FLEXIBLE DISPLAY (2.13" or 2.9") uncomment these lines!
#display.set_black_buffer(1, False) # display.set_black_buffer(1, False)
#display.set_color_buffer(1, False) # display.set_color_buffer(1, False)
display.rotation = 0 display.rotation = 0
FILENAME = "blinka154mono.bmp" FILENAME = "blinka154mono.bmp"
def read_le(s): def read_le(s):
# as of this writting, int.from_bytes does not have LE support, DIY! # as of this writting, int.from_bytes does not have LE support, DIY!
result = 0 result = 0
@ -46,10 +54,12 @@ def read_le(s):
shift += 8 shift += 8
return result return result
class BMPError(Exception): class BMPError(Exception):
pass pass
def display_bitmap(epd, filename): # pylint: disable=too-many-locals, too-many-branches
def display_bitmap(epd, filename): # pylint: disable=too-many-locals, too-many-branches
try: try:
f = open("/" + filename, "rb") f = open("/" + filename, "rb")
except OSError: except OSError:
@ -58,7 +68,7 @@ def display_bitmap(epd, filename): # pylint: disable=too-many-locals, too-many-b
print("File opened") print("File opened")
try: try:
if f.read(2) != b'BM': # check signature if f.read(2) != b"BM": # check signature
raise BMPError("Not BitMap file") raise BMPError("Not BitMap file")
bmpFileSize = read_le(f.read(4)) bmpFileSize = read_le(f.read(4))
@ -70,8 +80,10 @@ def display_bitmap(epd, filename): # pylint: disable=too-many-locals, too-many-b
bmpHeight = read_le(f.read(4)) bmpHeight = read_le(f.read(4))
flip = True flip = True
print("Size: %d\nImage offset: %d\nHeader size: %d" % print(
(bmpFileSize, bmpImageoffset, headerSize)) "Size: %d\nImage offset: %d\nHeader size: %d"
% (bmpFileSize, bmpImageoffset, headerSize)
)
print("Width: %d\nHeight: %d" % (bmpWidth, bmpHeight)) print("Width: %d\nHeight: %d" % (bmpWidth, bmpHeight))
if read_le(f.read(2)) != 1: if read_le(f.read(2)) != 1:
@ -95,13 +107,13 @@ def display_bitmap(epd, filename): # pylint: disable=too-many-locals, too-many-b
# print ("seek to %d" % pos) # print ("seek to %d" % pos)
f.seek(pos) f.seek(pos)
rowdata = f.read(3*bmpWidth) rowdata = f.read(3 * bmpWidth)
for col in range(bmpWidth): for col in range(bmpWidth):
b, g, r = rowdata[3*col:3*col+3] # BMP files store RGB in BGR b, g, r = rowdata[3 * col : 3 * col + 3] # BMP files store RGB in BGR
if r < 0x80 and g < 0x80 and b < 0x80: if r < 0x80 and g < 0x80 and b < 0x80:
epd.pixel(col, row, Adafruit_EPD.BLACK) epd.pixel(col, row, Adafruit_EPD.BLACK)
elif r >= 0x80 and g >= 0x80 and b >= 0x80: elif r >= 0x80 and g >= 0x80 and b >= 0x80:
pass #epd.pixel(row, col, Adafruit_EPD.WHITE) pass # epd.pixel(row, col, Adafruit_EPD.WHITE)
elif r >= 0x80: elif r >= 0x80:
epd.pixel(col, row, Adafruit_EPD.RED) epd.pixel(col, row, Adafruit_EPD.RED)
except OSError: except OSError:
@ -112,6 +124,7 @@ def display_bitmap(epd, filename): # pylint: disable=too-many-locals, too-many-b
f.close() f.close()
print("Finished drawing") print("Finished drawing")
# clear the buffer # clear the buffer
display.fill(Adafruit_EPD.WHITE) display.fill(Adafruit_EPD.WHITE)
display_bitmap(display, FILENAME) display_bitmap(display, FILENAME)

View file

@ -6,13 +6,13 @@ from PIL import Image
from PIL import ImageDraw from PIL import ImageDraw
from PIL import ImageFont from PIL import ImageFont
from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.epd import Adafruit_EPD
from adafruit_epd.il0373 import Adafruit_IL0373 # pylint: disable=unused-import from adafruit_epd.il0373 import Adafruit_IL0373 # pylint: disable=unused-import
from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import
from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import
from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import
from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import
from adafruit_epd.ssd1675b import Adafruit_SSD1675B # pylint: disable=unused-import from adafruit_epd.ssd1675b import Adafruit_SSD1675B # pylint: disable=unused-import
from adafruit_epd.ssd1681 import Adafruit_SSD1681 # pylint: disable=unused-import from adafruit_epd.ssd1681 import Adafruit_SSD1681 # pylint: disable=unused-import
# create the spi device and pins we will need # create the spi device and pins we will need
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
@ -22,31 +22,37 @@ spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
ecs = digitalio.DigitalInOut(board.D4) ecs = digitalio.DigitalInOut(board.D4)
dc = digitalio.DigitalInOut(board.D5) dc = digitalio.DigitalInOut(board.D5)
srcs = None srcs = None
rst = digitalio.DigitalInOut(board.D6) # can be None to not use this pin rst = digitalio.DigitalInOut(board.D6) # can be None to not use this pin
busy = digitalio.DigitalInOut(board.D7) # can be None to not use this pin busy = digitalio.DigitalInOut(board.D7) # can be None to not use this pin
# give them all to our driver # give them all to our driver
print("Creating display") print("Creating display")
#display = Adafruit_SSD1608(200, 200, spi, # 1.54" HD mono display # display = Adafruit_SSD1608(200, 200, spi, # 1.54" HD mono display
#display = Adafruit_SSD1681(200, 200, spi, # 1.54" HD mono display (alt) # display = Adafruit_SSD1681(200, 200, spi, # 1.54" HD mono display (alt)
#display = Adafruit_SSD1675(122, 250, spi, # 2.13" HD mono display # display = Adafruit_SSD1675(122, 250, spi, # 2.13" HD mono display
#display = Adafruit_IL91874(176, 264, spi, # 2.7" Tri-color display # display = Adafruit_IL91874(176, 264, spi, # 2.7" Tri-color display
#display = Adafruit_IL0373(152, 152, spi, # 1.54" Tri-color display # display = Adafruit_IL0373(152, 152, spi, # 1.54" Tri-color display
#display = Adafruit_IL0373(128, 296, spi, # 2.9" Tri-color display # display = Adafruit_IL0373(128, 296, spi, # 2.9" Tri-color display
#display = Adafruit_IL0398(400, 300, spi, # 4.2" Tri-color display # display = Adafruit_IL0398(400, 300, spi, # 4.2" Tri-color display
#display = Adafruit_IL0373(104, 212, spi, # 2.13" Tri-color display # display = Adafruit_IL0373(104, 212, spi, # 2.13" Tri-color display
display = Adafruit_SSD1675B(122, 250, spi, # 2.13" HD mono display (rev B) display = Adafruit_SSD1675B(
cs_pin=ecs, dc_pin=dc, sramcs_pin=srcs, 122,
rst_pin=rst, busy_pin=busy) 250,
spi, # 2.13" HD mono display (rev B)
cs_pin=ecs,
dc_pin=dc,
sramcs_pin=srcs,
rst_pin=rst,
busy_pin=busy,
)
display.rotation = 3 display.rotation = 3
# Create blank image for drawing. # Create blank image for drawing.
# Make sure to create image with mode '1' for 1-bit color. # Make sure to create image with mode '1' for 1-bit color.
width = display.width width = display.width
height = display.height height = display.height
image = Image.new('RGB', (width, height)) image = Image.new("RGB", (width, height))
WHITE = (0xFF, 0xFF, 0xFF) WHITE = (0xFF, 0xFF, 0xFF)
RED = (0xFF, 0x00, 0x00) RED = (0xFF, 0x00, 0x00)
@ -61,42 +67,45 @@ draw = ImageDraw.Draw(image)
draw.rectangle((0, 0, width, height), fill=WHITE) draw.rectangle((0, 0, width, height), fill=WHITE)
# Draw an outline box # Draw an outline box
draw.rectangle((1, 1, width-2, height-2), outline=BLACK, fill=WHITE) draw.rectangle((1, 1, width - 2, height - 2), outline=BLACK, fill=WHITE)
# Draw some shapes. # Draw some shapes.
# First define some constants to allow easy resizing of shapes. # First define some constants to allow easy resizing of shapes.
padding = 5 padding = 5
shape_width = 30 shape_width = 30
top = padding top = padding
bottom = height-padding bottom = height - padding
# Move left to right keeping track of the current x position for drawing shapes. # Move left to right keeping track of the current x position for drawing shapes.
x = padding x = padding
# Draw an ellipse. # Draw an ellipse.
draw.ellipse((x, top , x+shape_width, bottom), outline=RED, fill=WHITE) draw.ellipse((x, top, x + shape_width, bottom), outline=RED, fill=WHITE)
x += shape_width+padding x += shape_width + padding
# Draw a rectangle. # Draw a rectangle.
draw.rectangle((x, top, x+shape_width, bottom), outline=RED, fill=BLACK) draw.rectangle((x, top, x + shape_width, bottom), outline=RED, fill=BLACK)
x += shape_width+padding x += shape_width + padding
# Draw a triangle. # Draw a triangle.
draw.polygon([(x, bottom), (x+shape_width/2, top), (x+shape_width, bottom)], draw.polygon(
outline=BLACK, fill=RED) [(x, bottom), (x + shape_width / 2, top), (x + shape_width, bottom)],
x += shape_width+padding outline=BLACK,
fill=RED,
)
x += shape_width + padding
# Draw an X. # Draw an X.
draw.line((x, bottom, x+shape_width, top), fill=RED) draw.line((x, bottom, x + shape_width, top), fill=RED)
draw.line((x, top, x+shape_width, bottom), fill=RED) draw.line((x, top, x + shape_width, bottom), fill=RED)
x += shape_width+padding x += shape_width + padding
# Load default font. # Load default font.
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 20) font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 20)
# Alternatively load a TTF font. Make sure the .ttf font # Alternatively load a TTF font. Make sure the .ttf font
# file is in the same directory as the python script! # file is in the same directory as the python script!
# Some other nice fonts to try: http://www.dafont.com/bitmap.php # Some other nice fonts to try: http://www.dafont.com/bitmap.php
#font = ImageFont.truetype('Minecraftia.ttf', 8) # font = ImageFont.truetype('Minecraftia.ttf', 8)
# Write two lines of text. # Write two lines of text.
draw.text((x, top), 'Hello', font=font, fill=RED) draw.text((x, top), "Hello", font=font, fill=RED)
draw.text((x, top+20), 'World!', font=font, fill=RED) draw.text((x, top + 20), "World!", font=font, fill=RED)
# Display image. # Display image.
display.image(image) display.image(image)

View file

@ -23,16 +23,23 @@ rst = DigitalInOut(board.D27)
busy = DigitalInOut(board.D17) busy = DigitalInOut(board.D17)
# give them all to our driver # give them all to our driver
display = Adafruit_SSD1675B(122, 250, spi, # 2.13" HD mono display (rev B) display = Adafruit_SSD1675B(
cs_pin=ecs, dc_pin=dc, sramcs_pin=None, 122,
rst_pin=rst, busy_pin=busy) 250,
spi, # 2.13" HD mono display (rev B)
cs_pin=ecs,
dc_pin=dc,
sramcs_pin=None,
rst_pin=rst,
busy_pin=busy,
)
display.rotation = 1 display.rotation = 1
# Create blank image for drawing. # Create blank image for drawing.
# Make sure to create image with mode '1' for 1-bit color. # Make sure to create image with mode '1' for 1-bit color.
width = display.width width = display.width
height = display.height height = display.height
image = Image.new('RGB', (width, height)) image = Image.new("RGB", (width, height))
WHITE = (0xFF, 0xFF, 0xFF) WHITE = (0xFF, 0xFF, 0xFF)
BLACK = (0x00, 0x00, 0x00) BLACK = (0x00, 0x00, 0x00)
@ -48,41 +55,44 @@ draw = ImageDraw.Draw(image)
draw.rectangle((0, 0, width, height), fill=WHITE) draw.rectangle((0, 0, width, height), fill=WHITE)
# Draw an outline box # Draw an outline box
draw.rectangle((1, 1, width-2, height-2), outline=BLACK, fill=WHITE) draw.rectangle((1, 1, width - 2, height - 2), outline=BLACK, fill=WHITE)
# Draw some shapes. # Draw some shapes.
# First define some constants to allow easy resizing of shapes. # First define some constants to allow easy resizing of shapes.
padding = 5 padding = 5
shape_width = 30 shape_width = 30
top = padding top = padding
bottom = height-padding bottom = height - padding
# Move left to right keeping track of the current x position for drawing shapes. # Move left to right keeping track of the current x position for drawing shapes.
x = padding x = padding
# Draw an ellipse. # Draw an ellipse.
draw.ellipse((x, top , x+shape_width, bottom), outline=BLACK, fill=WHITE) draw.ellipse((x, top, x + shape_width, bottom), outline=BLACK, fill=WHITE)
x += shape_width+padding x += shape_width + padding
# Draw a rectangle. # Draw a rectangle.
draw.rectangle((x, top, x+shape_width, bottom), outline=WHITE, fill=BLACK) draw.rectangle((x, top, x + shape_width, bottom), outline=WHITE, fill=BLACK)
x += shape_width+padding x += shape_width + padding
# Draw a triangle. # Draw a triangle.
draw.polygon([(x, bottom), (x+shape_width/2, top), (x+shape_width, bottom)], draw.polygon(
outline=BLACK, fill=WHITE) [(x, bottom), (x + shape_width / 2, top), (x + shape_width, bottom)],
x += shape_width+padding outline=BLACK,
fill=WHITE,
)
x += shape_width + padding
# Draw an X. # Draw an X.
draw.line((x, bottom, x+shape_width, top), fill=BLACK) draw.line((x, bottom, x + shape_width, top), fill=BLACK)
draw.line((x, top, x+shape_width, bottom), fill=BLACK) draw.line((x, top, x + shape_width, bottom), fill=BLACK)
x += shape_width+padding x += shape_width + padding
# Load default font. # Load default font.
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 20) font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 20)
# Alternatively load a TTF font. Make sure the .ttf font # Alternatively load a TTF font. Make sure the .ttf font
# file is in the same directory as the python script! # file is in the same directory as the python script!
# Some other nice fonts to try: http://www.dafont.com/bitmap.php # Some other nice fonts to try: http://www.dafont.com/bitmap.php
#font = ImageFont.truetype('Minecraftia.ttf', 8) # font = ImageFont.truetype('Minecraftia.ttf', 8)
# Write two lines of text. # Write two lines of text.
draw.text((x, top), 'Hello', font=font, fill=BLACK) draw.text((x, top), "Hello", font=font, fill=BLACK)
draw.text((x, top+20), 'World!', font=font, fill=BLACK) draw.text((x, top + 20), "World!", font=font, fill=BLACK)
while True: while True:
if not switch1.value: if not switch1.value:

View file

@ -9,10 +9,10 @@ import busio
import board import board
from PIL import Image, ImageDraw, ImageFont from PIL import Image, ImageDraw, ImageFont
from adafruit_epd.il0373 import Adafruit_IL0373 from adafruit_epd.il0373 import Adafruit_IL0373
from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import
from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import
from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import
from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import
# First define some color constants # First define some color constants
WHITE = (0xFF, 0xFF, 0xFF) WHITE = (0xFF, 0xFF, 0xFF)
@ -35,23 +35,30 @@ rst = digitalio.DigitalInOut(board.D27)
busy = digitalio.DigitalInOut(board.D17) busy = digitalio.DigitalInOut(board.D17)
# give them all to our driver # give them all to our driver
#display = Adafruit_SSD1608(200, 200, spi, # 1.54" HD mono display # display = Adafruit_SSD1608(200, 200, spi, # 1.54" HD mono display
#display = Adafruit_SSD1675(122, 250, spi, # 2.13" HD mono display # display = Adafruit_SSD1675(122, 250, spi, # 2.13" HD mono display
#display = Adafruit_IL91874(176, 264, spi, # 2.7" Tri-color display # display = Adafruit_IL91874(176, 264, spi, # 2.7" Tri-color display
#display = Adafruit_IL0373(152, 152, spi, # 1.54" Tri-color display # display = Adafruit_IL0373(152, 152, spi, # 1.54" Tri-color display
#display = Adafruit_IL0373(128, 296, spi, # 2.9" Tri-color display # display = Adafruit_IL0373(128, 296, spi, # 2.9" Tri-color display
#display = Adafruit_IL0398(400, 300, spi, # 4.2" Tri-color display # display = Adafruit_IL0398(400, 300, spi, # 4.2" Tri-color display
display = Adafruit_IL0373(104, 212, spi, # 2.13" Tri-color display display = Adafruit_IL0373(
cs_pin=ecs, dc_pin=dc, sramcs_pin=srcs, 104,
rst_pin=rst, busy_pin=busy) 212,
spi, # 2.13" Tri-color display
cs_pin=ecs,
dc_pin=dc,
sramcs_pin=srcs,
rst_pin=rst,
busy_pin=busy,
)
# IF YOU HAVE A FLEXIBLE DISPLAY (2.13" or 2.9") uncomment these lines! # IF YOU HAVE A FLEXIBLE DISPLAY (2.13" or 2.9") uncomment these lines!
#display.set_black_buffer(1, False) # display.set_black_buffer(1, False)
#display.set_color_buffer(1, False) # display.set_color_buffer(1, False)
display.rotation = 1 display.rotation = 1
image = Image.new('RGB', (display.width, display.height)) image = Image.new("RGB", (display.width, display.height))
# Get drawing object to draw on image. # Get drawing object to draw on image.
draw = ImageDraw.Draw(image) draw = ImageDraw.Draw(image)
@ -60,17 +67,23 @@ draw = ImageDraw.Draw(image)
draw.rectangle((0, 0, display.width, display.height), fill=BACKGROUND_COLOR) draw.rectangle((0, 0, display.width, display.height), fill=BACKGROUND_COLOR)
# Draw a smaller inner foreground rectangle # Draw a smaller inner foreground rectangle
draw.rectangle((BORDER, BORDER, display.width - BORDER - 1, display.height - BORDER - 1), draw.rectangle(
fill=FOREGROUND_COLOR) (BORDER, BORDER, display.width - BORDER - 1, display.height - BORDER - 1),
fill=FOREGROUND_COLOR,
)
# Load a TTF Font # Load a TTF Font
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', FONTSIZE) font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", FONTSIZE)
# Draw Some Text # Draw Some Text
text = "Hello World!" text = "Hello World!"
(font_width, font_height) = font.getsize(text) (font_width, font_height) = font.getsize(text)
draw.text((display.width//2 - font_width//2, display.height//2 - font_height//2), draw.text(
text, font=font, fill=TEXT_COLOR) (display.width // 2 - font_width // 2, display.height // 2 - font_height // 2),
text,
font=font,
fill=TEXT_COLOR,
)
# Display image. # Display image.
display.image(image) display.image(image)

View file

@ -11,9 +11,9 @@ import busio
import board import board
from PIL import Image from PIL import Image
from adafruit_epd.il0373 import Adafruit_IL0373 from adafruit_epd.il0373 import Adafruit_IL0373
from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import from adafruit_epd.il91874 import Adafruit_IL91874 # pylint: disable=unused-import
from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import from adafruit_epd.il0398 import Adafruit_IL0398 # pylint: disable=unused-import
from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import from adafruit_epd.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import
from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import
@ -26,19 +26,26 @@ rst = digitalio.DigitalInOut(board.D27)
busy = digitalio.DigitalInOut(board.D17) busy = digitalio.DigitalInOut(board.D17)
# give them all to our driver # give them all to our driver
#display = Adafruit_SSD1608(200, 200, spi, # 1.54" HD mono display # display = Adafruit_SSD1608(200, 200, spi, # 1.54" HD mono display
#display = Adafruit_SSD1675(122, 250, spi, # 2.13" HD mono display # display = Adafruit_SSD1675(122, 250, spi, # 2.13" HD mono display
#display = Adafruit_IL91874(176, 264, spi, # 2.7" Tri-color display # display = Adafruit_IL91874(176, 264, spi, # 2.7" Tri-color display
#display = Adafruit_IL0373(152, 152, spi, # 1.54" Tri-color display # display = Adafruit_IL0373(152, 152, spi, # 1.54" Tri-color display
#display = Adafruit_IL0373(128, 296, spi, # 2.9" Tri-color display # display = Adafruit_IL0373(128, 296, spi, # 2.9" Tri-color display
#display = Adafruit_IL0398(400, 300, spi, # 4.2" Tri-color display # display = Adafruit_IL0398(400, 300, spi, # 4.2" Tri-color display
display = Adafruit_IL0373(104, 212, spi, # 2.13" Tri-color display display = Adafruit_IL0373(
cs_pin=ecs, dc_pin=dc, sramcs_pin=srcs, 104,
rst_pin=rst, busy_pin=busy) 212,
spi, # 2.13" Tri-color display
cs_pin=ecs,
dc_pin=dc,
sramcs_pin=srcs,
rst_pin=rst,
busy_pin=busy,
)
# IF YOU HAVE A FLEXIBLE DISPLAY (2.13" or 2.9") uncomment these lines! # IF YOU HAVE A FLEXIBLE DISPLAY (2.13" or 2.9") uncomment these lines!
#display.set_black_buffer(1, False) # display.set_black_buffer(1, False)
#display.set_color_buffer(1, False) # display.set_color_buffer(1, False)
display.rotation = 1 display.rotation = 1

View file

@ -11,16 +11,24 @@ from adafruit_epd.il91874 import Adafruit_IL91874
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
ecs = digitalio.DigitalInOut(board.D10) ecs = digitalio.DigitalInOut(board.D10)
dc = digitalio.DigitalInOut(board.D9) dc = digitalio.DigitalInOut(board.D9)
srcs = digitalio.DigitalInOut(board.D8) # can be None to use internal memory srcs = digitalio.DigitalInOut(board.D8) # can be None to use internal memory
# give them all to our driver # give them all to our driver
print("Creating display") print("Creating display")
display = Adafruit_IL91874(176, 264, spi, # 2.7" Tri-color display display = Adafruit_IL91874(
cs_pin=ecs, dc_pin=dc, sramcs_pin=srcs, 176,
rst_pin=None, busy_pin=None) 264,
spi, # 2.7" Tri-color display
cs_pin=ecs,
dc_pin=dc,
sramcs_pin=srcs,
rst_pin=None,
busy_pin=None,
)
display.rotation = 1 display.rotation = 1
def read_buttons(): def read_buttons():
with AnalogIn(board.A3) as ain: with AnalogIn(board.A3) as ain:
reading = ain.value / 65535 reading = ain.value / 65535
@ -34,6 +42,7 @@ def read_buttons():
return 2 return 2
return 1 return 1
while True: while True:
button = read_buttons() button = read_buttons()
if not button: if not button:
@ -50,11 +59,11 @@ while True:
display.display() display.display()
if button == 3: if button == 3:
print("Draw lines") print("Draw lines")
display.line(0, 0, display.width-1, display.height-1, Adafruit_EPD.BLACK) display.line(0, 0, display.width - 1, display.height - 1, Adafruit_EPD.BLACK)
display.line(0, display.height-1, display.width-1, 0, Adafruit_EPD.RED) display.line(0, display.height - 1, display.width - 1, 0, Adafruit_EPD.RED)
display.display() display.display()
if button == 4: if button == 4:
print("Draw text") print("Draw text")
display.text('hello world', 25, 10, Adafruit_EPD.BLACK) display.text("hello world", 25, 10, Adafruit_EPD.BLACK)
display.display() display.display()
time.sleep(0.01) time.sleep(0.01)

View file

@ -12,25 +12,32 @@ from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-impo
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
ecs = digitalio.DigitalInOut(board.D12) ecs = digitalio.DigitalInOut(board.D12)
dc = digitalio.DigitalInOut(board.D11) dc = digitalio.DigitalInOut(board.D11)
srcs = digitalio.DigitalInOut(board.D10) # can be None to use internal memory srcs = digitalio.DigitalInOut(board.D10) # can be None to use internal memory
rst = digitalio.DigitalInOut(board.D9) # can be None to not use this pin rst = digitalio.DigitalInOut(board.D9) # can be None to not use this pin
busy = digitalio.DigitalInOut(board.D5) # can be None to not use this pin busy = digitalio.DigitalInOut(board.D5) # can be None to not use this pin
# give them all to our driver # give them all to our driver
print("Creating display") print("Creating display")
#display = Adafruit_SSD1608(200, 200, spi, # 1.54" HD mono display # display = Adafruit_SSD1608(200, 200, spi, # 1.54" HD mono display
#display = Adafruit_SSD1675(122, 250, spi, # 2.13" HD mono display # display = Adafruit_SSD1675(122, 250, spi, # 2.13" HD mono display
#display = Adafruit_IL91874(176, 264, spi, # 2.7" Tri-color display # display = Adafruit_IL91874(176, 264, spi, # 2.7" Tri-color display
#display = Adafruit_IL0373(152, 152, spi, # 1.54" Tri-color display # display = Adafruit_IL0373(152, 152, spi, # 1.54" Tri-color display
#display = Adafruit_IL0373(128, 296, spi, # 2.9" Tri-color display # display = Adafruit_IL0373(128, 296, spi, # 2.9" Tri-color display
#display = Adafruit_IL0398(400, 300, spi, # 4.2" Tri-color display # display = Adafruit_IL0398(400, 300, spi, # 4.2" Tri-color display
display = Adafruit_IL0373(104, 212, spi, # 2.13" Tri-color display display = Adafruit_IL0373(
cs_pin=ecs, dc_pin=dc, sramcs_pin=srcs, 104,
rst_pin=rst, busy_pin=busy) 212,
spi, # 2.13" Tri-color display
cs_pin=ecs,
dc_pin=dc,
sramcs_pin=srcs,
rst_pin=rst,
busy_pin=busy,
)
# IF YOU HAVE A FLEXIBLE DISPLAY (2.13" or 2.9") uncomment these lines! # IF YOU HAVE A FLEXIBLE DISPLAY (2.13" or 2.9") uncomment these lines!
#display.set_black_buffer(1, False) # display.set_black_buffer(1, False)
#display.set_color_buffer(1, False) # display.set_color_buffer(1, False)
display.rotation = 1 display.rotation = 1
@ -44,9 +51,9 @@ display.fill_rect(5, 5, 10, 10, Adafruit_EPD.RED)
display.rect(0, 0, 20, 30, Adafruit_EPD.BLACK) display.rect(0, 0, 20, 30, Adafruit_EPD.BLACK)
print("Draw lines") print("Draw lines")
display.line(0, 0, display.width-1, display.height-1, Adafruit_EPD.BLACK) display.line(0, 0, display.width - 1, display.height - 1, Adafruit_EPD.BLACK)
display.line(0, display.height-1, display.width-1, 0, Adafruit_EPD.RED) display.line(0, display.height - 1, display.width - 1, 0, Adafruit_EPD.RED)
print("Draw text") print("Draw text")
display.text('hello world', 25, 10, Adafruit_EPD.BLACK) display.text("hello world", 25, 10, Adafruit_EPD.BLACK)
display.display() display.display()

View file

@ -7,6 +7,7 @@ https://github.com/pypa/sampleproject
# Always prefer setuptools over distutils # Always prefer setuptools over distutils
from setuptools import setup, find_packages from setuptools import setup, find_packages
# To use a consistent encoding # To use a consistent encoding
from codecs import open from codecs import open
from os import path from os import path
@ -14,48 +15,42 @@ from os import path
here = path.abspath(path.dirname(__file__)) here = path.abspath(path.dirname(__file__))
# Get the long description from the README file # Get the long description from the README file
with open(path.join(here, 'README.rst'), encoding='utf-8') as f: with open(path.join(here, "README.rst"), encoding="utf-8") as f:
long_description = f.read() long_description = f.read()
setup( setup(
name='adafruit-circuitpython-epd', name="adafruit-circuitpython-epd",
use_scm_version=True, use_scm_version=True,
setup_requires=['setuptools_scm'], setup_requires=["setuptools_scm"],
description="CircuitPython library for EPD e-ink displays.",
description='CircuitPython library for EPD e-ink displays.',
long_description=long_description, long_description=long_description,
long_description_content_type='text/x-rst', long_description_content_type="text/x-rst",
# The project's main homepage. # The project's main homepage.
url='https://github.com/adafruit/Adafruit_CircuitPython_EPD', url="https://github.com/adafruit/Adafruit_CircuitPython_EPD",
# Author details # Author details
author='Adafruit Industries', author="Adafruit Industries",
author_email='circuitpython@adafruit.com', author_email="circuitpython@adafruit.com",
install_requires=[
install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-busdevice', "Adafruit-Blinka",
'adafruit-circuitpython-framebuf'], "adafruit-circuitpython-busdevice",
"adafruit-circuitpython-framebuf",
],
# Choose your license # Choose your license
license='MIT', license="MIT",
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers # See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers=[ classifiers=[
'Development Status :: 3 - Alpha', "Development Status :: 3 - Alpha",
'Intended Audience :: Developers', "Intended Audience :: Developers",
'Topic :: Software Development :: Libraries', "Topic :: Software Development :: Libraries",
'Topic :: System :: Hardware', "Topic :: System :: Hardware",
'License :: OSI Approved :: MIT License', "License :: OSI Approved :: MIT License",
'Programming Language :: Python :: 3', "Programming Language :: Python :: 3",
'Programming Language :: Python :: 3.4', "Programming Language :: Python :: 3.4",
'Programming Language :: Python :: 3.5', "Programming Language :: Python :: 3.5",
], ],
# What does your project relate to? # What does your project relate to?
keywords='adafruit eink e-ink display epd hardware micropython circuitpython', keywords="adafruit eink e-ink display epd hardware micropython circuitpython",
# You can just specify the packages manually here if your project is # You can just specify the packages manually here if your project is
# simple. Or you can use find_packages(). # simple. Or you can use find_packages().
packages=['adafruit_epd'], packages=["adafruit_epd"],
) )