J-Link / J-Trace (UM08001) © 2004-2017 SEGGER Microcontroller GmbH & Co. KG
141
3.7.9 Using "virtual" Terminals in RTT
For virtual Terminals the target application needs only Up Channel 0. This is espe-
cially important on targets with low RAM.
If nothing is configured, all data is sent to Terminal 0.
The Teminal to output all following via Write, WriteString or printf can be set with
SEGGER_RTT_SetTerminal() .
Output of only one string via a specific Terminal can be done with
SEGGER_RTT_TerminalOut().
The sequences sent to change the Terminal are interpreted by RTT Viewer. Other
applications like a Telnet Client will ignore them.
3.7.10 Using Text Control Codes
RTT allows using Text Control Codes (ANSI escape codes) to configure the display of
text.
RTT Viewer supports changing the text color and background color and can erase the
Termi nal.
These Control Codes are pre-defined in the RTT application and can easily be used in
the application.
Example 1:
SEGGER_RTT_WriteString(0,
RTT_CTRL_RESET"Red: " \
RTT_CTRL_TEXT_BRIGHT_RED"This text is red. " \
RTT_CTRL_TEXT_BLACK"" \
RTT_CTRL_BG_BRIGHT_RED"This background is red. " \
RTT_CTRL_RESET"Normal text again.");
Example 2:
SEGGER_RTT_printf(0, "%sTime:%s%s %.7d\n",
RTT_CTRL_RESET,
RTT_CTRL_BG_BRIGHT_RED,
RTT_CTRL_TEXT_BRIGHT_WHITE,
1111111
);
//
// Clear the terminal.
// The first line will not be shown after this command.
//
SEGGER_RTT_WriteString(0, RTT_CTRL_CLEAR);
SEGGER_RTT_printf(0, "%sTime: %s%s%.7d\n",
RTT_CTRL_RESET,
RTT_CTRL_BG_BRIGHT_RED,
RTT_CTRL_TEXT_BRIGHT_WHITE,
2222222
);
Right-Click on Tab
-> Close Terminal Closes this Terminal Tab Alt-W
-> Clear Terminal
Clears the displayed output of this
Ter min al Tab.
Alt-R
Menu entry Contents Shortcut
Table 3.15: RTT Viewer Menus and Shortcuts