Skip to content

Commit

Permalink
Merge pull request #20 from mrmcwethy/issue19
Browse files Browse the repository at this point in the history
Fix for issue #19 OverflowError:  value must fit in 1 byte(s)
  • Loading branch information
makermelissa committed May 20, 2019
2 parents efdd7d3 + b900b30 commit ecdede6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions adafruit_epd/epd.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ def display(self): # pylint: disable=too-many-branches
#send read command
self._buf[0] = mcp_sram.Adafruit_MCP_SRAM.SRAM_READ
#send start address
self._buf[1] = self._buffer1_size >> 8
self._buf[2] = self._buffer1_size
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()

Expand Down
12 changes: 6 additions & 6 deletions adafruit_epd/mcp_sram.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def get_view(self, offset):
def write(self, addr, buf, reg=SRAM_WRITE):
"""write the passed buffer to the passed address"""
self._buf[0] = reg
self._buf[1] = addr >> 8
self._buf[2] = addr
self._buf[1] = (addr >> 8) & 0xFF
self._buf[2] = addr & 0xFF

with self._spi as spi:
spi.write(self._buf, end=3) # pylint: disable=no-member
Expand All @@ -81,8 +81,8 @@ def write(self, addr, buf, reg=SRAM_WRITE):
def read(self, addr, length, reg=SRAM_READ):
"""read passed number of bytes at the passed address"""
self._buf[0] = reg
self._buf[1] = addr >> 8
self._buf[2] = addr
self._buf[1] = (addr >> 8) & 0xFF
self._buf[2] = addr & 0xFF

buf = bytearray(length)
with self._spi as spi:
Expand Down Expand Up @@ -110,8 +110,8 @@ def write16(self, addr, value, reg=SRAM_WRITE):
def erase(self, addr, length, value):
"""erase the passed number of bytes starting at the passed address"""
self._buf[0] = Adafruit_MCP_SRAM.SRAM_WRITE
self._buf[1] = addr >> 8
self._buf[2] = addr
self._buf[1] = (addr >> 8) & 0xFF
self._buf[2] = addr & 0xFF
fill = bytearray([value])
with self._spi as spi:
spi.write(self._buf, end=3) # pylint: disable=no-member
Expand Down

0 comments on commit ecdede6

Please sign in to comment.