sys_info_extended.py aktualisiert
This commit is contained in:
@@ -29,6 +29,8 @@ def get_temp():
|
|||||||
temp = float(sp.getoutput("vcgencmd measure_temp").split("=")[1].split("'")[0])
|
temp = float(sp.getoutput("vcgencmd measure_temp").split("=")[1].split("'")[0])
|
||||||
return temp
|
return temp
|
||||||
|
|
||||||
|
def get_hostname():
|
||||||
|
return socket.gethostname()
|
||||||
|
|
||||||
def get_cpu():
|
def get_cpu():
|
||||||
return psutil.cpu_percent()
|
return psutil.cpu_percent()
|
||||||
@@ -105,9 +107,10 @@ def draw_bar_full(draw, line_num):
|
|||||||
|
|
||||||
def stats(device):
|
def stats(device):
|
||||||
with canvas(device) as draw:
|
with canvas(device) as draw:
|
||||||
temp = get_temp()
|
if datetime.now().second % (toggle_interval_seconds * 2) < toggle_interval_seconds:
|
||||||
draw_text(draw, 0, 0, "Temp")
|
draw_text(draw, 0, 0, get_hostname())
|
||||||
draw_text(draw, margin_x_figure, 0, "%s'C" % (format_percent(temp)))
|
else:
|
||||||
|
draw_text(draw, 0, 0, get_ip(network_interface_name))
|
||||||
|
|
||||||
cpu = get_cpu()
|
cpu = get_cpu()
|
||||||
draw_text(draw, 0, 1, "CPU")
|
draw_text(draw, 0, 1, "CPU")
|
||||||
@@ -136,8 +139,9 @@ def stats(device):
|
|||||||
if datetime.now().second % (toggle_interval_seconds * 2) < toggle_interval_seconds:
|
if datetime.now().second % (toggle_interval_seconds * 2) < toggle_interval_seconds:
|
||||||
draw_text(draw, 0, 4, get_uptime())
|
draw_text(draw, 0, 4, get_uptime())
|
||||||
else:
|
else:
|
||||||
draw_text(draw, 0, 4, get_ip(network_interface_name))
|
temp = get_temp()
|
||||||
|
draw_text(draw, 0, 4, "Temp")
|
||||||
|
draw_text(draw, margin_x_figure, 4, "%s'C" % (format_percent(temp)))
|
||||||
|
|
||||||
font_size = 12
|
font_size = 12
|
||||||
font_size_full = 10
|
font_size_full = 10
|
||||||
@@ -163,4 +167,4 @@ font_full = ImageFont.truetype(str(Path(__file__).resolve().parent.joinpath("fon
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
stats(device)
|
stats(device)
|
||||||
time.sleep(0.5)
|
time.sleep(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user