Last active
January 14, 2017 00:52
-
-
Save banditkroot/bda14d8a4eb230f2a3b0d101b7953260 to your computer and use it in GitHub Desktop.
CPU load with Codebug tether
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
#!/usr/bin/python3 | |
import codebug_tether | |
import psutil | |
import time | |
cb = codebug_tether.CodeBug('/dev/ttyACM0') | |
def setcol(x): | |
if x == 1: | |
return 0b11000 | |
if x == 2: | |
return 0b11100 | |
if x == 3: | |
return 0b11110 | |
if x == 4: | |
return 0b11111 | |
return 0b10000 | |
l0 = 0 | |
l1 = 0 | |
l2 = 0 | |
l3 = 0 | |
l4 = 0 | |
d = 0.01 | |
while True: | |
cpuload = (psutil.cpu_percent(interval = 1) // 20) - 1 | |
l0 = l1 | |
l1 = l2 | |
l2 = l3 | |
l3 = l4 | |
l4 = setcol(cpuload) | |
cb.set_col(0, l0) | |
cb.set_col(1, l1) | |
cb.set_col(2, l2) | |
cb.set_col(3, l3) | |
cb.set_col(4, l4) | |
time.sleep(d) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment