I needed to add -echo to my stty call, and now the problem is gone. (This makes sense if you think about it: The lcd and keypad are like an old-fashioned terminal, and by default when you type characters on those terminals, they are echoed back onto the screen.)
Here are some tips for linux users who want to use these displays from bash:
1. Set up your stty like this:
Code: Select all
DEV=/dev/ttyUSB0
stty 19200 raw -echo -F $DEV
2. When you write a remembered setting, put a sleep 0.2 after it. Writing a bunch of remembered settings in a row doesn't stick.
3. When you clear the input buffer, put a sleep 0.2 after that. If you clear and then immediately read, sometimes you'll get old data.
4. Don't try to get scrolling to work, it's hopelessly frustrating. Here is a simple bash function that you can call to put a line onto the screen. It does scrolling. (Note that I use a /tmp file for the buffer because you cannot count on variables scoping correctly in linux bash.)
Code: Select all
echo -ne "\xfe\x58\xfe\x52" > $DEV
FILL=" "
echo "$FILL" > /tmp/lcdlast
function lout {
LINE=`echo -ne "$1$FILL" | cut -c1-20`
echo -ne "\xfe\x58`cat /tmp/lcdlast`$LINE" > $DEV
echo "$LINE" > /tmp/lcdlast
}
#usage
lout "Hello"
lout "World"