Skip to content

Commit

Permalink
Merge pull request #35 from mariovisic/nice_to_cpu
Browse files Browse the repository at this point in the history
Reduce the CPU load when waiting for the display
  • Loading branch information
makermelissa committed Feb 11, 2020
2 parents dfcdd62 + 7b064da commit 1f18b62
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions adafruit_epd/epd.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self, width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy
# SPI interface (required)
self.spi_device = spi
while not self.spi_device.try_lock():
pass
time.sleep(0.01)
self.spi_device.configure(baudrate=1000000) # 1 Mhz
self.spi_device.unlock()

Expand All @@ -99,7 +99,7 @@ def display(self): # pylint: disable=too-many-branches

if self.sram:
while not self.spi_device.try_lock():
pass
time.sleep(0.01)
self.sram.cs_pin.value = False
#send read command
self._buf[0] = mcp_sram.Adafruit_MCP_SRAM.SRAM_READ
Expand All @@ -114,7 +114,7 @@ def display(self): # pylint: disable=too-many-branches
databyte = self.write_ram(0)

while not self.spi_device.try_lock():
pass
time.sleep(0.01)
self._dc.value = True

if self.sram:
Expand All @@ -131,7 +131,7 @@ def display(self): # pylint: disable=too-many-branches

if self.sram:
while not self.spi_device.try_lock():
pass
time.sleep(0.01)
self.sram.cs_pin.value = False
#send read command
self._buf[0] = mcp_sram.Adafruit_MCP_SRAM.SRAM_READ
Expand All @@ -147,7 +147,7 @@ def display(self): # pylint: disable=too-many-branches
databyte = self.write_ram(1)

while not self.spi_device.try_lock():
pass
time.sleep(0.01)
self._dc.value = True

if self.sram:
Expand Down Expand Up @@ -182,7 +182,7 @@ def command(self, cmd, data=None, end=True):
self._cs.value = False

while not self.spi_device.try_lock():
pass
time.sleep(0.01)
ret = self._spi_transfer(cmd)

if data is not None:
Expand Down
2 changes: 1 addition & 1 deletion adafruit_epd/il0373.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def busy_wait(self):
busy pin, or pausing"""
if self._busy:
while not self._busy.value:
pass
time.sleep(0.01)
else:
time.sleep(0.5)

Expand Down
2 changes: 1 addition & 1 deletion adafruit_epd/il91874.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def busy_wait(self):
busy pin, or pausing"""
if self._busy:
while not self._busy.value:
pass
time.sleep(0.01)
else:
time.sleep(0.5)

Expand Down

0 comments on commit 1f18b62

Please sign in to comment.