Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
py/mpprint.h: Add do_printf() macro.
Browse files Browse the repository at this point in the history
Signed-off-by: IhorNehrutsa <Ihor.Nehrutsa@gmail.com>
IhorNehrutsa authored and IhorNehrutsa committed Jan 10, 2024
1 parent 2ed976f commit aa08ab0
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/esp-hosted/esp_hosted_hal.h
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@
#if ESP_HOSTED_DEBUG
#define PROTOBUF_C_UNPACK_ERROR(...) error_printf(__VA_ARGS__);
#endif

/*
#define ANSI_C_RED "\x1B[31m"
#define ANSI_C_GREEN "\x1B[32m"
#define ANSI_C_YELLOW "\x1B[33m"
@@ -58,7 +58,7 @@
#define warn_printf(...) do_printf(ANSI_C_YELLOW); do_printf(__VA_ARGS__); do_printf(ANSI_C_DEFAULT);
#define error_printf(...) do_printf(ANSI_C_RED); do_printf(__VA_ARGS__); do_printf(ANSI_C_DEFAULT);
#define crit_printf(...) do_printf(ANSI_C_MAGENTA); do_printf(__VA_ARGS__); do_printf(ANSI_C_DEFAULT);

*/
typedef enum {
ESP_HOSTED_MODE_BT,
ESP_HOSTED_MODE_WIFI,
22 changes: 22 additions & 0 deletions py/mpprint.h
Original file line number Diff line number Diff line change
@@ -79,4 +79,26 @@ int mp_printf(const mp_print_t *print, const char *fmt, ...);
int mp_vprintf(const mp_print_t *print, const char *fmt, va_list args);
#endif

#define ANSI_C_RED "\x1B[31m"
#define ANSI_C_GREEN "\x1B[32m"
#define ANSI_C_YELLOW "\x1B[33m"
#define ANSI_C_BLUE "\x1B[34m"
#define ANSI_C_MAGENTA "\x1B[35m"
#define ANSI_C_CYAN "\x1B[36m"
#define ANSI_C_WHITE "\x1B[37m"
#define ANSI_C_DEFAULT "\x1B[0m"

#if DO_PRINTF
#define do_printf(...) mp_printf(&mp_plat_print, __VA_ARGS__)
#else
#define do_printf(...)
#endif

// Logging macros.
#define debug_printf(...) do_printf(ANSI_C_BLUE); do_printf(__VA_ARGS__); do_printf(ANSI_C_DEFAULT);
#define info_printf(...) do_printf(ANSI_C_GREEN); do_printf(__VA_ARGS__); do_printf(ANSI_C_DEFAULT);
#define warn_printf(...) do_printf(ANSI_C_YELLOW); do_printf(__VA_ARGS__); do_printf(ANSI_C_DEFAULT);
#define error_printf(...) do_printf(ANSI_C_RED); do_printf(__VA_ARGS__); do_printf(ANSI_C_DEFAULT);
#define crit_printf(...) do_printf(ANSI_C_MAGENTA); do_printf(__VA_ARGS__); do_printf(ANSI_C_DEFAULT);

#endif // MICROPY_INCLUDED_PY_MPPRINT_H

0 comments on commit aa08ab0

Please sign in to comment.