From 464f489ebdb3410de923ba70a0a018cb9850260b Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 28 May 2019 14:38:17 +0200 Subject: [PATCH] Fixed loop issue --- Calendar/EpdAdapter.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Calendar/EpdAdapter.py b/Calendar/EpdAdapter.py index 4817561..3f1037b 100644 --- a/Calendar/EpdAdapter.py +++ b/Calendar/EpdAdapter.py @@ -157,9 +157,14 @@ class EpdAdapter (DisplayAdapter): self.send_command(DEEP_SLEEP) self.send_data(0xa5) - def wait_until_idle (self): - while(self.digital_read(self.busy_pin) == 0): # 0: busy, 1: idle - self.delay_ms(100) + def wait_until_idle (self, max_wait_seconds = 60): + wait_ms = 100 + count = 0 + while(self.digital_read(self.busy_pin) == 0 and wait_ms * count < max_wait_seconds * 1000): # 0: busy, 1: idle + self.delay_ms(wait_ms) + count += 1 + if wait_ms * count >= max_wait_seconds * 1000: + print("Skipped idle confirmation") def reset (self): self.digital_write(self.reset_pin, GPIO.LOW) # module reset