#!/bin/sh
ChangeLines()
{
#echo -e "\033)11\064\06$nLineCount" > /var/ttyUSB0
#Print line number in protected mode
#echo -e "\033\046 " > /var/ttyUSB0
#echo -e "\033=01\035\046$nLineCount|\033\047\c" > /var/ttyUSB0
let "nActualLineCount = $nLineCount"
echo -e "\033)114\06$nLineCount" > /var/ttyUSB0
if [ "$nLineCount" = "$Lines" ]; then
echo "Lines Max"
nLineCount=1
else
echo "Lines Max++"
let "nLineCount += 1"
fi
}
Weather()
{
cd /var/media/ftp/ROOT/Bin
CURRENTTEMPSOURCE="http://www.donnerwetter.de/region/region.hts?plz=93422"
MORGENTEMPSOURCE="http://www.donnerwetter.de/region/morgen.hts?plz=93422"
tmp_file="/var/weather.tmp"
wget -O $tmp_file $CURRENTTEMPSOURCE
#set -- $(cat ./weather.tmp |grep "\"#5282C6\" class" |sed 's/.*center">//' | sed 's/<\/td>//')
#echo Par1=$1
#echo Par2=$2
#echo Par3=$3
#echo Par4=$4
i=0
strR="Weather today: "
strR=""
for str1 in $(cat $tmp_file | sed -n "s/^.*#5282C6.*class.*center\">\([A-Za-zьц]*\)<.*$/\1/p"); do
if [ "$i" -lt "4" ]; then
strR="$strR$str1"
#strR=$strR1
echo "str1:$str1"
#Get Weather type for Id i
j=0
for str2 in $(cat $tmp_file | sed -n "s/^.*wetsym_.*alt=\"\([a-zьц]*\)\".*$/\1/p"); do
if [ "$i" = "$j" ]; then
echo "Yess!!!str2: $str2"
strR=$(echo "$strR:$str2")
#strR=$strR1
echo "$strR"
else
echo "str2:$str2"
fi
let "j += 1"
done
k=0
for str3 in $(cat $tmp_file | sed -n "s/^.*#FFF384.*center\">\([-0-9]*\)°.*$/\1/p"); do
if [ "$i" = "$k" ]; then
echo "Yess!!!str3:$str3"
strR=$(echo "$strR $str3 ")
#strR=$strR1
echo "$strR"
else
echo "str3:$str3"
fi
let "k += 1"
done
fi
let "i += 1"
done
#Get current day
strD=$(cat $tmp_file |grep "<strong>[A-Za-z ,]*, [0-9]" | sed -n "s/^.*<strong>\([A-Za-z ,]*, [0-9].*\)<\/strong.*$/\1/p")
strR=$(echo "WETTER HEUTE($strD) $strR")
echo "$strR"
#strR=$(echo "$strR \n")
echo -e "\033(1 $strR" > /var/ttyUSB0
##############Get weather for morning
wget -O $tmp_file $MORGENTEMPSOURCE
#set -- $(cat $tmp_file |grep "\"#5282C6\" class" |sed 's/.*center">//' | sed 's/<\/td>//')
#echo Par1=$1
#echo Par2=$2
#echo Par3=$3
#echo Par4=$4
i=0
strR="Weather today: "
strR=""
for str1 in $(cat $tmp_file | sed -n "s/^.*#5282C6.*class.*center\">\([A-Za-zьц]*\)<.*$/\1/p"); do
if [ "$i" -lt "4" ]; then
strR="$strR$str1"
#strR=$strR1
echo "str1:$str1"
#Get Weather type for Id i
j=0
for str2 in $(cat $tmp_file | sed -n "s/^.*wetsym_.*alt=\"\([a-zьц]*\)\".*$/\1/p"); do
if [ "$i" = "$j" ]; then
echo "Yess!!!str2: $str2"
strR=$(echo "$strR:$str2")
#strR=$strR1
echo "$strR"
else
echo "str2:$str2"
fi
let "j += 1"
done
k=0
for str3 in $(cat $tmp_file | sed -n "s/^.*#FFF384.*center\">\([-0-9]*\)°.*$/\1/p"); do
if [ "$i" = "$k" ]; then
echo "Yess!!!str3:$str3"
strR=$(echo "$strR $str3 ")
#strR=$strR1
echo "$strR"
else
echo "str3:$str3"
fi
let "k += 1"
done
fi
let "i += 1"
done
#Get current day
strD=$(cat $tmp_file |grep "<strong>[A-Za-z ,]*, [0-9]" | sed -n "s/^.*<strong>\([A-Za-z ,]*, [0-9].*\)<\/strong.*$/\1/p")
strR=$(echo "WETTER MORGEN($strD)$strR")
echo "$strR"
#strR=$(echo "$strR \n")
echo -e "\033(2 $strR" > /var/ttyUSB0
#Turn cursor off
#echo -e "\033\140\001" > /var/ttyUSB0
#echo -e "\033=90" > /var/ttyUSB0
#echo -e "\033)11\064\061" > /var/ttyUSB0
#if [ "$bScrollStarted" = "0" ]; then
# bScrollStarted=1
# echo "Start Scrolling"
#echo -e "\033)11\064\061" > /var/ttyUSB0
#else
# echo "Scroll is already started"
#fi
}
Display()
{
while [ 1 ]; do
#Stop Scrolling
#echo -e "\033%1\c" > /var/ttyUSB0
#sleep 1
#echo -e "\033=00`date +%H:%M`" > /var/ttyUSB0
#date +"%H:%M\c" > /var/ttyUSB0
#start Scrolling
#echo -e "\033)11\064\061\c" > /var/ttyUSB0
let "nW += 1"
let "nL += 1"
echo "nW=$nW ; WeatherDelay=$WeatherDelay ; nL= $nL; nLineCount=$nLineCount"
if [ "$nW" = "$WeatherDelay" ]; then
echo "Call Weather"
nW=0
Weather
fi
if [ "$nL" = "$LinesDelay" ]; then
echo "ChangeLines"
nL=0
ChangeLines
fi
echo -e "\033=00$nActualLineCount| `date +%D_%H:%M`" > /var/ttyUSB0
sleep 30
done
}
cd /var/media/ftp/ROOT/Bin
sleep 1
#autoscroll off
echo -e "\033N" > /var/ttyUSB0
sleep 1
#brilliance
echo -e "\033G7" > /var/ttyUSB0
sleep 1
#cursor off
echo -e "\033\140\001" > /var/ttyUSB0
sleep 1
nW=0
nL=0
nActualLineCount=0
nLineCount=1
WeatherDelay=60
LinesDelay=2
Lines=2
bScrollStarted=0
Weather
ChangeLines
Display