Link Search Menu Expand Document

VOXL-CUtils

VOXL C Utils is a small package of C/C++ Utilities for use in various packages.

Table of Contents

  1. Silencing Macros
  2. Timing functions
  3. Terminal Font Manipulation
    1. Space Manipulation
    2. Face
    3. Foreground Color
    4. Background Color

Silencing Macros

The package contains the macros VCU_silent and VCU_silentErrors which can be used to silence the stdout and stderr outputs of their contents, respectively. For example:

VCU_silent(
	some_noisy_libaray_call();
)

will only print the output of stderr to the screen. You can also combine these to completely silence terminal output such as:

VCU_silent(
	VCU_silentErrors(
		some_very_noisy_libaray_call();
	)
)

Timing functions

The package contains the functions VCU_time_realtime_ns and VCU_time_monotonic_ns to get the real and monotonic time of the system, respectively. These can be used to time the execution of code or provide timestamps of sensor readings.

Terminal Font Manipulation

These definitions allow you to manipulate the terminal output in various ways. You can change the face/color of print statements like such: printf("This sentence has both " FONT_BOLD "bold" RESET_FONT " and " COLOR_RED "red" RESET_COLOR "text in it!"); resulting in: “This sentence has both bold and red text in it!”

Space Manipulation

NameDefinitionCode
Clear ScreenCLEAR_TERMINAL\033c
Disable Line WrapDISABLE_WRAP\033[?7l
Enable Line WrapENABLE_WRAP\033[?7h
Clear Current LineCLEAR_LINE\033[2K
Move Cursor To Top LeftGOTO_TOP_LEFT\033[f

Face

NameDefinitionCode
Reset All Font ItemsRESET_FONT\e[0m
BoldFONT_BOLD\e[1m
DimFONT_DIM\e[2m
UnderlineFONT_UNDERLINE\e[4m
Flashing FontFONT_BLINK\e[5m
Invert Fore/Back ColorsFONT_INVERT\e[7m
Hidden TextFONT_HIDDEN\e[8m
Reset BoldRESET_BOLD\e[21m
Reset DimRESET_DIM\e[22m
Reset UnderlineRESET_UNDERLINE\e[24m
Reset BlinkRESET_BLINK\e[25m
Reset InveryRESET_INVERT\e[27m
Reset HiddenRESET_HIDDEN\e[28m

Foreground Color

NameDefinitionCode
Reset ColorRESET_COLOR\e[39m
BlackCOLOR_BLK\e[30m
RedCOLOR_RED\e[31m
GreenCOLOR_GRN\e[32m
YellowCOLOR_YLW\e[33m
BlueCOLOR_BLU\e[34m
MagentaCOLOR_MAG\e[35m
CyanCOLOR_CYN\e[36m
Light GrayCOLOR_LIT_GRY\e[37m
Dark GrayCOLOR_DRK_GRY\e[90m
Light RedCOLOR_LIT_RED\e[91m
Light GreenCOLOR_LIT_GRN\e[92m
Light YellowCOLOR_LIT_YLW\e[93m
Light BlueCOLOR_LIT_BLU\e[94m
Light MagentaCOLOR_LIT_MAG\e[95m
Light CyanCOLOR_LIT_CYN\e[96m
WhiteCOLOR_WHT\e[97m

Background Color

NameDefinitionCode
Reset Background ColorRESET_COLOR_BKG\e[49m
Background BlackCOLOR_BKG_BLK\e[40m
Background RedCOLOR_BKG_RED\e[41m
Background GreenCOLOR_BKG_GRN\e[42m
Background YellowCOLOR_BKG_YLW\e[43m
Background BlueCOLOR_BKG_BLU\e[44m
Background MagentaCOLOR_BKG_MAG\e[45m
Background CyanCOLOR_BKG_CYN\e[46m
Background Light GrayCOLOR_BKG_LIT_GRY\e[47m
Background Dark GrayCOLOR_BKG_DRK_GRY\e[100m
Background Light RedCOLOR_BKG_LIT_RED\e[101m
Background Light GreenCOLOR_BKG_LIT_GRN\e[102m
Background Light YellowCOLOR_BKG_LIT_YLW\e[103m
Background Light BlueCOLOR_BKG_LIT_BLU\e[104m
Background Light MagentaCOLOR_BKG_LIT_MAG\e[105m
Background Light CyanCOLOR_BKG_LIT_CYN\e[106m
Background WhiteCOLOR_BKG_WHT\e[107m