C/C++ Header file with some useful macros for outputting colors and font formatting on terminals such as Linux console and Putty. Works with terminals on desktop/servers as well as terminals such as Putty for SSH connections or a microcontroller via UART.

Very easy to use, just include the header and call the macro.

Simple set of macros takes 0 bytes of RAM and only 4-5 bytes of constants in Flash since the calls are done via printf() arguments. Commands are a printf() statements with a string of 4 or 5 bytes.

 • Colors: Black, red, green, yellow, blue, magenta, cyan, gray, white
 • Foreground colors
 • Background colors
 • Bold
 • Underline
 • Double underline
 • Wavy underline
 • Blinking text
 • Italic
 • Overline
 • Strike out

Colors all work on VT100 compatible terminals, including foreground and background colors. Some font features are only available on Linux with modern terminal programs (wavy underline, strike out, etc).

The test program that generated the screen shots is included for testing.

 • Example running on Linux terminal:

 • Example from microcontroller on Putty via UART:

 • Example from an Arduino on TeraTerm via UART:

Example code:

#include "vt100colors.h"
#include "stdio.h"

int main(int argc, char ** argv)
printf("System running...\n");
printf("System ending\n");
return 0;

Bonus code! Use printf on an Arduino!
Want to use these colors on an Arduino and a terminal like Putty? Here is some macro magic to use snprintf and the Serial module as printf()

static char m_scratch[40];
#ifdef printf
#undef printf
#define printf(...) do{snprintf(m_scratch,sizeof(m_scratch),__VA_ARGS__);Serial.print(m_scratch);}while(0)

void setup() {
// put your setup code here, to run once:
printf("Printf %d, %d, %d...!\n",1,2,3);

Sign Up For Full Access
Members gain full access to the Prosource library with dozens of source files for ARM Cortex, ATMega, PIC processors as well as desktop and embedded Linux systems. Solutions for bootloaders, Buildroot and Yocto targets as well as guided how-tos on embedded development to gain critical knowledge in new systems and speed development.
Files size: 5.76 KB
RAM usage:0 bytes
Avg Flash:~32 bytes per call
File size: 2490 bytes
File size: 3411 bytes