]> cloudbase.mooo.com Git - irmp.git/blobdiff - irmp.c
Version 1.6.5: merged FDC1 and FDC2 to FDC, renamed DEBUG preprocessor constant to...
[irmp.git] / irmp.c
diff --git a/irmp.c b/irmp.c
index 91367744f45b4589cb59daffb60fe9368cc26ba7..b691d71f3429da61390cc32d4770d51db2a523e0 100644 (file)
--- a/irmp.c
+++ b/irmp.c
@@ -3,7 +3,7 @@
  *\r
  * Copyright (c) 2009-2010 Frank Meyer - frank(at)fli4l.de\r
  *\r
- * $Id: irmp.c,v 1.45 2010/06/11 14:47:24 fm Exp $\r
+ * $Id: irmp.c,v 1.50 2010/06/14 22:00:51 fm Exp $\r
  *\r
  * ATMEGA88 @ 8 MHz\r
  *\r
 #include <string.h>\r
 #include <inttypes.h>\r
 \r
-#define DEBUG\r
+#define ANALYZE\r
 #define PROGMEM\r
 #define memcpy_P        memcpy\r
 \r
 #include <string.h>\r
 typedef unsigned char   uint8_t;\r
 typedef unsigned short  uint16_t;\r
-#define DEBUG\r
+#define ANALYZE\r
 #define PROGMEM\r
 #define memcpy_P        memcpy\r
 \r
@@ -328,8 +328,17 @@ typedef unsigned int16  uint16_t;
 #define IRMP_SUPPORT_MANCHESTER                 0\r
 #endif\r
 \r
-#define IRMP_TIMEOUT_TIME                       16500.0e-6                    // timeout after 16.5 ms darkness\r
+#define IRMP_TIMEOUT_TIME                       16000.0e-6                  // timeout after 16 ms darkness\r
+#define IRMP_TIMEOUT_TIME_MS                    16L                         // timeout after 16 ms darkness\r
+\r
+#if (F_INTERRUPTS * IRMP_TIMEOUT_TIME_MS) / 1000 >= 255\r
+#define IRMP_TIMEOUT_LEN                        (uint16_t)(F_INTERRUPTS * IRMP_TIMEOUT_TIME + 0.5)\r
+typedef uint16_t    PAUSE_LEN;\r
+#else\r
 #define IRMP_TIMEOUT_LEN                        (uint8_t)(F_INTERRUPTS * IRMP_TIMEOUT_TIME + 0.5)\r
+typedef uint8_t     PAUSE_LEN;\r
+#endif\r
+\r
 #define IRMP_KEY_REPETITION_LEN                 (uint16_t)(F_INTERRUPTS * 150.0e-3 + 0.5)  // autodetect key repetition within 150 msec\r
 \r
 #define MIN_TOLERANCE_00                        1.0                           // -0%\r
@@ -511,47 +520,43 @@ typedef unsigned int16  uint16_t;
 #define SIEMENS_BIT_LEN_MIN                     ((uint8_t)(F_INTERRUPTS * SIEMENS_BIT_TIME * 1 + 0.5) - 1)\r
 #define SIEMENS_BIT_LEN_MAX                     ((uint8_t)(F_INTERRUPTS * SIEMENS_BIT_TIME * 1 + 0.5) + 1)\r
 \r
-#define FDC1_START_BIT_PULSE_LEN_MIN             ((uint8_t)(F_INTERRUPTS * FDC1_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
-#define FDC1_START_BIT_PULSE_LEN_MAX             ((uint8_t)(F_INTERRUPTS * FDC1_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
-#define FDC1_START_BIT_PAUSE_LEN_MIN             ((uint8_t)(F_INTERRUPTS * FDC1_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
-#define FDC1_START_BIT_PAUSE_LEN_MAX             ((uint8_t)(F_INTERRUPTS * FDC1_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
-#define FDC1_REPEAT_START_BIT_PAUSE_LEN_MIN      ((uint8_t)(F_INTERRUPTS * FDC1_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
-#define FDC1_REPEAT_START_BIT_PAUSE_LEN_MAX      ((uint8_t)(F_INTERRUPTS * FDC1_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
-#define FDC1_PULSE_LEN_MIN                       ((uint8_t)(F_INTERRUPTS * FDC1_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
-#define FDC1_PULSE_LEN_MAX                       ((uint8_t)(F_INTERRUPTS * FDC1_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
-#define FDC1_1_PAUSE_LEN_MIN                     ((uint8_t)(F_INTERRUPTS * FDC1_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
-#define FDC1_1_PAUSE_LEN_MAX                     ((uint8_t)(F_INTERRUPTS * FDC1_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
-#define FDC1_0_PAUSE_LEN_MIN                     ((uint8_t)(F_INTERRUPTS * FDC1_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
-#define FDC1_0_PAUSE_LEN_MAX                     ((uint8_t)(F_INTERRUPTS * FDC1_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
-\r
-#define FDC2_START_BIT_PULSE_LEN_MIN             ((uint8_t)(F_INTERRUPTS * FDC2_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
-#define FDC2_START_BIT_PULSE_LEN_MAX             ((uint8_t)(F_INTERRUPTS * FDC2_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
-#define FDC2_START_BIT_PAUSE_LEN_MIN             ((uint8_t)(F_INTERRUPTS * FDC2_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
-#define FDC2_START_BIT_PAUSE_LEN_MAX             ((uint8_t)(F_INTERRUPTS * FDC2_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
-#define FDC2_REPEAT_START_BIT_PAUSE_LEN_MIN      ((uint8_t)(F_INTERRUPTS * FDC2_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
-#define FDC2_REPEAT_START_BIT_PAUSE_LEN_MAX      ((uint8_t)(F_INTERRUPTS * FDC2_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
-#define FDC2_PULSE_LEN_MIN                       ((uint8_t)(F_INTERRUPTS * FDC2_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
-#define FDC2_PULSE_LEN_MAX                       ((uint8_t)(F_INTERRUPTS * FDC2_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
-#define FDC2_1_PAUSE_LEN_MIN                     ((uint8_t)(F_INTERRUPTS * FDC2_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
-#define FDC2_1_PAUSE_LEN_MAX                     ((uint8_t)(F_INTERRUPTS * FDC2_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
-#define FDC2_0_PAUSE_LEN_MIN                     ((uint8_t)(F_INTERRUPTS * FDC2_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
-#define FDC2_0_PAUSE_LEN_MAX                     ((uint8_t)(F_INTERRUPTS * FDC2_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
+#define FDC_START_BIT_PULSE_LEN_MIN             ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
+#define FDC_START_BIT_PULSE_LEN_MAX             ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
+#define FDC_START_BIT_PAUSE_LEN_MIN             ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
+#define FDC_START_BIT_PAUSE_LEN_MAX             ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
+#define FDC_PULSE_LEN_MIN                       ((uint8_t)(F_INTERRUPTS * FDC_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
+#define FDC_PULSE_LEN_MAX                       ((uint8_t)(F_INTERRUPTS * FDC_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
+#define FDC_1_PAUSE_LEN_MIN                     ((uint8_t)(F_INTERRUPTS * FDC_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
+#define FDC_1_PAUSE_LEN_MAX                     ((uint8_t)(F_INTERRUPTS * FDC_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
+#define FDC_0_PAUSE_LEN_MIN                     ((uint8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1)\r
+#define FDC_0_PAUSE_LEN_MAX                     ((uint8_t)(F_INTERRUPTS * FDC_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1)\r
+\r
+#define RCCAR_START_BIT_PULSE_LEN_MIN           ((uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
+#define RCCAR_START_BIT_PULSE_LEN_MAX           ((uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
+#define RCCAR_START_BIT_PAUSE_LEN_MIN           ((uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
+#define RCCAR_START_BIT_PAUSE_LEN_MAX           ((uint8_t)(F_INTERRUPTS * RCCAR_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
+#define RCCAR_PULSE_LEN_MIN                     ((uint8_t)(F_INTERRUPTS * RCCAR_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1)\r
+#define RCCAR_PULSE_LEN_MAX                     ((uint8_t)(F_INTERRUPTS * RCCAR_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1)\r
+#define RCCAR_1_PAUSE_LEN_MIN                   ((uint8_t)(F_INTERRUPTS * RCCAR_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
+#define RCCAR_1_PAUSE_LEN_MAX                   ((uint8_t)(F_INTERRUPTS * RCCAR_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
+#define RCCAR_0_PAUSE_LEN_MIN                   ((uint8_t)(F_INTERRUPTS * RCCAR_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1)\r
+#define RCCAR_0_PAUSE_LEN_MAX                   ((uint8_t)(F_INTERRUPTS * RCCAR_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1)\r
 \r
 #define AUTO_FRAME_REPETITION_LEN               (uint16_t)(F_INTERRUPTS * AUTO_FRAME_REPETITION_TIME + 0.5)       // use uint16_t!\r
 \r
-#ifdef DEBUG\r
-#define DEBUG_PUTCHAR(a)                        { if (! silent)             { putchar (a);          } }\r
-#define DEBUG_ONLY_NORMAL_PUTCHAR(a)            { if (! silent && !verbose) { putchar (a);          } }\r
-#define DEBUG_PRINTF(...)                       { if (verbose)              { printf (__VA_ARGS__); } }\r
-#define DEBUG_NEWLINE()                         { if (verbose)              { putchar ('\n');       } }\r
+#ifdef ANALYZE\r
+#define ANALYZE_PUTCHAR(a)                        { if (! silent)             { putchar (a);          } }\r
+#define ANALYZE_ONLY_NORMAL_PUTCHAR(a)            { if (! silent && !verbose) { putchar (a);          } }\r
+#define ANALYZE_PRINTF(...)                       { if (verbose)              { printf (__VA_ARGS__); } }\r
+#define ANALYZE_NEWLINE()                         { if (verbose)              { putchar ('\n');       } }\r
 static int      silent;\r
 static int      time_counter;\r
 static int      verbose;\r
 #else\r
-#define DEBUG_PUTCHAR(a)\r
-#define DEBUG_ONLY_NORMAL_PUTCHAR(a)\r
-#define DEBUG_PRINTF(...)\r
-#define DEBUG_NEWLINE()\r
+#define ANALYZE_PUTCHAR(a)\r
+#define ANALYZE_ONLY_NORMAL_PUTCHAR(a)\r
+#define ANALYZE_PRINTF(...)\r
+#define ANALYZE_NEWLINE()\r
 #endif\r
 \r
 #if IRMP_LOGGING == 1\r
@@ -1108,52 +1113,52 @@ static PROGMEM IRMP_PARAMETER siemens_param =
 \r
 #endif\r
 \r
-#if IRMP_SUPPORT_FDC1_PROTOCOL == 1\r
+#if IRMP_SUPPORT_FDC_PROTOCOL == 1\r
 \r
-static PROGMEM IRMP_PARAMETER fdc1_param =\r
+static PROGMEM IRMP_PARAMETER fdc_param =\r
 {\r
-    IRMP_FDC1_PROTOCOL,                                                 // protocol:        ir protocol\r
-    FDC1_PULSE_LEN_MIN,                                                 // pulse_1_len_min: minimum length of pulse with bit value 1\r
-    FDC1_PULSE_LEN_MAX,                                                 // pulse_1_len_max: maximum length of pulse with bit value 1\r
-    FDC1_1_PAUSE_LEN_MIN,                                               // pause_1_len_min: minimum length of pause with bit value 1\r
-    FDC1_1_PAUSE_LEN_MAX,                                               // pause_1_len_max: maximum length of pause with bit value 1\r
-    FDC1_PULSE_LEN_MIN,                                                 // pulse_0_len_min: minimum length of pulse with bit value 0\r
-    FDC1_PULSE_LEN_MAX,                                                 // pulse_0_len_max: maximum length of pulse with bit value 0\r
-    FDC1_0_PAUSE_LEN_MIN,                                               // pause_0_len_min: minimum length of pause with bit value 0\r
-    FDC1_0_PAUSE_LEN_MAX,                                               // pause_0_len_max: maximum length of pause with bit value 0\r
-    FDC1_ADDRESS_OFFSET,                                                // address_offset:  address offset\r
-    FDC1_ADDRESS_OFFSET + FDC1_ADDRESS_LEN,                             // address_end:     end of address\r
-    FDC1_COMMAND_OFFSET,                                                // command_offset:  command offset\r
-    FDC1_COMMAND_OFFSET + FDC1_COMMAND_LEN,                             // command_end:     end of command\r
-    FDC1_COMPLETE_DATA_LEN,                                             // complete_len:    complete length of frame\r
-    FDC1_STOP_BIT,                                                      // stop_bit:        flag: frame has stop bit\r
-    FDC1_LSB,                                                           // lsb_first:       flag: LSB first\r
-    FDC1_FLAGS                                                          // flags:           some flags\r
+    IRMP_FDC_PROTOCOL,                                                  // protocol:        ir protocol\r
+    FDC_PULSE_LEN_MIN,                                                  // pulse_1_len_min: minimum length of pulse with bit value 1\r
+    FDC_PULSE_LEN_MAX,                                                  // pulse_1_len_max: maximum length of pulse with bit value 1\r
+    FDC_1_PAUSE_LEN_MIN,                                                // pause_1_len_min: minimum length of pause with bit value 1\r
+    FDC_1_PAUSE_LEN_MAX,                                                // pause_1_len_max: maximum length of pause with bit value 1\r
+    FDC_PULSE_LEN_MIN,                                                  // pulse_0_len_min: minimum length of pulse with bit value 0\r
+    FDC_PULSE_LEN_MAX,                                                  // pulse_0_len_max: maximum length of pulse with bit value 0\r
+    FDC_0_PAUSE_LEN_MIN,                                                // pause_0_len_min: minimum length of pause with bit value 0\r
+    FDC_0_PAUSE_LEN_MAX,                                                // pause_0_len_max: maximum length of pause with bit value 0\r
+    FDC_ADDRESS_OFFSET,                                                 // address_offset:  address offset\r
+    FDC_ADDRESS_OFFSET + FDC_ADDRESS_LEN,                               // address_end:     end of address\r
+    FDC_COMMAND_OFFSET,                                                 // command_offset:  command offset\r
+    FDC_COMMAND_OFFSET + FDC_COMMAND_LEN,                               // command_end:     end of command\r
+    FDC_COMPLETE_DATA_LEN,                                              // complete_len:    complete length of frame\r
+    FDC_STOP_BIT,                                                       // stop_bit:        flag: frame has stop bit\r
+    FDC_LSB,                                                            // lsb_first:       flag: LSB first\r
+    FDC_FLAGS                                                           // flags:           some flags\r
 };\r
 \r
 #endif\r
 \r
-#if IRMP_SUPPORT_FDC2_PROTOCOL == 1\r
+#if IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
 \r
-static PROGMEM IRMP_PARAMETER fdc2_param =\r
+static PROGMEM IRMP_PARAMETER rccar_param =\r
 {\r
-    IRMP_FDC2_PROTOCOL,                                                 // protocol:        ir protocol\r
-    FDC2_PULSE_LEN_MIN,                                                 // pulse_1_len_min: minimum length of pulse with bit value 1\r
-    FDC2_PULSE_LEN_MAX,                                                 // pulse_1_len_max: maximum length of pulse with bit value 1\r
-    FDC2_1_PAUSE_LEN_MIN,                                               // pause_1_len_min: minimum length of pause with bit value 1\r
-    FDC2_1_PAUSE_LEN_MAX,                                               // pause_1_len_max: maximum length of pause with bit value 1\r
-    FDC2_PULSE_LEN_MIN,                                                 // pulse_0_len_min: minimum length of pulse with bit value 0\r
-    FDC2_PULSE_LEN_MAX,                                                 // pulse_0_len_max: maximum length of pulse with bit value 0\r
-    FDC2_0_PAUSE_LEN_MIN,                                               // pause_0_len_min: minimum length of pause with bit value 0\r
-    FDC2_0_PAUSE_LEN_MAX,                                               // pause_0_len_max: maximum length of pause with bit value 0\r
-    FDC2_ADDRESS_OFFSET,                                                // address_offset:  address offset\r
-    FDC2_ADDRESS_OFFSET + FDC2_ADDRESS_LEN,                             // address_end:     end of address\r
-    FDC2_COMMAND_OFFSET,                                                // command_offset:  command offset\r
-    FDC2_COMMAND_OFFSET + FDC2_COMMAND_LEN,                             // command_end:     end of command\r
-    FDC2_COMPLETE_DATA_LEN,                                             // complete_len:    complete length of frame\r
-    FDC2_STOP_BIT,                                                      // stop_bit:        flag: frame has stop bit\r
-    FDC2_LSB,                                                           // lsb_first:       flag: LSB first\r
-    FDC2_FLAGS                                                          // flags:           some flags\r
+    IRMP_RCCAR_PROTOCOL,                                                // protocol:        ir protocol\r
+    RCCAR_PULSE_LEN_MIN,                                                // pulse_1_len_min: minimum length of pulse with bit value 1\r
+    RCCAR_PULSE_LEN_MAX,                                                // pulse_1_len_max: maximum length of pulse with bit value 1\r
+    RCCAR_1_PAUSE_LEN_MIN,                                              // pause_1_len_min: minimum length of pause with bit value 1\r
+    RCCAR_1_PAUSE_LEN_MAX,                                              // pause_1_len_max: maximum length of pause with bit value 1\r
+    RCCAR_PULSE_LEN_MIN,                                                // pulse_0_len_min: minimum length of pulse with bit value 0\r
+    RCCAR_PULSE_LEN_MAX,                                                // pulse_0_len_max: maximum length of pulse with bit value 0\r
+    RCCAR_0_PAUSE_LEN_MIN,                                              // pause_0_len_min: minimum length of pause with bit value 0\r
+    RCCAR_0_PAUSE_LEN_MAX,                                              // pause_0_len_max: maximum length of pause with bit value 0\r
+    RCCAR_ADDRESS_OFFSET,                                               // address_offset:  address offset\r
+    RCCAR_ADDRESS_OFFSET + RCCAR_ADDRESS_LEN,                           // address_end:     end of address\r
+    RCCAR_COMMAND_OFFSET,                                               // command_offset:  command offset\r
+    RCCAR_COMMAND_OFFSET + RCCAR_COMMAND_LEN,                           // command_end:     end of command\r
+    RCCAR_COMPLETE_DATA_LEN,                                            // complete_len:    complete length of frame\r
+    RCCAR_STOP_BIT,                                                     // stop_bit:        flag: frame has stop bit\r
+    RCCAR_LSB,                                                          // lsb_first:       flag: LSB first\r
+    RCCAR_FLAGS                                                         // flags:           some flags\r
 };\r
 \r
 #endif\r
@@ -1168,7 +1173,7 @@ static volatile uint16_t                    irmp_command;
 static volatile uint16_t                    irmp_id;                    // only used for SAMSUNG protocol\r
 static volatile uint8_t                     irmp_flags;\r
 \r
-#ifdef DEBUG\r
+#ifdef ANALYZE\r
 static uint8_t                              IRMP_PIN;\r
 #endif\r
 \r
@@ -1177,7 +1182,7 @@ static uint8_t                              IRMP_PIN;
  *  @details  Configures IRMP input pin\r
  *---------------------------------------------------------------------------------------------------------------------------------------------------\r
  */\r
-#ifndef DEBUG\r
+#ifndef ANALYZE\r
 void\r
 irmp_init (void)\r
 {\r
@@ -1226,12 +1231,24 @@ irmp_get_data (IRMP_DATA * irmp_data_p)
                 }\r
                 else if ((irmp_command & 0xFF00) == 0xD100)\r
                 {\r
-                    DEBUG_PRINTF ("Switching to APPLE protocol\n");\r
+                    ANALYZE_PRINTF ("Switching to APPLE protocol\n");\r
                     irmp_protocol = IRMP_APPLE_PROTOCOL;\r
                     irmp_command &= 0xff;\r
                     rtc = TRUE;\r
                 }\r
                 break;\r
+#endif\r
+#if IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
+            case IRMP_RCCAR_PROTOCOL:\r
+                // frame in irmp_data:\r
+                // Bit 12 11 10 9  8  7  6  5  4  3  2  1  0\r
+                //     V  D7 D6 D5 D4 D3 D2 D1 D0 A1 A0 C1 C0   //         10 9  8  7  6  5  4  3  2  1  0\r
+                irmp_address = (irmp_command & 0x000C) >> 2;    // addr:   0  0  0  0  0  0  0  0  0  A1 A0\r
+                irmp_command = ((irmp_command & 0x1000) >> 2) | // V-Bit:  V  0  0  0  0  0  0  0  0  0  0\r
+                               ((irmp_command & 0x0003) << 8) | // C-Bits: 0  C1 C0 0  0  0  0  0  0  0  0\r
+                               ((irmp_command & 0x0FF0) >> 4);  // D-Bits:          D7 D6 D5 D4 D3 D2 D1 D0\r
+                rtc = TRUE;                                     // Summe:  V  C1 C0 D7 D6 D5 D4 D3 D2 D1 D0\r
+                break;\r
 #endif\r
             default:\r
                 rtc = TRUE;\r
@@ -1313,30 +1330,30 @@ irmp_store_bit (uint8_t value)
 uint8_t\r
 irmp_ISR (void)\r
 {\r
-    static uint8_t    irmp_start_bit_detected;                                  // flag: start bit detected\r
-    static uint8_t    wait_for_space;                                           // flag: wait for data bit space\r
-    static uint8_t    wait_for_start_space;                                     // flag: wait for start bit space\r
-    static uint8_t    irmp_pulse_time;                                          // count bit time for pulse\r
-    static uint8_t    irmp_pause_time;                                          // count bit time for pause\r
-    static uint16_t   last_irmp_address = 0xFFFF;                               // save last irmp address to recognize key repetition\r
-    static uint16_t   last_irmp_command = 0xFFFF;                               // save last irmp command to recognize key repetition\r
-    static uint16_t   repetition_counter;                                       // SIRCS repeats frame 2-5 times with 45 ms pause\r
-    static uint8_t    repetition_frame_number;\r
+    static uint8_t      irmp_start_bit_detected;                                // flag: start bit detected\r
+    static uint8_t      wait_for_space;                                         // flag: wait for data bit space\r
+    static uint8_t      wait_for_start_space;                                   // flag: wait for start bit space\r
+    static uint8_t      irmp_pulse_time;                                        // count bit time for pulse\r
+    static PAUSE_LEN    irmp_pause_time;                                        // count bit time for pause\r
+    static uint16_t     last_irmp_address = 0xFFFF;                             // save last irmp address to recognize key repetition\r
+    static uint16_t     last_irmp_command = 0xFFFF;                             // save last irmp command to recognize key repetition\r
+    static uint16_t     repetition_counter;                                     // SIRCS repeats frame 2-5 times with 45 ms pause\r
+    static uint8_t      repetition_frame_number;\r
 #if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
-    static uint16_t   last_irmp_denon_command;                                  // save last irmp command to recognize DENON frame repetition\r
+    static uint16_t     last_irmp_denon_command;                                // save last irmp command to recognize DENON frame repetition\r
 #endif\r
 #if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
-    static uint8_t    rc5_cmd_bit6;                                             // bit 6 of RC5 command is the inverted 2nd start bit\r
+    static uint8_t      rc5_cmd_bit6;                                           // bit 6 of RC5 command is the inverted 2nd start bit\r
 #endif\r
 #if IRMP_SUPPORT_MANCHESTER == 1\r
-    static uint8_t    last_pause;                                               // last pause value\r
+    static PAUSE_LEN    last_pause;                                             // last pause value\r
 #endif\r
 #if IRMP_SUPPORT_MANCHESTER == 1 || IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
-    static uint8_t    last_value;                                               // last bit value\r
+    static uint8_t      last_value;                                             // last bit value\r
 #endif\r
-    uint8_t           irmp_input;                                               // input value\r
+    uint8_t             irmp_input;                                             // input value\r
 \r
-#ifdef DEBUG\r
+#ifdef ANALYZE\r
     time_counter++;\r
 #endif\r
 \r
@@ -1350,10 +1367,10 @@ irmp_ISR (void)
         {                                                                       // no...\r
             if (! irmp_input)                                                   // receiving burst?\r
             {                                                                   // yes...\r
-#ifdef DEBUG\r
+#ifdef ANALYZE\r
                 if (! irmp_pulse_time)\r
                 {\r
-                    DEBUG_PRINTF("%8d [starting pulse]\n", time_counter);\r
+                    ANALYZE_PRINTF("%8d [starting pulse]\n", time_counter);\r
                 }\r
 #endif\r
                 irmp_pulse_time++;                                              // increment counter\r
@@ -1389,8 +1406,8 @@ irmp_ISR (void)
 \r
                     if (irmp_pause_time > IRMP_TIMEOUT_LEN)                     // timeout?\r
                     {                                                           // yes...\r
-                        DEBUG_PRINTF ("error 1: pause after start bit pulse %d too long: %d\n", irmp_pulse_time, irmp_pause_time);\r
-                        DEBUG_ONLY_NORMAL_PUTCHAR ('\n');\r
+                        ANALYZE_PRINTF ("error 1: pause after start bit pulse %d too long: %d\n", irmp_pulse_time, irmp_pause_time);\r
+                        ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
                         irmp_start_bit_detected = 0;                            // reset flags, let's wait for another start bit\r
                         irmp_pulse_time         = 0;\r
                         irmp_pause_time         = 0;\r
@@ -1400,13 +1417,13 @@ irmp_ISR (void)
                 {                                                               // receiving first data pulse!\r
                     IRMP_PARAMETER * irmp_param_p = (IRMP_PARAMETER *) 0;\r
 \r
-                    DEBUG_PRINTF ("start-bit: pulse = %d, pause = %d\n", irmp_pulse_time, irmp_pause_time);\r
+                    ANALYZE_PRINTF ("start-bit: pulse = %d, pause = %d\n", irmp_pulse_time, irmp_pause_time);\r
 \r
 #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1\r
                     if (irmp_pulse_time >= SIRCS_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SIRCS_START_BIT_PULSE_LEN_MAX &&\r
                         irmp_pause_time >= SIRCS_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SIRCS_START_BIT_PAUSE_LEN_MAX)\r
                     {                                                           // it's SIRCS\r
-                        DEBUG_PRINTF ("protocol = SIRCS, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("protocol = SIRCS, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         SIRCS_START_BIT_PULSE_LEN_MIN, SIRCS_START_BIT_PULSE_LEN_MAX,\r
                                         SIRCS_START_BIT_PAUSE_LEN_MIN, SIRCS_START_BIT_PAUSE_LEN_MAX);\r
                         irmp_param_p = (IRMP_PARAMETER *) (IRMP_PARAMETER *) &sircs_param;\r
@@ -1418,7 +1435,7 @@ irmp_ISR (void)
                     if (irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&\r
                         irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX)\r
                     {\r
-                        DEBUG_PRINTF ("protocol = NEC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("protocol = NEC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,\r
                                         NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX);\r
                         irmp_param_p = (IRMP_PARAMETER *) &nec_param;\r
@@ -1426,7 +1443,7 @@ irmp_ISR (void)
                     else if (irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN        && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX &&\r
                              irmp_pause_time >= NEC_REPEAT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_REPEAT_START_BIT_PAUSE_LEN_MAX)\r
                     {                                                           // it's NEC\r
-                        DEBUG_PRINTF ("protocol = NEC (repetition frame), start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("protocol = NEC (repetition frame), start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX,\r
                                         NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX);\r
 \r
@@ -1439,7 +1456,7 @@ irmp_ISR (void)
                     if (irmp_pulse_time >= SAMSUNG_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_START_BIT_PULSE_LEN_MAX &&\r
                         irmp_pause_time >= SAMSUNG_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_START_BIT_PAUSE_LEN_MAX)\r
                     {                                                           // it's SAMSUNG\r
-                        DEBUG_PRINTF ("protocol = SAMSUNG, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("protocol = SAMSUNG, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         SAMSUNG_START_BIT_PULSE_LEN_MIN, SAMSUNG_START_BIT_PULSE_LEN_MAX,\r
                                         SAMSUNG_START_BIT_PAUSE_LEN_MIN, SAMSUNG_START_BIT_PAUSE_LEN_MAX);\r
                         irmp_param_p = (IRMP_PARAMETER *) &samsung_param;\r
@@ -1451,7 +1468,7 @@ irmp_ISR (void)
                     if (irmp_pulse_time >= MATSUSHITA_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= MATSUSHITA_START_BIT_PULSE_LEN_MAX &&\r
                         irmp_pause_time >= MATSUSHITA_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= MATSUSHITA_START_BIT_PAUSE_LEN_MAX)\r
                     {                                                           // it's MATSUSHITA\r
-                        DEBUG_PRINTF ("protocol = MATSUSHITA, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("protocol = MATSUSHITA, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         MATSUSHITA_START_BIT_PULSE_LEN_MIN, MATSUSHITA_START_BIT_PULSE_LEN_MAX,\r
                                         MATSUSHITA_START_BIT_PAUSE_LEN_MIN, MATSUSHITA_START_BIT_PAUSE_LEN_MAX);\r
                         irmp_param_p = (IRMP_PARAMETER *) &matsushita_param;\r
@@ -1463,7 +1480,7 @@ irmp_ISR (void)
                     if (irmp_pulse_time >= KASEIKYO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= KASEIKYO_START_BIT_PULSE_LEN_MAX &&\r
                         irmp_pause_time >= KASEIKYO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KASEIKYO_START_BIT_PAUSE_LEN_MAX)\r
                     {                                                           // it's KASEIKYO\r
-                        DEBUG_PRINTF ("protocol = KASEIKYO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("protocol = KASEIKYO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         KASEIKYO_START_BIT_PULSE_LEN_MIN, KASEIKYO_START_BIT_PULSE_LEN_MAX,\r
                                         KASEIKYO_START_BIT_PAUSE_LEN_MIN, KASEIKYO_START_BIT_PAUSE_LEN_MAX);\r
                         irmp_param_p = (IRMP_PARAMETER *) &kaseikyo_param;\r
@@ -1475,7 +1492,7 @@ irmp_ISR (void)
                     if (irmp_pulse_time >= RECS80_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RECS80_START_BIT_PULSE_LEN_MAX &&\r
                         irmp_pause_time >= RECS80_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RECS80_START_BIT_PAUSE_LEN_MAX)\r
                     {                                                           // it's RECS80\r
-                        DEBUG_PRINTF ("protocol = RECS80, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("protocol = RECS80, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         RECS80_START_BIT_PULSE_LEN_MIN, RECS80_START_BIT_PULSE_LEN_MAX,\r
                                         RECS80_START_BIT_PAUSE_LEN_MIN, RECS80_START_BIT_PAUSE_LEN_MAX);\r
                         irmp_param_p = (IRMP_PARAMETER *) &recs80_param;\r
@@ -1489,7 +1506,7 @@ irmp_ISR (void)
                         ((irmp_pause_time >= RC5_START_BIT_LEN_MIN && irmp_pause_time <= RC5_START_BIT_LEN_MAX) ||\r
                          (irmp_pause_time >= 2 * RC5_START_BIT_LEN_MIN && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX)))\r
                     {                                                           // it's RC5\r
-                        DEBUG_PRINTF ("protocol = RC5, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("protocol = RC5, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX,\r
                                         RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX);\r
                         irmp_param_p = (IRMP_PARAMETER *) &rc5_param;\r
@@ -1514,7 +1531,7 @@ irmp_ISR (void)
                         ((irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX) ||\r
                          (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX)))\r
                     {                                                           // it's DENON\r
-                        DEBUG_PRINTF ("protocol = DENON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("protocol = DENON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n",\r
                                         DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX,\r
                                         DENON_1_PAUSE_LEN_MIN, DENON_1_PAUSE_LEN_MAX,\r
                                         DENON_0_PAUSE_LEN_MIN, DENON_0_PAUSE_LEN_MAX);\r
@@ -1527,7 +1544,7 @@ irmp_ISR (void)
                     if (irmp_pulse_time >= RC6_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RC6_START_BIT_PULSE_LEN_MAX &&\r
                         irmp_pause_time >= RC6_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RC6_START_BIT_PAUSE_LEN_MAX)\r
                     {                                                           // it's RC6\r
-                        DEBUG_PRINTF ("protocol = RC6, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("protocol = RC6, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         RC6_START_BIT_PULSE_LEN_MIN, RC6_START_BIT_PULSE_LEN_MAX,\r
                                         RC6_START_BIT_PAUSE_LEN_MIN, RC6_START_BIT_PAUSE_LEN_MAX);\r
                         irmp_param_p = (IRMP_PARAMETER *) &rc6_param;\r
@@ -1541,7 +1558,7 @@ irmp_ISR (void)
                     if (irmp_pulse_time >= RECS80EXT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RECS80EXT_START_BIT_PULSE_LEN_MAX &&\r
                         irmp_pause_time >= RECS80EXT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RECS80EXT_START_BIT_PAUSE_LEN_MAX)\r
                     {                                                           // it's RECS80EXT\r
-                        DEBUG_PRINTF ("protocol = RECS80EXT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("protocol = RECS80EXT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         RECS80EXT_START_BIT_PULSE_LEN_MIN, RECS80EXT_START_BIT_PULSE_LEN_MAX,\r
                                         RECS80EXT_START_BIT_PAUSE_LEN_MIN, RECS80EXT_START_BIT_PAUSE_LEN_MAX);\r
                         irmp_param_p = (IRMP_PARAMETER *) &recs80ext_param;\r
@@ -1553,7 +1570,7 @@ irmp_ISR (void)
                     if (irmp_pulse_time >= NUBERT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NUBERT_START_BIT_PULSE_LEN_MAX &&\r
                         irmp_pause_time >= NUBERT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NUBERT_START_BIT_PAUSE_LEN_MAX)\r
                     {                                                           // it's NUBERT\r
-                        DEBUG_PRINTF ("protocol = NUBERT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("protocol = NUBERT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         NUBERT_START_BIT_PULSE_LEN_MIN, NUBERT_START_BIT_PULSE_LEN_MAX,\r
                                         NUBERT_START_BIT_PAUSE_LEN_MIN, NUBERT_START_BIT_PAUSE_LEN_MAX);\r
                         irmp_param_p = (IRMP_PARAMETER *) &nubert_param;\r
@@ -1565,17 +1582,17 @@ irmp_ISR (void)
                     if (irmp_pulse_time >= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN && irmp_pulse_time <= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX &&\r
                         irmp_pause_time >= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX)\r
                     {                                                           // it's BANG_OLUFSEN\r
-                        DEBUG_PRINTF ("protocol = BANG_OLUFSEN\n");\r
-                        DEBUG_PRINTF ("start bit 1 timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("protocol = BANG_OLUFSEN\n");\r
+                        ANALYZE_PRINTF ("start bit 1 timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX,\r
                                         BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX);\r
-                        DEBUG_PRINTF ("start bit 2 timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("start bit 2 timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX,\r
                                         BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX);\r
-                        DEBUG_PRINTF ("start bit 3 timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("start bit 3 timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX,\r
                                         BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX);\r
-                        DEBUG_PRINTF ("start bit 4 timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("start bit 4 timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX,\r
                                         BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX);\r
                         irmp_param_p = (IRMP_PARAMETER *) &bang_olufsen_param;\r
@@ -1588,7 +1605,7 @@ irmp_ISR (void)
                     if (irmp_pulse_time >= GRUNDIG_OR_NOKIA_START_BIT_LEN_MIN && irmp_pulse_time <= GRUNDIG_OR_NOKIA_START_BIT_LEN_MAX &&\r
                         irmp_pause_time >= GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MIN && irmp_pause_time <= GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MAX)\r
                     {                                                           // it's GRUNDIG\r
-                        DEBUG_PRINTF ("protocol = GRUNDIG, pre bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("protocol = GRUNDIG, pre bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         GRUNDIG_OR_NOKIA_START_BIT_LEN_MIN, GRUNDIG_OR_NOKIA_START_BIT_LEN_MAX,\r
                                         GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MIN, GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MAX);\r
                         irmp_param_p = (IRMP_PARAMETER *) &grundig_param;\r
@@ -1604,7 +1621,7 @@ irmp_ISR (void)
                         ((irmp_pause_time >= SIEMENS_START_BIT_LEN_MIN && irmp_pause_time <= SIEMENS_START_BIT_LEN_MAX) ||\r
                          (irmp_pause_time >= 2 * SIEMENS_START_BIT_LEN_MIN && irmp_pause_time <= 2 * SIEMENS_START_BIT_LEN_MAX)))\r
                     {                                                           // it's SIEMENS\r
-                        DEBUG_PRINTF ("protocol = SIEMENS, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                        ANALYZE_PRINTF ("protocol = SIEMENS, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
                                         SIEMENS_START_BIT_LEN_MIN, SIEMENS_START_BIT_LEN_MAX,\r
                                         SIEMENS_START_BIT_LEN_MIN, SIEMENS_START_BIT_LEN_MAX);\r
                         irmp_param_p = (IRMP_PARAMETER *) &siemens_param;\r
@@ -1613,30 +1630,30 @@ irmp_ISR (void)
                     }\r
                     else\r
 #endif // IRMP_SUPPORT_SIEMENS_PROTOCOL == 1\r
-#if IRMP_SUPPORT_FDC1_PROTOCOL == 1\r
-                    if (irmp_pulse_time >= FDC1_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC1_START_BIT_PULSE_LEN_MAX &&\r
-                        irmp_pause_time >= FDC1_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC1_START_BIT_PAUSE_LEN_MAX)\r
+#if IRMP_SUPPORT_FDC_PROTOCOL == 1\r
+                    if (irmp_pulse_time >= FDC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC_START_BIT_PULSE_LEN_MAX &&\r
+                        irmp_pause_time >= FDC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC_START_BIT_PAUSE_LEN_MAX)\r
                     {\r
-                        DEBUG_PRINTF ("protocol = FDC1, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
-                                        FDC1_START_BIT_PULSE_LEN_MIN, FDC1_START_BIT_PULSE_LEN_MAX,\r
-                                        FDC1_START_BIT_PAUSE_LEN_MIN, FDC1_START_BIT_PAUSE_LEN_MAX);\r
-                        irmp_param_p = (IRMP_PARAMETER *) &fdc1_param;\r
+                        ANALYZE_PRINTF ("protocol = FDC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                                        FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX,\r
+                                        FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX);\r
+                        irmp_param_p = (IRMP_PARAMETER *) &fdc_param;\r
                     }\r
                     else\r
-#endif // IRMP_SUPPORT_FDC1_PROTOCOL == 1\r
-#if IRMP_SUPPORT_FDC2_PROTOCOL == 1\r
-                    if (irmp_pulse_time >= FDC2_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC2_START_BIT_PULSE_LEN_MAX &&\r
-                        irmp_pause_time >= FDC2_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC2_START_BIT_PAUSE_LEN_MAX)\r
+#endif // IRMP_SUPPORT_FDC_PROTOCOL == 1\r
+#if IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
+                    if (irmp_pulse_time >= RCCAR_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_START_BIT_PULSE_LEN_MAX &&\r
+                        irmp_pause_time >= RCCAR_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_START_BIT_PAUSE_LEN_MAX)\r
                     {\r
-                        DEBUG_PRINTF ("protocol = FDC2, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
-                                        FDC2_START_BIT_PULSE_LEN_MIN, FDC2_START_BIT_PULSE_LEN_MAX,\r
-                                        FDC2_START_BIT_PAUSE_LEN_MIN, FDC2_START_BIT_PAUSE_LEN_MAX);\r
-                        irmp_param_p = (IRMP_PARAMETER *) &fdc2_param;\r
+                        ANALYZE_PRINTF ("protocol = RCCAR, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",\r
+                                        RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX,\r
+                                        RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX);\r
+                        irmp_param_p = (IRMP_PARAMETER *) &rccar_param;\r
                     }\r
                     else\r
-#endif // IRMP_SUPPORT_FDC2_PROTOCOL == 1\r
+#endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1\r
                     {\r
-                        DEBUG_PRINTF ("protocol = UNKNOWN\n");\r
+                        ANALYZE_PRINTF ("protocol = UNKNOWN\n");\r
                         irmp_start_bit_detected = 0;                            // wait for another start bit...\r
                     }\r
 \r
@@ -1644,46 +1661,46 @@ irmp_ISR (void)
                     {\r
                         memcpy_P (&irmp_param, irmp_param_p, sizeof (IRMP_PARAMETER));\r
 \r
-#ifdef DEBUG\r
+#ifdef ANALYZE\r
                         if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))\r
                         {\r
-                            DEBUG_PRINTF ("pulse_1: %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max);\r
-                            DEBUG_PRINTF ("pause_1: %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max);\r
+                            ANALYZE_PRINTF ("pulse_1: %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max);\r
+                            ANALYZE_PRINTF ("pause_1: %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max);\r
                         }\r
                         else\r
                         {\r
-                            DEBUG_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max,\r
+                            ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max,\r
                                           2 * irmp_param.pulse_1_len_min, 2 * irmp_param.pulse_1_len_max);\r
-                            DEBUG_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max,\r
+                            ANALYZE_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max,\r
                                           2 * irmp_param.pause_1_len_min, 2 * irmp_param.pause_1_len_max);\r
                         }\r
 \r
 #if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
                         if (irmp_param.protocol == IRMP_RC6_PROTOCOL)\r
                         {\r
-                            DEBUG_PRINTF ("pulse_toggle: %3d - %3d\n", RC6_TOGGLE_BIT_LEN_MIN, RC6_TOGGLE_BIT_LEN_MAX);\r
+                            ANALYZE_PRINTF ("pulse_toggle: %3d - %3d\n", RC6_TOGGLE_BIT_LEN_MIN, RC6_TOGGLE_BIT_LEN_MAX);\r
                         }\r
 #endif\r
 \r
                         if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))\r
                         {\r
-                            DEBUG_PRINTF ("pulse_0: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);\r
-                            DEBUG_PRINTF ("pause_0: %3d - %3d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max);\r
+                            ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);\r
+                            ANALYZE_PRINTF ("pause_0: %3d - %3d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max);\r
                         }\r
 \r
 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
                         if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL)\r
                         {\r
-                            DEBUG_PRINTF ("pulse_r: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);\r
-                            DEBUG_PRINTF ("pause_r: %3d - %3d\n", BANG_OLUFSEN_R_PAUSE_LEN_MIN, BANG_OLUFSEN_R_PAUSE_LEN_MAX);\r
+                            ANALYZE_PRINTF ("pulse_r: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max);\r
+                            ANALYZE_PRINTF ("pause_r: %3d - %3d\n", BANG_OLUFSEN_R_PAUSE_LEN_MIN, BANG_OLUFSEN_R_PAUSE_LEN_MAX);\r
                         }\r
 #endif\r
 \r
-                        DEBUG_PRINTF ("command_offset: %2d\n", irmp_param.command_offset);\r
-                        DEBUG_PRINTF ("command_len:    %3d\n", irmp_param.command_end - irmp_param.command_offset);\r
-                        DEBUG_PRINTF ("complete_len:   %3d\n", irmp_param.complete_len);\r
-                        DEBUG_PRINTF ("stop_bit:       %3d\n", irmp_param.stop_bit);\r
-#endif // DEBUG\r
+                        ANALYZE_PRINTF ("command_offset: %2d\n", irmp_param.command_offset);\r
+                        ANALYZE_PRINTF ("command_len:    %3d\n", irmp_param.command_end - irmp_param.command_offset);\r
+                        ANALYZE_PRINTF ("complete_len:   %3d\n", irmp_param.complete_len);\r
+                        ANALYZE_PRINTF ("stop_bit:       %3d\n", irmp_param.stop_bit);\r
+#endif // ANALYZE\r
                     }\r
 \r
                     irmp_bit = 0;\r
@@ -1693,17 +1710,17 @@ irmp_ISR (void)
                     {\r
                         if (irmp_pause_time > irmp_param.pulse_1_len_max && irmp_pause_time <= 2 * irmp_param.pulse_1_len_max)\r
                         {\r
-                            DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
-                            DEBUG_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1');\r
-                            DEBUG_NEWLINE ();\r
+                            ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+                            ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1');\r
+                            ANALYZE_NEWLINE ();\r
                             irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1);\r
                         }\r
                         else if (! last_value)\r
                         {\r
-                            DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+                            ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
 \r
-                            DEBUG_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0');\r
-                            DEBUG_NEWLINE ();\r
+                            ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0');\r
+                            ANALYZE_NEWLINE ();\r
                             irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0);\r
                         }\r
                     }\r
@@ -1713,18 +1730,18 @@ irmp_ISR (void)
 #if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
                     if (irmp_param.protocol == IRMP_DENON_PROTOCOL)\r
                     {\r
-                        DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+                        ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
 \r
                         if (irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX)\r
                         {                                                       // pause timings correct for "1"?\r
-                          DEBUG_PUTCHAR ('1');                                  // yes, store 1\r
-                          DEBUG_NEWLINE ();\r
+                          ANALYZE_PUTCHAR ('1');                                  // yes, store 1\r
+                          ANALYZE_NEWLINE ();\r
                           irmp_store_bit (1);\r
                         }\r
                         else // if (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX)\r
                         {                                                       // pause timings correct for "0"?\r
-                          DEBUG_PUTCHAR ('0');                                  // yes, store 0\r
-                          DEBUG_NEWLINE ();\r
+                          ANALYZE_PUTCHAR ('0');                                  // yes, store 0\r
+                          ANALYZE_NEWLINE ();\r
                           irmp_store_bit (0);\r
                         }\r
                     }\r
@@ -1745,17 +1762,17 @@ irmp_ISR (void)
                     {\r
                         if (irmp_pulse_time >= irmp_param.pulse_0_len_min && irmp_pulse_time <= irmp_param.pulse_0_len_max)\r
                         {\r
-#ifdef DEBUG\r
+#ifdef ANALYZE\r
                             if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))\r
                             {\r
-                                DEBUG_PRINTF ("stop bit detected\n");\r
+                                ANALYZE_PRINTF ("stop bit detected\n");\r
                             }\r
 #endif\r
                             irmp_param.stop_bit = 0;\r
                         }\r
                         else\r
                         {\r
-                            DEBUG_PRINTF ("stop bit timing wrong\n");\r
+                            ANALYZE_PRINTF ("stop bit timing wrong\n");\r
 \r
                             irmp_start_bit_detected = 0;                        // wait for another start bit...\r
                             irmp_pulse_time         = 0;\r
@@ -1789,7 +1806,7 @@ irmp_ISR (void)
                             }\r
                             else if (irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN)\r
                             {\r
-                                DEBUG_PRINTF ("Switching to NOKIA protocol\n");\r
+                                ANALYZE_PRINTF ("Switching to NOKIA protocol\n");\r
                                 irmp_param.protocol         = IRMP_NOKIA_PROTOCOL;      // change protocol\r
                                 irmp_param.address_offset   = NOKIA_ADDRESS_OFFSET;\r
                                 irmp_param.address_end      = NOKIA_ADDRESS_OFFSET + NOKIA_ADDRESS_LEN;\r
@@ -1822,8 +1839,8 @@ irmp_ISR (void)
                             }\r
                             else\r
                             {\r
-                                DEBUG_PRINTF ("error 2: pause %d after data bit %d too long\n", irmp_pause_time, irmp_bit);\r
-                                DEBUG_ONLY_NORMAL_PUTCHAR ('\n');\r
+                                ANALYZE_PRINTF ("error 2: pause %d after data bit %d too long\n", irmp_pause_time, irmp_bit);\r
+                                ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
 \r
                                 irmp_start_bit_detected = 0;                    // wait for another start bit...\r
                                 irmp_pulse_time         = 0;\r
@@ -1839,7 +1856,7 @@ irmp_ISR (void)
 \r
                 if (got_light)\r
                 {\r
-                    DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+                    ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
 \r
 #if IRMP_SUPPORT_MANCHESTER == 1\r
                     if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))                                     // manchester\r
@@ -1849,24 +1866,24 @@ irmp_ISR (void)
                         {\r
                             if (irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MAX && irmp_pause_time > RC6_TOGGLE_BIT_LEN_MAX)\r
                             {\r
-                                DEBUG_PUTCHAR ('1');\r
+                                ANALYZE_PUTCHAR ('1');\r
                                 irmp_store_bit (1);\r
                             }\r
 \r
-                            DEBUG_PUTCHAR ('0');\r
+                            ANALYZE_PUTCHAR ('0');\r
                             irmp_store_bit (0);\r
                             last_value = 0;\r
-                            DEBUG_NEWLINE ();\r
+                            ANALYZE_NEWLINE ();\r
                         }\r
                         else\r
 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1\r
                         if (irmp_pulse_time > irmp_param.pulse_1_len_max && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max)\r
                         {\r
-                            DEBUG_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1');\r
+                            ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1');\r
                             irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0  :  1 );\r
-                            DEBUG_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0');\r
+                            ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0');\r
                             irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 :   0 );\r
-                            DEBUG_NEWLINE ();\r
+                            ANALYZE_NEWLINE ();\r
                             last_value = (irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0;\r
                         }\r
                         else // if (irmp_pulse_time >= irmp_param.pulse_1_len_max && irmp_pulse_time <= irmp_param.pulse_1_len_max)\r
@@ -1892,8 +1909,8 @@ irmp_ISR (void)
 #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1\r
 #endif // 0\r
 \r
-                            DEBUG_PUTCHAR (manchester_value + '0');\r
-                            DEBUG_NEWLINE ();\r
+                            ANALYZE_PUTCHAR (manchester_value + '0');\r
+                            ANALYZE_NEWLINE ();\r
                             irmp_store_bit (manchester_value);\r
                         }\r
 \r
@@ -1910,7 +1927,7 @@ irmp_ISR (void)
                         if (irmp_pulse_time >= SAMSUNG_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_PULSE_LEN_MAX &&\r
                             irmp_pause_time >= SAMSUNG_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_START_BIT_PAUSE_LEN_MAX)\r
                         {\r
-                            DEBUG_PRINTF ("SYNC\n");\r
+                            ANALYZE_PRINTF ("SYNC\n");\r
                             wait_for_space = 0;\r
                             irmp_tmp_id = 0;\r
                             irmp_bit++;\r
@@ -1924,25 +1941,25 @@ irmp_ISR (void)
 \r
                             if (irmp_pause_time >= SAMSUNG_1_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_1_PAUSE_LEN_MAX)\r
                             {\r
-                                DEBUG_PUTCHAR ('1');\r
-                                DEBUG_NEWLINE ();\r
+                                ANALYZE_PUTCHAR ('1');\r
+                                ANALYZE_NEWLINE ();\r
                                 irmp_store_bit (1);\r
                                 wait_for_space = 0;\r
                             }\r
                             else\r
                             {\r
-                                DEBUG_PUTCHAR ('0');\r
-                                DEBUG_NEWLINE ();\r
+                                ANALYZE_PUTCHAR ('0');\r
+                                ANALYZE_NEWLINE ();\r
                                 irmp_store_bit (0);\r
                                 wait_for_space = 0;\r
                             }\r
 \r
-                            DEBUG_PRINTF ("Switching to SAMSUNG32 protocol\n");\r
+                            ANALYZE_PRINTF ("Switching to SAMSUNG32 protocol\n");\r
                         }\r
                         else\r
                         {                                                           // timing incorrect!\r
-                            DEBUG_PRINTF ("error 3 Samsung: timing not correct: data bit %d,  pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
-                            DEBUG_ONLY_NORMAL_PUTCHAR ('\n');\r
+                            ANALYZE_PRINTF ("error 3 Samsung: timing not correct: data bit %d,  pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+                            ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
                             irmp_start_bit_detected = 0;                            // reset flags and wait for next start bit\r
                             irmp_pause_time         = 0;\r
                         }\r
@@ -1959,15 +1976,15 @@ irmp_ISR (void)
                             {\r
                                 if (irmp_pause_time >= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX)\r
                                 {\r
-                                    DEBUG_PRINTF ("3rd start bit\n");\r
+                                    ANALYZE_PRINTF ("3rd start bit\n");\r
                                     wait_for_space = 0;\r
                                     irmp_tmp_id = 0;\r
                                     irmp_bit++;\r
                                 }\r
                                 else\r
                                 {                                                   // timing incorrect!\r
-                                    DEBUG_PRINTF ("error 3a B&O: timing not correct: data bit %d,  pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
-                                    DEBUG_ONLY_NORMAL_PUTCHAR ('\n');\r
+                                    ANALYZE_PRINTF ("error 3a B&O: timing not correct: data bit %d,  pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+                                    ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
                                     irmp_start_bit_detected = 0;                    // reset flags and wait for next start bit\r
                                     irmp_pause_time         = 0;\r
                                 }\r
@@ -1976,15 +1993,15 @@ irmp_ISR (void)
                             {\r
                                 if (irmp_pause_time >= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX)\r
                                 {\r
-                                    DEBUG_PRINTF ("trailer bit\n");\r
+                                    ANALYZE_PRINTF ("trailer bit\n");\r
                                     wait_for_space = 0;\r
                                     irmp_tmp_id = 0;\r
                                     irmp_bit++;\r
                                 }\r
                                 else\r
                                 {                                                   // timing incorrect!\r
-                                    DEBUG_PRINTF ("error 3b B&O: timing not correct: data bit %d,  pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
-                                    DEBUG_ONLY_NORMAL_PUTCHAR ('\n');\r
+                                    ANALYZE_PRINTF ("error 3b B&O: timing not correct: data bit %d,  pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+                                    ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
                                     irmp_start_bit_detected = 0;                    // reset flags and wait for next start bit\r
                                     irmp_pause_time         = 0;\r
                                 }\r
@@ -1993,31 +2010,31 @@ irmp_ISR (void)
                             {\r
                                 if (irmp_pause_time >= BANG_OLUFSEN_1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_1_PAUSE_LEN_MAX)\r
                                 {                                                   // pulse & pause timings correct for "1"?\r
-                                    DEBUG_PUTCHAR ('1');\r
-                                    DEBUG_NEWLINE ();\r
+                                    ANALYZE_PUTCHAR ('1');\r
+                                    ANALYZE_NEWLINE ();\r
                                     irmp_store_bit (1);\r
                                     last_value = 1;\r
                                     wait_for_space = 0;\r
                                 }\r
                                 else if (irmp_pause_time >= BANG_OLUFSEN_0_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_0_PAUSE_LEN_MAX)\r
                                 {                                                   // pulse & pause timings correct for "0"?\r
-                                    DEBUG_PUTCHAR ('0');\r
-                                    DEBUG_NEWLINE ();\r
+                                    ANALYZE_PUTCHAR ('0');\r
+                                    ANALYZE_NEWLINE ();\r
                                     irmp_store_bit (0);\r
                                     last_value = 0;\r
                                     wait_for_space = 0;\r
                                 }\r
                                 else if (irmp_pause_time >= BANG_OLUFSEN_R_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_R_PAUSE_LEN_MAX)\r
                                 {\r
-                                    DEBUG_PUTCHAR (last_value + '0');\r
-                                    DEBUG_NEWLINE ();\r
+                                    ANALYZE_PUTCHAR (last_value + '0');\r
+                                    ANALYZE_NEWLINE ();\r
                                     irmp_store_bit (last_value);\r
                                     wait_for_space = 0;\r
                                 }\r
                                 else\r
                                 {                                                   // timing incorrect!\r
-                                    DEBUG_PRINTF ("error 3c B&O: timing not correct: data bit %d,  pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
-                                    DEBUG_ONLY_NORMAL_PUTCHAR ('\n');\r
+                                    ANALYZE_PRINTF ("error 3c B&O: timing not correct: data bit %d,  pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+                                    ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
                                     irmp_start_bit_detected = 0;                    // reset flags and wait for next start bit\r
                                     irmp_pause_time         = 0;\r
                                 }\r
@@ -2025,8 +2042,8 @@ irmp_ISR (void)
                         }\r
                         else\r
                         {                                                           // timing incorrect!\r
-                            DEBUG_PRINTF ("error 3d B&O: timing not correct: data bit %d,  pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
-                            DEBUG_ONLY_NORMAL_PUTCHAR ('\n');\r
+                            ANALYZE_PRINTF ("error 3d B&O: timing not correct: data bit %d,  pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+                            ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
                             irmp_start_bit_detected = 0;                            // reset flags and wait for next start bit\r
                             irmp_pause_time         = 0;\r
                         }\r
@@ -2037,23 +2054,23 @@ irmp_ISR (void)
                     if (irmp_pulse_time >= irmp_param.pulse_1_len_min && irmp_pulse_time <= irmp_param.pulse_1_len_max &&\r
                         irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max)\r
                     {                                                               // pulse & pause timings correct for "1"?\r
-                        DEBUG_PUTCHAR ('1');\r
-                        DEBUG_NEWLINE ();\r
+                        ANALYZE_PUTCHAR ('1');\r
+                        ANALYZE_NEWLINE ();\r
                         irmp_store_bit (1);\r
                         wait_for_space = 0;\r
                     }\r
                     else if (irmp_pulse_time >= irmp_param.pulse_0_len_min && irmp_pulse_time <= irmp_param.pulse_0_len_max &&\r
                              irmp_pause_time >= irmp_param.pause_0_len_min && irmp_pause_time <= irmp_param.pause_0_len_max)\r
                     {                                                               // pulse & pause timings correct for "0"?\r
-                        DEBUG_PUTCHAR ('0');\r
-                        DEBUG_NEWLINE ();\r
+                        ANALYZE_PUTCHAR ('0');\r
+                        ANALYZE_NEWLINE ();\r
                         irmp_store_bit (0);\r
                         wait_for_space = 0;\r
                     }\r
                     else\r
                     {                                                               // timing incorrect!\r
-                        DEBUG_PRINTF ("error 3: timing not correct: data bit %d,  pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
-                        DEBUG_ONLY_NORMAL_PUTCHAR ('\n');\r
+                        ANALYZE_PRINTF ("error 3: timing not correct: data bit %d,  pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time);\r
+                        ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
                         irmp_start_bit_detected = 0;                                // reset flags and wait for next start bit\r
                         irmp_pause_time         = 0;\r
                     }\r
@@ -2089,7 +2106,7 @@ irmp_ISR (void)
                 // if SIRCS protocol and the code will be repeated within 50 ms, we will ignore 2nd and 3rd repetition frame\r
                 if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && (repetition_frame_number == 1 || repetition_frame_number == 2))\r
                 {\r
-                    DEBUG_PRINTF ("code skipped: SIRCS auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
+                    ANALYZE_PRINTF ("code skipped: SIRCS auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
                                     repetition_frame_number + 1, repetition_counter, AUTO_FRAME_REPETITION_LEN);\r
                     repetition_counter = 0;\r
                 }\r
@@ -2100,7 +2117,7 @@ irmp_ISR (void)
                 // if SAMSUNG32 protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame\r
                 if (irmp_param.protocol == IRMP_SAMSUNG32_PROTOCOL && (repetition_frame_number & 0x01))\r
                 {\r
-                    DEBUG_PRINTF ("code skipped: SAMSUNG32 auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
+                    ANALYZE_PRINTF ("code skipped: SAMSUNG32 auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
                                     repetition_frame_number + 1, repetition_counter, AUTO_FRAME_REPETITION_LEN);\r
                     repetition_counter = 0;\r
                 }\r
@@ -2111,7 +2128,7 @@ irmp_ISR (void)
                 // if NUBERT protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame\r
                 if (irmp_param.protocol == IRMP_NUBERT_PROTOCOL && (repetition_frame_number & 0x01))\r
                 {\r
-                    DEBUG_PRINTF ("code skipped: NUBERT auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
+                    ANALYZE_PRINTF ("code skipped: NUBERT auto repetition frame #%d, counter = %d, auto repetition len = %d\n",\r
                                     repetition_frame_number + 1, repetition_counter, AUTO_FRAME_REPETITION_LEN);\r
                     repetition_counter = 0;\r
                 }\r
@@ -2119,7 +2136,7 @@ irmp_ISR (void)
 #endif\r
 \r
                 {\r
-                    DEBUG_PRINTF ("code detected, length = %d\n", irmp_bit);\r
+                    ANALYZE_PRINTF ("code detected, length = %d\n", irmp_bit);\r
                     irmp_ir_detected = TRUE;\r
 \r
 #if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
@@ -2135,7 +2152,7 @@ irmp_ISR (void)
                         }\r
                         else\r
                         {\r
-                            DEBUG_PRINTF ("waiting for inverted command repetition\n");\r
+                            ANALYZE_PRINTF ("waiting for inverted command repetition\n");\r
                             irmp_ir_detected = FALSE;\r
                             last_irmp_denon_command = irmp_tmp_command;\r
                         }\r
@@ -2146,7 +2163,7 @@ irmp_ISR (void)
 #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1\r
                     if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && irmp_tmp_command == 0x01ff)\r
                     {                                                               // Grundig start frame?\r
-                        DEBUG_PRINTF ("Detected GRUNDIG start frame, ignoring it\n");\r
+                        ANALYZE_PRINTF ("Detected GRUNDIG start frame, ignoring it\n");\r
                         irmp_ir_detected = FALSE;\r
                     }\r
                     else\r
@@ -2155,7 +2172,7 @@ irmp_ISR (void)
 #if IRMP_SUPPORT_NOKIA_PROTOCOL == 1\r
                     if (irmp_param.protocol == IRMP_NOKIA_PROTOCOL && irmp_tmp_address == 0x00ff && irmp_tmp_command == 0x00fe)\r
                     {                                                               // Nokia start frame?\r
-                        DEBUG_PRINTF ("Detected NOKIA start frame, ignoring it\n");\r
+                        ANALYZE_PRINTF ("Detected NOKIA start frame, ignoring it\n");\r
                         irmp_ir_detected = FALSE;\r
                     }\r
                     else\r
@@ -2202,7 +2219,7 @@ irmp_ISR (void)
                 }\r
                 else\r
                 {\r
-                    DEBUG_ONLY_NORMAL_PUTCHAR ('\n');\r
+                    ANALYZE_ONLY_NORMAL_PUTCHAR ('\n');\r
                 }\r
 \r
                 irmp_start_bit_detected = 0;                                        // and wait for next start bit\r
@@ -2215,7 +2232,7 @@ irmp_ISR (void)
     return (irmp_ir_detected);\r
 }\r
 \r
-#ifdef DEBUG\r
+#ifdef ANALYZE\r
 \r
 // main function - for unix/linux + windows only!\r
 // AVR: see main.c!\r
@@ -2271,31 +2288,34 @@ print_timings (void)
             GRUNDIG_OR_NOKIA_START_BIT_LEN_MIN, GRUNDIG_OR_NOKIA_START_BIT_LEN_MAX, GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MIN, GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MAX);\r
     printf ("SIEMENS        1               %3d - %3d           %3d - %3d\n",\r
             SIEMENS_START_BIT_LEN_MIN, SIEMENS_START_BIT_LEN_MAX, SIEMENS_START_BIT_LEN_MIN, SIEMENS_START_BIT_LEN_MAX);\r
-    printf ("FDC1           1               %3d - %3d           %3d - %3d\n",\r
-            FDC1_START_BIT_PULSE_LEN_MIN, FDC1_START_BIT_PULSE_LEN_MAX, FDC1_START_BIT_PAUSE_LEN_MIN, FDC1_START_BIT_PAUSE_LEN_MAX);\r
-    printf ("FDC2           1               %3d - %3d           %3d - %3d\n",\r
-            FDC2_START_BIT_PULSE_LEN_MIN, FDC2_START_BIT_PULSE_LEN_MAX, FDC2_START_BIT_PAUSE_LEN_MIN, FDC2_START_BIT_PAUSE_LEN_MAX);\r
+    printf ("FDC           1               %3d - %3d           %3d - %3d\n",\r
+            FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX, FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX);\r
+    printf ("RCCAR          1               %3d - %3d           %3d - %3d\n",\r
+            RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX, RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX);\r
 }\r
 \r
 void\r
-print_spectrum (char * text, int * buf)\r
+print_spectrum (char * text, int * buf, int is_pulse)\r
 {\r
     int     i;\r
     int     j;\r
-    int     max = 0;\r
+    int     min;\r
+    int     max;\r
+    int     max_value = 0;\r
     int     value;\r
     int     sum = 0;\r
     int     counter = 0;\r
     double  average = 0;\r
+    double  tolerance;\r
 \r
-    puts ("--------------------------------------------------------------------------------------------------------------");\r
+    puts ("-------------------------------------------------------------------------------");\r
     printf ("%s:\n", text);\r
 \r
     for (i = 0; i < 256; i++)\r
     {\r
-        if (buf[i] > max)\r
+        if (buf[i] > max_value)\r
         {\r
-            max = buf[i];\r
+            max_value = buf[i];\r
         }\r
     }\r
 \r
@@ -2304,7 +2324,7 @@ print_spectrum (char * text, int * buf)
         if (buf[i] > 0)\r
         {\r
             printf ("%3d ", i);\r
-            value = (buf[i] * 100) / max;\r
+            value = (buf[i] * 60) / max_value;\r
 \r
             for (j = 0; j < value; j++)\r
             {\r
@@ -2317,13 +2337,39 @@ print_spectrum (char * text, int * buf)
         }\r
         else\r
         {\r
+            max = i - 1;\r
+\r
             if (counter > 0)\r
             {\r
                 average = (float) sum / (float) counter;\r
-                printf ("average: %0.2f = %0.2f usec\n", average, (1000000. * average) / (float) F_INTERRUPTS);\r
+\r
+                if (is_pulse)\r
+                {\r
+                    printf ("pulse ");\r
+                }\r
+                else\r
+                {\r
+                    printf ("pause ");\r
+                }\r
+\r
+                printf ("avg: %4.1f=%6.1f us, ", average, (1000000. * average) / (float) F_INTERRUPTS);\r
+                printf ("min: %2d=%6.1f us, ", min, (1000000. * min) / (float) F_INTERRUPTS);\r
+                printf ("max: %2d=%6.1f us, ", max, (1000000. * max) / (float) F_INTERRUPTS);\r
+\r
+                tolerance = (max - average);\r
+\r
+                if (average - min > tolerance)\r
+                {\r
+                    tolerance = average - min;\r
+                }\r
+\r
+                tolerance = tolerance * 100 / average;\r
+                printf ("tol: %4.1f%%\n", tolerance);\r
             }\r
+\r
             counter = 0;\r
             sum = 0;\r
+            min = i + 1;\r
         }\r
     }\r
 }\r
@@ -2508,7 +2554,7 @@ main (int argc, char ** argv)
 \r
             if (irmp_get_data (&irmp_data))\r
             {\r
-                DEBUG_ONLY_NORMAL_PUTCHAR (' ');\r
+                ANALYZE_ONLY_NORMAL_PUTCHAR (' ');\r
                 printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x\n",\r
                         irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags);\r
             }\r
@@ -2517,13 +2563,13 @@ main (int argc, char ** argv)
 \r
     if (analyze)\r
     {\r
-        print_spectrum ("START PULSES", start_pulses);\r
-        print_spectrum ("START PAUSES", start_pauses);\r
-        print_spectrum ("PULSES", pulses);\r
-        print_spectrum ("PAUSES", pauses);\r
-        puts ("--------------------------------------------------------------------------------------------------------------");\r
+        print_spectrum ("START PULSES", start_pulses, TRUE);\r
+        print_spectrum ("START PAUSES", start_pauses, FALSE);\r
+        print_spectrum ("PULSES", pulses, TRUE);\r
+        print_spectrum ("PAUSES", pauses, FALSE);\r
+        puts ("-------------------------------------------------------------------------------");\r
     }\r
     return 0;\r
 }\r
 \r
-#endif // DEBUG\r
+#endif // ANALYZE\r