-
Notifications
You must be signed in to change notification settings - Fork 53
Example: Display CPU usage
arvydas edited this page Sep 21, 2014
·
4 revisions
This example shows how to display CPU usage with BlinkStick. Green = 0%, Amber = 50%, Red = 100%.
This tutorial requires psutil. Install it via:
pip install psutil
from blinkstick import blinkstick
import psutil
bstick = blinkstick.find_first()
if bstick is None:
print "No BlinkSticks found..."
else:
print "Displaying CPU usage (Green = 0%, Amber = 50%, Red = 100%)"
print "Press Ctrl+C to exit"
#go into a forever loop
while True:
cpu = psutil.cpu_percent(interval=1)
intensity = int(255 * cpu / 100)
bstick.set_color(intensity, 255 - intensity, 0)