display current time on default screen
This commit is contained in:
parent
9b948b0820
commit
b67ed823c2
10
pyLCDinfo.py
10
pyLCDinfo.py
|
@ -2,9 +2,10 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
""" Author: Hendrik Schutter, mail@hendrikschutter.com
|
""" Author: Hendrik Schutter, mail@hendrikschutter.com
|
||||||
Date of creation: 2022/05/23
|
Date of creation: 2022/05/23
|
||||||
Date of last modification: 2022/05/23
|
Date of last modification: 2022/10/17
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
from rpi_lcd import LCD
|
from rpi_lcd import LCD
|
||||||
import netifaces as ni
|
import netifaces as ni
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -43,6 +44,10 @@ def get_uptime():
|
||||||
|
|
||||||
return strftime("%H:%M:%S", gmtime(60*60*24))
|
return strftime("%H:%M:%S", gmtime(60*60*24))
|
||||||
|
|
||||||
|
|
||||||
|
def get_system_time():
|
||||||
|
return datetime.now().strftime("%H:%M")
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
if len(sys.argv) != 4:
|
if len(sys.argv) != 4:
|
||||||
|
@ -57,6 +62,7 @@ def main():
|
||||||
#print(get_wireguard_state(wireguard_interface))
|
#print(get_wireguard_state(wireguard_interface))
|
||||||
#print(get_disk_usage(disk_path))
|
#print(get_disk_usage(disk_path))
|
||||||
#print(get_uptime())
|
#print(get_uptime())
|
||||||
|
#print(get_system_time())
|
||||||
|
|
||||||
lcd.clear()
|
lcd.clear()
|
||||||
lcd.text(" Offsite Backup", 1)
|
lcd.text(" Offsite Backup", 1)
|
||||||
|
@ -94,6 +100,7 @@ def main():
|
||||||
state_ok = True
|
state_ok = True
|
||||||
lcd.clear()
|
lcd.clear()
|
||||||
lcd.text(" VPN connected ", 1)
|
lcd.text(" VPN connected ", 1)
|
||||||
|
lcd.text(get_system_time().rjust(16-len(get_system_time())), 2, align='left')
|
||||||
time.sleep(10.0)
|
time.sleep(10.0)
|
||||||
else:
|
else:
|
||||||
lcd.backlight(turn_on=False)
|
lcd.backlight(turn_on=False)
|
||||||
|
@ -117,6 +124,7 @@ def main():
|
||||||
|
|
||||||
lcd.clear()
|
lcd.clear()
|
||||||
lcd.text(" VPN Connected ", 1)
|
lcd.text(" VPN Connected ", 1)
|
||||||
|
lcd.text(get_system_time().rjust(16-len(get_system_time())), 2, align='left')
|
||||||
time.sleep(40.0) #sleep a lot to idle cpu
|
time.sleep(40.0) #sleep a lot to idle cpu
|
||||||
|
|
||||||
#check if wireguard is still connected
|
#check if wireguard is still connected
|
||||||
|
|
Loading…
Reference in New Issue