-
-
Save JeffersGlass/2f00055507645a03431b1d8438268415 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from psutil import cpu_percent, net_io_counters | |
from gpiozero import LEDBarGraph | |
from time import sleep | |
graph = LEDBarGraph(12, 21, 20, pwm=True) | |
#Show CPU occupation percentage | |
while True: | |
graph.value = cpu_percent()/100 | |
sleep(.1) | |
#Show network activitiy | |
''' | |
oldBytes = net_io_counters().bytes_sent + net_io_counters().bytes_recv | |
while True: | |
newBytes = net_io_counters().bytes_sent + net_io_counters().bytes_recv | |
diff = newBytes - oldBytes | |
oldBytes = newBytes | |
print (newBytes) | |
graph.value = min(1, max(0, diff / 10000)) #constrain value to 0:1 | |
sleep(.1) | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment