Background: Our project has a text-based menu which is displayed on a screen and navigated by using a joystick (up, down, left, right) to configure settings etc.
A hardware change may remove the screen from the project, so as an alternative we're looking at sending the same menu out over the serial port to allow user control via a terminal program.
Now, the communications part is done (we can send & recieve data), and the menu structure and navigation is there (we can traverse a menu structure & modify variables) but the issue is correctly controlling the terminal output to re-write the screen / move the cursor (however it's easiest to make it work) rather than spit out multiple pages.
Example:
If you have this menu output on the serial port:
MENU>1 = Login 2 = Setup 3 = Options 4 = Help 5 = Exit
And then maybe press the "down" key or enter "4", the software would have to re-send the text again:
MENU 1 = Login 2 = Setup 3 = Options>4 = Help 5 = Exit
But that means your terminal screen (EG hyperterm) now looks like this:
MENU>1 = Login 2 = Setup 3 = Options 4 = Help 5 = Exit4MENU 1 = Login 2 = Setup 3 = Options>4 = Help 5 = Exit
I've found some stuff on Google about VT100 escape codes etc. but not a lot of source code / examples, it seems to be such a common thing (built into everything Linux etc.) that no-one ever codes it themselves or if they do they don't feel it's worth mentioning.
So, before I try to roll my own from scratch, does anyone have any VT100 or similar routines/examples?
Solved! Go to Solution.
I'd prefer a single command-line menu system with help and completion, but that's just me :smileyhappy:.
> I've found some stuff on Google about VT100 escape codes etc.
http://en.wikipedia.org/wiki/ANSI_escape_code
The first standard for ANSI escape sequences was ECMA-48, adopted in 1976. ... The first popular video terminal to support these sequences was the Digital VT100 introduced in 1978,
So the ANSI sequences are the "master standard" that you should be searching for.
The "where to get sample code" question came up recently in this forum in this post:
https://community.freescale.com/message/106452#106452
I responded with a pointer to a copy of the "snippets.org" code, and have found thes files, which might be all you need:
http://www8.cs.umu.se/~isak/snippets/ansiscrn.h
http://www8.cs.umu.se/~isak/snippets/ansisys.txt
Search around in the directory those are in. There are quite a few matches on "ANSI". There's also "Mark Kimes ANSI screen code interpreter".
You Application may be simple enough to just have "in line ANSII codes" for driving the screen. If you want to write your code to conform to a STANDARD, then you might like to consider curses or ncurses:
http://en.wikipedia.org/wiki/Curses_%28programming_library%29
You could then write the curses library code to "direct address" the on-board screen or generate ANSI sequences for the terminal.
Another option would be to have your menu program use ANSI codes for everything, and rewrite your display driver to interpret those codes rather than having two different interfaces.
In the "Hex-to-BCD-Conversion" post, "Leong" also suggested the following, which gets a lot of Linux source code hits.
There may not be anything "simple" there though.
Tom
I'd prefer a single command-line menu system with help and completion, but that's just me :smileyhappy:.
> I've found some stuff on Google about VT100 escape codes etc.
http://en.wikipedia.org/wiki/ANSI_escape_code
The first standard for ANSI escape sequences was ECMA-48, adopted in 1976. ... The first popular video terminal to support these sequences was the Digital VT100 introduced in 1978,
So the ANSI sequences are the "master standard" that you should be searching for.
The "where to get sample code" question came up recently in this forum in this post:
https://community.freescale.com/message/106452#106452
I responded with a pointer to a copy of the "snippets.org" code, and have found thes files, which might be all you need:
http://www8.cs.umu.se/~isak/snippets/ansiscrn.h
http://www8.cs.umu.se/~isak/snippets/ansisys.txt
Search around in the directory those are in. There are quite a few matches on "ANSI". There's also "Mark Kimes ANSI screen code interpreter".
You Application may be simple enough to just have "in line ANSII codes" for driving the screen. If you want to write your code to conform to a STANDARD, then you might like to consider curses or ncurses:
http://en.wikipedia.org/wiki/Curses_%28programming_library%29
You could then write the curses library code to "direct address" the on-board screen or generate ANSI sequences for the terminal.
Another option would be to have your menu program use ANSI codes for everything, and rewrite your display driver to interpret those codes rather than having two different interfaces.
In the "Hex-to-BCD-Conversion" post, "Leong" also suggested the following, which gets a lot of Linux source code hits.
There may not be anything "simple" there though.
Tom
Thanks Tom, some good stuff there - and that snippets page is a goldmine of stuff.
Just to follow this one up, we have a terminal system up and working now.
A few wrinkles were that there's more than one level of control in a telnet/terminal window; there are escape codes, but there are also telnet negotiation commands which are sent as 0xFF, <something>, where the byte FF is referred to as "Interpret As Command" and tell the terminal things abou whether to send/not send each charater as it's typed, whether to echo locally or not, etc., which makes a difference when navigating with cursor keys or trying to communicate over a link with no inbuilt flow control.