Created
April 3, 2015 13:57
-
-
Save rdmarsh/76a11d335fa07d5509b4 to your computer and use it in GitHub Desktop.
Silly program to light up LEDs on raspberrypi piface depending on system load
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/python | |
| #silly program to light up LEDs on raspberrypi piface depending on system load | |
| #basically multiplys load by x10, rounds, and lights up that many leds | |
| from time import sleep | |
| import pifacedigitalio | |
| import sys | |
| DELAY = 1.0 # seconds | |
| MAXLED = 8 | |
| MULTIPLIER = 10 | |
| if __name__ == "__main__": | |
| pifacedigital = pifacedigitalio.PiFaceDigital() | |
| while True: | |
| file = open('/proc/loadavg', 'r') | |
| line = file.readline() | |
| load = line.split( ) | |
| omin = float(load[0]) | |
| omin = round(omin * MULTIPLIER,0) | |
| omin = int(omin) | |
| if omin > MAXLED: | |
| omin = MAXLED | |
| for offled in range (omin,MAXLED): | |
| pifacedigital.leds[offled].turn_off() | |
| for onled in range(omin): | |
| pifacedigital.leds[onled].turn_on() | |
| sleep(DELAY) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment