Skip to content

Commit 1f18b62

Browse files
authored
Merge pull request #35 from mariovisic/nice_to_cpu
Reduce the CPU load when waiting for the display
2 parents dfcdd62 + 7b064da commit 1f18b62

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

adafruit_epd/epd.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __init__(self, width, height, spi, cs_pin, dc_pin, sramcs_pin, rst_pin, busy
7272
# SPI interface (required)
7373
self.spi_device = spi
7474
while not self.spi_device.try_lock():
75-
pass
75+
time.sleep(0.01)
7676
self.spi_device.configure(baudrate=1000000) # 1 Mhz
7777
self.spi_device.unlock()
7878

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

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

116116
while not self.spi_device.try_lock():
117-
pass
117+
time.sleep(0.01)
118118
self._dc.value = True
119119

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

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

149149
while not self.spi_device.try_lock():
150-
pass
150+
time.sleep(0.01)
151151
self._dc.value = True
152152

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

184184
while not self.spi_device.try_lock():
185-
pass
185+
time.sleep(0.01)
186186
ret = self._spi_transfer(cmd)
187187

188188
if data is not None:

adafruit_epd/il0373.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def busy_wait(self):
9696
busy pin, or pausing"""
9797
if self._busy:
9898
while not self._busy.value:
99-
pass
99+
time.sleep(0.01)
100100
else:
101101
time.sleep(0.5)
102102

adafruit_epd/il91874.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def busy_wait(self):
105105
busy pin, or pausing"""
106106
if self._busy:
107107
while not self._busy.value:
108-
pass
108+
time.sleep(0.01)
109109
else:
110110
time.sleep(0.5)
111111

0 commit comments

Comments
 (0)