Skip to content

Commit 4bcb9d7

Browse files
committed
* Implement sub-second sleep function, hal_sleep_us() for i2c (intended for CPython). * Document with a comment to help with future failures on platforms that are missing `time.sleep_us()`
1 parent 4376476 commit 4bcb9d7

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lcd/i2c_lcd.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ def hal_backlight_off(self):
6060
"""Allows the hal layer to turn the backlight off."""
6161
self.bus.write_byte(self.i2c_addr, 0)
6262

63+
def hal_sleep_us(self, usecs):
64+
"""Sleep for some time (given in microseconds)."""
65+
time.sleep(usecs / 1000000)
66+
6367
def hal_write_command(self, cmd):
6468
"""Writes a command to the LCD.
6569

lcd/lcd_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,4 @@ def hal_write_data(self, data):
205205

206206
def hal_sleep_us(self, usecs):
207207
"""Sleep for some time (given in microseconds)."""
208-
time.sleep_us(usecs)
208+
time.sleep_us(usecs) # NOTE this is not part of Standard Python library, specific hal layers will need to override this

0 commit comments

Comments
 (0)