From c95424b6ecb771f57dbbacd59a69894c1150d4fd Mon Sep 17 00:00:00 2001 From: Saumit Dinesan Date: Sat, 22 Apr 2023 23:31:40 +0530 Subject: Adding 16x2 lcd drivers+IP Display script --- lcd-ipaddress-display/dispip.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lcd-ipaddress-display/dispip.py (limited to 'lcd-ipaddress-display/dispip.py') 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() -- cgit v1.2.3