You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.3 KiB
73 lines
1.3 KiB
#!/bin/bash
|
|
|
|
line[0]=$1
|
|
line[1]=$2
|
|
|
|
COLOR="green"
|
|
IMG_PATH="./images"
|
|
CHAR_PATH="${IMG_PATH}/LCD_characters_${COLOR}"
|
|
|
|
if [ ! -e ${IMG_PATH} ]
|
|
then
|
|
echo "Cannot find path for images \"${IMG_PATH}\""
|
|
exit 10
|
|
fi
|
|
|
|
if [ ! -e ${CHAR_PATH} ]
|
|
then
|
|
echo "Cannot find path for character-images \"${CHAR_PATH}\""
|
|
exit 11
|
|
fi
|
|
|
|
cp "${IMG_PATH}/LCD_${COLOR}.png" /tmp/LCD_$$.png
|
|
|
|
special_flag="false"
|
|
for (( n=0; n<2; n++ ))
|
|
do
|
|
y=$( bc -l <<<"50 + $n * 50" )
|
|
xpos=0
|
|
for (( i=0; i<${#line[$n]}; i++ ))
|
|
do
|
|
c=${line[${n}]:${i}:1}
|
|
if [[ "${c}" == "%" ]]
|
|
then
|
|
if [[ "${special_flag}" == "false" ]]
|
|
then
|
|
special_flag="true"
|
|
special=""
|
|
continue
|
|
else
|
|
special_flag="false"
|
|
if [ ! -e "${CHAR_PATH}/${special}.png" ]
|
|
then
|
|
echo "Cannot find \"${CHAR_PATH}/${special}.png\"."
|
|
c=" "
|
|
else
|
|
c=${special}
|
|
fi
|
|
fi
|
|
fi
|
|
if [[ "${special_flag}" == "true" ]]
|
|
then
|
|
special="${special}${c}"
|
|
continue
|
|
fi
|
|
xpos=$((xpos + 1))
|
|
if [[ "${c}" != " " ]]
|
|
then
|
|
if [[ ${c} == "." ]]
|
|
then
|
|
c="dot"
|
|
fi
|
|
x=$( bc -l <<<"230 + ${xpos} * 30" )
|
|
composite -gravity NorthWest -geometry "+${x}+${y}" "${CHAR_PATH}/${c}.png" /tmp/LCD_$$.png /tmp/LCD_$$.png
|
|
fi
|
|
done
|
|
done
|
|
|
|
if [ "${3}" ]
|
|
then
|
|
mv /tmp/LCD_$$.png "${3}"
|
|
else
|
|
echo "Created /tmp/LCD_$$.png"
|
|
fi
|
|
|