For my robot, I use a set of macro to add color to chprintf and I think it would be interesting to share with other people in the forum.
Here are the macros:
Code: Select all
#define chprintf_r(x, y) chprintf(x, "\x1b[31m" y "\x1b[0m") /* Red */
#define chprintf_g(x, y) chprintf(x, "\x1b[32m" y "\x1b[0m") /* Green */
#define chprintf_y(x, y) chprintf(x, "\x1b[33m" y "\x1b[0m") /* Yellow. */
#define chprintf_b(x, y) chprintf(x, "\x1b[34m" y "\x1b[0m") /* Blue. */
#define chprintf_m(x, y) chprintf(x, "\x1b[35m" y "\x1b[0m") /* Magenta. */
#define chprintf_c(x, y) chprintf(x, "\x1b[36m" y "\x1b[0m") /* Cyant. */
#define chprintf_w(x, y) chprintf(x, "\x1b[0m" y "\x1b[0m") /* White. */
so to print a test in green we can use:
Code: Select all
chprintf_g(chp, "\n\r Application is started.");
I join for example an image of the output log of the robot at boot time
If it could be interesting to have that feature, I can add it to chiprintf so that it will be easily usable by developers.
Thanks