1

I'm working with a mbed NXP LPC1768, and Tera Term. I having problems clearing the screen so it'll just look the stats are constantly updating without the scrolling.

Ron
  • 14,674
  • 4
  • 34
  • 47
dhz
  • 101
  • 1
  • 6
  • I'm working with C++. – dhz Oct 06 '17 at 18:47
  • 1
    Try sending ESC "\[2J". [VT100 ESC sequences](http://www.comptechdoc.org/os/linux/howlinuxworks/linux_hlvt100.html) – 001 Oct 06 '17 at 18:48
  • Aw man, that sound much simpler than the "See if you can use a curses library." I was going to suggest. – user4581301 Oct 06 '17 at 18:50
  • google dec vt100 then look for the commands – old_timer Oct 06 '17 at 18:54
  • The question marked as a duplicate is not a duplicate - the question is not the same, this is about clearing the screen in a terminal emulator, the other question was about clearing a console window in Windows. Even if the answer happens to be the same for different reasons. – Clifford Oct 07 '17 at 15:09

1 Answers1

3

TeraTerm supports emulations of DEC VT100 to DEC VT382. VT100 being the lowest common denominator (also known as ANSI Terminal). To control VT100/ANSI terminal you send escape sequences.

The escape sequence for "erase screen" is <ESC>[2J. Where <ESC> is the ASCII escape character 0x1b. So you send the escaped string "\x1b[2J" to the serial port to clear the terminal.

There is however a simpler and more efficient method of updating a value statically on the screen without clearing the entire screen. If you configure the terminal so that it requires CR+LF for newline, and then simply send only a CR as follows (for example):

for(;;)
{
    output( result_string ) ;
    output( "              " ) ; // enough space to overwrite the
                                 // previous result if the line 
                                 // length is variable.
    output( "\r" ) ;
    delay( update_delay) ;
}

Then result_string will be repeatedly written on the same line without scrolling or advancing.

Clifford
  • 88,407
  • 13
  • 85
  • 165