Created
June 29, 2013 09:45
-
-
Save sunng87/5890563 to your computer and use it in GitHub Desktop.
Displaying IP address of wlan0 on LCD.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 -4 addr show wlan0 | grep inet | awk '{print $2}' | cut -d/ -f1" | |
lcd.begin(16,1) | |
def run_cmd(cmd): | |
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE) | |
output = p.communicate()[0] | |
if p.returncode != 0: | |
return None | |
return output | |
lcd.message("Obtaining IP\n") | |
lcd.message("...") | |
while 1: | |
lcd.clear() | |
ipaddr = run_cmd(cmd) | |
if ipaddr: | |
lcd.message("wlan0 IP Addr:\n") | |
lcd.message(ipaddr) | |
break | |
sleep(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment