python - Send message to LCD via Command Line argument using Raspberry Pi -
i have piece of code (from adafruit website) write chars lcd. there possibility of doing via command line arguments?
thank in advance.
code:
#!/usr/bin/python adafruit_charlcd import adafruit_charlcd subprocess import * time import sleep, strftime datetime import datetime lcd = adafruit_charlcd() 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)
the relevant code example is:
#!/usr/bin/python adafruit_charlcd import adafruit_charlcd lcd = adafruit_charlcd() lcd.begin(16,1) lcd.message(somekindofstring)
...where somekindofstring message. doesn't writing arbitrary hard. if it's more "how know command line arguments are?" aspect, want @ sys.argv (tutorial)
Comments
Post a Comment