Skip to content

Instantly share code, notes, and snippets.

@aansubarkah
Created January 16, 2016 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aansubarkah/11e1365403bcf5a99e12 to your computer and use it in GitHub Desktop.
Save aansubarkah/11e1365403bcf5a99e12 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
from Adafruit_CharLCD import Adafruit_CharLCD
from subprocess import *
from time import sleep, strftime
from datetime import datetime
lcd = Adafruit_CharLCD()
cmd = "ip addr show eth0 | grep inet | awk '{print $2}' | cut -d/ -f1" # linux command to get ip address
# columns, lines
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('%d %b %H:%M\n')) # 1st row, display current time
lcd.message('IP %s' % (ipaddr)) # 2nd row, display an ip address
sleep(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment