DM: fix some pylint stuff

This commit is contained in:
dean 2018-07-12 17:03:30 -04:00
parent b0727ae67f
commit 59bfc3f68f
3 changed files with 24 additions and 37 deletions

View file

@ -76,16 +76,14 @@ class Adafruit_EPD(object):
def draw_pixel(self, x, y, color):
pass
def get_pixel(self, x, y):
pass
#framebuf methods
def fill(self, color):
self.fill_rect(self, 0, 0, self.width, self.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 \
or y >= self.height or x >= self.width:
if width < 1 or height < 1 or (x+width) <= 0:
return
if (y+height) <= 0 or y >= self.height or x >= self.width:
return
xend = min(self.width, x+width)
yend = min(self.height, y+height)
@ -99,8 +97,10 @@ class Adafruit_EPD(object):
def pixel(self, x, y, color=None):
if x < 0 or x >= self.width or y < 0 or y >= self.height:
return None
if color is None:
return self.get_pixel(self, x, y)
#TODO: figure this out when we know what framebuffer we
# will actually use
#if color is None:
# return self.get_pixel(self, x, y)
self.draw_pixel(self, x, y, color)
return None

View file

@ -82,7 +82,7 @@ class Adafruit_IL0373(Adafruit_EPD):
while not self.spi_device.try_lock():
pass
self.sram._cs.value = False
self.sram.cs_pin.value = False
#send read command
self.spi_device.write(bytearray([Adafruit_MCP_SRAM.SRAM_READ]))
#send start address
@ -98,15 +98,15 @@ class Adafruit_IL0373(Adafruit_EPD):
self._dc.value = True
xfer = bytearray([cmd])
outbuf = bytearray(1)
for i in range(self.bw_bufsize):
for _ in range(self.bw_bufsize):
outbuf[0] = xfer[0]
self.spi_device.write_readinto(outbuf, xfer)
self._cs.value = True
self.sram._cs.value = True
self.sram.cs_pin.value = True
time.sleep(.002)
self.sram._cs.value = False
self.sram.cs_pin.value = False
#send read command
self.spi_device.write(bytearray([Adafruit_MCP_SRAM.SRAM_READ]))
#send start address
@ -122,11 +122,11 @@ class Adafruit_IL0373(Adafruit_EPD):
self._dc.value = True
xfer = bytearray([cmd])
outbuf = bytearray(1)
for i in range(self.bw_bufsize):
for _ in range(self.bw_bufsize):
outbuf[0] = xfer[0]
self.spi_device.write_readinto(outbuf, xfer)
self._cs.value = True
self.sram._cs.value = True
self.sram.cs_pin.value = True
self.spi_device.unlock()
self.update()
@ -153,19 +153,6 @@ class Adafruit_IL0373(Adafruit_EPD):
self.sram.write8(addr, current)
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):
self.sram.erase(0x00, self.bw_bufsize, 0xFF)
self.sram.erase(self.bw_bufsize, self.red_bufsize, 0xFF)

View file

@ -13,14 +13,14 @@ class Adafruit_MCP_SRAM(object):
def __init__(self, cs_pin, spi):
# Handle hardware 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():
pass
self._cs.value = False
self.cs_pin.value = False
self.spi_device.write(bytearray([Adafruit_MCP_SRAM.SRAM_WRSR, 0x43]))
self._cs.value = True
self.cs_pin.value = True
self.spi_device.unlock()
def write(self, addr, buf, reg=SRAM_WRITE):
@ -28,9 +28,9 @@ class Adafruit_MCP_SRAM(object):
while not self.spi_device.try_lock():
pass
self._cs.value = False
self.cs_pin.value = False
self.spi_device.write(cmd)
self._cs.value = True
self.cs_pin.value = True
self.spi_device.unlock()
def read(self, addr, length, reg=SRAM_READ):
@ -39,10 +39,10 @@ class Adafruit_MCP_SRAM(object):
buf = bytearray(length)
while not self.spi_device.try_lock():
pass
self._cs.value = False
self.cs_pin.value = False
self.spi_device.write(cmd)
self.spi_device.readinto(buf)
self._cs.value = True
self.cs_pin.value = True
self.spi_device.unlock()
return buf
@ -64,9 +64,9 @@ class Adafruit_MCP_SRAM(object):
while not self.spi_device.try_lock():
pass
self._cs.value = False
self.cs_pin.value = False
self.spi_device.write(cmd)
for x in range(length):
for _ in range(length):
self.spi_device.write(bytearray([value]))
self._cs.value = True
self.cs_pin.value = True
self.spi_device.unlock()