summaryrefslogtreecommitdiff
path: root/lcd-ipaddress-display/dispip.py
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2023-04-22 23:31:40 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2023-04-22 23:31:40 +0530
commitc95424b6ecb771f57dbbacd59a69894c1150d4fd (patch)
treef53c721b839c1bcbe0accf418c435cdf31e78c18 /lcd-ipaddress-display/dispip.py
parent4633e624fdc4e61928b8c7743d9bbd50c5d75a6a (diff)
Adding 16x2 lcd drivers+IP Display script
Diffstat (limited to 'lcd-ipaddress-display/dispip.py')
-rw-r--r--lcd-ipaddress-display/dispip.py20
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()