mirror of
https://gitlab.sectorq.eu/jaydee/python.git
synced 2025-12-14 02:34:53 +01:00
init
This commit is contained in:
47
test.py
Normal file
47
test.py
Normal file
@@ -0,0 +1,47 @@
|
||||
# Import LCD library
|
||||
from RPLCD import i2c
|
||||
import psutil
|
||||
|
||||
# Import sleep library
|
||||
from time import sleep
|
||||
|
||||
# constants to initialise the LCD
|
||||
lcdmode = 'i2c'
|
||||
cols = 20
|
||||
rows = 4
|
||||
charmap = 'A00'
|
||||
i2c_expander = 'PCF8574'
|
||||
|
||||
# Generally 27 is the address;Find yours using: i2cdetect -y 1
|
||||
address = 0x27
|
||||
port = 0 # 0 on an older Raspberry Pi
|
||||
|
||||
# Initialise the LCD
|
||||
lcd = i2c.CharLCD(i2c_expander, address, port=port, charmap=charmap,
|
||||
cols=cols, rows=rows)
|
||||
|
||||
|
||||
while True:
|
||||
myCmd = ""
|
||||
# Write a string on first line and move to next line
|
||||
mem_data = psutil.virtual_memory()
|
||||
net_sum = psutil.net_if_addrs()["eth0"]
|
||||
eth0_ip = (net_sum[0][1])
|
||||
cpu_load = round(psutil.getloadavg(),2)
|
||||
print(cpu_load[0])
|
||||
lcd.backlight_enabled = True
|
||||
lcd.cursor_pos = (0, 0)
|
||||
lcd.write_string('Memory : ' + str(mem_data.percent))
|
||||
lcd.crlf()
|
||||
lcd.write_string('IP : ' + str(eth0_ip))
|
||||
lcd.crlf()
|
||||
lcd.write_string('Phppot')
|
||||
lcd.crlf()
|
||||
lcd.write_string("CPU: " + str(cpu_load))
|
||||
sleep(5)
|
||||
#lcd.clear()
|
||||
# Switch off backlight
|
||||
#lcd.backlight_enabled = False
|
||||
#sleep(3)
|
||||
# Clear the LCD screen
|
||||
#lcd.close(clear=True)
|
||||
Reference in New Issue
Block a user