diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fff3aa9..1dad804 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,7 +40,7 @@ jobs: source actions-ci/install.sh - name: Pip install pylint, black, & Sphinx 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 run: git describe --dirty --always --tags - name: PyLint diff --git a/adafruit_epd/epd.py b/adafruit_epd/epd.py index 9cbd3bf..46de793 100644 --- a/adafruit_epd/epd.py +++ b/adafruit_epd/epd.py @@ -34,9 +34,11 @@ __version__ = "0.0.0-auto.0" __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 """ + BLACK = const(0) WHITE = const(1) INVERSE = const(2) @@ -44,8 +46,9 @@ class Adafruit_EPD: # pylint: disable=too-many-instance-attributes, too-many-pub DARK = const(4) LIGHT = const(5) - - def __init__(self, width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin): # pylint: disable=too-many-arguments + def __init__( + self, width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy_pin + ): # pylint: disable=too-many-arguments self._width = width self._height = height @@ -73,7 +76,7 @@ def __init__(self, width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy self.spi_device = spi while not self.spi_device.try_lock(): 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._spibuf = bytearray(1) @@ -101,16 +104,16 @@ def display(self): # pylint: disable=too-many-branches while not self.spi_device.try_lock(): time.sleep(0.01) self.sram.cs_pin.value = False - #send read command + # send read command self._buf[0] = mcp_sram.Adafruit_MCP_SRAM.SRAM_READ - #send start address + # send start address self._buf[1] = 0 self._buf[2] = 0 self.spi_device.write(self._buf, end=3) self.spi_device.unlock() - #first data byte from SRAM will be transfered in at the - #same time as the EPD command is transferred out + # first data byte from SRAM will be transfered in at the + # same time as the EPD command is transferred out databyte = self.write_ram(0) while not self.spi_device.try_lock(): @@ -127,23 +130,23 @@ def display(self): # pylint: disable=too-many-branches self._cs.value = True self.spi_device.unlock() - time.sleep(.002) + time.sleep(0.002) if self.sram: while not self.spi_device.try_lock(): time.sleep(0.01) self.sram.cs_pin.value = False - #send read command + # send read command 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[2] = self._buffer1_size & 0xFF self.spi_device.write(self._buf, end=3) self.spi_device.unlock() if self._buffer2_size != 0: - #first data byte from SRAM will be transfered in at the - #same time as the EPD command is transferred out + # first data byte from SRAM will be transfered in at the + # same time as the EPD command is transferred out databyte = self.write_ram(1) while not self.spi_device.try_lock(): @@ -166,7 +169,6 @@ def display(self): # pylint: disable=too-many-branches self.update() - def hardware_reset(self): """If we have a reset pin, do a hardware reset by toggling it""" if self._rst: @@ -251,7 +253,7 @@ def set_color_buffer(self, index, inverted): def _color_dup(self, func, args, color): black = getattr(self._blackframebuf, 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) else: black(*args, color=(color == Adafruit_EPD.BLACK) != self._black_inverted) @@ -259,7 +261,7 @@ def _color_dup(self, func, args, color): def pixel(self, x, y, color): """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): """fill the screen with the passed color""" @@ -273,28 +275,45 @@ def fill(self, color): self._blackframebuf.fill(black_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""" - 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""" - 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""" - 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"): """Write text string at location (x, y) in given color, using font file""" - if self._blackframebuf is self._colorframebuf: # monochrome - self._blackframebuf.text(string, x, y, font_name=font_name, - color=(color != Adafruit_EPD.WHITE) != self._black_inverted) + if self._blackframebuf is self._colorframebuf: # monochrome + self._blackframebuf.text( + string, + x, + y, + font_name=font_name, + color=(color != Adafruit_EPD.WHITE) != self._black_inverted, + ) else: - self._blackframebuf.text(string, x, 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) + self._blackframebuf.text( + string, + x, + 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 def width(self): @@ -329,17 +348,19 @@ def vline(self, x, y, height, color): """draw a vertical line""" self.fill_rect(x, y, 1, height, color) - 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.') + 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)) + raise ValueError( + "Image must be same dimensions as display ({0}x{1}).".format( + self.width, self.height + ) + ) if self.sram: raise RuntimeError("PIL image is not for use with SRAM assist") # Grab all the pixels from the image, faster than getpixel. @@ -350,7 +371,7 @@ def image(self, image): for y in range(image.size[1]): for x in range(image.size[0]): 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 self.pixel(x, y, Adafruit_EPD.RED) elif (pixel[0] < 0x80) and (pixel[1] < 0x80) and (pixel[2] < 0x80): diff --git a/adafruit_epd/il0373.py b/adafruit_epd/il0373.py index 0db613b..8beb174 100644 --- a/adafruit_epd/il0373.py +++ b/adafruit_epd/il0373.py @@ -59,12 +59,17 @@ _IL0373_RESOLUTION = const(0x61) _IL0373_VCM_DC_SETTING = const(0x82) + class Adafruit_IL0373(Adafruit_EPD): """driver class for Adafruit IL0373 ePaper display breakouts""" + # pylint: disable=too-many-arguments - def __init__(self, width, height, spi, *, cs_pin, dc_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) + def __init__( + self, width, height, spi, *, cs_pin, dc_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._buffer2_size = int(width * height / 8) @@ -77,10 +82,12 @@ def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, b self._buffer2 = bytearray((width * height) // 8) # since we have *two* framebuffers - one for red and one for black # we dont subclass but manage manually - self._framebuf1 = adafruit_framebuf.FrameBuffer(self._buffer1, width, height, - buf_format=adafruit_framebuf.MHMSB) - self._framebuf2 = adafruit_framebuf.FrameBuffer(self._buffer2, width, height, - buf_format=adafruit_framebuf.MHMSB) + self._framebuf1 = adafruit_framebuf.FrameBuffer( + self._buffer1, 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_color_buffer(1, True) # pylint: enable=too-many-arguments @@ -105,7 +112,7 @@ def power_up(self): self.hardware_reset() 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_POWER_ON) @@ -134,7 +141,7 @@ def update(self): time.sleep(0.1) self.busy_wait() if not self._busy: - time.sleep(15) # wait 15 seconds + time.sleep(15) # wait 15 seconds def write_ram(self, index): """Send the one byte command for starting the RAM write process. Returns @@ -146,7 +153,7 @@ def write_ram(self, index): return self.command(_IL0373_DTM2, end=False) 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 the superclass""" - return # on this chip it does nothing + return # on this chip it does nothing diff --git a/adafruit_epd/il0398.py b/adafruit_epd/il0398.py index 41cd006..290c57b 100644 --- a/adafruit_epd/il0398.py +++ b/adafruit_epd/il0398.py @@ -60,12 +60,17 @@ _IL0398_GETSTATUS = const(0x71) _IL0398_VCM_DC_SETTING = const(0x82) + class Adafruit_IL0398(Adafruit_EPD): """driver class for Adafruit IL0373 ePaper display breakouts""" + # pylint: disable=too-many-arguments - def __init__(self, width, height, spi, *, cs_pin, dc_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) + def __init__( + self, width, height, spi, *, cs_pin, dc_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._buffer2_size = int(width * height / 8) @@ -78,10 +83,12 @@ def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, b self._buffer2 = bytearray((width * height) // 8) # since we have *two* framebuffers - one for red and one for black # we dont subclass but manage manually - self._framebuf1 = adafruit_framebuf.FrameBuffer(self._buffer1, width, height, - buf_format=adafruit_framebuf.MHMSB) - self._framebuf2 = adafruit_framebuf.FrameBuffer(self._buffer2, width, height, - buf_format=adafruit_framebuf.MHMSB) + self._framebuf1 = adafruit_framebuf.FrameBuffer( + self._buffer1, 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_color_buffer(1, True) # pylint: enable=too-many-arguments @@ -97,7 +104,7 @@ def busy_wait(self): busy pin, or pausing""" if self._busy: while not self._busy.value: - #self.command(_IL0398_GETSTATUS) + # self.command(_IL0398_GETSTATUS) time.sleep(0.01) else: time.sleep(0.5) @@ -134,7 +141,7 @@ def update(self): time.sleep(0.1) self.busy_wait() if not self._busy: - time.sleep(15) # wait 15 seconds + time.sleep(15) # wait 15 seconds def write_ram(self, index): """Send the one byte command for starting the RAM write process. Returns @@ -146,7 +153,7 @@ def write_ram(self, index): return self.command(_IL0398_DTM2, end=False) 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 the superclass""" - return # on this chip it does nothing + return # on this chip it does nothing diff --git a/adafruit_epd/il91874.py b/adafruit_epd/il91874.py index 32a5c84..36dba11 100644 --- a/adafruit_epd/il91874.py +++ b/adafruit_epd/il91874.py @@ -60,19 +60,24 @@ _IL91874_VCM_DC_SETTING = const(0x82) # 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_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_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_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_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_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 + class Adafruit_IL91874(Adafruit_EPD): """driver class for Adafruit IL91874 ePaper display breakouts""" + # pylint: disable=too-many-arguments - def __init__(self, width, height, spi, *, cs_pin, dc_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) + def __init__( + self, width, height, spi, *, cs_pin, dc_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._buffer2_size = int(width * height / 8) @@ -85,10 +90,12 @@ def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, b self._buffer2 = bytearray((width * height) // 8) # since we have *two* framebuffers - one for red and one for black # we dont subclass but manage manually - self._framebuf1 = adafruit_framebuf.FrameBuffer(self._buffer1, width, height, - buf_format=adafruit_framebuf.MHMSB) - self._framebuf2 = adafruit_framebuf.FrameBuffer(self._buffer2, width, height, - buf_format=adafruit_framebuf.MHMSB) + self._framebuf1 = adafruit_framebuf.FrameBuffer( + self._buffer1, 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_color_buffer(1, False) self._single_byte_tx = True @@ -118,7 +125,7 @@ def power_up(self): self.command(_IL91874_PANEL_SETTING, bytearray([0xAF])) 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(0xF8, bytearray([0x60, 0xA5])) # mystery command in example code @@ -157,7 +164,7 @@ def update(self): self.command(_IL91874_DISPLAY_REFRESH) self.busy_wait() if not self._busy: - time.sleep(16) # wait 16 seconds + time.sleep(16) # wait 16 seconds def write_ram(self, index): """Send the one byte command for starting the RAM write process. Returns @@ -169,7 +176,7 @@ def write_ram(self, index): return self.command(_IL91874_DTM2, end=False) 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 the superclass""" - return # on this chip it does nothing + return # on this chip it does nothing diff --git a/adafruit_epd/mcp_sram.py b/adafruit_epd/mcp_sram.py index b8fb089..ec59f7b 100644 --- a/adafruit_epd/mcp_sram.py +++ b/adafruit_epd/mcp_sram.py @@ -34,23 +34,27 @@ SRAM_SEQUENTIAL_MODE = const(1 << 6) + class Adafruit_MCP_SRAM_View: """A interface class that turns an SRAM chip into something like a memoryview""" + def __init__(self, sram, offset): self._sram = sram self._offset = offset self._buf = [0] 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): self._buf[0] = val - self._sram.write(self._offset+i, self._buf) + self._sram.write(self._offset + i, self._buf) + class Adafruit_MCP_SRAM: """supporting class for communicating with Microchip SRAM chips""" + SRAM_READ = 0x03 SRAM_WRITE = 0x02 SRAM_RDSR = 0x05 @@ -65,7 +69,7 @@ def __init__(self, cs_pin, spi): self._buf[0] = Adafruit_MCP_SRAM.SRAM_WRSR self._buf[1] = 0x43 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): """Create an object that can be used as a memoryview, with a given offset""" @@ -78,8 +82,8 @@ def write(self, addr, buf, reg=SRAM_WRITE): self._buf[2] = addr & 0xFF with self._spi as spi: - spi.write(self._buf, end=3) # pylint: disable=no-member - spi.write(bytearray(buf)) # pylint: disable=no-member + spi.write(self._buf, end=3) # pylint: disable=no-member + spi.write(bytearray(buf)) # pylint: disable=no-member def read(self, addr, length, reg=SRAM_READ): """read passed number of bytes at the passed address""" @@ -89,8 +93,8 @@ def read(self, addr, length, reg=SRAM_READ): buf = bytearray(length) with self._spi as spi: - spi.write(self._buf, end=3) # pylint: disable=no-member - spi.readinto(buf) # pylint: disable=no-member + spi.write(self._buf, end=3) # pylint: disable=no-member + spi.readinto(buf) # pylint: disable=no-member return buf def read8(self, addr, reg=SRAM_READ): @@ -117,6 +121,6 @@ def erase(self, addr, length, value): self._buf[2] = addr & 0xFF fill = bytearray([value]) 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): - spi.write(fill) # pylint: disable=no-member + spi.write(fill) # pylint: disable=no-member diff --git a/adafruit_epd/ssd1608.py b/adafruit_epd/ssd1608.py index 1a5f80c..7adf9f5 100644 --- a/adafruit_epd/ssd1608.py +++ b/adafruit_epd/ssd1608.py @@ -66,17 +66,22 @@ _SSD1608_SET_RAMXCOUNT = const(0x4E) _SSD1608_SET_RAMYCOUNT = const(0x4F) _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): """driver class for Adafruit SSD1608 ePaper display breakouts""" + # pylint: disable=too-many-arguments - def __init__(self, width, height, spi, *, cs_pin, dc_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) + def __init__( + self, width, height, spi, *, cs_pin, dc_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: - height += (8 - height % 8) + height += 8 - height % 8 self._height = height self._buffer1_size = int(width * height / 8) @@ -85,8 +90,9 @@ def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, b self._buffer1 = self.sram.get_view(0) else: self._buffer1 = bytearray((width * height) // 8) - self._framebuf1 = adafruit_framebuf.FrameBuffer(self._buffer1, width, height, - buf_format=adafruit_framebuf.MHMSB) + self._framebuf1 = adafruit_framebuf.FrameBuffer( + self._buffer1, width, height, buf_format=adafruit_framebuf.MHMSB + ) self.set_black_buffer(0, True) self.set_color_buffer(0, True) # pylint: enable=too-many-arguments @@ -113,8 +119,10 @@ def power_up(self): self.command(_SSD1608_SW_RESET) self.busy_wait() # driver output control - self.command(_SSD1608_DRIVER_CONTROL, - bytearray([self._width-1, (self._width-1) >> 8, 0x00])) + self.command( + _SSD1608_DRIVER_CONTROL, + bytearray([self._width - 1, (self._width - 1) >> 8, 0x00]), + ) # Set dummy line period self.command(_SSD1608_WRITE_DUMMY, bytearray([0x1B])) # Set gate line width @@ -122,10 +130,12 @@ def power_up(self): # Data entry sequence self.command(_SSD1608_DATA_MODE, bytearray([0x03])) # 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 - self.command(_SSD1608_SET_RAMYPOS, - bytearray([0, 0, self._height - 1, (self._height - 1) >> 8])) + self.command( + _SSD1608_SET_RAMYPOS, + bytearray([0, 0, self._height - 1, (self._height - 1) >> 8]), + ) # Vcom Voltage self.command(_SSD1608_WRITE_VCOM, bytearray([0x70])) # LUT @@ -143,7 +153,7 @@ def update(self): self.command(_SSD1608_MASTER_ACTIVATE) self.busy_wait() if not self._busy: - time.sleep(3) # wait 3 seconds + time.sleep(3) # wait 3 seconds def write_ram(self, index): """Send the one byte command for starting the RAM write process. Returns @@ -153,10 +163,10 @@ def write_ram(self, index): return self.command(_SSD1608_WRITE_RAM, end=False) 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 the superclass""" # Set RAM X address counter self.command(_SSD1608_SET_RAMXCOUNT, bytearray([x])) # Set RAM Y address counter - self.command(_SSD1608_SET_RAMYCOUNT, bytearray([y>>8, y])) + self.command(_SSD1608_SET_RAMYCOUNT, bytearray([y >> 8, y])) diff --git a/adafruit_epd/ssd1675.py b/adafruit_epd/ssd1675.py index f2f1f7f..6198f22 100644 --- a/adafruit_epd/ssd1675.py +++ b/adafruit_epd/ssd1675.py @@ -60,17 +60,22 @@ _SSD1675_SET_RAMYCOUNT = const(0x4F) _SSD1675_SET_ANALOGBLOCK = const(0x74) _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): """driver class for Adafruit SSD1675 ePaper display breakouts""" + # pylint: disable=too-many-arguments - def __init__(self, width, height, spi, *, cs_pin, dc_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) + def __init__( + self, width, height, spi, *, cs_pin, dc_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 if stride % 8 != 0: - stride += (8 - stride % 8) + stride += 8 - stride % 8 self._buffer1_size = int(stride * height / 8) self._buffer2_size = self._buffer1_size @@ -83,10 +88,20 @@ def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, b self._buffer2 = bytearray(self._buffer2_size) # since we have *two* framebuffers - one for red and one for black # we dont subclass but manage manually - self._framebuf1 = adafruit_framebuf.FrameBuffer(self._buffer1, width, 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._framebuf1 = adafruit_framebuf.FrameBuffer( + self._buffer1, + width, + 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_color_buffer(0, True) # pylint: enable=too-many-arguments @@ -121,8 +136,7 @@ def power_up(self): self.command(_SSD1675_SET_DIGITALBLOCK, bytearray([0x3B])) # driver output control - self.command(_SSD1675_DRIVER_CONTROL, - bytearray([0xFA, 0x01, 0x00])) + self.command(_SSD1675_DRIVER_CONTROL, bytearray([0xFA, 0x01, 0x00])) # Data entry sequence self.command(_SSD1675_DATA_MODE, bytearray([0x03])) # Set ram X start/end postion @@ -161,7 +175,7 @@ def update(self): self.command(_SSD1675_MASTER_ACTIVATE) self.busy_wait() if not self._busy: - time.sleep(3) # wait 3 seconds + time.sleep(3) # wait 3 seconds def write_ram(self, index): """Send the one byte command for starting the RAM write process. Returns @@ -173,8 +187,8 @@ def write_ram(self, index): return self.command(_SSD1675_WRITE_RAM2, end=False) 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 the superclass""" 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])) diff --git a/adafruit_epd/ssd1675b.py b/adafruit_epd/ssd1675b.py index f9e8fd9..bf8135e 100644 --- a/adafruit_epd/ssd1675b.py +++ b/adafruit_epd/ssd1675b.py @@ -86,17 +86,22 @@ _SSD1675B_SET_ANALOGBLOCK = const(0x74) _SSD1675B_SET_DIGITALBLOCK = const(0x7E) _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): """driver class for Adafruit SSD1675B ePaper display breakouts""" + # pylint: disable=too-many-arguments - def __init__(self, width, height, spi, *, cs_pin, dc_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) + def __init__( + self, width, height, spi, *, cs_pin, dc_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 if stride % 8 != 0: - stride += (8 - stride % 8) + stride += 8 - stride % 8 self._buffer1_size = int(stride * height / 8) self._buffer2_size = self._buffer1_size @@ -109,10 +114,20 @@ def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, b self._buffer2 = bytearray(self._buffer2_size) # since we have *two* framebuffers - one for red and one for black # we dont subclass but manage manually - self._framebuf1 = adafruit_framebuf.FrameBuffer(self._buffer1, width, 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._framebuf1 = adafruit_framebuf.FrameBuffer( + self._buffer1, + width, + 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_color_buffer(0, True) # pylint: enable=too-many-arguments @@ -146,8 +161,10 @@ def power_up(self): # set digital block control self.command(_SSD1675B_SET_DIGITALBLOCK, bytearray([0x3B])) - self.command(_SSD1675B_DRIVER_CONTROL, - bytearray([self._height-1, (self._height-1) >> 8, 0x00])) + self.command( + _SSD1675B_DRIVER_CONTROL, + bytearray([self._height - 1, (self._height - 1) >> 8, 0x00]), + ) # Data entry sequence self.command(_SSD1675B_DATA_MODE, bytearray([0x03])) @@ -155,8 +172,10 @@ def power_up(self): # Set ram X start/end postion self.command(_SSD1675B_SET_RAMXPOS, bytearray([0x00, self._width // 8])) # Set ram Y start/end postion - self.command(_SSD1675B_SET_RAMYPOS, - bytearray([0x0, 0x0, self._height-1, (self._height-1) >> 8])) + self.command( + _SSD1675B_SET_RAMYPOS, + bytearray([0x0, 0x0, self._height - 1, (self._height - 1) >> 8]), + ) # Border color self.command(_SSD1675B_WRITE_BORDER, bytearray([0x03])) @@ -175,12 +194,15 @@ def power_up(self): self.command(_SSD1675B_WRITE_LUT, _LUT_DATA[0:100]) # Set temperature control - #self.command(_SSD1675B_TEMP_CONTROL, bytearray([0x80])) + # self.command(_SSD1675B_TEMP_CONTROL, bytearray([0x80])) # Set RAM X address counter self.command(_SSD1675B_SET_RAMXCOUNT, bytearray([0])) # 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() @@ -195,7 +217,7 @@ def update(self): self.command(_SSD1675B_MASTER_ACTIVATE) self.busy_wait() if not self._busy: - time.sleep(3) # wait 3 seconds + time.sleep(3) # wait 3 seconds def write_ram(self, index): """Send the one byte command for starting the RAM write process. Returns @@ -207,8 +229,8 @@ def write_ram(self, index): return self.command(_SSD1675B_WRITE_RAM2, end=False) 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 the superclass""" 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])) diff --git a/adafruit_epd/ssd1681.py b/adafruit_epd/ssd1681.py index 6d9ba95..fa0156e 100644 --- a/adafruit_epd/ssd1681.py +++ b/adafruit_epd/ssd1681.py @@ -83,17 +83,22 @@ _SSD1681_SET_RAMYCOUNT = const(0x4F) _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): """driver class for Adafruit SSD1681 ePaper display breakouts""" + # pylint: disable=too-many-arguments - def __init__(self, width, height, spi, *, cs_pin, dc_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) + def __init__( + self, width, height, spi, *, cs_pin, dc_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: - height += (8 - height % 8) + height += 8 - height % 8 self._height = height self._buffer1_size = int(width * height / 8) @@ -102,8 +107,9 @@ def __init__(self, width, height, spi, *, cs_pin, dc_pin, sramcs_pin, rst_pin, b self._buffer1 = self.sram.get_view(0) else: self._buffer1 = bytearray((width * height) // 8) - self._framebuf1 = adafruit_framebuf.FrameBuffer(self._buffer1, width, height, - buf_format=adafruit_framebuf.MHMSB) + self._framebuf1 = adafruit_framebuf.FrameBuffer( + self._buffer1, width, height, buf_format=adafruit_framebuf.MHMSB + ) self.set_black_buffer(0, True) self.set_color_buffer(0, True) # pylint: enable=too-many-arguments @@ -130,15 +136,19 @@ def power_up(self): self.command(_SSD1681_SW_RESET) self.busy_wait() # driver output control - self.command(_SSD1681_DRIVER_CONTROL, - bytearray([self._width-1, (self._width-1) >> 8, 0x00])) + self.command( + _SSD1681_DRIVER_CONTROL, + bytearray([self._width - 1, (self._width - 1) >> 8, 0x00]), + ) # data entry mode self.command(_SSD1681_DATA_MODE, bytearray([0x03])) # 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 - self.command(_SSD1681_SET_RAMYPOS, - bytearray([0, 0, self._height - 1, (self._height - 1) >> 8])) + self.command( + _SSD1681_SET_RAMYPOS, + bytearray([0, 0, self._height - 1, (self._height - 1) >> 8]), + ) # Set border waveform self.command(_SSD1681_WRITE_BORDER, bytearray([0x05])) # Set temperature control @@ -157,7 +167,7 @@ def update(self): self.command(_SSD1681_MASTER_ACTIVATE) self.busy_wait() if not self._busy: - time.sleep(3) # wait 3 seconds + time.sleep(3) # wait 3 seconds def write_ram(self, index): """Send the one byte command for starting the RAM write process. Returns @@ -167,10 +177,10 @@ def write_ram(self, index): return self.command(_SSD1681_WRITE_BWRAM, end=False) 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 the superclass""" # Set RAM X address counter self.command(_SSD1681_SET_RAMXCOUNT, bytearray([x])) # Set RAM Y address counter - self.command(_SSD1681_SET_RAMYCOUNT, bytearray([y>>8, y])) + self.command(_SSD1681_SET_RAMYCOUNT, bytearray([y >> 8, y])) diff --git a/docs/conf.py b/docs/conf.py index 43b9354..a73ba72 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,7 +2,8 @@ import os import sys -sys.path.insert(0, os.path.abspath('..')) + +sys.path.insert(0, os.path.abspath("..")) # -- General configuration ------------------------------------------------ @@ -10,10 +11,10 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', - 'sphinx.ext.napoleon', - 'sphinx.ext.todo', + "sphinx.ext.autodoc", + "sphinx.ext.intersphinx", + "sphinx.ext.napoleon", + "sphinx.ext.todo", ] # Uncomment the below if you use native CircuitPython modules such as @@ -22,29 +23,40 @@ # 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. -templates_path = ['_templates'] +templates_path = ["_templates"] -source_suffix = '.rst' +source_suffix = ".rst" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'Adafruit EPD Library' -copyright = u'2018 Dean Miller' -author = u'Dean Miller' +project = u"Adafruit EPD Library" +copyright = u"2018 Dean Miller" +author = u"Dean Miller" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = u'1.0' +version = u"1.0" # 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 # for a list of supported languages. @@ -56,7 +68,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # 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 # documents. @@ -68,7 +80,7 @@ add_function_parentheses = True # 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. todo_include_todos = False @@ -83,59 +95,62 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # 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 try: 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: - html_theme = 'default' - html_theme_path = ['.'] + html_theme = "default" + html_theme_path = ["."] else: - html_theme_path = ['.'] + html_theme_path = ["."] # 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, # 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 docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. # -html_favicon = '_static/favicon.ico' +html_favicon = "_static/favicon.ico" # Output file base name for HTML help builder. -htmlhelp_basename = 'AdafruitEpdLibrarydoc' +htmlhelp_basename = "AdafruitEpdLibrarydoc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). 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 --------------------------------------- @@ -143,8 +158,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). 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 ------------------------------------------- @@ -153,7 +173,13 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'AdafruitEPDLibrary', u'Adafruit EPD Library Documentation', - author, 'AdafruitEPDLibrary', 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "AdafruitEPDLibrary", + u"Adafruit EPD Library Documentation", + author, + "AdafruitEPDLibrary", + "One line description of project.", + "Miscellaneous", + ), ] diff --git a/examples/epd_bitmap.py b/examples/epd_bitmap.py index 9591469..fa3c59e 100644 --- a/examples/epd_bitmap.py +++ b/examples/epd_bitmap.py @@ -3,9 +3,9 @@ import board from adafruit_epd.epd import Adafruit_EPD from adafruit_epd.il0373 import Adafruit_IL0373 -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.ssd1608 import Adafruit_SSD1608 # 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.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import @@ -13,30 +13,38 @@ spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) ecs = digitalio.DigitalInOut(board.D10) dc = digitalio.DigitalInOut(board.D9) -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 -busy = digitalio.DigitalInOut(board.D12) # can be None to not use this pin +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 +busy = digitalio.DigitalInOut(board.D12) # can be None to not use this pin # give them all to our driver print("Creating 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_IL91874(176, 264, spi, # 2.7" 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_IL0398(400, 300, spi, # 4.2" Tri-color display -display = Adafruit_IL0373(104, 212, spi, # 2.13" Tri-color display - cs_pin=ecs, dc_pin=dc, sramcs_pin=srcs, - rst_pin=rst, busy_pin=busy) +# display = Adafruit_SSD1608(200, 200, spi, # 1.54" 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_IL0373(152, 152, spi, # 1.54" 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_IL0373( + 104, + 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! -#display.set_black_buffer(1, False) -#display.set_color_buffer(1, False) +# display.set_black_buffer(1, False) +# display.set_color_buffer(1, False) display.rotation = 0 FILENAME = "blinka154mono.bmp" + def read_le(s): # as of this writting, int.from_bytes does not have LE support, DIY! result = 0 @@ -46,10 +54,12 @@ def read_le(s): shift += 8 return result + class BMPError(Exception): 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: f = open("/" + filename, "rb") except OSError: @@ -58,7 +68,7 @@ def display_bitmap(epd, filename): # pylint: disable=too-many-locals, too-many-b print("File opened") try: - if f.read(2) != b'BM': # check signature + if f.read(2) != b"BM": # check signature raise BMPError("Not BitMap file") 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)) flip = True - print("Size: %d\nImage offset: %d\nHeader size: %d" % - (bmpFileSize, bmpImageoffset, headerSize)) + print( + "Size: %d\nImage offset: %d\nHeader size: %d" + % (bmpFileSize, bmpImageoffset, headerSize) + ) print("Width: %d\nHeight: %d" % (bmpWidth, bmpHeight)) 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) f.seek(pos) - rowdata = f.read(3*bmpWidth) + rowdata = f.read(3 * 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: epd.pixel(col, row, Adafruit_EPD.BLACK) 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: epd.pixel(col, row, Adafruit_EPD.RED) except OSError: @@ -112,6 +124,7 @@ def display_bitmap(epd, filename): # pylint: disable=too-many-locals, too-many-b f.close() print("Finished drawing") + # clear the buffer display.fill(Adafruit_EPD.WHITE) display_bitmap(display, FILENAME) diff --git a/examples/epd_blinka.py b/examples/epd_blinka.py index 163335b..8f4d4b6 100644 --- a/examples/epd_blinka.py +++ b/examples/epd_blinka.py @@ -6,13 +6,13 @@ from PIL import ImageDraw from PIL import ImageFont from adafruit_epd.epd import Adafruit_EPD -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.il0398 import Adafruit_IL0398 # 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.il0373 import Adafruit_IL0373 # 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.ssd1608 import Adafruit_SSD1608 # 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.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 spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) @@ -22,31 +22,37 @@ ecs = digitalio.DigitalInOut(board.D4) dc = digitalio.DigitalInOut(board.D5) srcs = None -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 - +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 # give them all to our driver print("Creating 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_SSD1675(122, 250, spi, # 2.13" HD mono 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(128, 296, spi, # 2.9" 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_SSD1675B(122, 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 = Adafruit_SSD1608(200, 200, spi, # 1.54" HD mono display +# 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_IL91874(176, 264, spi, # 2.7" 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_IL0398(400, 300, spi, # 4.2" 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) + cs_pin=ecs, + dc_pin=dc, + sramcs_pin=srcs, + rst_pin=rst, + busy_pin=busy, +) display.rotation = 3 # Create blank image for drawing. # Make sure to create image with mode '1' for 1-bit color. width = display.width height = display.height -image = Image.new('RGB', (width, height)) +image = Image.new("RGB", (width, height)) WHITE = (0xFF, 0xFF, 0xFF) RED = (0xFF, 0x00, 0x00) @@ -61,42 +67,45 @@ draw.rectangle((0, 0, width, height), fill=WHITE) # 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. # First define some constants to allow easy resizing of shapes. padding = 5 shape_width = 30 top = padding -bottom = height-padding +bottom = height - padding # Move left to right keeping track of the current x position for drawing shapes. x = padding # Draw an ellipse. -draw.ellipse((x, top , x+shape_width, bottom), outline=RED, fill=WHITE) -x += shape_width+padding +draw.ellipse((x, top, x + shape_width, bottom), outline=RED, fill=WHITE) +x += shape_width + padding # Draw a rectangle. -draw.rectangle((x, top, x+shape_width, bottom), outline=RED, fill=BLACK) -x += shape_width+padding +draw.rectangle((x, top, x + shape_width, bottom), outline=RED, fill=BLACK) +x += shape_width + padding # Draw a triangle. -draw.polygon([(x, bottom), (x+shape_width/2, top), (x+shape_width, bottom)], - outline=BLACK, fill=RED) -x += shape_width+padding +draw.polygon( + [(x, bottom), (x + shape_width / 2, top), (x + shape_width, bottom)], + outline=BLACK, + fill=RED, +) +x += shape_width + padding # Draw an X. -draw.line((x, bottom, x+shape_width, top), fill=RED) -draw.line((x, top, x+shape_width, bottom), fill=RED) -x += shape_width+padding +draw.line((x, bottom, x + shape_width, top), fill=RED) +draw.line((x, top, x + shape_width, bottom), fill=RED) +x += shape_width + padding # 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 # file is in the same directory as the python script! # 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. -draw.text((x, top), 'Hello', font=font, fill=RED) -draw.text((x, top+20), 'World!', font=font, fill=RED) +draw.text((x, top), "Hello", font=font, fill=RED) +draw.text((x, top + 20), "World!", font=font, fill=RED) # Display image. display.image(image) diff --git a/examples/epd_bonnet.py b/examples/epd_bonnet.py index b64d179..c6460cb 100644 --- a/examples/epd_bonnet.py +++ b/examples/epd_bonnet.py @@ -23,16 +23,23 @@ busy = DigitalInOut(board.D17) # give them all to our driver -display = Adafruit_SSD1675B(122, 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 = Adafruit_SSD1675B( + 122, + 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 # Create blank image for drawing. # Make sure to create image with mode '1' for 1-bit color. width = display.width height = display.height -image = Image.new('RGB', (width, height)) +image = Image.new("RGB", (width, height)) WHITE = (0xFF, 0xFF, 0xFF) BLACK = (0x00, 0x00, 0x00) @@ -48,41 +55,44 @@ draw.rectangle((0, 0, width, height), fill=WHITE) # 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. # First define some constants to allow easy resizing of shapes. padding = 5 shape_width = 30 top = padding -bottom = height-padding +bottom = height - padding # Move left to right keeping track of the current x position for drawing shapes. x = padding # Draw an ellipse. -draw.ellipse((x, top , x+shape_width, bottom), outline=BLACK, fill=WHITE) -x += shape_width+padding +draw.ellipse((x, top, x + shape_width, bottom), outline=BLACK, fill=WHITE) +x += shape_width + padding # Draw a rectangle. -draw.rectangle((x, top, x+shape_width, bottom), outline=WHITE, fill=BLACK) -x += shape_width+padding +draw.rectangle((x, top, x + shape_width, bottom), outline=WHITE, fill=BLACK) +x += shape_width + padding # Draw a triangle. -draw.polygon([(x, bottom), (x+shape_width/2, top), (x+shape_width, bottom)], - outline=BLACK, fill=WHITE) -x += shape_width+padding +draw.polygon( + [(x, bottom), (x + shape_width / 2, top), (x + shape_width, bottom)], + outline=BLACK, + fill=WHITE, +) +x += shape_width + padding # Draw an X. -draw.line((x, bottom, x+shape_width, top), fill=BLACK) -draw.line((x, top, x+shape_width, bottom), fill=BLACK) -x += shape_width+padding +draw.line((x, bottom, x + shape_width, top), fill=BLACK) +draw.line((x, top, x + shape_width, bottom), fill=BLACK) +x += shape_width + padding # 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 # file is in the same directory as the python script! # 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. -draw.text((x, top), 'Hello', font=font, fill=BLACK) -draw.text((x, top+20), 'World!', font=font, fill=BLACK) +draw.text((x, top), "Hello", font=font, fill=BLACK) +draw.text((x, top + 20), "World!", font=font, fill=BLACK) while True: if not switch1.value: diff --git a/examples/epd_pillow_demo.py b/examples/epd_pillow_demo.py index ee93947..7da3351 100644 --- a/examples/epd_pillow_demo.py +++ b/examples/epd_pillow_demo.py @@ -9,10 +9,10 @@ import board from PIL import Image, ImageDraw, ImageFont from adafruit_epd.il0373 import Adafruit_IL0373 -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.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import -from adafruit_epd.ssd1675 import Adafruit_SSD1675 # 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.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import +from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import # First define some color constants WHITE = (0xFF, 0xFF, 0xFF) @@ -35,23 +35,30 @@ busy = digitalio.DigitalInOut(board.D17) # give them all to our driver -#display = Adafruit_SSD1608(200, 200, spi, # 1.54" 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_IL0373(152, 152, spi, # 1.54" 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_IL0373(104, 212, spi, # 2.13" Tri-color display - cs_pin=ecs, dc_pin=dc, sramcs_pin=srcs, - rst_pin=rst, busy_pin=busy) +# display = Adafruit_SSD1608(200, 200, spi, # 1.54" 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_IL0373(152, 152, spi, # 1.54" 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_IL0373( + 104, + 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! -#display.set_black_buffer(1, False) -#display.set_color_buffer(1, False) +# display.set_black_buffer(1, False) +# display.set_color_buffer(1, False) 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. draw = ImageDraw.Draw(image) @@ -60,17 +67,23 @@ draw.rectangle((0, 0, display.width, display.height), fill=BACKGROUND_COLOR) # Draw a smaller inner foreground rectangle -draw.rectangle((BORDER, BORDER, display.width - BORDER - 1, display.height - BORDER - 1), - fill=FOREGROUND_COLOR) +draw.rectangle( + (BORDER, BORDER, display.width - BORDER - 1, display.height - BORDER - 1), + fill=FOREGROUND_COLOR, +) # 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 text = "Hello World!" (font_width, font_height) = font.getsize(text) -draw.text((display.width//2 - font_width//2, display.height//2 - font_height//2), - text, font=font, fill=TEXT_COLOR) +draw.text( + (display.width // 2 - font_width // 2, display.height // 2 - font_height // 2), + text, + font=font, + fill=TEXT_COLOR, +) # Display image. display.image(image) diff --git a/examples/epd_pillow_image.py b/examples/epd_pillow_image.py index 026d425..615972e 100644 --- a/examples/epd_pillow_image.py +++ b/examples/epd_pillow_image.py @@ -11,9 +11,9 @@ import board from PIL import Image from adafruit_epd.il0373 import Adafruit_IL0373 -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.ssd1608 import Adafruit_SSD1608 # 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.ssd1608 import Adafruit_SSD1608 # pylint: disable=unused-import from adafruit_epd.ssd1675 import Adafruit_SSD1675 # pylint: disable=unused-import @@ -26,19 +26,26 @@ busy = digitalio.DigitalInOut(board.D17) # give them all to our driver -#display = Adafruit_SSD1608(200, 200, spi, # 1.54" 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_IL0373(152, 152, spi, # 1.54" 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_IL0373(104, 212, spi, # 2.13" Tri-color display - cs_pin=ecs, dc_pin=dc, sramcs_pin=srcs, - rst_pin=rst, busy_pin=busy) +# display = Adafruit_SSD1608(200, 200, spi, # 1.54" 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_IL0373(152, 152, spi, # 1.54" 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_IL0373( + 104, + 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! -#display.set_black_buffer(1, False) -#display.set_color_buffer(1, False) +# display.set_black_buffer(1, False) +# display.set_color_buffer(1, False) display.rotation = 1 diff --git a/examples/epd_shieldtest.py b/examples/epd_shieldtest.py index 7d61998..7cbef0c 100644 --- a/examples/epd_shieldtest.py +++ b/examples/epd_shieldtest.py @@ -11,16 +11,24 @@ spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) ecs = digitalio.DigitalInOut(board.D10) 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 print("Creating display") -display = Adafruit_IL91874(176, 264, spi, # 2.7" Tri-color display - cs_pin=ecs, dc_pin=dc, sramcs_pin=srcs, - rst_pin=None, busy_pin=None) +display = Adafruit_IL91874( + 176, + 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 + def read_buttons(): with AnalogIn(board.A3) as ain: reading = ain.value / 65535 @@ -34,6 +42,7 @@ def read_buttons(): return 2 return 1 + while True: button = read_buttons() if not button: @@ -50,11 +59,11 @@ def read_buttons(): display.display() if button == 3: print("Draw lines") - 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, 0, display.width - 1, display.height - 1, Adafruit_EPD.BLACK) + display.line(0, display.height - 1, display.width - 1, 0, Adafruit_EPD.RED) display.display() if button == 4: print("Draw text") - display.text('hello world', 25, 10, Adafruit_EPD.BLACK) + display.text("hello world", 25, 10, Adafruit_EPD.BLACK) display.display() time.sleep(0.01) diff --git a/examples/epd_simpletest.py b/examples/epd_simpletest.py index 2f6052d..6ba2280 100644 --- a/examples/epd_simpletest.py +++ b/examples/epd_simpletest.py @@ -12,25 +12,32 @@ spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) ecs = digitalio.DigitalInOut(board.D12) dc = digitalio.DigitalInOut(board.D11) -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 -busy = digitalio.DigitalInOut(board.D5) # can be None to not use this pin +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 +busy = digitalio.DigitalInOut(board.D5) # can be None to not use this pin # give them all to our driver print("Creating 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_IL91874(176, 264, spi, # 2.7" 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_IL0398(400, 300, spi, # 4.2" Tri-color display -display = Adafruit_IL0373(104, 212, spi, # 2.13" Tri-color display - cs_pin=ecs, dc_pin=dc, sramcs_pin=srcs, - rst_pin=rst, busy_pin=busy) +# display = Adafruit_SSD1608(200, 200, spi, # 1.54" 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_IL0373(152, 152, spi, # 1.54" 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_IL0373( + 104, + 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! -#display.set_black_buffer(1, False) -#display.set_color_buffer(1, False) +# display.set_black_buffer(1, False) +# display.set_color_buffer(1, False) display.rotation = 1 @@ -44,9 +51,9 @@ display.rect(0, 0, 20, 30, Adafruit_EPD.BLACK) print("Draw lines") -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, 0, display.width - 1, display.height - 1, Adafruit_EPD.BLACK) +display.line(0, display.height - 1, display.width - 1, 0, Adafruit_EPD.RED) print("Draw text") -display.text('hello world', 25, 10, Adafruit_EPD.BLACK) +display.text("hello world", 25, 10, Adafruit_EPD.BLACK) display.display() diff --git a/setup.py b/setup.py index f61cf29..1ffc192 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,7 @@ # Always prefer setuptools over distutils from setuptools import setup, find_packages + # To use a consistent encoding from codecs import open from os import path @@ -14,48 +15,42 @@ here = path.abspath(path.dirname(__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() setup( - name='adafruit-circuitpython-epd', - + name="adafruit-circuitpython-epd", use_scm_version=True, - setup_requires=['setuptools_scm'], - - description='CircuitPython library for EPD e-ink displays.', + setup_requires=["setuptools_scm"], + description="CircuitPython library for EPD e-ink displays.", long_description=long_description, - long_description_content_type='text/x-rst', - + long_description_content_type="text/x-rst", # The project's main homepage. - url='https://github.com/adafruit/Adafruit_CircuitPython_EPD', - + url="https://github.com/adafruit/Adafruit_CircuitPython_EPD", # Author details - author='Adafruit Industries', - author_email='circuitpython@adafruit.com', - - install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-busdevice', - 'adafruit-circuitpython-framebuf'], - + author="Adafruit Industries", + author_email="circuitpython@adafruit.com", + install_requires=[ + "Adafruit-Blinka", + "adafruit-circuitpython-busdevice", + "adafruit-circuitpython-framebuf", + ], # Choose your license - license='MIT', - + license="MIT", # See https://pypi.python.org/pypi?%3Aaction=list_classifiers classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Topic :: Software Development :: Libraries', - 'Topic :: System :: Hardware', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries", + "Topic :: System :: Hardware", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", ], - # 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 # simple. Or you can use find_packages(). - packages=['adafruit_epd'], + packages=["adafruit_epd"], )