Rev 308 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
249 | 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 |
||
254 | killagreg | 31 | #ifdef DEBUG |
32 | #include "printf_P.h" // only include functions if DEBUG is defined in main.h |
||
249 | ingob | 33 | |
34 | #define Debug(format, args...) { _printf_P(&Debug_Putchar, (format) , ## args); DebugSend(CMD_NONE); } |
||
35 | #define Debug_Raw(format, args...) { _printf_P(&Debug_Putchar, (format) , ## args); DebugSend(CMD_RAW_OUTPUT); } |
||
36 | #define Debug_Warning(format, args...) { _printf_P(&Debug_Putchar, (format) , ## args); DebugSend(CMD_WARNING_MSG); } |
||
37 | #define Debug_Error(format, args...) { _printf_P(&Debug_Putchar, (format) , ## args); DebugSend(CMD_ERROR_MSG); } |
||
38 | #define Debug_OK(format, args...) { _printf_P(&Debug_Putchar, (format) , ## args); DebugSend(CMD_GREEN_MSG); } |
||
39 | |||
254 | killagreg | 40 | typedef struct |
249 | ingob | 41 | { |
254 | killagreg | 42 | u8 Cmd; // bitcoded command |
43 | u8 Text[32]; |
||
44 | } __attribute__((packed)) Debug_t; |
||
249 | ingob | 45 | |
254 | killagreg | 46 | extern Debug_t tDebug; |
47 | extern u8 SendDebugOutput; |
||
249 | ingob | 48 | |
49 | void Debug_Putchar(char c); |
||
50 | void DebugSend(unsigned char cmd); |
||
51 | |||
52 | #else // dummy macros (won't waste flash, if #DEBUG is disabled) |
||
53 | #define Debug(format, args...) ; |
||
54 | #define Debug_Raw(format, args...) ; |
||
55 | #define Debug_Warning(format, args...) ; |
||
56 | #define Debug_Error(format, args...) ; |
||
57 | #define Debug_OK(format, args...) ; |
||
58 | #endif |
||
59 | |||
60 | // ---------------------------------------------- |
||
61 | #endif |