Skip to content

Commit 76d602b

Browse files
check for LCD and exit if not found
1 parent f556443 commit 76d602b

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

lcdprint.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ def lcdPrint(passedIn):
2727
while i2c.try_lock():
2828
pass
2929

30+
if DEFAULT_I2C_ADDR not in i2c.scan():
31+
print("LCD not found at address: ",hex(DEFAULT_I2C_ADDR))
32+
i2c.unlock()
33+
return
34+
3035
# 2 lines, 16 characters per line
3136
lcd = I2cLcd(i2c, DEFAULT_I2C_ADDR, 2, 16)
3237

lcdscroll.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ def kbdInterrupt():
5151
while i2c.try_lock():
5252
pass
5353

54+
if DEFAULT_I2C_ADDR not in i2c.scan():
55+
print("LCD not found at address: ",hex(DEFAULT_I2C_ADDR))
56+
i2c.unlock()
57+
return
58+
5459
# 2 lines, 16 characters per line
5560
lcd = I2cLcd(i2c, DEFAULT_I2C_ADDR, 2, 16)
5661

0 commit comments

Comments
 (0)