Created
November 11, 2020 12:19
-
-
Save rhodrid/0963c228ebac265752ef30701c290a07 to your computer and use it in GitHub Desktop.
QNAP LCD control
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 | |
TEXT="${@:2:$#}" | |
function printUsage() { | |
echo "Usage: $0 <off|on>" | |
echo "Usage: $0 <1|2> Text Message" | |
exit 0 | |
} | |
function setDisplay() { | |
if [ ${#2} -gt 15 ]; then | |
echo "String to set can be max 16 characters!" | |
exit 1 | |
fi | |
printf "Setting line $1 on display to \"%s\"\n" "$2" | |
# Text we print must be padded to exactly 16 characters to wipe old text | |
printf "M\f\x`expr $1 - 1` %-16s" "$2" > /dev/ttyS1 | |
} | |
if [ $# -eq 0 ]; then | |
printUsage | |
fi | |
stty -F /dev/ttyS1 1200 | |
if [ $1 = "off" ]; then | |
echo "Turning display off" | |
echo -e "M^\x0" > /dev/ttyS1 | |
exit 0 | |
fi | |
if [ $1 = "on" ]; then | |
echo "Turning display on" | |
echo -e "M^\x1" > /dev/ttyS1 | |
exit 0 | |
fi | |
if [ $1 = "1" ] || [ $1 = "2" ]; then | |
setDisplay $1 "$TEXT" | |
exit 0 | |
fi | |
printUsage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment