Rev 1723 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1637 | ingob | 1 | #ifndef _DEBUG_H |
2 | #define _DEBUG_H |
||
3 | // ---------------------------------------------- |
||
4 | #define CMD_NONE 0x00 |
||
5 | #define CMD_RAW_OUTPUT 0x01 |
||
6 | #define CMD_ERROR_MSG 0x02 |
||
7 | #define CMD_WARNING_MSG 0x04 |
||
8 | #define CMD_GREEN_MSG 0x08 |
||
9 | |||
10 | // debug console in MK-Tool can also handle ANSI ESC seq. |
||
11 | #define ANSI_ATTRIBUTE_OFF "\033[0m" |
||
12 | #define ANSI_BOLD "\033[1m" |
||
13 | #define ANSI_UNDERSCORE "\033[4m" |
||
14 | #define ANSI_BLINK "\033[5m" |
||
15 | #define ANSI_INVERSE "\033[7m" |
||
16 | #define ANSI_INVISIBLE "\033[8m" |
||
17 | |||
18 | #define ANSI_COLOR_BLACK "\033[30m" |
||
19 | #define ANSI_COLOR_RED "\033[31m" |
||
20 | #define ANSI_COLOR_GREEN "\033[32m" |
||
21 | #define ANSI_COLOR_YELLOW "\033[33m" |
||
22 | #define ANSI_COLOR_BLUE "\033[34m" |
||
23 | #define ANSI_COLOR_VIOLETT "\033[35m" |
||
24 | #define ANSI_COLOR_KOBALTBLUE "\033[36m" |
||
25 | #define ANSI_COLOR_WHITE "\033[37m" |
||
26 | |||
27 | #define ANSI_CLEAR "\033[2J" |
||
28 | #define ANSI_HOME "\033[H" |
||
29 | |||
30 | // macros for easier use |
||
31 | #ifdef DEBUG // only include functions if DEBUG is defined in main.h |
||
32 | |||
33 | #define Debug(format, args...) { _printf_P(&Debug_Putchar, PSTR(format) , ## args); DebugSend(CMD_NONE); } |
||
34 | #define Debug_Raw(format, args...) { _printf_P(&Debug_Putchar, PSTR(format) , ## args); DebugSend(CMD_RAW_OUTPUT); } |
||
35 | #define Debug_Warning(format, args...) { _printf_P(&Debug_Putchar, PSTR(format) , ## args); DebugSend(CMD_WARNING_MSG); } |
||
36 | #define Debug_Error(format, args...) { _printf_P(&Debug_Putchar, PSTR(format) , ## args); DebugSend(CMD_ERROR_MSG); } |
||
37 | #define Debug_OK(format, args...) { _printf_P(&Debug_Putchar, PSTR(format) , ## args); DebugSend(CMD_GREEN_MSG); } |
||
38 | |||
39 | struct str_Debug |
||
40 | { |
||
41 | unsigned char Cmd; // bitcoded command |
||
42 | char Text[32]; |
||
43 | }; |
||
44 | |||
45 | extern struct str_Debug tDebug; |
||
46 | unsigned char SendDebugOutput; |
||
47 | |||
48 | void Debug_Putchar(char c); |
||
49 | void DebugSend(unsigned char cmd); |
||
50 | |||
51 | #else // dummy macros (won't waste flash, if #DEBUG is disabled) |
||
52 | #define Debug(format, args...) ; |
||
53 | #define Debug_Raw(format, args...) ; |
||
54 | #define Debug_Warning(format, args...) ; |
||
55 | #define Debug_Error(format, args...) ; |
||
56 | #define Debug_OK(format, args...) ; |
||
57 | #endif |
||
58 | |||
59 | // ---------------------------------------------- |
||
60 | #endif |