Skip to content

Instantly share code, notes, and snippets.

@possan
Created September 1, 2013 18:23
Show Gist options
  • Save possan/6406273 to your computer and use it in GitHub Desktop.
Save possan/6406273 to your computer and use it in GitHub Desktop.
Led test for chromebook pixel lightbar
#!/bin/bash
led() {
IDX=$1
RGB=$2
# echo "led $IDX $RGB"
R="${RGB:0:1}"
G="${RGB:1:1}"
B="${RGB:2:1}"
# echo "set led $IDX to $R,$G,$B"
RR="$R$R"
GG="$G$G"
BB="$B$B"
# echo "set led $IDX to $RR,$GG,$BB"
/usr/sbin/ectool lightbar $IDX $RR $GG $BB
}
bar() {
C0=$1
C1=$2
C2=$3
C3=$4
DEL=$5
echo "set bar to $C0 $C1 $C2 $C3"
led "0" "$C0"
led "1" "$C1"
led "2" "$C2"
led "3" "$C3"
# echo "delay $DEL seconds."
sleep $DEL
}
/usr/sbin/ectool lightbar on
/usr/sbin/ectool lightbar seq stop
D=0.05
I=0
O=2
SCALE=(\
"100" \
"200" \
"300" \
"400" \
"600" \
"820" \
"a31" \
"c42" \
"f53" \
"c42" \
"a31" \
"820" \
"600" \
"400" \
"300" \
"200" \
"100" \
"000" \
"000" \
"000" \
"000" \
"000" \
"000" \
"000" \
"000" \
"000" \
"000" \
"000" \
"000" \
"000" \
"000" \
"000" \
)
SCALELEN=30
while [ 1 ]; do
echo "Forward..."
# forward
for I in {0..25}; do
# while [ 1 ]; do
O1=$((($I + 30 - $O * 1) % $SCALELEN))
O2=$((($I + 30 - $O * 2) % $SCALELEN))
O3=$((($I + 30 - $O * 3) % $SCALELEN))
O4=$((($I + 30 - $O * 4) % $SCALELEN))
bar ${SCALE[$O1]} ${SCALE[$O2]} ${SCALE[$O3]} ${SCALE[$O4]} $D
# let I=I+1
done;
echo "Back..."
for I in {0..25}; do
# while [ 1 ]; do
O1=$((($I + 30 - $O * 4) % $SCALELEN))
O2=$((($I + 30 - $O * 3) % $SCALELEN))
O3=$((($I + 30 - $O * 2) % $SCALELEN))
O4=$((($I + 30 - $O * 1) % $SCALELEN))
bar ${SCALE[$O1]} ${SCALE[$O2]} ${SCALE[$O3]} ${SCALE[$O4]} $D
# let I=I+1
done;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment