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