Last active
February 3, 2017 11:22
-
-
Save argrento/d3da244650f71dc9a9e8fc7697ed3466 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Copyright 2017 Kirill Snezhko | |
# MIT License | |
# Small script that blinks ip-address of your Orange Pi Zero | |
# blink led red_led | |
# we need root to do this | |
function strobe { | |
echo 1 > "/sys/class/leds/red_led/brightness" | |
sleep $1 | |
echo 0 > "/sys/class/leds/red_led/brightness" | |
sleep $1 | |
} | |
# display quarter of a ip address | |
function draw_number { | |
# split string to letters | |
DIGITS="$(grep -o . <<<$1)" | |
# blink every digit | |
for DIGIT in ${DIGITS[@]} | |
do | |
# blink 10 times for zero | |
if [$DIGIT == 0] | |
then | |
$DIGIT = 10 | |
fi | |
for ((i=1; i<=$DIGIT; i++)); do | |
strobe 0.2 | |
done | |
# medium blink between didits | |
sleep 1 | |
strobe 1 | |
done | |
# large blink between quarters | |
sleep 2 | |
strobe 2 | |
} | |
# get all ip addresses | |
IPS="$(hostname -I)" | |
# ready to go? | |
sleep 5 | |
# IPS is splitted by the whitespace | |
for IP in $IPS | |
do | |
# replace "." with " " and split again | |
QUARTERS=(${IP//./ }) | |
for QUARTER in ${QUARTERS[@]} | |
do | |
draw_number $QUARTER | |
done | |
sleep 1 | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment