X-Git-Url: http://cloudbase.mooo.com/gitweb/irmp.git/blobdiff_plain/1f54e86cd05ee6e47b5da32107d191f0983ccf04..93ba2e012efb687bfd4387ee9f5b35dd456aa1f4:/irmp.c diff --git a/irmp.c b/irmp.c index bf75b69..020860f 100644 --- a/irmp.c +++ b/irmp.c @@ -3,11 +3,20 @@ * * Copyright (c) 2009-2011 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp.c,v 1.106 2011/08/16 07:51:19 fm Exp $ + * $Id: irmp.c,v 1.110 2011/09/22 10:19:44 fm Exp $ * * ATMEGA88 @ 8 MHz * - * Typical manufacturers: + * Supported mikrocontrollers: + * + * ATtiny45, ATtiny85 + * ATtiny84 + * ATmega8, ATmega16, ATmega32 + * ATmega162 + * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284 + * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P + * + * Typical manufacturers of remote controls: * * SIRCS - Sony * NEC - NEC, Yamaha, Canon, Tevion, Harman/Kardon, Hitachi, JVC, Pioneer, Toshiba, Xoro, Orion, and many other Japanese manufacturers @@ -288,6 +297,10 @@ *--------------------------------------------------------------------------------------------------------------------------------------------------- */ +#if defined(__18CXX) +#define PIC_C18 // Microchip C18 Compiler +#endif + #if defined(__PCM__) || defined(__PCB__) || defined(__PCH__) // CCS PIC Compiler instead of AVR #define PIC_CCS_COMPILER #endif @@ -316,14 +329,17 @@ typedef unsigned short uint16_t; #else -#ifdef PIC_CCS_COMPILER +#if defined (PIC_CCS_COMPILER) || defined(PIC_C18) #include -typedef unsigned int8 uint8_t; -typedef unsigned int16 uint16_t; #define PROGMEM #define memcpy_P memcpy +#if defined (PIC_CCS_COMPILER) +typedef unsigned int8 uint8_t; +typedef unsigned int16 uint16_t; +#endif + #else // AVR: #include @@ -333,7 +349,7 @@ typedef unsigned int16 uint16_t; #include #include -#endif // PIC_CCS_COMPILER +#endif // PIC_CCS_COMPILER or PIC_C18 #endif // windows #endif // unix @@ -365,9 +381,7 @@ typedef unsigned int16 uint16_t; #define IRMP_SUPPORT_MANCHESTER 0 #endif -#if IRMP_SUPPORT_NETBOX_PROTOCOL == 1 || \ - IRMP_SUPPORT_MERLIN_PROTOCOL == 1 || \ - IRMP_SUPPORT_IMON_PROTOCOL == 1 +#if IRMP_SUPPORT_NETBOX_PROTOCOL == 1 #define IRMP_SUPPORT_SERIAL 1 #else #define IRMP_SUPPORT_SERIAL 0 @@ -420,18 +434,18 @@ typedef unsigned int16 uint16_t; #define SIRCS_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define SIRCS_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#define NEC_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) -#define NEC_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) -#define NEC_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) -#define NEC_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) -#define NEC_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) -#define NEC_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) -#define NEC_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) -#define NEC_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) -#define NEC_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) -#define NEC_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) -#define NEC_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) -#define NEC_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) +#define NEC_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define NEC_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define NEC_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define NEC_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define NEC_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define NEC_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define NEC_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define NEC_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define NEC_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define NEC_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define NEC_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define NEC_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) // autodetect nec repetition frame within 50 msec: // NEC seems to send the first repetition frame after 40ms, further repetition frames after 100 ms #if 0 @@ -675,34 +689,16 @@ typedef unsigned int16 uint16_t; #define LEGO_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * LEGO_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) #define LEGO_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * LEGO_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) -#define MERLIN_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MERLIN_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define MERLIN_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MERLIN_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#define MERLIN_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MERLIN_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define MERLIN_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MERLIN_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#define MERLIN_PULSE_LEN ((uint8_t)(F_INTERRUPTS * MERLIN_PULSE_TIME)) -#define MERLIN_PAUSE_LEN ((uint8_t)(F_INTERRUPTS * MERLIN_PAUSE_TIME)) -#define MERLIN_PULSE_REST_LEN ((uint8_t)(F_INTERRUPTS * MERLIN_PULSE_TIME / 4)) -#define MERLIN_PAUSE_REST_LEN ((uint8_t)(F_INTERRUPTS * MERLIN_PAUSE_TIME / 4)) - -#define IMON_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * IMON_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define IMON_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * IMON_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#define IMON_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * IMON_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define IMON_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * IMON_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#define IMON_PULSE_LEN ((uint8_t)(F_INTERRUPTS * IMON_PULSE_TIME)) -#define IMON_PAUSE_LEN ((uint8_t)(F_INTERRUPTS * IMON_PAUSE_TIME)) -#define IMON_PULSE_REST_LEN ((uint8_t)(F_INTERRUPTS * IMON_PULSE_TIME / 4)) -#define IMON_PAUSE_REST_LEN ((uint8_t)(F_INTERRUPTS * IMON_PAUSE_TIME / 4)) - #define AUTO_FRAME_REPETITION_LEN (uint16_t)(F_INTERRUPTS * AUTO_FRAME_REPETITION_TIME + 0.5) // use uint16_t! #ifdef ANALYZE -#define ANALYZE_PUTCHAR(a) { if (! silent) { putchar (a); } } -#define ANALYZE_ONLY_NORMAL_PUTCHAR(a) { if (! silent && !verbose) { putchar (a); } } -#define ANALYZE_PRINTF(...) { if (verbose) { printf (__VA_ARGS__); } } -#define ANALYZE_NEWLINE() { if (verbose) { putchar ('\n'); } } -static int silent; -static int time_counter; -static int verbose; +#define ANALYZE_PUTCHAR(a) { if (! silent) { putchar (a); } } +#define ANALYZE_ONLY_NORMAL_PUTCHAR(a) { if (! silent && !verbose) { putchar (a); } } +#define ANALYZE_PRINTF(...) { if (verbose) { printf (__VA_ARGS__); } } +#define ANALYZE_NEWLINE() { if (verbose) { putchar ('\n'); } } +static int silent; +static int time_counter; +static int verbose; #else #define ANALYZE_PUTCHAR(a) #define ANALYZE_ONLY_NORMAL_PUTCHAR(a) @@ -710,6 +706,10 @@ static int verbose; #define ANALYZE_NEWLINE() #endif +#if IRMP_USE_CALLBACK == 1 +static void (*irmp_callback_ptr) (uint8_t); +#endif // IRMP_USE_CALLBACK == 1 + /*--------------------------------------------------------------------------------------------------------------------------------------------------- * Protocol names *--------------------------------------------------------------------------------------------------------------------------------------------------- @@ -748,8 +748,7 @@ irmp_protocol_names[IRMP_N_PROTOCOLS + 1] = "NEC16", "NEC42", "LEGO", - "THOMSON", - "MERLIN" + "THOMSON" }; #endif @@ -1027,9 +1026,9 @@ static const PROGMEM IRMP_PARAMETER nec42_param = NEC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 NEC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 NEC42_ADDRESS_OFFSET, // address_offset: address offset - NEC42_ADDRESS_OFFSET + NEC_ADDRESS_LEN, // address_end: end of address + NEC42_ADDRESS_OFFSET + NEC42_ADDRESS_LEN, // address_end: end of address NEC42_COMMAND_OFFSET, // command_offset: command offset - NEC42_COMMAND_OFFSET + NEC_COMMAND_LEN, // command_end: end of command + NEC42_COMMAND_OFFSET + NEC42_COMMAND_LEN, // command_end: end of command NEC42_COMPLETE_DATA_LEN, // complete_len: complete length of frame NEC_STOP_BIT, // stop_bit: flag: frame has stop bit NEC_LSB, // lsb_first: flag: LSB first @@ -1492,31 +1491,6 @@ static const PROGMEM IRMP_PARAMETER lego_param = #endif -#if IRMP_SUPPORT_MERLIN_PROTOCOL == 1 - -static const PROGMEM IRMP_PARAMETER merlin_param = -{ - IRMP_MERLIN_PROTOCOL, // protocol: ir protocol - MERLIN_PULSE_LEN, // pulse_1_len_min: minimum length of pulse with bit value 1, here: exact value - MERLIN_PULSE_REST_LEN, // pulse_1_len_max: maximum length of pulse with bit value 1, here: rest value - MERLIN_PAUSE_LEN, // pause_1_len_min: minimum length of pause with bit value 1, here: exact value - MERLIN_PAUSE_REST_LEN, // pause_1_len_max: maximum length of pause with bit value 1, here: rest value - MERLIN_PULSE_LEN, // pulse_0_len_min: minimum length of pulse with bit value 0, here: exact value - MERLIN_PULSE_REST_LEN, // pulse_0_len_max: maximum length of pulse with bit value 0, here: rest value - MERLIN_PAUSE_LEN, // pause_0_len_min: minimum length of pause with bit value 0, here: exact value - MERLIN_PAUSE_REST_LEN, // pause_0_len_max: maximum length of pause with bit value 0, here: rest value - MERLIN_ADDRESS_OFFSET, // address_offset: address offset - MERLIN_ADDRESS_OFFSET + MERLIN_ADDRESS_LEN, // address_end: end of address - MERLIN_COMMAND_OFFSET, // command_offset: command offset - MERLIN_COMMAND_OFFSET + MERLIN_COMMAND_LEN, // command_end: end of command - MERLIN_COMPLETE_DATA_LEN, // complete_len: complete length of frame - MERLIN_STOP_BIT, // stop_bit: flag: frame has stop bit - MERLIN_LSB, // lsb_first: flag: LSB first - MERLIN_FLAGS // flags: some flags -}; - -#endif - #if IRMP_SUPPORT_THOMSON_PROTOCOL == 1 static const PROGMEM IRMP_PARAMETER thomson_param = @@ -1542,31 +1516,6 @@ static const PROGMEM IRMP_PARAMETER thomson_param = #endif -#if IRMP_SUPPORT_IMON_PROTOCOL == 1 - -static const PROGMEM IRMP_PARAMETER imon_param = -{ - IRMP_IMON_PROTOCOL, // protocol: ir protocol - IMON_PULSE_LEN, // pulse_1_len_min: minimum length of pulse with bit value 1 - IMON_PULSE_REST_LEN, // pulse_1_len_max: maximum length of pulse with bit value 1 - IMON_PAUSE_LEN, // pause_1_len_min: minimum length of pause with bit value 1 - IMON_PAUSE_REST_LEN, // pause_1_len_max: maximum length of pause with bit value 1 - IMON_PULSE_LEN, // pulse_0_len_min: minimum length of pulse with bit value 0 - IMON_PULSE_REST_LEN, // pulse_0_len_max: maximum length of pulse with bit value 0 - IMON_PAUSE_LEN, // pause_0_len_min: minimum length of pause with bit value 0 - IMON_PAUSE_REST_LEN, // pause_0_len_max: maximum length of pause with bit value 0 - IMON_ADDRESS_OFFSET, // address_offset: address offset - IMON_ADDRESS_OFFSET + IMON_ADDRESS_LEN, // address_end: end of address - IMON_COMMAND_OFFSET, // command_offset: command offset - IMON_COMMAND_OFFSET + IMON_COMMAND_LEN, // command_end: end of command - IMON_COMPLETE_DATA_LEN, // complete_len: complete length of frame - IMON_STOP_BIT, // stop_bit: flag: frame has stop bit - IMON_LSB, // lsb_first: flag: LSB first - IMON_FLAGS // flags: some flags -}; - -#endif - static uint8_t irmp_bit; // current bit position static IRMP_PARAMETER irmp_param; @@ -1595,10 +1544,10 @@ static uint8_t IRMP_PIN; void irmp_init (void) { -#ifndef PIC_CCS_COMPILER +#if !defined(PIC_CCS_COMPILER) && !defined(PIC_C18) // only AVR IRMP_PORT &= ~(1<= JVC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= JVC_START_BIT_PULSE_LEN_MAX && irmp_pause_time >= JVC_REPEAT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= JVC_REPEAT_START_BIT_PAUSE_LEN_MAX) { - ANALYZE_PRINTF ("protocol = NEC or JVC repeat frame, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + ANALYZE_PRINTF ("protocol = NEC or JVC (type 1) repeat frame, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", JVC_START_BIT_PULSE_LEN_MIN, JVC_START_BIT_PULSE_LEN_MAX, JVC_REPEAT_START_BIT_PAUSE_LEN_MIN, JVC_REPEAT_START_BIT_PAUSE_LEN_MAX); irmp_param_p = (IRMP_PARAMETER *) &nec_param; @@ -2066,13 +2036,39 @@ irmp_ISR (void) else if (irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX && irmp_pause_time >= NEC_REPEAT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_REPEAT_START_BIT_PAUSE_LEN_MAX) { // it's NEC - ANALYZE_PRINTF ("protocol = NEC (repetition frame), start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX, - NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX); +#if IRMP_SUPPORT_JVC_PROTOCOL == 1 + if (irmp_protocol == IRMP_JVC_PROTOCOL) // last protocol was JVC, awaiting repeat frame + { // some jvc remote controls use nec repetition frame for jvc repetition frame + ANALYZE_PRINTF ("protocol = JVC repeat frame type 2, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX, + NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX); + irmp_param_p = (IRMP_PARAMETER *) &nec_param; + } + else +#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1 + { + ANALYZE_PRINTF ("protocol = NEC (repetition frame), start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX, + NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX); - irmp_param_p = (IRMP_PARAMETER *) &nec_rep_param; + irmp_param_p = (IRMP_PARAMETER *) &nec_rep_param; + } } else + +#if IRMP_SUPPORT_JVC_PROTOCOL == 1 + if (irmp_protocol == IRMP_JVC_PROTOCOL && // last protocol was JVC, awaiting repeat frame + irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= NEC_0_PAUSE_LEN_MIN && irmp_pause_time <= NEC_0_PAUSE_LEN_MAX) + { // it's JVC repetition type 3 + ANALYZE_PRINTF ("protocol = JVC repeat frame type 3, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX, + NEC_0_PAUSE_LEN_MIN, NEC_0_PAUSE_LEN_MAX); + irmp_param_p = (IRMP_PARAMETER *) &nec_param; + } + else +#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1 + #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1 #if IRMP_SUPPORT_NIKON_PROTOCOL == 1 @@ -2366,18 +2362,6 @@ irmp_ISR (void) else #endif // IRMP_SUPPORT_NETBOX_PROTOCOL == 1 -#if IRMP_SUPPORT_MERLIN_PROTOCOL == 1 - if (irmp_pulse_time >= MERLIN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= MERLIN_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= MERLIN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= MERLIN_START_BIT_PAUSE_LEN_MAX) - { // it's MERLIN - ANALYZE_PRINTF ("protocol = MERLIN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - MERLIN_START_BIT_PULSE_LEN_MIN, MERLIN_START_BIT_PULSE_LEN_MAX, - MERLIN_START_BIT_PAUSE_LEN_MIN, MERLIN_START_BIT_PAUSE_LEN_MAX); - irmp_param_p = (IRMP_PARAMETER *) &merlin_param; - } - else -#endif // IRMP_SUPPORT_MERLIN_PROTOCOL == 1 - #if IRMP_SUPPORT_LEGO_PROTOCOL == 1 if (irmp_pulse_time >= LEGO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= LEGO_START_BIT_PULSE_LEN_MAX && irmp_pause_time >= LEGO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= LEGO_START_BIT_PAUSE_LEN_MAX) @@ -2388,19 +2372,7 @@ irmp_ISR (void) irmp_param_p = (IRMP_PARAMETER *) &lego_param; } else -#endif // IRMP_SUPPORT_NEC_PROTOCOL == 1 - -#if IRMP_SUPPORT_IMON_PROTOCOL == 1 - if (irmp_pulse_time >= IMON_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= IMON_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= IMON_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= IMON_START_BIT_PAUSE_LEN_MAX) - { // it's IMON - ANALYZE_PRINTF ("protocol = IMON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - IMON_START_BIT_PULSE_LEN_MIN, IMON_START_BIT_PULSE_LEN_MAX, - IMON_START_BIT_PAUSE_LEN_MIN, IMON_START_BIT_PAUSE_LEN_MAX); - irmp_param_p = (IRMP_PARAMETER *) &imon_param; - } - else -#endif // IRMP_SUPPORT_IMON_PROTOCOL == 1 +#endif // IRMP_SUPPORT_LEGO_PROTOCOL == 1 { ANALYZE_PRINTF ("protocol = UNKNOWN\n"); @@ -2446,8 +2418,15 @@ irmp_ISR (void) if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) { - ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", 2 * irmp_param.pulse_1_len_min, 2 * irmp_param.pulse_1_len_max); - ANALYZE_PRINTF ("pause_0: %3d - %3d\n", 2 * irmp_param.pause_1_len_min, 2 * irmp_param.pause_1_len_max); + ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max); + ANALYZE_PRINTF ("pause_0: %3d - %3d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max); + } + else + { + ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max, + 2 * irmp_param.pulse_0_len_min, 2 * irmp_param.pulse_0_len_max); + ANALYZE_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max, + 2 * irmp_param.pause_0_len_min, 2 * irmp_param.pause_0_len_max); } #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 @@ -2576,7 +2555,8 @@ irmp_ISR (void) } else { - ANALYZE_PRINTF ("error: stop bit timing wrong\n"); + ANALYZE_PRINTF ("error: stop bit timing wrong, irmp_bit = %d, irmp_pulse_time = %d, pulse_0_len_min = %d, pulse_0_len_max = %d\n", + irmp_bit, irmp_pulse_time, irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max); // irmp_busy_flag = FALSE; irmp_start_bit_detected = 0; // wait for another start bit... @@ -2609,15 +2589,6 @@ irmp_ISR (void) got_light = TRUE; // this is a lie, but helps (generates stop bit) } else -#if 1 - // MERLIN generates no stop bit, here is the timeout condition: - if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) && irmp_param.protocol == IRMP_MERLIN_PROTOCOL && - irmp_pause_time >= MERLIN_PULSE_LEN * (MERLIN_COMPLETE_DATA_LEN - irmp_bit)) - { - got_light = TRUE; // this is a lie, but helps (generates stop bit) - } - else -#endif #endif #if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1 if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && !irmp_param.stop_bit) @@ -2710,7 +2681,7 @@ irmp_ISR (void) #if IRMP_SUPPORT_JVC_PROTOCOL == 1 else if (irmp_param.protocol == IRMP_NEC_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17)) // it was a JVC stop bit { - ANALYZE_PRINTF ("Switching to JVC protocol\n"); + ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit); irmp_param.stop_bit = TRUE; // set flag irmp_param.protocol = IRMP_JVC_PROTOCOL; // switch protocol irmp_param.complete_len = irmp_bit; // patch length: 16 or 17 @@ -2737,9 +2708,9 @@ irmp_ISR (void) } #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1 #if IRMP_SUPPORT_JVC_PROTOCOL == 1 - else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit == 16) // it was a JVC stop bit + else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17)) // it was a JVC stop bit { - ANALYZE_PRINTF ("Switching to JVC protocol\n"); + ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit); irmp_param.stop_bit = TRUE; // set flag irmp_param.protocol = IRMP_JVC_PROTOCOL; // switch protocol irmp_param.complete_len = irmp_bit; // patch length: 16 or 17 @@ -3059,9 +3030,8 @@ irmp_ISR (void) #endif // IRMP_SUPPORT_NEC42_PROTOCOL == 1 irmp_bit == 8 && irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX) { -printf ("! %d %d !\n", irmp_pause_time, NEC_START_BIT_PAUSE_LEN_MAX); ANALYZE_PRINTF ("Switching to NEC16 protocol\n"); - irmp_param.protocol = IRMP_NEC16_PROTOCOL; + irmp_param.protocol = IRMP_NEC16_PROTOCOL; irmp_param.address_offset = NEC16_ADDRESS_OFFSET; irmp_param.address_end = NEC16_ADDRESS_OFFSET + NEC16_ADDRESS_LEN; irmp_param.command_offset = NEC16_COMMAND_OFFSET;