Last active
December 8, 2016 16:36
-
-
Save mperlet/1840c628ba7934b8785540ea2fa53af4 to your computer and use it in GitHub Desktop.
blinkstrip-show-percentage.sh
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
#!/bin/bash | |
COLOR=red | |
NUMOFLEDS=7 | |
function setLed() { | |
blinkstick --channel 0 --index $1 $3 --brightness=$2 | |
} | |
function makeled() { | |
led=$1 | |
bri=$2 | |
# reset leds | |
for i in $(seq $(expr $led + 1) $NUMOFLEDS) | |
do | |
setLed $i 0 $COLOR | |
done | |
# set prev leds | |
for i in $(seq 0 $(expr $led - 1)) | |
do | |
setLed $i 100 $COLOR | |
done | |
# set last led | |
setLed $led $bri $COLOR | |
} | |
if [[ !$# -eq 1 ]] | |
then | |
echo "./pb <percent>" | |
exit 1 | |
fi | |
v=$(expr $1 \* $NUMOFLEDS) | |
lednr=$(expr $v / 100) | |
ledbri=$(expr $v % 100) | |
if [[ $lednr -eq $NUMOFLEDS ]] | |
then | |
lednr=7 | |
ledbri=100 | |
fi | |
makeled $lednr $ledbri |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
show cpu load: