DM: fix some pylint stuff
This commit is contained in:
parent
b0727ae67f
commit
59bfc3f68f
3 changed files with 24 additions and 37 deletions
|
|
@ -76,16 +76,14 @@ class Adafruit_EPD(object):
|
||||||
def draw_pixel(self, x, y, color):
|
def draw_pixel(self, x, y, color):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_pixel(self, x, y):
|
|
||||||
pass
|
|
||||||
|
|
||||||
#framebuf methods
|
#framebuf methods
|
||||||
def fill(self, color):
|
def fill(self, color):
|
||||||
self.fill_rect(self, 0, 0, self.width, self.height, color)
|
self.fill_rect(self, 0, 0, self.width, self.height, color)
|
||||||
|
|
||||||
def fill_rect(self, x, y, width, height, color):
|
def fill_rect(self, x, y, width, height, color):
|
||||||
if width < 1 or height < 1 or (x+width) <= 0 or (y+height) <= 0 \
|
if width < 1 or height < 1 or (x+width) <= 0:
|
||||||
or y >= self.height or x >= self.width:
|
return
|
||||||
|
if (y+height) <= 0 or y >= self.height or x >= self.width:
|
||||||
return
|
return
|
||||||
xend = min(self.width, x+width)
|
xend = min(self.width, x+width)
|
||||||
yend = min(self.height, y+height)
|
yend = min(self.height, y+height)
|
||||||
|
|
@ -99,8 +97,10 @@ class Adafruit_EPD(object):
|
||||||
def pixel(self, x, y, color=None):
|
def pixel(self, x, y, color=None):
|
||||||
if x < 0 or x >= self.width or y < 0 or y >= self.height:
|
if x < 0 or x >= self.width or y < 0 or y >= self.height:
|
||||||
return None
|
return None
|
||||||
if color is None:
|
#TODO: figure this out when we know what framebuffer we
|
||||||
return self.get_pixel(self, x, y)
|
# will actually use
|
||||||
|
#if color is None:
|
||||||
|
# return self.get_pixel(self, x, y)
|
||||||
|
|
||||||
self.draw_pixel(self, x, y, color)
|
self.draw_pixel(self, x, y, color)
|
||||||
return None
|
return None
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ class Adafruit_IL0373(Adafruit_EPD):
|
||||||
|
|
||||||
while not self.spi_device.try_lock():
|
while not self.spi_device.try_lock():
|
||||||
pass
|
pass
|
||||||
self.sram._cs.value = False
|
self.sram.cs_pin.value = False
|
||||||
#send read command
|
#send read command
|
||||||
self.spi_device.write(bytearray([Adafruit_MCP_SRAM.SRAM_READ]))
|
self.spi_device.write(bytearray([Adafruit_MCP_SRAM.SRAM_READ]))
|
||||||
#send start address
|
#send start address
|
||||||
|
|
@ -98,15 +98,15 @@ class Adafruit_IL0373(Adafruit_EPD):
|
||||||
self._dc.value = True
|
self._dc.value = True
|
||||||
xfer = bytearray([cmd])
|
xfer = bytearray([cmd])
|
||||||
outbuf = bytearray(1)
|
outbuf = bytearray(1)
|
||||||
for i in range(self.bw_bufsize):
|
for _ in range(self.bw_bufsize):
|
||||||
outbuf[0] = xfer[0]
|
outbuf[0] = xfer[0]
|
||||||
self.spi_device.write_readinto(outbuf, xfer)
|
self.spi_device.write_readinto(outbuf, xfer)
|
||||||
self._cs.value = True
|
self._cs.value = True
|
||||||
self.sram._cs.value = True
|
self.sram.cs_pin.value = True
|
||||||
|
|
||||||
time.sleep(.002)
|
time.sleep(.002)
|
||||||
|
|
||||||
self.sram._cs.value = False
|
self.sram.cs_pin.value = False
|
||||||
#send read command
|
#send read command
|
||||||
self.spi_device.write(bytearray([Adafruit_MCP_SRAM.SRAM_READ]))
|
self.spi_device.write(bytearray([Adafruit_MCP_SRAM.SRAM_READ]))
|
||||||
#send start address
|
#send start address
|
||||||
|
|
@ -122,11 +122,11 @@ class Adafruit_IL0373(Adafruit_EPD):
|
||||||
self._dc.value = True
|
self._dc.value = True
|
||||||
xfer = bytearray([cmd])
|
xfer = bytearray([cmd])
|
||||||
outbuf = bytearray(1)
|
outbuf = bytearray(1)
|
||||||
for i in range(self.bw_bufsize):
|
for _ in range(self.bw_bufsize):
|
||||||
outbuf[0] = xfer[0]
|
outbuf[0] = xfer[0]
|
||||||
self.spi_device.write_readinto(outbuf, xfer)
|
self.spi_device.write_readinto(outbuf, xfer)
|
||||||
self._cs.value = True
|
self._cs.value = True
|
||||||
self.sram._cs.value = True
|
self.sram.cs_pin.value = True
|
||||||
self.spi_device.unlock()
|
self.spi_device.unlock()
|
||||||
|
|
||||||
self.update()
|
self.update()
|
||||||
|
|
@ -153,19 +153,6 @@ class Adafruit_IL0373(Adafruit_EPD):
|
||||||
self.sram.write8(addr, current)
|
self.sram.write8(addr, current)
|
||||||
return
|
return
|
||||||
|
|
||||||
def get_pixel(self, x, y, color):
|
|
||||||
if (x < 0) or (x >= self.width) or (y < 0) or (y >= self.height):
|
|
||||||
return None
|
|
||||||
|
|
||||||
if x == 0:
|
|
||||||
x = 1
|
|
||||||
|
|
||||||
addr = int(((self.width - x) * self.height + y)/8)
|
|
||||||
if color == Adafruit_EPD.RED:
|
|
||||||
addr = addr + self.bw_bufsize
|
|
||||||
current = self.sram.read8(addr)
|
|
||||||
return current
|
|
||||||
|
|
||||||
def clear_buffer(self):
|
def clear_buffer(self):
|
||||||
self.sram.erase(0x00, self.bw_bufsize, 0xFF)
|
self.sram.erase(0x00, self.bw_bufsize, 0xFF)
|
||||||
self.sram.erase(self.bw_bufsize, self.red_bufsize, 0xFF)
|
self.sram.erase(self.bw_bufsize, self.red_bufsize, 0xFF)
|
||||||
|
|
|
||||||
|
|
@ -13,14 +13,14 @@ class Adafruit_MCP_SRAM(object):
|
||||||
def __init__(self, cs_pin, spi):
|
def __init__(self, cs_pin, spi):
|
||||||
# Handle hardware SPI
|
# Handle hardware SPI
|
||||||
self.spi_device = spi
|
self.spi_device = spi
|
||||||
self._cs = cs_pin
|
self.cs_pin = cs_pin
|
||||||
|
|
||||||
self._cs.direction = digitalio.Direction.OUTPUT
|
self.cs_pin.direction = digitalio.Direction.OUTPUT
|
||||||
while not self.spi_device.try_lock():
|
while not self.spi_device.try_lock():
|
||||||
pass
|
pass
|
||||||
self._cs.value = False
|
self.cs_pin.value = False
|
||||||
self.spi_device.write(bytearray([Adafruit_MCP_SRAM.SRAM_WRSR, 0x43]))
|
self.spi_device.write(bytearray([Adafruit_MCP_SRAM.SRAM_WRSR, 0x43]))
|
||||||
self._cs.value = True
|
self.cs_pin.value = True
|
||||||
self.spi_device.unlock()
|
self.spi_device.unlock()
|
||||||
|
|
||||||
def write(self, addr, buf, reg=SRAM_WRITE):
|
def write(self, addr, buf, reg=SRAM_WRITE):
|
||||||
|
|
@ -28,9 +28,9 @@ class Adafruit_MCP_SRAM(object):
|
||||||
|
|
||||||
while not self.spi_device.try_lock():
|
while not self.spi_device.try_lock():
|
||||||
pass
|
pass
|
||||||
self._cs.value = False
|
self.cs_pin.value = False
|
||||||
self.spi_device.write(cmd)
|
self.spi_device.write(cmd)
|
||||||
self._cs.value = True
|
self.cs_pin.value = True
|
||||||
self.spi_device.unlock()
|
self.spi_device.unlock()
|
||||||
|
|
||||||
def read(self, addr, length, reg=SRAM_READ):
|
def read(self, addr, length, reg=SRAM_READ):
|
||||||
|
|
@ -39,10 +39,10 @@ class Adafruit_MCP_SRAM(object):
|
||||||
buf = bytearray(length)
|
buf = bytearray(length)
|
||||||
while not self.spi_device.try_lock():
|
while not self.spi_device.try_lock():
|
||||||
pass
|
pass
|
||||||
self._cs.value = False
|
self.cs_pin.value = False
|
||||||
self.spi_device.write(cmd)
|
self.spi_device.write(cmd)
|
||||||
self.spi_device.readinto(buf)
|
self.spi_device.readinto(buf)
|
||||||
self._cs.value = True
|
self.cs_pin.value = True
|
||||||
self.spi_device.unlock()
|
self.spi_device.unlock()
|
||||||
return buf
|
return buf
|
||||||
|
|
||||||
|
|
@ -64,9 +64,9 @@ class Adafruit_MCP_SRAM(object):
|
||||||
|
|
||||||
while not self.spi_device.try_lock():
|
while not self.spi_device.try_lock():
|
||||||
pass
|
pass
|
||||||
self._cs.value = False
|
self.cs_pin.value = False
|
||||||
self.spi_device.write(cmd)
|
self.spi_device.write(cmd)
|
||||||
for x in range(length):
|
for _ in range(length):
|
||||||
self.spi_device.write(bytearray([value]))
|
self.spi_device.write(bytearray([value]))
|
||||||
self._cs.value = True
|
self.cs_pin.value = True
|
||||||
self.spi_device.unlock()
|
self.spi_device.unlock()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue