Last active
July 7, 2017 10:49
-
-
Save raspberrycoulis/9979623eec9e5643abb38118d65e0e3d to your computer and use it in GitHub Desktop.
Display CPU usage on Pimoroni's Scroll pHAT HD
This file contains hidden or 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
#!/usr/bin/env python | |
import sys | |
import time | |
try: | |
import psutil | |
except ImportError: | |
sys.exit("This script requires the psutil module\nInstall with: sudo pip install psutil") | |
import scrollphathd as sphd | |
print(""" | |
Scroll pHAT HD: CPU | |
Displays a graph with CPU values. | |
Press Ctrl+C to exit! | |
""") | |
i = 0 | |
cpu_values = [0] * sphd.DISPLAY_WIDTH | |
sphd.rotate(180) | |
while True: | |
try: | |
cpu_values.pop(0) | |
cpu_values.append(psutil.cpu_percent()) | |
sphd.set_graph(cpu_values, low=0, high=25, brightness=0.25) | |
sphd.show() | |
time.sleep(0.2) | |
except KeyboardInterrupt: | |
sphd.clear() | |
sys.exit(-1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment