Skip to content

Reduce the CPU load when waiting for the display #35

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 2 commits into from
Feb 11, 2020
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
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