Skip to content

Fix for issue #19 OverflowError: value must fit in 1 byte(s) #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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