progress_bar.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2019 Inria
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
18 #include <stdlib.h>
19 #include <inttypes.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
28 #ifndef CONFIG_PROGRESS_BAR_LENGTH
29 #define CONFIG_PROGRESS_BAR_LENGTH (25U)
30 #endif
31 
35 #ifndef CONFIG_PROGRESS_BAR_FULL_CHARACTER
36 #define CONFIG_PROGRESS_BAR_FULL_CHARACTER "█"
37 #endif
38 
42 #ifndef CONFIG_PROGRESS_BAR_EMPTY_CHARACTER
43 #define CONFIG_PROGRESS_BAR_EMPTY_CHARACTER " "
44 #endif
45 
49 #ifndef CONFIG_PROGRESS_BAR_PREFIX_CHARACTER
50 #define CONFIG_PROGRESS_BAR_PREFIX_CHARACTER "|"
51 #endif
52 
56 #ifndef CONFIG_PROGRESS_BAR_SUFFIX_CHARACTER
57 #define CONFIG_PROGRESS_BAR_SUFFIX_CHARACTER "|"
58 #endif
59 
63 #ifndef CONFIG_PROGRESS_BAR_PREFIX_MAX_LENGTH
64 #define CONFIG_PROGRESS_BAR_PREFIX_MAX_LENGTH (32U)
65 #endif
66 
70 #ifndef CONFIG_PROGRESS_BAR_SUFFIX_MAX_LENGTH
71 #define CONFIG_PROGRESS_BAR_SUFFIX_MAX_LENGTH (32U)
72 #endif
73 
77 typedef struct {
79  uint8_t value;
85 
93 void progress_bar_print(char *prefix, char *suffix, uint8_t value);
94 
101 
113 void progress_bar_prepare_multi(uint8_t len);
114 
121 void progress_bar_update_multi(progress_bar_t *progress_bar_list, uint8_t len);
122 
123 #ifdef __cplusplus
124 }
125 #endif
126 
Adds include for missing inttype definitions.
void progress_bar_print(char *prefix, char *suffix, uint8_t value)
Print a progress bar in the terminal.
void progress_bar_prepare_multi(uint8_t len)
Prepare the output for displaying multiple progress bars.
#define CONFIG_PROGRESS_BAR_PREFIX_MAX_LENGTH
Progress bar prefix max length.
Definition: progress_bar.h:64
void progress_bar_update(progress_bar_t *progress_bar)
Update the progress bar display in the terminal.
#define CONFIG_PROGRESS_BAR_SUFFIX_MAX_LENGTH
Progress bar suffix max length.
Definition: progress_bar.h:71
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.
Progress bar descriptor.
Definition: progress_bar.h:77
uint8_t value
Current value of the progress bar.
Definition: progress_bar.h:79