Echo when reading keypad input

LK/ELK/VK/PK/OK/MX/GLK/EGLK/GVK/GLT Series

Moderators: Henry, Mods

Post Reply
jesmith
LCD?
Posts: 3
Joined: Thu Jun 03, 2010 7:51 am

Echo when reading keypad input

Post by jesmith »

I have a LK202-25-USB which I am using in Linux. I'm doing all my I/O just using bash. Everything is working correctly.

However, when I poll for keypad input, I'm seeing the characters that are returned displayed on the LCD. If there is no character returned, I see ^@ on the LCD.

This is the line I'm using to poll for a character:

Code: Select all

DATA=`( dd if=$DEV bs=1 count=1 2>/dev/null& ) ; echo -ne "\xfe\x26" > $DEV ; sleep 0.2`
Is local echo something that these devices do by default, or is this some kind of a tty duplex issue? If it is a built-in behavior, is there any way to turn it off?

Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Post by Clark »

Hi Jesmith,

Echo is not built into the display by default and is usually only something seen when the receive and transmit signals are tied together. If you could, I would recommend connecting to a windows machine and starting a basic program such as our uProject to determine if it is a display fault or something in code.

Thanks,
~Troy
Troy Clark
Design & Development
Matrix Orbital

jesmith
LCD?
Posts: 3
Joined: Thu Jun 03, 2010 7:51 am

Post by jesmith »

I'm sure it's a software issue, because I'm seeing exactly the same behavior on two different displays.

Any ideas on how I might fix this on the Linux side? Perhaps some stty call I can make?

jesmith
LCD?
Posts: 3
Joined: Thu Jun 03, 2010 7:51 am

Solved

Post by jesmith »

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"

Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Post by Clark »

Great info for the Linux community, thanks Jesmith!

~Troy
Troy Clark
Design & Development
Matrix Orbital

Post Reply