Skip to content
Closed
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
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ python-i2c-lcd
### Setup

```
sudo apt-get install python-smbus i2c-tools
sudo apt-get install python3-smbus i2c-tools
sudo modprobe i2c-dev
sudo modprobe i2c-bcm2708
```
Expand All @@ -15,16 +15,22 @@ add `i2c-dev` to `/etc/modules`.
### Usage

```
python2 ./display.py line_1~line_2~line_3~line_4
python3 ./display.py line_1~line_2~line_3~line_4
# OR
chmod +x display.py
./display.py line_1~line2
```

or clock demo:


```
python2 ./datetime-test.py
python3 ./datetime-test.py
# OR
chmod +x datetime-test.py
./datetime-test.py
```

### Based on
* https://github.com/pimatic/pimatic/issues/271
* http://www.gejanssen.com/howto/i2c_display_2004_raspberrypi/index.html
* http://www.gejanssen.com/howto/i2c_display_2004_raspberrypi/index.html
11 changes: 7 additions & 4 deletions datetime-test.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import lcd
#!/usr/bin/env python3

from time import time
from time import sleep
from datetime import datetime
import lcddriver

lcd = lcd.lcd()
lcd = lcddriver.lcd()

#lcd.display_string("11111111111111111111222222222222222222223333333333333333333344444444444444444444", 1)
lcd.display_string("LCD", 1)
lcd.display_string("Hello World", 2)
lcd.clear()

while True:
dateString = datetime.now().strftime('%b %d %y')
timeString = datetime.now().strftime('%H:%M:%S')
lcd.display_string(dateString, 3)
lcd.display_string(timeString, 4)
lcd.display_string(dateString, 1)
lcd.display_string(timeString, 2)
sleep(1)
4 changes: 3 additions & 1 deletion display.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3

from lcddriver import lcd
import sys

Expand All @@ -22,4 +24,4 @@
line = line.replace('_', ' ')
if len(line) > 16 :
line = lines[0:16]
my_lcd.display_string(line, i+1)
my_lcd.display_string(line, i+1)