*\r
* Copyright (c) 2009-2010 Frank Meyer - frank(at)fli4l.de\r
*\r
- * $Id: irmp.c,v 1.41 2010/06/10 21:24:50 fm Exp $\r
+ * $Id: irmp.c,v 1.45 2010/06/11 14:47:24 fm Exp $\r
*\r
* ATMEGA88 @ 8 MHz\r
*\r
#define IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL 0\r
#endif\r
\r
+#if IRMP_SUPPORT_RC5_PROTOCOL == 1 || IRMP_SUPPORT_RC6_PROTOCOL == 1 || IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1 || IRMP_SUPPORT_SIEMENS_PROTOCOL == 1 \r
+#define IRMP_SUPPORT_MANCHESTER 1\r
+#else\r
+#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_LEN (uint8_t)(F_INTERRUPTS * IRMP_TIMEOUT_TIME + 0.5)\r
#define IRMP_KEY_REPETITION_LEN (uint16_t)(F_INTERRUPTS * 150.0e-3 + 0.5) // autodetect key repetition within 150 msec\r
#define RECS80_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
#define RECS80_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
\r
-#define RC5_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_00 + 0.5) - 1)\r
-#define RC5_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_00 + 0.5) + 1)\r
-#define RC5_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_00 + 0.5) - 1)\r
-#define RC5_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_00 + 0.5) + 1)\r
+#define RC5_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
+#define RC5_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
+#define RC5_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
+#define RC5_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1)\r
\r
#define DENON_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1)\r
#define DENON_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MAX_TOLERANCE_10 + 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_30 + 0.5) - 1)\r
-#define FDC2_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC2_0_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
\r
#define AUTO_FRAME_REPETITION_LEN (uint16_t)(F_INTERRUPTS * AUTO_FRAME_REPETITION_TIME + 0.5) // use uint16_t!\r
\r
uint8_t complete_len; // complete length of frame\r
uint8_t stop_bit; // flag: frame has stop bit\r
uint8_t lsb_first; // flag: LSB first\r
+ uint8_t flags; // some flags\r
} IRMP_PARAMETER;\r
\r
#if IRMP_SUPPORT_SIRCS_PROTOCOL == 1\r
SIRCS_COMMAND_OFFSET + SIRCS_COMMAND_LEN, // command_end: end of command\r
SIRCS_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
SIRCS_STOP_BIT, // stop_bit: flag: frame has stop bit\r
- SIRCS_LSB // lsb_first: flag: LSB first\r
+ SIRCS_LSB, // lsb_first: flag: LSB first\r
+ SIRCS_FLAGS // flags: some flags\r
};\r
\r
#endif\r
NEC_COMMAND_OFFSET + NEC_COMMAND_LEN, // command_end: end of command\r
NEC_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
NEC_STOP_BIT, // stop_bit: flag: frame has stop bit\r
- NEC_LSB // lsb_first: flag: LSB first\r
+ NEC_LSB, // lsb_first: flag: LSB first\r
+ NEC_FLAGS // flags: some flags\r
};\r
\r
static PROGMEM IRMP_PARAMETER nec_rep_param =\r
0, // command_end: end of command\r
0, // complete_len: complete length of frame\r
NEC_STOP_BIT, // stop_bit: flag: frame has stop bit\r
- NEC_LSB // lsb_first: flag: LSB first\r
+ NEC_LSB, // lsb_first: flag: LSB first\r
+ NEC_FLAGS // flags: some flags\r
};\r
\r
#endif\r
SAMSUNG_COMMAND_OFFSET + SAMSUNG_COMMAND_LEN, // command_end: end of command\r
SAMSUNG_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
SAMSUNG_STOP_BIT, // stop_bit: flag: frame has stop bit\r
- SAMSUNG_LSB // lsb_first: flag: LSB first\r
+ SAMSUNG_LSB, // lsb_first: flag: LSB first\r
+ SAMSUNG_FLAGS // flags: some flags\r
};\r
\r
#endif\r
MATSUSHITA_COMMAND_OFFSET + MATSUSHITA_COMMAND_LEN, // command_end: end of command\r
MATSUSHITA_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
MATSUSHITA_STOP_BIT, // stop_bit: flag: frame has stop bit\r
- MATSUSHITA_LSB // lsb_first: flag: LSB first\r
+ MATSUSHITA_LSB, // lsb_first: flag: LSB first\r
+ MATSUSHITA_FLAGS // flags: some flags\r
};\r
\r
#endif\r
KASEIKYO_COMMAND_OFFSET + KASEIKYO_COMMAND_LEN, // command_end: end of command\r
KASEIKYO_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
KASEIKYO_STOP_BIT, // stop_bit: flag: frame has stop bit\r
- KASEIKYO_LSB // lsb_first: flag: LSB first\r
+ KASEIKYO_LSB, // lsb_first: flag: LSB first\r
+ KASEIKYO_FLAGS // flags: some flags\r
};\r
\r
#endif\r
RECS80_COMMAND_OFFSET + RECS80_COMMAND_LEN, // command_end: end of command\r
RECS80_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
RECS80_STOP_BIT, // stop_bit: flag: frame has stop bit\r
- RECS80_LSB // lsb_first: flag: LSB first\r
+ RECS80_LSB, // lsb_first: flag: LSB first\r
+ RECS80_FLAGS // flags: some flags\r
};\r
\r
#endif\r
RC5_COMMAND_OFFSET + RC5_COMMAND_LEN, // command_end: end of command\r
RC5_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
RC5_STOP_BIT, // stop_bit: flag: frame has stop bit\r
- RC5_LSB // lsb_first: flag: LSB first\r
+ RC5_LSB, // lsb_first: flag: LSB first\r
+ RC5_FLAGS // flags: some flags\r
};\r
\r
#endif\r
DENON_COMMAND_OFFSET + DENON_COMMAND_LEN, // command_end: end of command\r
DENON_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
DENON_STOP_BIT, // stop_bit: flag: frame has stop bit\r
- DENON_LSB // lsb_first: flag: LSB first\r
+ DENON_LSB, // lsb_first: flag: LSB first\r
+ DENON_FLAGS // flags: some flags\r
};\r
\r
#endif\r
RC6_COMMAND_OFFSET + RC6_COMMAND_LEN, // command_end: end of command\r
RC6_COMPLETE_DATA_LEN_SHORT, // complete_len: complete length of frame\r
RC6_STOP_BIT, // stop_bit: flag: frame has stop bit\r
- RC6_LSB // lsb_first: flag: LSB first\r
+ RC6_LSB, // lsb_first: flag: LSB first\r
+ RC6_FLAGS // flags: some flags\r
};\r
\r
#endif\r
RECS80EXT_COMMAND_OFFSET + RECS80EXT_COMMAND_LEN, // command_end: end of command\r
RECS80EXT_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
RECS80EXT_STOP_BIT, // stop_bit: flag: frame has stop bit\r
- RECS80EXT_LSB // lsb_first: flag: LSB first\r
+ RECS80EXT_LSB, // lsb_first: flag: LSB first\r
+ RECS80EXT_FLAGS // flags: some flags\r
};\r
\r
#endif\r
NUBERT_COMMAND_OFFSET + NUBERT_COMMAND_LEN, // command_end: end of command\r
NUBERT_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
NUBERT_STOP_BIT, // stop_bit: flag: frame has stop bit\r
- NUBERT_LSB // lsb_first: flag: LSB first\r
+ NUBERT_LSB, // lsb_first: flag: LSB first\r
+ NUBERT_FLAGS // flags: some flags\r
};\r
\r
#endif\r
BANG_OLUFSEN_COMMAND_OFFSET + BANG_OLUFSEN_COMMAND_LEN, // command_end: end of command\r
BANG_OLUFSEN_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
BANG_OLUFSEN_STOP_BIT, // stop_bit: flag: frame has stop bit\r
- BANG_OLUFSEN_LSB // lsb_first: flag: LSB first\r
+ BANG_OLUFSEN_LSB, // lsb_first: flag: LSB first\r
+ BANG_OLUFSEN_FLAGS // flags: some flags\r
};\r
\r
#endif\r
GRUNDIG_COMMAND_OFFSET + GRUNDIG_COMMAND_LEN + 1, // command_end: end of command (USE 1 bit MORE to STORE NOKIA DATA!)\r
NOKIA_COMPLETE_DATA_LEN, // complete_len: complete length of frame, here: NOKIA instead of GRUNDIG!\r
GRUNDIG_OR_NOKIA_STOP_BIT, // stop_bit: flag: frame has stop bit\r
- GRUNDIG_OR_NOKIA_LSB // lsb_first: flag: LSB first\r
+ GRUNDIG_OR_NOKIA_LSB, // lsb_first: flag: LSB first\r
+ GRUNDIG_OR_NOKIA_FLAGS // flags: some flags\r
};\r
\r
#endif\r
SIEMENS_COMMAND_OFFSET + SIEMENS_COMMAND_LEN, // command_end: end of command\r
SIEMENS_COMPLETE_DATA_LEN, // complete_len: complete length of frame\r
SIEMENS_STOP_BIT, // stop_bit: flag: frame has stop bit\r
- SIEMENS_LSB // lsb_first: flag: LSB first\r
+ SIEMENS_LSB, // lsb_first: flag: LSB first\r
+ SIEMENS_FLAGS // flags: some flags\r
};\r
\r
#endif\r
\r
static PROGMEM IRMP_PARAMETER fdc1_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
+ 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
};\r
\r
#endif\r
\r
static PROGMEM IRMP_PARAMETER fdc2_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
+ 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
};\r
\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
#endif\r
-#if IRMP_SUPPORT_RC5_PROTOCOL == 1 || IRMP_SUPPORT_RC6_PROTOCOL == 1 || IRMP_SUPPORT_SIEMENS_PROTOCOL == 1\r
+#if IRMP_SUPPORT_MANCHESTER == 1\r
static uint8_t last_pause; // last pause value\r
#endif\r
-#if IRMP_SUPPORT_RC5_PROTOCOL == 1 || IRMP_SUPPORT_RC6_PROTOCOL == 1 || IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 || \\r
- IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1 || IRMP_SUPPORT_SIEMENS_PROTOCOL == 1 \r
+#if IRMP_SUPPORT_MANCHESTER == 1 || IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
static uint8_t last_value; // last bit value\r
#endif\r
uint8_t irmp_input; // input value\r
{\r
memcpy_P (&irmp_param, irmp_param_p, sizeof (IRMP_PARAMETER));\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
+#ifdef DEBUG\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
+ }\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
+ 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
+ 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
DEBUG_PRINTF ("pulse_toggle: %3d - %3d\n", RC6_TOGGLE_BIT_LEN_MIN, RC6_TOGGLE_BIT_LEN_MAX);\r
}\r
#endif\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
+\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
+ }\r
\r
#if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1\r
if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL)\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
}\r
\r
irmp_bit = 0;\r
\r
-#if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
- if (irmp_param.protocol == IRMP_RC5_PROTOCOL)\r
+#if IRMP_SUPPORT_MANCHESTER == 1\r
+ if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) && irmp_param.protocol != IRMP_RC6_PROTOCOL) // manchester, but not rc6\r
{\r
- if (irmp_pause_time > RC5_START_BIT_LEN_MAX && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX)\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 ('1');\r
- DEBUG_NEWLINE ();\r
- irmp_store_bit (1);\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
+ 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
- DEBUG_PUTCHAR ('0');\r
- DEBUG_NEWLINE ();\r
- irmp_store_bit (0);\r
- }\r
- }\r
- else\r
-#endif // IRMP_SUPPORT_RC5_PROTOCOL == 1\r
+ DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
\r
-#if IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1\r
- if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL || irmp_param.protocol == IRMP_NOKIA_PROTOCOL)\r
- {\r
- if (irmp_pause_time > GRUNDIG_OR_NOKIA_START_BIT_LEN_MAX && irmp_pause_time <= 2 * GRUNDIG_OR_NOKIA_START_BIT_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 ('0');\r
- DEBUG_NEWLINE ();\r
- irmp_store_bit (0);\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
- DEBUG_PUTCHAR ('1');\r
- DEBUG_NEWLINE ();\r
- irmp_store_bit (1);\r
- }\r
- }\r
- else\r
-#endif // IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1\r
-\r
-#if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1\r
- if (irmp_param.protocol == IRMP_SIEMENS_PROTOCOL)\r
- {\r
- if (irmp_pause_time > SIEMENS_START_BIT_LEN_MAX && irmp_pause_time <= 2 * SIEMENS_START_BIT_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 ('0');\r
- DEBUG_NEWLINE ();\r
- irmp_store_bit (0);\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
- DEBUG_PUTCHAR ('1');\r
- DEBUG_NEWLINE ();\r
- irmp_store_bit (1);\r
+ DEBUG_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0');\r
+ DEBUG_NEWLINE ();\r
+ irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0);\r
}\r
}\r
else\r
-#endif // IRMP_SUPPORT_SIEMENS_PROTOCOL == 1\r
+#endif // IRMP_SUPPORT_MANCHESTER == 1\r
\r
#if IRMP_SUPPORT_DENON_PROTOCOL == 1\r
if (irmp_param.protocol == IRMP_DENON_PROTOCOL)\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
- if (irmp_param.protocol != IRMP_RC5_PROTOCOL &&\r
- irmp_param.protocol != IRMP_RC6_PROTOCOL &&\r
- irmp_param.protocol != IRMP_GRUNDIG_PROTOCOL &&\r
- irmp_param.protocol != IRMP_NOKIA_PROTOCOL &&\r
- irmp_param.protocol != IRMP_SIEMENS_PROTOCOL)\r
+ if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER))\r
{\r
DEBUG_PRINTF ("stop bit detected\n");\r
}\r
}\r
else\r
#endif\r
-#if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
- if (irmp_param.protocol == IRMP_RC5_PROTOCOL &&\r
- irmp_pause_time > 2 * RC5_BIT_LEN_MAX && irmp_bit >= RC5_COMPLETE_DATA_LEN - 2 && !irmp_param.stop_bit)\r
- { // special rc5 decoder\r
- got_light = TRUE; // this is a lie, but generates a stop bit ;-)\r
- irmp_param.stop_bit = TRUE; // set flag\r
- }\r
- else\r
-#endif\r
-#if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
- if (irmp_param.protocol == IRMP_RC6_PROTOCOL &&\r
- irmp_pause_time > 2 * RC6_BIT_LEN_MAX && irmp_bit >= irmp_param.complete_len - 2 && !irmp_param.stop_bit)\r
- { // special rc6 decoder\r
- got_light = TRUE; // this is a lie, but generates a stop bit ;-)\r
- irmp_param.stop_bit = TRUE; // set flag\r
- }\r
- else\r
-#endif\r
-#if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1\r
- if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL &&\r
- irmp_pause_time > 2 * GRUNDIG_OR_NOKIA_BIT_LEN_MAX && irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN - 2 && !irmp_param.stop_bit)\r
- { // special Grundig/Nokia decoder\r
- irmp_param.complete_len = GRUNDIG_COMPLETE_DATA_LEN; // correct complete len\r
- got_light = TRUE; // this is a lie, but generates a stop bit ;-)\r
- irmp_param.stop_bit = TRUE; // set flag\r
- }\r
- else\r
-#endif\r
-#if IRMP_SUPPORT_NOKIA_PROTOCOL == 1\r
- if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL &&\r
- irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN)\r
+#if IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1\r
+ if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && !irmp_param.stop_bit)\r
{\r
- DEBUG_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
- irmp_param.command_offset = NOKIA_COMMAND_OFFSET;\r
- irmp_param.command_end = NOKIA_COMMAND_OFFSET + NOKIA_COMMAND_LEN;\r
-\r
- if (irmp_tmp_command & 0x300)\r
+ if (irmp_pause_time > 2 * irmp_param.pause_1_len_max && irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN - 2)\r
+ { // special manchester decoder\r
+ irmp_param.complete_len = GRUNDIG_COMPLETE_DATA_LEN; // correct complete len\r
+ got_light = TRUE; // this is a lie, but generates a stop bit ;-)\r
+ irmp_param.stop_bit = TRUE; // set flag\r
+ }\r
+ else if (irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN)\r
{\r
- irmp_tmp_address = (irmp_tmp_command >> 8);\r
- irmp_tmp_command &= 0xFF;\r
+ DEBUG_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
+ irmp_param.command_offset = NOKIA_COMMAND_OFFSET;\r
+ irmp_param.command_end = NOKIA_COMMAND_OFFSET + NOKIA_COMMAND_LEN;\r
+\r
+ if (irmp_tmp_command & 0x300)\r
+ {\r
+ irmp_tmp_address = (irmp_tmp_command >> 8);\r
+ irmp_tmp_command &= 0xFF;\r
+ }\r
}\r
}\r
else\r
#endif\r
-#if IRMP_SUPPORT_NOKIA_PROTOCOL == 1\r
- if (irmp_param.protocol == IRMP_NOKIA_PROTOCOL &&\r
- irmp_pause_time > 2 * GRUNDIG_OR_NOKIA_BIT_LEN_MAX && irmp_bit >= NOKIA_COMPLETE_DATA_LEN - 2 && !irmp_param.stop_bit)\r
- { // special Grundig/Nokia decoder\r
- got_light = TRUE; // this is a lie, but generates a stop bit ;-)\r
- irmp_param.stop_bit = TRUE; // set flag\r
- }\r
- else\r
-#endif\r
-#if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1\r
- if (irmp_param.protocol == IRMP_SIEMENS_PROTOCOL &&\r
- irmp_pause_time > 2 * SIEMENS_BIT_LEN_MAX && irmp_bit >= SIEMENS_COMPLETE_DATA_LEN - 2 && !irmp_param.stop_bit)\r
- { // special rc5 decoder\r
+#if IRMP_SUPPORT_MANCHESTER == 1\r
+ if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) &&\r
+ irmp_pause_time > 2 * irmp_param.pause_1_len_max && irmp_bit >= irmp_param.complete_len - 2 && !irmp_param.stop_bit)\r
+ { // special manchester decoder\r
got_light = TRUE; // this is a lie, but generates a stop bit ;-)\r
irmp_param.stop_bit = TRUE; // set flag\r
}\r
else\r
-#endif\r
+#endif // IRMP_SUPPORT_MANCHESTER == 1\r
if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout?\r
{ // yes...\r
if (irmp_bit == irmp_param.complete_len - 1 && irmp_param.stop_bit == 0)\r
{\r
DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time);\r
\r
-#if IRMP_SUPPORT_RC5_PROTOCOL == 1\r
- if (irmp_param.protocol == IRMP_RC5_PROTOCOL) // special rc5 decoder\r
+#if IRMP_SUPPORT_MANCHESTER == 1\r
+ if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) // manchester\r
{\r
- if (irmp_pulse_time > RC5_BIT_LEN_MAX && irmp_pulse_time <= 2 * RC5_BIT_LEN_MAX)\r
- {\r
- DEBUG_PUTCHAR ('1');\r
- irmp_store_bit (1);\r
- DEBUG_PUTCHAR ('0');\r
- DEBUG_NEWLINE ();\r
- irmp_store_bit (0);\r
- last_value = 0;\r
- }\r
-\r
- else // if (irmp_pulse_time >= RC5_BIT_LEN_MIN && irmp_pulse_time <= RC5_BIT_LEN_MAX)\r
+#if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
+ if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit >= 3 && irmp_bit <= 5) // special bits of rc6\r
{\r
- uint8_t rc5_value;\r
-\r
- if (last_pause > RC5_BIT_LEN_MAX && last_pause <= 2 * RC5_BIT_LEN_MAX)\r
- {\r
- rc5_value = last_value ? 0 : 1;\r
- last_value = rc5_value;\r
- }\r
- else\r
+ if (irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MAX && irmp_pause_time > RC6_TOGGLE_BIT_LEN_MAX)\r
{\r
- rc5_value = last_value;\r
+ DEBUG_PUTCHAR ('1');\r
+ irmp_store_bit (1);\r
}\r
\r
- DEBUG_PUTCHAR (rc5_value + '0');\r
+ DEBUG_PUTCHAR ('0');\r
+ irmp_store_bit (0);\r
+ last_value = 0;\r
DEBUG_NEWLINE ();\r
- irmp_store_bit (rc5_value);\r
}\r
-\r
- last_pause = irmp_pause_time;\r
- wait_for_space = 0;\r
- }\r
- else\r
-#endif\r
-\r
-#if IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1\r
- if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL || // special Grundig decoder\r
- irmp_param.protocol == IRMP_NOKIA_PROTOCOL) // special Nokia decoder\r
- {\r
- if (irmp_pulse_time > GRUNDIG_OR_NOKIA_BIT_LEN_MAX && irmp_pulse_time <= 2 * GRUNDIG_OR_NOKIA_BIT_LEN_MAX)\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 ('0');\r
- irmp_store_bit (0);\r
- DEBUG_PUTCHAR ('1');\r
+ DEBUG_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
+ irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0 );\r
DEBUG_NEWLINE ();\r
- irmp_store_bit (1);\r
- last_value = 1;\r
+ last_value = (irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0;\r
}\r
-\r
- else // if (irmp_pulse_time >= GRUNDIG_BIT_LEN_MIN && irmp_pulse_time <= GRUNDIG_OR_NOKIA_BIT_LEN_MAX)\r
+ else // if (irmp_pulse_time >= irmp_param.pulse_1_len_max && irmp_pulse_time <= irmp_param.pulse_1_len_max)\r
{\r
- uint8_t grundig_value;\r
+ uint8_t manchester_value;\r
\r
- if (last_pause > GRUNDIG_OR_NOKIA_BIT_LEN_MAX && last_pause <= 2 * GRUNDIG_OR_NOKIA_BIT_LEN_MAX)\r
+ if (last_pause > irmp_param.pause_1_len_max && last_pause <= 2 * irmp_param.pause_1_len_max)\r
{\r
- grundig_value = last_value ? 0 : 1;\r
- last_value = grundig_value;\r
+ manchester_value = last_value ? 0 : 1;\r
+ last_value = manchester_value;\r
}\r
else\r
{\r
- grundig_value = last_value;\r
+ manchester_value = last_value;\r
}\r
\r
- DEBUG_PUTCHAR (grundig_value + '0');\r
- DEBUG_NEWLINE ();\r
- irmp_store_bit (grundig_value);\r
- }\r
-\r
- last_pause = irmp_pause_time;\r
- wait_for_space = 0;\r
- }\r
- else\r
-#endif\r
-\r
+#if 0\r
#if IRMP_SUPPORT_RC6_PROTOCOL == 1\r
- if (irmp_param.protocol == IRMP_RC6_PROTOCOL) // special rc6 decoder\r
- {\r
- switch (irmp_bit)\r
- { // handle toggle bit, which is 2 times longer than other bits\r
- case 3:\r
- case 4:\r
- case 5:\r
- if (irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MAX && irmp_pause_time > RC6_TOGGLE_BIT_LEN_MAX)\r
- {\r
- DEBUG_PUTCHAR ('1');\r
- irmp_store_bit (1);\r
- }\r
-\r
- DEBUG_PUTCHAR ('0');\r
- irmp_store_bit (0);\r
- last_value = 0;\r
- DEBUG_NEWLINE ();\r
- break;\r
-\r
- default:\r
- if (irmp_pulse_time > RC6_BIT_LEN_MAX && irmp_pulse_time <= 2 * RC6_BIT_LEN_MAX)\r
- {\r
- DEBUG_PUTCHAR ('0');\r
- irmp_store_bit (0);\r
- DEBUG_PUTCHAR ('1');\r
- DEBUG_NEWLINE ();\r
- irmp_store_bit (1);\r
- last_value = 1;\r
- }\r
- else // if (irmp_pulse_time >= RC6_BIT_LEN_MIN && irmp_pulse_time <= RC6_BIT_LEN_MAX)\r
- {\r
- uint8_t rc5_value;\r
-\r
- if (last_pause > RC6_BIT_LEN_MAX && last_pause <= 2 * RC6_BIT_LEN_MAX)\r
- {\r
- rc5_value = last_value ? 0 : 1;\r
- last_value = rc5_value;\r
- }\r
- else\r
- {\r
- rc5_value = last_value;\r
- }\r
-\r
- if (irmp_bit == 1 && rc5_value == 0)\r
- {\r
- irmp_param.complete_len = RC6_COMPLETE_DATA_LEN_LONG;\r
- }\r
-\r
- DEBUG_PUTCHAR (rc5_value + '0');\r
- DEBUG_NEWLINE ();\r
- irmp_store_bit (rc5_value);\r
- }\r
-\r
- last_pause = irmp_pause_time;\r
- break;\r
- } // switch\r
-\r
- wait_for_space = 0;\r
- }\r
- else\r
-#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1\r
-\r
-#if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1\r
- if (irmp_param.protocol == IRMP_SIEMENS_PROTOCOL) // special siemens decoder\r
- {\r
- if (irmp_pulse_time > SIEMENS_BIT_LEN_MAX && irmp_pulse_time <= 2 * SIEMENS_BIT_LEN_MAX)\r
- {\r
- DEBUG_PUTCHAR ('0');\r
- irmp_store_bit (0);\r
- DEBUG_PUTCHAR ('1');\r
- DEBUG_NEWLINE ();\r
- irmp_store_bit (1);\r
- last_value = 1;\r
- }\r
-\r
- else // if (irmp_pulse_time >= SIEMENS_BIT_LEN_MIN && irmp_pulse_time <= SIEMENS_BIT_LEN_MAX)\r
- {\r
- uint8_t siemens_value;\r
-\r
- if (last_pause > SIEMENS_BIT_LEN_MAX && last_pause <= 2 * SIEMENS_BIT_LEN_MAX)\r
- {\r
- siemens_value = last_value ? 0 : 1;\r
- last_value = siemens_value;\r
- }\r
- else\r
+ if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 1 && manchester_value == 0) // RC6 mode != 0 ???\r
{\r
- siemens_value = last_value;\r
+ irmp_param.complete_len = RC6_COMPLETE_DATA_LEN_LONG;\r
}\r
+#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1\r
+#endif // 0\r
\r
- DEBUG_PUTCHAR (siemens_value + '0');\r
+ DEBUG_PUTCHAR (manchester_value + '0');\r
DEBUG_NEWLINE ();\r
- irmp_store_bit (siemens_value);\r
+ irmp_store_bit (manchester_value);\r
}\r
\r
- last_pause = irmp_pause_time;\r
- wait_for_space = 0;\r
+ last_pause = irmp_pause_time;\r
+ wait_for_space = 0;\r
}\r
else\r
-#endif\r
+#endif // IRMP_SUPPORT_MANCHESTER == 1\r
+\r
\r
#if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1\r
if (irmp_param.protocol == IRMP_SAMSUNG_PROTOCOL && irmp_bit == 16) // Samsung: 16th bit\r
// Compile it under linux with:\r
// cc irmp.c -o irmp\r
//\r
-// usage: ./irmp [-v|-s|-a|-p] < file\r
+// usage: ./irmp [-v|-s|-a|-l|-p] < file\r
+// options:\r
+// -v verbose\r
+// -s silent\r
+// -a analyze\r
+// -l list pulse/pauses\r
+// -p print timings\r
\r
static void\r
print_timings (void)\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
}\r
\r
+void\r
+print_spectrum (char * text, int * buf)\r
+{\r
+ int i;\r
+ int j;\r
+ int max = 0;\r
+ int value;\r
+ int sum = 0;\r
+ int counter = 0;\r
+ double average = 0;\r
+\r
+ puts ("--------------------------------------------------------------------------------------------------------------");\r
+ printf ("%s:\n", text);\r
+\r
+ for (i = 0; i < 256; i++)\r
+ {\r
+ if (buf[i] > max)\r
+ {\r
+ max = buf[i];\r
+ }\r
+ }\r
+\r
+ for (i = 0; i < 100; i++)\r
+ {\r
+ if (buf[i] > 0)\r
+ {\r
+ printf ("%3d ", i);\r
+ value = (buf[i] * 100) / max;\r
+\r
+ for (j = 0; j < value; j++)\r
+ {\r
+ putchar ('o');\r
+ }\r
+ printf (" %d\n", buf[i]);\r
+\r
+ sum += i * buf[i];\r
+ counter += buf[i];\r
+ }\r
+ else\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
+ counter = 0;\r
+ sum = 0;\r
+ }\r
+ }\r
+}\r
+\r
int\r
main (int argc, char ** argv)\r
{\r
int i;\r
int analyze = FALSE;\r
+ int list = FALSE;\r
int ch;\r
int last_ch = 0;\r
int pulse = 0;\r
int pause = 0;\r
\r
- int min_pulse_long = 100000;\r
- int max_pulse_long = 0;\r
- int sum_pulses_long = 0;\r
- int n_pulses_long = 0;\r
-\r
- int min_pulse_short = 100000;\r
- int max_pulse_short = 0;\r
- int sum_pulses_short = 0;\r
- int n_pulses_short = 0;\r
-\r
- int min_pause_long = 100000;\r
- int max_pause_long = 0;\r
- int sum_pauses_long = 0;\r
- int n_pauses_long = 0;\r
-\r
- int min_pause_short = 100000;\r
- int max_pause_short = 0;\r
- int sum_pauses_short = 0;\r
- int n_pauses_short = 0;\r
-\r
- int min_start_pulse = 100000;\r
- int max_start_pulse = 0;\r
- int sum_start_pulses = 0;\r
- int n_start_pulses = 0;\r
-\r
- int min_start_pause = 100000;\r
- int max_start_pause = 0;\r
- int sum_start_pauses = 0;\r
- int n_start_pauses = 0;\r
+ int start_pulses[256];\r
+ int start_pauses[256];\r
+ int pulses[256];\r
+ int pauses[256];\r
\r
int first_pulse = TRUE;\r
int first_pause = TRUE;\r
{\r
verbose = TRUE;\r
}\r
+ else if (! strcmp (argv[1], "-l"))\r
+ {\r
+ list = TRUE;\r
+ }\r
else if (! strcmp (argv[1], "-a"))\r
{\r
analyze = TRUE;\r
}\r
}\r
\r
+ for (i = 0; i < 256; i++)\r
+ {\r
+ start_pulses[i] = 0;\r
+ start_pauses[i] = 0;\r
+ pulses[i] = 0;\r
+ pauses[i] = 0;\r
+ }\r
+\r
IRMP_PIN = 0xFF;\r
\r
while ((ch = getchar ()) != EOF)\r
{\r
if (last_ch != ch)\r
{\r
- if (analyze && pause > 0)\r
+ if (pause > 0)\r
{\r
- printf ("pause: %d\n", pause);\r
-\r
- if (first_pause)\r
+ if (list)\r
{\r
- if (min_start_pause > pause)\r
- {\r
- min_start_pause = pause;\r
- }\r
- if (max_start_pause < pause)\r
- {\r
- max_start_pause = pause;\r
- }\r
- n_start_pauses++;\r
- sum_start_pauses += pause;\r
- first_pause = FALSE;\r
+ printf ("pause: %d\n", pause);\r
}\r
- else\r
+\r
+ if (analyze)\r
{\r
- if (pause >= 10)\r
+ if (first_pause)\r
{\r
- if (pause > 100) // perhaps repetition frame follows\r
- {\r
- first_pulse = TRUE;\r
- first_pause = TRUE;\r
- }\r
- else\r
+ if (pause < 256)\r
{\r
- if (min_pause_long > pause)\r
- {\r
- min_pause_long = pause;\r
- }\r
- if (max_pause_long < pause)\r
- {\r
- max_pause_long = pause;\r
- }\r
- n_pauses_long++;\r
- sum_pauses_long += pause;\r
+ start_pauses[pause]++;\r
}\r
+ first_pause = FALSE;\r
}\r
else\r
{\r
- if (min_pause_short > pause)\r
- {\r
- min_pause_short = pause;\r
- }\r
- if (max_pause_short < pause)\r
+ if (pause < 256)\r
{\r
- max_pause_short = pause;\r
+ pauses[pause]++;\r
}\r
- n_pauses_short++;\r
- sum_pauses_short += pause;\r
}\r
}\r
}\r
{\r
if (last_ch != ch)\r
{\r
- if (analyze)\r
+ if (list)\r
{\r
printf ("pulse: %d ", pulse);\r
+ }\r
\r
+ if (analyze)\r
+ {\r
if (first_pulse)\r
{\r
- if (min_start_pulse > pulse)\r
- {\r
- min_start_pulse = pulse;\r
- }\r
- if (max_start_pulse < pulse)\r
+ if (pulse < 256)\r
{\r
- max_start_pulse = pulse;\r
+ start_pulses[pulse]++;\r
}\r
- n_start_pulses++;\r
- sum_start_pulses += pulse;\r
first_pulse = FALSE;\r
}\r
else\r
{\r
- if (pulse >= 10)\r
- {\r
- if (min_pulse_long > pulse)\r
- {\r
- min_pulse_long = pulse;\r
- }\r
- if (max_pulse_long < pulse)\r
- {\r
- max_pulse_long = pulse;\r
- }\r
- n_pulses_long++;\r
- sum_pulses_long += pulse;\r
- }\r
- else\r
+ if (pulse < 256)\r
{\r
- if (min_pulse_short > pulse)\r
- {\r
- min_pulse_short = pulse;\r
- }\r
- if (max_pulse_short < pulse)\r
- {\r
- max_pulse_short = pulse;\r
- }\r
- n_pulses_short++;\r
- sum_pulses_short += pulse;\r
+ pulses[pulse]++;\r
}\r
}\r
}\r
pulse = 0;\r
}\r
+\r
pause++;\r
IRMP_PIN = 0xff;\r
}\r
{\r
IRMP_PIN = 0xff;\r
\r
- if (analyze && pause > 0)\r
+ if (list && pause > 0)\r
{\r
printf ("pause: %d\n", pause);\r
}\r
}\r
else if (ch == '#')\r
{\r
- puts ("-------------------------------------------------------------------");\r
- putchar (ch);\r
-\r
- while ((ch = getchar()) != '\n' && ch != EOF)\r
+ if (analyze)\r
+ {\r
+ while ((ch = getchar()) != '\n' && ch != EOF)\r
+ {\r
+ ;\r
+ }\r
+ }\r
+ else\r
{\r
- if (ch != '\r') // ignore CR in DOS/Windows files\r
+ puts ("-------------------------------------------------------------------");\r
+ putchar (ch);\r
+\r
+ while ((ch = getchar()) != '\n' && ch != EOF)\r
{\r
- putchar (ch);\r
+ if (ch != '\r') // ignore CR in DOS/Windows files\r
+ {\r
+ putchar (ch);\r
+ }\r
}\r
+ putchar ('\n');\r
}\r
- putchar ('\n');\r
+\r
}\r
\r
last_ch = ch;\r
\r
- if (! analyze)\r
+ if (! analyze && ! list)\r
{\r
(void) irmp_ISR ();\r
- }\r
\r
- if (irmp_get_data (&irmp_data))\r
- {\r
- DEBUG_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
+ if (irmp_get_data (&irmp_data))\r
+ {\r
+ DEBUG_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
}\r
}\r
\r
if (analyze)\r
{\r
- printf ("\nSTATITSTICS:\n");\r
- printf ("---------------------------------\n");\r
- printf ("number of start pulses: %d\n", n_start_pulses);\r
- printf ("minimum start pulse length: %d usec\n", (1000000 * min_start_pulse) / F_INTERRUPTS);\r
- printf ("maximum start pulse length: %d usec\n", (1000000 * max_start_pulse) / F_INTERRUPTS);\r
- if (n_start_pulses > 0)\r
- {\r
- printf ("average start pulse length: %d usec\n", ((1000000 * sum_start_pulses) / n_start_pulses) / F_INTERRUPTS);\r
- }\r
- putchar ('\n');\r
- printf ("number of start pauses: %d\n", n_start_pauses);\r
- if (n_start_pauses > 0)\r
- {\r
- printf ("minimum start pause length: %d usec\n", (1000000 * min_start_pause) / F_INTERRUPTS);\r
- printf ("maximum start pause length: %d usec\n", (1000000 * max_start_pause) / F_INTERRUPTS);\r
- printf ("average start pause length: %d usec\n", ((1000000 * sum_start_pauses) / n_start_pauses) / F_INTERRUPTS);\r
- }\r
- putchar ('\n');\r
- printf ("number of long pulses: %d\n", n_pulses_long);\r
- if (n_pulses_long > 0)\r
- {\r
- printf ("minimum long pulse length: %d usec\n", (1000000 * min_pulse_long) / F_INTERRUPTS);\r
- printf ("maximum long pulse length: %d usec\n", (1000000 * max_pulse_long) / F_INTERRUPTS);\r
- printf ("average long pulse length: %d usec\n", ((1000000 * sum_pulses_long) / n_pulses_long) / F_INTERRUPTS);\r
- }\r
- putchar ('\n');\r
- printf ("number of short pulses: %d\n", n_pulses_short);\r
- if (n_pulses_short > 0)\r
- {\r
- printf ("minimum short pulse length: %d usec\n", (1000000 * min_pulse_short) / F_INTERRUPTS);\r
- printf ("maximum short pulse length: %d usec\n", (1000000 * max_pulse_short) / F_INTERRUPTS);\r
- printf ("average short pulse length: %d usec\n", ((1000000 * sum_pulses_short) / n_pulses_short) / F_INTERRUPTS);\r
-\r
- }\r
- putchar ('\n');\r
- printf ("number of long pauses: %d\n", n_pauses_long);\r
- if (n_pauses_long > 0)\r
- {\r
- printf ("minimum long pause length: %d usec\n", (1000000 * min_pause_long) / F_INTERRUPTS);\r
- printf ("maximum long pause length: %d usec\n", (1000000 * max_pause_long) / F_INTERRUPTS);\r
- printf ("average long pause length: %d usec\n", ((1000000 * sum_pauses_long) / n_pauses_long) / F_INTERRUPTS);\r
- }\r
- putchar ('\n');\r
- printf ("number of short pauses: %d\n", n_pauses_short);\r
- if (n_pauses_short > 0)\r
- {\r
- printf ("minimum short pause length: %d usec\n", (1000000 * min_pause_short) / F_INTERRUPTS);\r
- printf ("maximum short pause length: %d usec\n", (1000000 * max_pause_short) / F_INTERRUPTS);\r
- printf ("average short pause length: %d usec\n", ((1000000 * sum_pauses_short) / n_pauses_short) / F_INTERRUPTS);\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
}\r
return 0;\r
}\r