diff options
Diffstat (limited to 'lcd-ipaddress-display/dispip.py')
| -rw-r--r-- | lcd-ipaddress-display/dispip.py | 20 | 
1 files changed, 20 insertions, 0 deletions
| diff --git a/lcd-ipaddress-display/dispip.py b/lcd-ipaddress-display/dispip.py new file mode 100644 index 0000000..22b044c --- /dev/null +++ b/lcd-ipaddress-display/dispip.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python + +import drivers +from time import sleep +from subprocess import check_output + +display = drivers.Lcd() + +try: +    # Retrieve the IP address +    IP = check_output(["hostname", "-I"]).split()[0].decode() +    print("Writing to display") +    while True: +        display.lcd_display_string("IP Address: ", 1) +        display.lcd_display_string(str(IP), 2)  # Display the IP address on the second line +        # sleep(1)  # Uncomment the following line to loop with 1 sec delay +except KeyboardInterrupt: +    # If there is a KeyboardInterrupt (when you press ctrl+c), exit the program and cleanup +    print("Cleaning up!") +    display.lcd_clear() | 
