Skip to content

Instantly share code, notes, and snippets.

@JeffersGlass
Created August 30, 2020 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JeffersGlass/2f00055507645a03431b1d8438268415 to your computer and use it in GitHub Desktop.
Save JeffersGlass/2f00055507645a03431b1d8438268415 to your computer and use it in GitHub Desktop.
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