My implementation of VT100 ESC-sequence utility

Dependents:   test_vt100 maze_vt100_MMA8451Q funcgen test_MAG3110 ... more

Embed: (wiki syntax)

« Back to documentation index

vt100 Class Reference

vt100 Class Reference

vt100 class Utility for handling text/letter on a terminal which can handle VT100 escape command sequence. More...

#include <vt100.h>

Public Member Functions

 vt100 (int baud=115200)
 constructor
 ~vt100 (void)
 destructor
void cls (void)
 clear screen
void locate (int x, int y)
 move cursor to (x, y)
void putChar (int x, int y, char c)
 print a letter c at (x,y)
void putStr (int x, int y, char *str)
 print a string str from (x,y)
void line (int x1, int y1, int x2, int y2, char c='*')
 print a line of char
void frame (int x1, int y1, int x2, int y2)
 print a text frame
void circle (int x0, int y0, int r, char c='*')
 print a text circle the letter to form the circle
int setFG (int newFG)
 set foreground color
int getFG (void)
 get current foreground color
int setBG (int newBG)
 set background color
int getBG (void)
 get current background color
void black (void)
 set foreground color to black
void red (void)
 set foreground color to red
void green (void)
 set foreground color to green
void yellow (void)
 set foreground color to yellow
void blue (void)
 set foreground color to blue
void purple (void)
 set foreground color to purple
void cian (void)
 set foreground color to cian
void white (void)
 set foreground color to white

Detailed Description

vt100 class Utility for handling text/letter on a terminal which can handle VT100 escape command sequence.

Example:

 #include "mbed.h"
 #include "vt100.h"
 
 vt100 tty ;
 
 int main() {
   int count = 0 ;
   tty.cls() ;
   tty.black() ;
   tty.frame(5, 5, 15, 9) ;
   while(1) {
       tty.locate(7, 7) ;
       tty.setFG(count % 8) ;
       printf("%d\r\n", count++) ;
       wait(1.0) ;
   }
 }

Note: I know there should be other libraries with similar functions, but I could not help writing one for myself anyway.

Definition at line 34 of file vt100.h.


Constructor & Destructor Documentation

vt100 ( int  baud = 115200 )

constructor

Parameters:
baudbaud rate

Definition at line 16 of file vt100.cpp.

~vt100 ( void   )

destructor

Definition at line 22 of file vt100.cpp.


Member Function Documentation

void black ( void   )

set foreground color to black

Definition at line 178 of file vt100.cpp.

void blue ( void   )

set foreground color to blue

Definition at line 198 of file vt100.cpp.

void cian ( void   )

set foreground color to cian

Definition at line 208 of file vt100.cpp.

void circle ( int  x0,
int  y0,
int  r,
char  c = '*' 
)

print a text circle the letter to form the circle

Parameters:
x0center column
y1center row
rradius

Definition at line 120 of file vt100.cpp.

void cls ( void   )

clear screen

Definition at line 26 of file vt100.cpp.

void frame ( int  x1,
int  y1,
int  x2,
int  y2 
)

print a text frame

Parameters:
x1left column
y1top row
x2right column
y2bottom row

Definition at line 91 of file vt100.cpp.

int getBG ( void   )

get current background color

Returns:
current background color

Definition at line 173 of file vt100.cpp.

int getFG ( void   )

get current foreground color

Returns:
current foreground color

Definition at line 161 of file vt100.cpp.

void green ( void   )

set foreground color to green

Definition at line 188 of file vt100.cpp.

void line ( int  x1,
int  y1,
int  x2,
int  y2,
char  c = '*' 
)

print a line of char

Parameters:
cthe letter to form the line
x1starting column
y1starting row
x2ending column
y2ending row

Definition at line 49 of file vt100.cpp.

void locate ( int  x,
int  y 
)

move cursor to (x, y)

Parameters:
xstart column of the next letter
ystart row of the next letter
Note:
no value checking is performed.

Definition at line 32 of file vt100.cpp.

void purple ( void   )

set foreground color to purple

Definition at line 203 of file vt100.cpp.

void putChar ( int  x,
int  y,
char  c 
)

print a letter c at (x,y)

Parameters:
cthe letter to be written
xcolumn of the letter
yrow of the letter

Definition at line 37 of file vt100.cpp.

void putStr ( int  x,
int  y,
char *  str 
)

print a string str from (x,y)

Parameters:
*strc-style string to be written
xcolumn of the first letter
yrow of the first letter

Definition at line 43 of file vt100.cpp.

void red ( void   )

set foreground color to red

Definition at line 183 of file vt100.cpp.

int setBG ( int  newBG )

set background color

Parameters:
newBGnew background color
Returns:
previous background color

Definition at line 166 of file vt100.cpp.

int setFG ( int  newFG )

set foreground color

Parameters:
newFGnew foreground color
Returns:
previous foreground color
Note:
0 BLACK
1 RED
2 GREEN
3 YELLOW
4 BLUE
5 PURPLE
6 CIAN
7 WHITE

Definition at line 153 of file vt100.cpp.

void white ( void   )

set foreground color to white

Definition at line 213 of file vt100.cpp.

void yellow ( void   )

set foreground color to yellow

Definition at line 193 of file vt100.cpp.