From b45ee09a5e31b9f626a1b5e7591d23955961e420 Mon Sep 17 00:00:00 2001 From: Ed Watson Date: Thu, 6 Feb 2014 22:36:09 +0000 Subject: [PATCH 1/3] Adding clock example --- .../Adafruit_CharLCDPlate.py | 2 +- .../Adafruit_CharLCDPlate_IPclock_example.py | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100755 Adafruit_CharLCDPlate/Adafruit_CharLCDPlate_IPclock_example.py diff --git a/Adafruit_CharLCDPlate/Adafruit_CharLCDPlate.py b/Adafruit_CharLCDPlate/Adafruit_CharLCDPlate.py index 06b9300c..75315b54 100644 --- a/Adafruit_CharLCDPlate/Adafruit_CharLCDPlate.py +++ b/Adafruit_CharLCDPlate/Adafruit_CharLCDPlate.py @@ -439,7 +439,7 @@ def buttons(self): if __name__ == '__main__': - lcd = Adafruit_CharLCDPlate() + lcd = Adafruit_CharLCDPlate(busnum = 1) lcd.begin(16, 2) lcd.clear() lcd.message("Adafruit RGB LCD\nPlate w/Keypad!") diff --git a/Adafruit_CharLCDPlate/Adafruit_CharLCDPlate_IPclock_example.py b/Adafruit_CharLCDPlate/Adafruit_CharLCDPlate_IPclock_example.py new file mode 100755 index 00000000..94d52b1d --- /dev/null +++ b/Adafruit_CharLCDPlate/Adafruit_CharLCDPlate_IPclock_example.py @@ -0,0 +1,25 @@ +#!/usr/bin/python + +from Adafruit_CharLCDPlate import Adafruit_CharLCDPlate +from subprocess import * +from time import sleep, strftime +from datetime import datetime + +lcd = Adafruit_CharLCDPlate() + +# Quotes so it pick up only ipv4 address +cmd = "ip addr show eth0 | grep 'inet ' | awk '{print $2}' | cut -d/ -f1" + +lcd.begin(16,1) + +def run_cmd(cmd): + p = Popen(cmd, shell=True, stdout=PIPE) + output = p.communicate()[0] + return output + +while 1: + lcd.clear() + ipaddr = run_cmd(cmd) + lcd.message(datetime.now().strftime('%b %d %H:%M:%S\n')) + lcd.message('IP %s' % ( ipaddr ) ) + sleep(2) From f4cca078f08dcc8791c5efdebb1984e78416b082 Mon Sep 17 00:00:00 2001 From: Edmund Watson Date: Thu, 6 Feb 2014 22:43:42 +0000 Subject: [PATCH 2/3] Update README.md Adding what I have done --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index aba2ae53..48b82c68 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +Added + +Clock + IP example for Adafruit_CharLCDPlate + +Ed Watson (tactmaster) + Adafruit's Raspberry-Pi Python Code Library ============ Here is a growing collection of libraries and example python scripts From a921b436959be0e9e98b1aaeb45bebb1126def21 Mon Sep 17 00:00:00 2001 From: Edmund Watson Date: Thu, 6 Feb 2014 22:44:19 +0000 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 48b82c68..cae9a4a0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ Added - +============ Clock + IP example for Adafruit_CharLCDPlate Ed Watson (tactmaster)