VT100 Terminal

A simple library for controlling the cursor position and colour on a serial terminal emulator.

/media/uploads/simon/terminal2.png

Hello World!

Import program

00001 // simple test for a ANSI/VT100 Terminal, sford
00002 
00003 #include "mbed.h"
00004 #include "Terminal.h"
00005 
00006 Terminal term(USBTX, USBRX); // tx, rx
00007 
00008 int main() {
00009     term.printf("Hello World!\nHow are you?");
00010 
00011     wait(2);
00012 
00013     term.locate(3,1);
00014     term.foreground(0xFF0000);
00015     term.printf("I'm Great!");
00016 
00017     wait(3);
00018 
00019     term.cls();
00020 }

Library

Import library

Public Member Functions

  Terminal (PinName tx, PinName rx)
  Create the Terminal interface.
int  putc (int c)
  Write a character to the terminal.
int  printf (const char *format,...)
  Write a formated string to the terminal.
void  locate (int column, int row)
  Locate to a screen column and row.
void  cls ()
  Clear the screen and locate to 0,0.
void  foreground (int colour)
  Set the foreground colour.
void  background (int colour)
  Set the background colour.

Details

A terminal program like Teraterm or Hyperterminal often supports escape sequences to control things like cursor location and colour. A common set of escape codes are those first used on the VT100 terminal, which are listed sequences, as found here:

Reference