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.
MicroDexed/doc/bin/gen_lcd_screen.sh

77 lines
1.4 KiB

#!/bin/bash
IMG_PATH="${1}"
line[0]="${2}"
line[1]="${3}"
TARGET="${4}"
COLOR="green"
TARGET_EXTENSION="jpg"
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
convert /tmp/LCD_$$.png /tmp/LCD_$$.${TARGET_EXTENSION}
if [ "${3}" ]
then
mv /tmp/LCD_$$.${TARGET_EXTENSION} "${TARGET}"
else
echo "Created /tmp/LCD_$$.${TARGET_EXTENSION}"
fi