Skip to content

Instantly share code, notes, and snippets.

@hogelog
Forked from MKnkgw/ipaddr.sh
Last active December 22, 2015 18:09
Show Gist options
  • Save hogelog/6511007 to your computer and use it in GitHub Desktop.
Save hogelog/6511007 to your computer and use it in GitHub Desktop.
#!/bin/sh
LCD=0x3e
LANG=
IP=`/sbin/ifconfig eth0 | grep "inet addr:" | cut -f2 -d : | cut -f1 -d " "`
echo "IP: $IP"
ip_char_at(){
ch=`echo $IP | cut -f$1 -d . | cut -c $2`
if [ -z $ch ]; then
echo 0x20
else
echo 0x3$ch
fi
}
IP1=`ip_char_at 1 1`
IP2=`ip_char_at 1 2`
IP3=`ip_char_at 1 3`
IP4=`ip_char_at 2 1`
IP5=`ip_char_at 2 2`
IP6=`ip_char_at 2 3`
IP7=`ip_char_at 3 1`
IP8=`ip_char_at 3 2`
IP9=`ip_char_at 3 3`
IP10=`ip_char_at 4 1`
IP11=`ip_char_at 4 2`
IP12=`ip_char_at 4 3`
sudo i2cset -y 1 $LCD 0x40 $IP1 $IP2 $IP3 0x2e $IP4 $IP5 $IP6 0x2e i
sudo i2cset -y 1 $LCD 0x00 0xc0 i
sudo i2cset -y 1 $LCD 0x40 0xa0 0xa0 $IP7 $IP8 $IP9 0x2e $IP10 $IP11 $IP12 i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment