Loading...
Searching...
No Matches
progress_bar.h File Reference

A simple CLI progress bar. More...

Detailed Description

A simple CLI progress bar.

Author
Alexandre Abadie alexa.nosp@m.ndre.nosp@m..abad.nosp@m.ie@i.nosp@m.nria..nosp@m.fr

Definition in file progress_bar.h.

#include <stdlib.h>
#include <inttypes.h>
+ Include dependency graph for progress_bar.h:

Go to the source code of this file.

Data Structures

struct  progress_bar_t
 Progress bar descriptor. More...
 
#define CONFIG_PROGRESS_BAR_LENGTH   (25U)
 Progress bar maximum characters length.
 
#define CONFIG_PROGRESS_BAR_FULL_CHARACTER   "█"
 Progress bar character.
 
#define CONFIG_PROGRESS_BAR_EMPTY_CHARACTER   " "
 Progress bar empty character.
 
#define CONFIG_PROGRESS_BAR_PREFIX_CHARACTER   "|"
 Character displayed on the left of the progress bar.
 
#define CONFIG_PROGRESS_BAR_SUFFIX_CHARACTER   "|"
 Character displayed on the left of the progress bar.
 
#define CONFIG_PROGRESS_BAR_PREFIX_MAX_LENGTH   (32U)
 Progress bar prefix max length.
 
#define CONFIG_PROGRESS_BAR_SUFFIX_MAX_LENGTH   (32U)
 Progress bar suffix max length.
 
void progress_bar_print (char *prefix, char *suffix, uint8_t value)
 Print a progress bar in the terminal.
 
void progress_bar_update (progress_bar_t *progress_bar)
 Update the progress bar display in the terminal.
 
void progress_bar_prepare_multi (uint8_t len)
 Prepare the output for displaying multiple progress bars.
 
void progress_bar_update_multi (progress_bar_t *progress_bar_list, uint8_t len)
 Update all progress bar displays of the given progress bars list.
 

Macro Definition Documentation

◆ CONFIG_PROGRESS_BAR_EMPTY_CHARACTER

#define CONFIG_PROGRESS_BAR_EMPTY_CHARACTER   " "

Progress bar empty character.

Definition at line 47 of file progress_bar.h.

◆ CONFIG_PROGRESS_BAR_FULL_CHARACTER

#define CONFIG_PROGRESS_BAR_FULL_CHARACTER   "█"

Progress bar character.

Definition at line 40 of file progress_bar.h.

◆ CONFIG_PROGRESS_BAR_LENGTH

#define CONFIG_PROGRESS_BAR_LENGTH   (25U)

Progress bar maximum characters length.

Definition at line 33 of file progress_bar.h.

◆ CONFIG_PROGRESS_BAR_PREFIX_CHARACTER

#define CONFIG_PROGRESS_BAR_PREFIX_CHARACTER   "|"

Character displayed on the left of the progress bar.

Definition at line 54 of file progress_bar.h.

◆ CONFIG_PROGRESS_BAR_PREFIX_MAX_LENGTH

#define CONFIG_PROGRESS_BAR_PREFIX_MAX_LENGTH   (32U)

Progress bar prefix max length.

Definition at line 68 of file progress_bar.h.

◆ CONFIG_PROGRESS_BAR_SUFFIX_CHARACTER

#define CONFIG_PROGRESS_BAR_SUFFIX_CHARACTER   "|"

Character displayed on the left of the progress bar.

Definition at line 61 of file progress_bar.h.

◆ CONFIG_PROGRESS_BAR_SUFFIX_MAX_LENGTH

#define CONFIG_PROGRESS_BAR_SUFFIX_MAX_LENGTH   (32U)

Progress bar suffix max length.

Definition at line 75 of file progress_bar.h.

Function Documentation

◆ progress_bar_prepare_multi()

void progress_bar_prepare_multi ( uint8_t  len)

Prepare the output for displaying multiple progress bars.

This function is just adding enough empty lines to give enough space to print the list of progress bars.

This function must be called only once and before starting the progress bar list updates with.

Parameters
[in]lenThe length of the progress bar array

◆ progress_bar_print()

void progress_bar_print ( char *  prefix,
char *  suffix,
uint8_t  value 
)

Print a progress bar in the terminal.

Parameters
[in]prefixString displayed on the left of the progress bar
[in]suffixString displayed on the right of the progress bar
[in]valueValue of the progress bar

◆ progress_bar_update()

void progress_bar_update ( progress_bar_t progress_bar)

Update the progress bar display in the terminal.

Parameters
[in]progress_barPointer to the progress bar descriptor

◆ progress_bar_update_multi()

void progress_bar_update_multi ( progress_bar_t progress_bar_list,
uint8_t  len 
)

Update all progress bar displays of the given progress bars list.

Parameters
[in]progress_bar_listAn array of progress bars
[in]lenThe length of the progress bar array