From: ukw Date: Tue, 17 Nov 2015 13:56:13 +0000 (+0000) Subject: Version 2.9.7: added port to to ESP8266 and TEENSY, added PANASONIC protocol, added... X-Git-Tag: irmp-libopencm3-pre-1~21 X-Git-Url: http://cloudbase.mooo.com/gitweb/irmp.git/commitdiff_plain/95b27043614a5578c29432ab88bec145479bc25c Version 2.9.7: added port to to ESP8266 and TEENSY, added PANASONIC protocol, added BOSE support for IRSND git-svn-id: svn://mikrocontroller.net/irmp@168 aeb2e35e-bfc4-4214-b83c-9e8de998ed28 --- diff --git a/README.txt b/README.txt index 30c9295..cf43d38 100644 --- a/README.txt +++ b/README.txt @@ -1,8 +1,8 @@ IRMP - Infrared Multi Protocol Decoder -------------------------------------- -Version IRMP: 2.9.6 2015-10-11 -Version IRSND: 2.9.5 2015-09-20 +Version IRMP: 2.9.7 2015-11-17 +Version IRSND: 2.9.7 2015-11-17 Dokumentation: diff --git a/irmp.c b/irmp.c index 3ad1948..ac7d689 100644 --- a/irmp.c +++ b/irmp.c @@ -3,7 +3,7 @@ * * Copyright (c) 2009-2015 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp.c,v 1.178 2015/11/10 08:39:27 fm Exp $ + * $Id: irmp.c,v 1.181 2015/11/17 13:51:45 fm Exp $ * * Supported AVR mikrocontrollers: * @@ -61,6 +61,12 @@ #define MIN_TOLERANCE_00 1.0 // -0% #define MAX_TOLERANCE_00 1.0 // +0% +#define MIN_TOLERANCE_02 0.98 // -2% +#define MAX_TOLERANCE_02 1.02 // +2% + +#define MIN_TOLERANCE_03 0.97 // -3% +#define MAX_TOLERANCE_03 1.03 // +3% + #define MIN_TOLERANCE_05 0.95 // -5% #define MAX_TOLERANCE_05 1.05 // +5% @@ -149,12 +155,23 @@ #define KASEIKYO_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) #define KASEIKYO_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) #define KASEIKYO_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) -#define KASEIKYO_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1) -#define KASEIKYO_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1) -#define KASEIKYO_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) -#define KASEIKYO_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) -#define KASEIKYO_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1) -#define KASEIKYO_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1) +#define KASEIKYO_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) +#define KASEIKYO_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) +#define KASEIKYO_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define KASEIKYO_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define KASEIKYO_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define KASEIKYO_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) + +#define PANASONIC_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define PANASONIC_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define PANASONIC_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define PANASONIC_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define PANASONIC_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) +#define PANASONIC_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) +#define PANASONIC_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define PANASONIC_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define PANASONIC_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define PANASONIC_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) #define RECS80_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) #define RECS80_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) @@ -605,6 +622,7 @@ static const char proto_fan[] PROGMEM = "FAN"; static const char proto_s100[] PROGMEM = "S100"; static const char proto_acp24[] PROGMEM = "ACP24"; static const char proto_technics[] PROGMEM = "TECHNICS"; +static const char proto_panasonic[] PROGMEM = "PANASONIC"; static const char proto_radio1[] PROGMEM = "RADIO1"; @@ -659,6 +677,7 @@ irmp_protocol_names[IRMP_N_PROTOCOLS + 1] PROGMEM = proto_s100, proto_acp24, proto_technics, + proto_panasonic, proto_radio1 }; @@ -682,6 +701,12 @@ irmp_protocol_names[IRMP_N_PROTOCOLS + 1] PROGMEM = # include "stm32f4xx_usart.h" #elif defined(ARM_STM32F10X) # define STM32_UART_COM USART3 // UART3 on PB10 +#elif defined(ARDUINO) // Arduino Serial implementation +# if defined(USB_SERIAL) +# include "usb_serial.h" +# else +# error USB_SERIAL not defined in ARDUINO Environment +# endif #else # if IRMP_EXT_LOGGING == 1 // use external logging # include "irmpextlog.h" @@ -812,19 +837,23 @@ irmp_uart_init (void) // UART enable USART_Cmd(STM32_UART_COM, ENABLE); - + +#elif defined(ARDUINO) + // we use the Arduino Serial Imlementation + // you have to call Serial.begin(SER_BAUD); in Arduino setup() function + #elif defined (__AVR_XMEGA__) - PMIC.CTRL |= PMIC_HILVLEN_bm; + PMIC.CTRL |= PMIC_HILVLEN_bm; + + USARTC1.BAUDCTRLB = 0; + USARTC1.BAUDCTRLA = F_CPU / 153600 - 1; + USARTC1.CTRLA = USART_RXCINTLVL_HI_gc; // High Level (Empfangen) + USARTC1.CTRLB = USART_TXEN_bm | USART_RXEN_bm; //Aktiviert Senden und Empfangen + USARTC1.CTRLC = USART_CHSIZE_8BIT_gc; //Größe der Zeichen: 8 Bit + PORTC.DIR |= (1<<7); //TXD als Ausgang setzen + PORTC.DIR &= ~(1<<6); - USARTC1.BAUDCTRLB = 0; - USARTC1.BAUDCTRLA = F_CPU /153600-1; - USARTC1.CTRLA = USART_RXCINTLVL_HI_gc; // High Level (Empfangen) - USARTC1.CTRLB = USART_TXEN_bm | USART_RXEN_bm; //Aktiviert Senden und Empfangen - USARTC1.CTRLC = USART_CHSIZE_8BIT_gc; //Größe der Zeichen: 8 Bit - PORTC.DIR |= (1<<7); //TXD als Ausgang setzen - PORTC.DIR &= ~(1<<6); - #else #if (IRMP_EXT_LOGGING == 0) // use UART @@ -860,32 +889,36 @@ irmp_uart_putc (unsigned char ch) // warten bis altes Byte gesendet wurde while (USART_GetFlagStatus(STM32_UART_COM, USART_FLAG_TXE) == RESET) { - ; + ; } USART_SendData(STM32_UART_COM, ch); if (ch == '\n') { - while (USART_GetFlagStatus(STM32_UART_COM, USART_FLAG_TXE) == RESET); - USART_SendData(STM32_UART_COM, '\r'); + while (USART_GetFlagStatus(STM32_UART_COM, USART_FLAG_TXE) == RESET); + USART_SendData(STM32_UART_COM, '\r'); } +#elif defined(ARDUINO) + // we use the Arduino Serial Imlementation + usb_serial_putchar(ch); + #else #if (IRMP_EXT_LOGGING == 0) - - # if defined (__AVR_XMEGA__) - while (!(USARTC1.STATUS & USART_DREIF_bm)); - USARTC1.DATA = ch; - - # else //AVR_MEGA + + # if defined (__AVR_XMEGA__) + while (!(USARTC1.STATUS & USART_DREIF_bm)); + USARTC1.DATA = ch; + + # else //AVR_MEGA while (!(UART0_UCSRA & UART0_UDRE_BIT_VALUE)) { - ; + ; } UART0_UDR = ch; - #endif //__AVR_XMEGA__ + #endif //__AVR_XMEGA__ #else sendextlog(ch); // use external log @@ -917,80 +950,80 @@ irmp_log (uint_fast8_t val) if (! val && (startcycles < STARTCYCLES) && !buf_idx) // prevent that single random zeros init logging { - startcycles++; + startcycles++; } else { - startcycles = 0; - - if (! val || buf_idx != 0) // start or continue logging on "0", "1" cannot init logging - { - if (last_val == val) - { - cnt++; - - if (val && cnt > ENDBITS) // if high received then look at log-stop condition - { // if stop condition is true, output on uart - uint_fast8_t i8; - uint_fast16_t i; - uint_fast16_t j; - uint_fast8_t v = '1'; - uint_fast16_t d; - - for (i8 = 0; i8 < STARTCYCLES; i8++) - { - irmp_uart_putc ('0'); // the ignored starting zeros - } - - for (i = 0; i < buf_idx; i++) - { - d = buf[i]; - - if (d == 0xff) - { - i++; - d = buf[i]; - i++; - d |= ((uint_fast16_t) buf[i] << 8); - } - - for (j = 0; j < d; j++) - { - irmp_uart_putc (v); - } - - v = (v == '1') ? '0' : '1'; - } - - for (i8 = 0; i8 < 20; i8++) - { - irmp_uart_putc ('1'); - } - - irmp_uart_putc ('\n'); - buf_idx = 0; - last_val = 1; - cnt = 0; - } - } - else if (buf_idx < DATALEN - 3) - { - if (cnt >= 0xff) - { - buf[buf_idx++] = 0xff; - buf[buf_idx++] = (cnt & 0xff); - buf[buf_idx] = (cnt >> 8); - } - else - { - buf[buf_idx] = cnt; - } - - buf_idx++; - cnt = 1; - last_val = val; - } - } + startcycles = 0; + + if (! val || buf_idx != 0) // start or continue logging on "0", "1" cannot init logging + { + if (last_val == val) + { + cnt++; + + if (val && cnt > ENDBITS) // if high received then look at log-stop condition + { // if stop condition is true, output on uart + uint_fast8_t i8; + uint_fast16_t i; + uint_fast16_t j; + uint_fast8_t v = '1'; + uint_fast16_t d; + + for (i8 = 0; i8 < STARTCYCLES; i8++) + { + irmp_uart_putc ('0'); // the ignored starting zeros + } + + for (i = 0; i < buf_idx; i++) + { + d = buf[i]; + + if (d == 0xff) + { + i++; + d = buf[i]; + i++; + d |= ((uint_fast16_t) buf[i] << 8); + } + + for (j = 0; j < d; j++) + { + irmp_uart_putc (v); + } + + v = (v == '1') ? '0' : '1'; + } + + for (i8 = 0; i8 < 20; i8++) + { + irmp_uart_putc ('1'); + } + + irmp_uart_putc ('\n'); + buf_idx = 0; + last_val = 1; + cnt = 0; + } + } + else if (buf_idx < DATALEN - 3) + { + if (cnt >= 0xff) + { + buf[buf_idx++] = 0xff; + buf[buf_idx++] = (cnt & 0xff); + buf[buf_idx] = (cnt >> 8); + } + else + { + buf[buf_idx] = cnt; + } + + buf_idx++; + cnt = 1; + last_val = val; + } + } } } @@ -1240,6 +1273,31 @@ static const PROGMEM IRMP_PARAMETER kaseikyo_param = #endif +#if IRMP_SUPPORT_PANASONIC_PROTOCOL == 1 + +static const PROGMEM IRMP_PARAMETER panasonic_param = +{ + IRMP_PANASONIC_PROTOCOL, // protocol: ir protocol + PANASONIC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + PANASONIC_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + PANASONIC_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + PANASONIC_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + PANASONIC_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + PANASONIC_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + PANASONIC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + PANASONIC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + PANASONIC_ADDRESS_OFFSET, // address_offset: address offset + PANASONIC_ADDRESS_OFFSET + PANASONIC_ADDRESS_LEN, // address_end: end of address + PANASONIC_COMMAND_OFFSET, // command_offset: command offset + PANASONIC_COMMAND_OFFSET + PANASONIC_COMMAND_LEN, // command_end: end of command + PANASONIC_COMPLETE_DATA_LEN, // complete_len: complete length of frame + PANASONIC_STOP_BIT, // stop_bit: flag: frame has stop bit + PANASONIC_LSB, // lsb_first: flag: LSB first + PANASONIC_FLAGS // flags: some flags +}; + +#endif + #if IRMP_SUPPORT_RECS80_PROTOCOL == 1 static const PROGMEM IRMP_PARAMETER recs80_param = @@ -1981,41 +2039,45 @@ irmp_init (void) { #if defined(PIC_CCS) || defined(PIC_C18) // PIC: do nothing #elif defined (ARM_STM32) // STM32 - GPIO_InitTypeDef GPIO_InitStructure; - - /* GPIOx clock enable */ - #if defined (ARM_STM32L1XX) - RCC_AHBPeriphClockCmd(IRMP_PORT_RCC, ENABLE); - #elif defined (ARM_STM32F10X) - RCC_APB2PeriphClockCmd(IRMP_PORT_RCC, ENABLE); - #elif defined (ARM_STM32F4XX) - RCC_AHB1PeriphClockCmd(IRMP_PORT_RCC, ENABLE); - #endif - - /* GPIO Configuration */ - GPIO_InitStructure.GPIO_Pin = IRMP_BIT; - #if defined (ARM_STM32L1XX) || defined (ARM_STM32F4XX) - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - #elif defined (ARM_STM32F10X) - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; - #endif - GPIO_Init(IRMP_PORT, &GPIO_InitStructure); + GPIO_InitTypeDef GPIO_InitStructure; + + /* GPIOx clock enable */ +# if defined (ARM_STM32L1XX) + RCC_AHBPeriphClockCmd(IRMP_PORT_RCC, ENABLE); +# elif defined (ARM_STM32F10X) + RCC_APB2PeriphClockCmd(IRMP_PORT_RCC, ENABLE); +# elif defined (ARM_STM32F4XX) + RCC_AHB1PeriphClockCmd(IRMP_PORT_RCC, ENABLE); +# endif + + /* GPIO Configuration */ + GPIO_InitStructure.GPIO_Pin = IRMP_BIT; +# if defined (ARM_STM32L1XX) || defined (ARM_STM32F4XX) + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; +# elif defined (ARM_STM32F10X) + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; +# endif + GPIO_Init(IRMP_PORT, &GPIO_InitStructure); + #elif defined(STELLARIS_ARM_CORTEX_M4) - // Enable the GPIO port - ROM_SysCtlPeripheralEnable(IRMP_PORT_PERIPH); - - // Set as an input - ROM_GPIODirModeSet(IRMP_PORT_BASE, IRMP_PORT_PIN, GPIO_DIR_MODE_IN); - ROM_GPIOPadConfigSet(IRMP_PORT_BASE, IRMP_PORT_PIN, - GPIO_STRENGTH_2MA, - GPIO_PIN_TYPE_STD_WPU); + // Enable the GPIO port + ROM_SysCtlPeripheralEnable(IRMP_PORT_PERIPH); + + // Set as an input + ROM_GPIODirModeSet(IRMP_PORT_BASE, IRMP_PORT_PIN, GPIO_DIR_MODE_IN); + ROM_GPIOPadConfigSet(IRMP_PORT_BASE, IRMP_PORT_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); + #elif defined(__SDCC_stm8) // STM8 - IRMP_GPIO_STRUCT->CR1 |= (1<DDR &= ~(1<CR1 |= (1<> 8) == (~irmp_command & 0x00FF)) - { - irmp_command &= 0xff; - irmp_command |= irmp_id << 8; - rtc = TRUE; - } - break; + case IRMP_SAMSUNG_PROTOCOL: + if ((irmp_command >> 8) == (~irmp_command & 0x00FF)) + { + irmp_command &= 0xff; + irmp_command |= irmp_id << 8; + rtc = TRUE; + } + break; #if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1 - case IRMP_SAMSUNG48_PROTOCOL: - irmp_command = (irmp_command & 0x00FF) | ((irmp_id & 0x00FF) << 8); - rtc = TRUE; - break; + case IRMP_SAMSUNG48_PROTOCOL: + irmp_command = (irmp_command & 0x00FF) | ((irmp_id & 0x00FF) << 8); + rtc = TRUE; + break; #endif #endif #if IRMP_SUPPORT_NEC_PROTOCOL == 1 - case IRMP_NEC_PROTOCOL: - if ((irmp_command >> 8) == (~irmp_command & 0x00FF)) - { - irmp_command &= 0xff; - rtc = TRUE; - } - else if (irmp_address == 0x87EE) - { -#ifdef ANALYZE - ANALYZE_PRINTF ("Switching to APPLE protocol\n"); -#endif // ANALYZE - irmp_protocol = IRMP_APPLE_PROTOCOL; - irmp_address = (irmp_command & 0xFF00) >> 8; - irmp_command &= 0x00FF; - rtc = TRUE; - } - break; + case IRMP_NEC_PROTOCOL: + if ((irmp_command >> 8) == (~irmp_command & 0x00FF)) + { + irmp_command &= 0xff; + rtc = TRUE; + } + else if (irmp_address == 0x87EE) + { +#ifdef ANALYZE + ANALYZE_PRINTF ("Switching to APPLE protocol\n"); +#endif // ANALYZE + irmp_protocol = IRMP_APPLE_PROTOCOL; + irmp_address = (irmp_command & 0xFF00) >> 8; + irmp_command &= 0x00FF; + rtc = TRUE; + } + break; #endif #if IRMP_SUPPORT_BOSE_PROTOCOL == 1 - case IRMP_BOSE_PROTOCOL: - if ((irmp_command >> 8) == (~irmp_command & 0x00FF)) - { - irmp_command &= 0xff; - rtc = TRUE; - } - break; + case IRMP_BOSE_PROTOCOL: + if ((irmp_command >> 8) == (~irmp_command & 0x00FF)) + { + irmp_command &= 0xff; + rtc = TRUE; + } + break; #endif #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1 - case IRMP_SIEMENS_PROTOCOL: - case IRMP_RUWIDO_PROTOCOL: - if (((irmp_command >> 1) & 0x0001) == (~irmp_command & 0x0001)) - { - irmp_command >>= 1; - rtc = TRUE; - } - break; + case IRMP_SIEMENS_PROTOCOL: + case IRMP_RUWIDO_PROTOCOL: + if (((irmp_command >> 1) & 0x0001) == (~irmp_command & 0x0001)) + { + irmp_command >>= 1; + rtc = TRUE; + } + break; #endif #if IRMP_SUPPORT_KATHREIN_PROTOCOL == 1 - case IRMP_KATHREIN_PROTOCOL: - if (irmp_command != 0x0000) - { - rtc = TRUE; - } - break; + case IRMP_KATHREIN_PROTOCOL: + if (irmp_command != 0x0000) + { + rtc = TRUE; + } + break; #endif #if IRMP_SUPPORT_RC5_PROTOCOL == 1 - case IRMP_RC5_PROTOCOL: - irmp_address &= ~0x20; // clear toggle bit - rtc = TRUE; - break; + case IRMP_RC5_PROTOCOL: + irmp_address &= ~0x20; // clear toggle bit + rtc = TRUE; + break; #endif #if IRMP_SUPPORT_S100_PROTOCOL == 1 - case IRMP_S100_PROTOCOL: - irmp_address &= ~0x20; // clear toggle bit - rtc = TRUE; - break; + case IRMP_S100_PROTOCOL: + irmp_address &= ~0x20; // clear toggle bit + rtc = TRUE; + break; #endif #if IRMP_SUPPORT_IR60_PROTOCOL == 1 - case IRMP_IR60_PROTOCOL: - if (irmp_command != 0x007d) // 0x007d (== 62<<1 + 1) is start instruction frame - { - rtc = TRUE; - } - else - { -#ifdef ANALYZE - ANALYZE_PRINTF("Info IR60: got start instruction frame\n"); -#endif // ANALYZE - } - break; + case IRMP_IR60_PROTOCOL: + if (irmp_command != 0x007d) // 0x007d (== 62<<1 + 1) is start instruction frame + { + rtc = TRUE; + } + else + { +#ifdef ANALYZE + ANALYZE_PRINTF("Info IR60: got start instruction frame\n"); +#endif // ANALYZE + } + break; #endif #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1 - case IRMP_RCCAR_PROTOCOL: - // frame in irmp_data: - // Bit 12 11 10 9 8 7 6 5 4 3 2 1 0 - // V D7 D6 D5 D4 D3 D2 D1 D0 A1 A0 C1 C0 // 10 9 8 7 6 5 4 3 2 1 0 - irmp_address = (irmp_command & 0x000C) >> 2; // addr: 0 0 0 0 0 0 0 0 0 A1 A0 - irmp_command = ((irmp_command & 0x1000) >> 2) | // V-Bit: V 0 0 0 0 0 0 0 0 0 0 - ((irmp_command & 0x0003) << 8) | // C-Bits: 0 C1 C0 0 0 0 0 0 0 0 0 - ((irmp_command & 0x0FF0) >> 4); // D-Bits: D7 D6 D5 D4 D3 D2 D1 D0 - rtc = TRUE; // Summe: V C1 C0 D7 D6 D5 D4 D3 D2 D1 D0 - break; + case IRMP_RCCAR_PROTOCOL: + // frame in irmp_data: + // Bit 12 11 10 9 8 7 6 5 4 3 2 1 0 + // V D7 D6 D5 D4 D3 D2 D1 D0 A1 A0 C1 C0 // 10 9 8 7 6 5 4 3 2 1 0 + irmp_address = (irmp_command & 0x000C) >> 2; // addr: 0 0 0 0 0 0 0 0 0 A1 A0 + irmp_command = ((irmp_command & 0x1000) >> 2) | // V-Bit: V 0 0 0 0 0 0 0 0 0 0 + ((irmp_command & 0x0003) << 8) | // C-Bits: 0 C1 C0 0 0 0 0 0 0 0 0 + ((irmp_command & 0x0FF0) >> 4); // D-Bits: D7 D6 D5 D4 D3 D2 D1 D0 + rtc = TRUE; // Summe: V C1 C0 D7 D6 D5 D4 D3 D2 D1 D0 + break; #endif #if IRMP_SUPPORT_NETBOX_PROTOCOL == 1 // squeeze code to 8 bit, upper bit indicates release-key - case IRMP_NETBOX_PROTOCOL: - if (irmp_command & 0x1000) // last bit set? - { - if ((irmp_command & 0x1f) == 0x15) // key pressed: 101 01 (LSB) - { - irmp_command >>= 5; - irmp_command &= 0x7F; - rtc = TRUE; - } - else if ((irmp_command & 0x1f) == 0x10) // key released: 000 01 (LSB) - { - irmp_command >>= 5; - irmp_command |= 0x80; - rtc = TRUE; - } - else - { -#ifdef ANALYZE - ANALYZE_PRINTF("error NETBOX: bit6/7 must be 0/1\n"); -#endif // ANALYZE - } - } - else - { -#ifdef ANALYZE - ANALYZE_PRINTF("error NETBOX: last bit not set\n"); -#endif // ANALYZE - } - break; + case IRMP_NETBOX_PROTOCOL: + if (irmp_command & 0x1000) // last bit set? + { + if ((irmp_command & 0x1f) == 0x15) // key pressed: 101 01 (LSB) + { + irmp_command >>= 5; + irmp_command &= 0x7F; + rtc = TRUE; + } + else if ((irmp_command & 0x1f) == 0x10) // key released: 000 01 (LSB) + { + irmp_command >>= 5; + irmp_command |= 0x80; + rtc = TRUE; + } + else + { +#ifdef ANALYZE + ANALYZE_PRINTF("error NETBOX: bit6/7 must be 0/1\n"); +#endif // ANALYZE + } + } + else + { +#ifdef ANALYZE + ANALYZE_PRINTF("error NETBOX: last bit not set\n"); +#endif // ANALYZE + } + break; #endif #if IRMP_SUPPORT_LEGO_PROTOCOL == 1 - case IRMP_LEGO_PROTOCOL: - { - uint_fast8_t crc = 0x0F ^ ((irmp_command & 0xF000) >> 12) ^ ((irmp_command & 0x0F00) >> 8) ^ ((irmp_command & 0x00F0) >> 4); - - if ((irmp_command & 0x000F) == crc) - { - irmp_command >>= 4; - rtc = TRUE; - } - else - { -#ifdef ANALYZE - ANALYZE_PRINTF ("CRC error in LEGO protocol\n"); -#endif // ANALYZE - // rtc = TRUE; // don't accept codes with CRC errors - } - break; - } + case IRMP_LEGO_PROTOCOL: + { + uint_fast8_t crc = 0x0F ^ ((irmp_command & 0xF000) >> 12) ^ ((irmp_command & 0x0F00) >> 8) ^ ((irmp_command & 0x00F0) >> 4); + + if ((irmp_command & 0x000F) == crc) + { + irmp_command >>= 4; + rtc = TRUE; + } + else + { +#ifdef ANALYZE + ANALYZE_PRINTF ("CRC error in LEGO protocol\n"); +#endif // ANALYZE + // rtc = TRUE; // don't accept codes with CRC errors + } + break; + } #endif - default: - { - rtc = TRUE; - break; - } - } - - if (rtc) - { - irmp_data_p->protocol = irmp_protocol; - irmp_data_p->address = irmp_address; - irmp_data_p->command = irmp_command; - irmp_data_p->flags = irmp_flags; - irmp_command = 0; - irmp_address = 0; - irmp_flags = 0; - } - - irmp_ir_detected = FALSE; + default: + { + rtc = TRUE; + break; + } + } + + if (rtc) + { + irmp_data_p->protocol = irmp_protocol; + irmp_data_p->address = irmp_address; + irmp_data_p->command = irmp_command; + irmp_data_p->flags = irmp_flags; + irmp_command = 0; + irmp_address = 0; + irmp_flags = 0; + } + + irmp_ir_detected = FALSE; } return rtc; @@ -2270,38 +2332,38 @@ irmp_store_bit (uint_fast8_t value) #if IRMP_SUPPORT_ACP24_PROTOCOL == 1 if (irmp_param.protocol == IRMP_ACP24_PROTOCOL) // squeeze 64 bits into 16 bits: { - if (value) - { - // ACP24-Frame: - // 1 2 3 4 5 6 - // 0123456789012345678901234567890123456789012345678901234567890123456789 - // N VVMMM ? ??? t vmA x y TTTT - // - // irmp_data_p->command: - // - // 5432109876543210 - // NAVVvMMMmtxyTTTT - - switch (irmp_bit) - { - case 0: irmp_tmp_command |= (1<<15); break; // N - case 2: irmp_tmp_command |= (1<<13); break; // V - case 3: irmp_tmp_command |= (1<<12); break; // V - case 4: irmp_tmp_command |= (1<<10); break; // M - case 5: irmp_tmp_command |= (1<< 9); break; // M - case 6: irmp_tmp_command |= (1<< 8); break; // M - case 20: irmp_tmp_command |= (1<< 6); break; // t - case 22: irmp_tmp_command |= (1<<11); break; // v - case 23: irmp_tmp_command |= (1<< 7); break; // m - case 24: irmp_tmp_command |= (1<<14); break; // A - case 26: irmp_tmp_command |= (1<< 5); break; // x - case 44: irmp_tmp_command |= (1<< 4); break; // y - case 66: irmp_tmp_command |= (1<< 3); break; // T - case 67: irmp_tmp_command |= (1<< 2); break; // T - case 68: irmp_tmp_command |= (1<< 1); break; // T - case 69: irmp_tmp_command |= (1<< 0); break; // T - } - } + if (value) + { + // ACP24-Frame: + // 1 2 3 4 5 6 + // 0123456789012345678901234567890123456789012345678901234567890123456789 + // N VVMMM ? ??? t vmA x y TTTT + // + // irmp_data_p->command: + // + // 5432109876543210 + // NAVVvMMMmtxyTTTT + + switch (irmp_bit) + { + case 0: irmp_tmp_command |= (1<<15); break; // N + case 2: irmp_tmp_command |= (1<<13); break; // V + case 3: irmp_tmp_command |= (1<<12); break; // V + case 4: irmp_tmp_command |= (1<<10); break; // M + case 5: irmp_tmp_command |= (1<< 9); break; // M + case 6: irmp_tmp_command |= (1<< 8); break; // M + case 20: irmp_tmp_command |= (1<< 6); break; // t + case 22: irmp_tmp_command |= (1<<11); break; // v + case 23: irmp_tmp_command |= (1<< 7); break; // m + case 24: irmp_tmp_command |= (1<<14); break; // A + case 26: irmp_tmp_command |= (1<< 5); break; // x + case 44: irmp_tmp_command |= (1<< 4); break; // y + case 66: irmp_tmp_command |= (1<< 3); break; // T + case 67: irmp_tmp_command |= (1<< 2); break; // T + case 68: irmp_tmp_command |= (1<< 1); break; // T + case 69: irmp_tmp_command |= (1<< 0); break; // T + } + } } else #endif // IRMP_SUPPORT_ACP24_PROTOCOL @@ -2309,100 +2371,100 @@ irmp_store_bit (uint_fast8_t value) #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1 if (irmp_param.protocol == IRMP_ORTEK_PROTOCOL) { - if (irmp_bit < 14) - { - if (value) - { - parity++; - } - } - else if (irmp_bit == 14) - { - if (value) // value == 1: even parity - { - if (parity & 0x01) - { - parity = PARITY_CHECK_FAILED; - } - else - { - parity = PARITY_CHECK_OK; - } - } - else - { - if (parity & 0x01) // value == 0: odd parity - { - parity = PARITY_CHECK_OK; - } - else - { - parity = PARITY_CHECK_FAILED; - } - } - } + if (irmp_bit < 14) + { + if (value) + { + parity++; + } + } + else if (irmp_bit == 14) + { + if (value) // value == 1: even parity + { + if (parity & 0x01) + { + parity = PARITY_CHECK_FAILED; + } + else + { + parity = PARITY_CHECK_OK; + } + } + else + { + if (parity & 0x01) // value == 0: odd parity + { + parity = PARITY_CHECK_OK; + } + else + { + parity = PARITY_CHECK_FAILED; + } + } + } } else #endif { - ; + ; } #if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1 if (irmp_bit == 0 && irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL) { - first_bit = value; + first_bit = value; } else #endif if (irmp_bit >= irmp_param.address_offset && irmp_bit < irmp_param.address_end) { - if (irmp_param.lsb_first) - { - irmp_tmp_address |= (((uint_fast16_t) (value)) << (irmp_bit - irmp_param.address_offset)); // CV wants cast - } - else - { - irmp_tmp_address <<= 1; - irmp_tmp_address |= value; - } + if (irmp_param.lsb_first) + { + irmp_tmp_address |= (((uint_fast16_t) (value)) << (irmp_bit - irmp_param.address_offset)); // CV wants cast + } + else + { + irmp_tmp_address <<= 1; + irmp_tmp_address |= value; + } } else if (irmp_bit >= irmp_param.command_offset && irmp_bit < irmp_param.command_end) { - if (irmp_param.lsb_first) - { + if (irmp_param.lsb_first) + { #if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_SAMSUNG48_PROTOCOL && irmp_bit >= 32) - { - irmp_tmp_id |= (((uint_fast16_t) (value)) << (irmp_bit - 32)); // CV wants cast - } - else + if (irmp_param.protocol == IRMP_SAMSUNG48_PROTOCOL && irmp_bit >= 32) + { + irmp_tmp_id |= (((uint_fast16_t) (value)) << (irmp_bit - 32)); // CV wants cast + } + else #endif - { - irmp_tmp_command |= (((uint_fast16_t) (value)) << (irmp_bit - irmp_param.command_offset)); // CV wants cast - } - } - else - { - irmp_tmp_command <<= 1; - irmp_tmp_command |= value; - } + { + irmp_tmp_command |= (((uint_fast16_t) (value)) << (irmp_bit - irmp_param.command_offset)); // CV wants cast + } + } + else + { + irmp_tmp_command <<= 1; + irmp_tmp_command |= value; + } } #if IRMP_SUPPORT_LGAIR_PROTOCOL == 1 if (irmp_param.protocol == IRMP_NEC_PROTOCOL || irmp_param.protocol == IRMP_NEC42_PROTOCOL) { - if (irmp_bit < 8) - { - irmp_lgair_address <<= 1; // LGAIR uses MSB - irmp_lgair_address |= value; - } - else if (irmp_bit < 24) - { - irmp_lgair_command <<= 1; // LGAIR uses MSB - irmp_lgair_command |= value; - } + if (irmp_bit < 8) + { + irmp_lgair_address <<= 1; // LGAIR uses MSB + irmp_lgair_address |= value; + } + else if (irmp_bit < 24) + { + irmp_lgair_command <<= 1; // LGAIR uses MSB + irmp_lgair_command |= value; + } } // NO else! #endif @@ -2410,7 +2472,7 @@ irmp_store_bit (uint_fast8_t value) #if IRMP_SUPPORT_NEC42_PROTOCOL == 1 if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit >= 13 && irmp_bit < 26) { - irmp_tmp_address2 |= (((uint_fast16_t) (value)) << (irmp_bit - 13)); // CV wants cast + irmp_tmp_address2 |= (((uint_fast16_t) (value)) << (irmp_bit - 13)); // CV wants cast } else #endif @@ -2418,7 +2480,7 @@ irmp_store_bit (uint_fast8_t value) #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 if (irmp_param.protocol == IRMP_SAMSUNG_PROTOCOL && irmp_bit >= SAMSUNG_ID_OFFSET && irmp_bit < SAMSUNG_ID_OFFSET + SAMSUNG_ID_LEN) { - irmp_tmp_id |= (((uint_fast16_t) (value)) << (irmp_bit - SAMSUNG_ID_OFFSET)); // store with LSB first + irmp_tmp_id |= (((uint_fast16_t) (value)) << (irmp_bit - SAMSUNG_ID_OFFSET)); // store with LSB first } else #endif @@ -2426,31 +2488,31 @@ irmp_store_bit (uint_fast8_t value) #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL) { - if (irmp_bit >= 20 && irmp_bit < 24) - { - irmp_tmp_command |= (((uint_fast16_t) (value)) << (irmp_bit - 8)); // store 4 system bits (genre 1) in upper nibble with LSB first - } - else if (irmp_bit >= 24 && irmp_bit < 28) - { - genre2 |= (((uint_fast8_t) (value)) << (irmp_bit - 20)); // store 4 system bits (genre 2) in upper nibble with LSB first - } - - if (irmp_bit < KASEIKYO_COMPLETE_DATA_LEN) - { - if (value) - { - xor_check[irmp_bit / 8] |= 1 << (irmp_bit % 8); - } - else - { - xor_check[irmp_bit / 8] &= ~(1 << (irmp_bit % 8)); - } - } + if (irmp_bit >= 20 && irmp_bit < 24) + { + irmp_tmp_command |= (((uint_fast16_t) (value)) << (irmp_bit - 8)); // store 4 system bits (genre 1) in upper nibble with LSB first + } + else if (irmp_bit >= 24 && irmp_bit < 28) + { + genre2 |= (((uint_fast8_t) (value)) << (irmp_bit - 20)); // store 4 system bits (genre 2) in upper nibble with LSB first + } + + if (irmp_bit < KASEIKYO_COMPLETE_DATA_LEN) + { + if (value) + { + xor_check[irmp_bit / 8] |= 1 << (irmp_bit % 8); + } + else + { + xor_check[irmp_bit / 8] &= ~(1 << (irmp_bit % 8)); + } + } } else #endif { - ; + ; } irmp_bit++; @@ -2470,20 +2532,20 @@ irmp_store_bit2 (uint_fast8_t value) if (irmp_param.protocol) { - irmp_bit2 = irmp_bit - 2; + irmp_bit2 = irmp_bit - 2; } else { - irmp_bit2 = irmp_bit - 1; + irmp_bit2 = irmp_bit - 1; } if (irmp_bit2 >= irmp_param2.address_offset && irmp_bit2 < irmp_param2.address_end) { - irmp_tmp_address2 |= (((uint_fast16_t) (value)) << (irmp_bit2 - irmp_param2.address_offset)); // CV wants cast + irmp_tmp_address2 |= (((uint_fast16_t) (value)) << (irmp_bit2 - irmp_param2.address_offset)); // CV wants cast } else if (irmp_bit2 >= irmp_param2.command_offset && irmp_bit2 < irmp_param2.command_end) { - irmp_tmp_command2 |= (((uint_fast16_t) (value)) << (irmp_bit2 - irmp_param2.command_offset)); // CV wants cast + irmp_tmp_command2 |= (((uint_fast16_t) (value)) << (irmp_bit2 - irmp_param2.command_offset)); // CV wants cast } } #endif // IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) @@ -2533,13 +2595,13 @@ irmp_ISR (void) #if IRMP_USE_CALLBACK == 1 if (irmp_callback_ptr) { - static uint_fast8_t last_inverted_input; + static uint_fast8_t last_inverted_input; - if (last_inverted_input != !irmp_input) - { - (*irmp_callback_ptr) (! irmp_input); - last_inverted_input = !irmp_input; - } + if (last_inverted_input != !irmp_input) + { + (*irmp_callback_ptr) (! irmp_input); + last_inverted_input = !irmp_input; + } } #endif // IRMP_USE_CALLBACK == 1 @@ -2547,2222 +2609,2236 @@ irmp_ISR (void) if (! irmp_ir_detected) // ir code already detected? { // no... - if (! irmp_start_bit_detected) // start bit detected? - { // no... - if (! irmp_input) // receiving burst? - { // yes... + if (! irmp_start_bit_detected) // start bit detected? + { // no... + if (! irmp_input) // receiving burst? + { // yes... // irmp_busy_flag = TRUE; #ifdef ANALYZE - if (! irmp_pulse_time) - { - ANALYZE_PRINTF("%8.3fms [starting pulse]\n", (double) (time_counter * 1000) / F_INTERRUPTS); - } -#endif // ANALYZE - irmp_pulse_time++; // increment counter - } - else - { // no... - if (irmp_pulse_time) // it's dark.... - { // set flags for counting the time of darkness... - irmp_start_bit_detected = 1; - wait_for_start_space = 1; - wait_for_space = 0; - irmp_tmp_command = 0; - irmp_tmp_address = 0; + if (! irmp_pulse_time) + { + ANALYZE_PRINTF("%8.3fms [starting pulse]\n", (double) (time_counter * 1000) / F_INTERRUPTS); + } +#endif // ANALYZE + irmp_pulse_time++; // increment counter + } + else + { // no... + if (irmp_pulse_time) // it's dark.... + { // set flags for counting the time of darkness... + irmp_start_bit_detected = 1; + wait_for_start_space = 1; + wait_for_space = 0; + irmp_tmp_command = 0; + irmp_tmp_address = 0; #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 - genre2 = 0; + genre2 = 0; #endif #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 - irmp_tmp_id = 0; + irmp_tmp_id = 0; #endif #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) || IRMP_SUPPORT_NEC42_PROTOCOL == 1 - irmp_tmp_command2 = 0; - irmp_tmp_address2 = 0; + irmp_tmp_command2 = 0; + irmp_tmp_address2 = 0; #endif #if IRMP_SUPPORT_LGAIR_PROTOCOL == 1 - irmp_lgair_command = 0; - irmp_lgair_address = 0; + irmp_lgair_command = 0; + irmp_lgair_address = 0; #endif - irmp_bit = 0xff; - irmp_pause_time = 1; // 1st pause: set to 1, not to 0! + irmp_bit = 0xff; + irmp_pause_time = 1; // 1st pause: set to 1, not to 0! #if IRMP_SUPPORT_RC5_PROTOCOL == 1 || IRMP_SUPPORT_S100_PROTOCOL == 1 - rc5_cmd_bit6 = 0; // fm 2010-03-07: bugfix: reset it after incomplete RC5 frame! + rc5_cmd_bit6 = 0; // fm 2010-03-07: bugfix: reset it after incomplete RC5 frame! #endif - } - else - { - if (key_repetition_len < 0xFFFF) // avoid overflow of counter - { - key_repetition_len++; + } + else + { + if (key_repetition_len < 0xFFFF) // avoid overflow of counter + { + key_repetition_len++; #if IRMP_SUPPORT_DENON_PROTOCOL == 1 - if (denon_repetition_len < 0xFFFF) // avoid overflow of counter - { - denon_repetition_len++; + if (denon_repetition_len < 0xFFFF) // avoid overflow of counter + { + denon_repetition_len++; - if (denon_repetition_len >= DENON_AUTO_REPETITION_PAUSE_LEN && last_irmp_denon_command != 0) - { + if (denon_repetition_len >= DENON_AUTO_REPETITION_PAUSE_LEN && last_irmp_denon_command != 0) + { #ifdef ANALYZE - ANALYZE_PRINTF ("%8.3fms warning: did not receive inverted command repetition\n", - (double) (time_counter * 1000) / F_INTERRUPTS); + ANALYZE_PRINTF ("%8.3fms warning: did not receive inverted command repetition\n", + (double) (time_counter * 1000) / F_INTERRUPTS); #endif // ANALYZE - last_irmp_denon_command = 0; - denon_repetition_len = 0xFFFF; - } - } + last_irmp_denon_command = 0; + denon_repetition_len = 0xFFFF; + } + } #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1 - } - } - } - } - else - { - if (wait_for_start_space) // we have received start bit... - { // ...and are counting the time of darkness - if (irmp_input) // still dark? - { // yes - irmp_pause_time++; // increment counter + } + } + } + } + else + { + if (wait_for_start_space) // we have received start bit... + { // ...and are counting the time of darkness + if (irmp_input) // still dark? + { // yes + irmp_pause_time++; // increment counter #if IRMP_SUPPORT_NIKON_PROTOCOL == 1 - if (((irmp_pulse_time < NIKON_START_BIT_PULSE_LEN_MIN || irmp_pulse_time > NIKON_START_BIT_PULSE_LEN_MAX) && irmp_pause_time > IRMP_TIMEOUT_LEN) || - irmp_pause_time > IRMP_TIMEOUT_NIKON_LEN) + if (((irmp_pulse_time < NIKON_START_BIT_PULSE_LEN_MIN || irmp_pulse_time > NIKON_START_BIT_PULSE_LEN_MAX) && irmp_pause_time > IRMP_TIMEOUT_LEN) || + irmp_pause_time > IRMP_TIMEOUT_NIKON_LEN) #else - if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout? + if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout? #endif - { // yes... + { // yes... #if IRMP_SUPPORT_JVC_PROTOCOL == 1 - if (irmp_protocol == IRMP_JVC_PROTOCOL) // don't show eror if JVC protocol, irmp_pulse_time has been set below! - { - ; - } - else + if (irmp_protocol == IRMP_JVC_PROTOCOL) // don't show eror if JVC protocol, irmp_pulse_time has been set below! + { + ; + } + else #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1 - { + { #ifdef ANALYZE - ANALYZE_PRINTF ("%8.3fms error 1: pause after start bit pulse %d too long: %d\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_pulse_time, irmp_pause_time); - ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); + ANALYZE_PRINTF ("%8.3fms error 1: pause after start bit pulse %d too long: %d\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_pulse_time, irmp_pause_time); + ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); #endif // ANALYZE - } + } - irmp_start_bit_detected = 0; // reset flags, let's wait for another start bit - irmp_pulse_time = 0; - irmp_pause_time = 0; - } - } - else - { // receiving first data pulse! - IRMP_PARAMETER * irmp_param_p; - irmp_param_p = (IRMP_PARAMETER *) 0; + irmp_start_bit_detected = 0; // reset flags, let's wait for another start bit + irmp_pulse_time = 0; + irmp_pause_time = 0; + } + } + else + { // receiving first data pulse! + IRMP_PARAMETER * irmp_param_p; + irmp_param_p = (IRMP_PARAMETER *) 0; #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) - irmp_param2.protocol = 0; + irmp_param2.protocol = 0; #endif #ifdef ANALYZE - ANALYZE_PRINTF ("%8.3fms [start-bit: pulse = %2d, pause = %2d]\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_pulse_time, irmp_pause_time); + ANALYZE_PRINTF ("%8.3fms [start-bit: pulse = %2d, pause = %2d]\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_pulse_time, irmp_pause_time); #endif // ANALYZE #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1 - if (irmp_pulse_time >= SIRCS_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SIRCS_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= SIRCS_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SIRCS_START_BIT_PAUSE_LEN_MAX) - { // it's SIRCS + if (irmp_pulse_time >= SIRCS_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SIRCS_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= SIRCS_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SIRCS_START_BIT_PAUSE_LEN_MAX) + { // it's SIRCS #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = SIRCS, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - SIRCS_START_BIT_PULSE_LEN_MIN, SIRCS_START_BIT_PULSE_LEN_MAX, - SIRCS_START_BIT_PAUSE_LEN_MIN, SIRCS_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = SIRCS, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + SIRCS_START_BIT_PULSE_LEN_MIN, SIRCS_START_BIT_PULSE_LEN_MAX, + SIRCS_START_BIT_PAUSE_LEN_MIN, SIRCS_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &sircs_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &sircs_param; + } + else #endif // IRMP_SUPPORT_SIRCS_PROTOCOL == 1 #if IRMP_SUPPORT_JVC_PROTOCOL == 1 - if (irmp_protocol == IRMP_JVC_PROTOCOL && // last protocol was JVC, awaiting repeat frame - irmp_pulse_time >= 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) - { -#ifdef ANALYZE - 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); -#endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &nec_param; - } - else + if (irmp_protocol == IRMP_JVC_PROTOCOL && // last protocol was JVC, awaiting repeat frame + irmp_pulse_time >= 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) + { +#ifdef ANALYZE + 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); +#endif // ANALYZE + irmp_param_p = (IRMP_PARAMETER *) &nec_param; + } + else #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1 #if IRMP_SUPPORT_NEC_PROTOCOL == 1 - if (irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX) - { + if (irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX) + { #if IRMP_SUPPORT_NEC42_PROTOCOL == 1 #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = NEC42, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX, - NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = NEC42, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX, + NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &nec42_param; + irmp_param_p = (IRMP_PARAMETER *) &nec42_param; #else #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = NEC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX, - NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = NEC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX, + NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &nec_param; + irmp_param_p = (IRMP_PARAMETER *) &nec_param; #endif - } - 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 + } + 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 #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 + 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 #ifdef ANALYZE - 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); + 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); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &nec_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &nec_param; + } + else #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1 - { + { #ifdef ANALYZE - 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); + 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); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &nec_rep_param; - } - } - else + 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 -#ifdef ANALYZE - 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); -#endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &nec_param; - } - else + 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 +#ifdef ANALYZE + 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); +#endif // ANALYZE + irmp_param_p = (IRMP_PARAMETER *) &nec_param; + } + else #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1 #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1 #if IRMP_SUPPORT_TELEFUNKEN_PROTOCOL == 1 - if (irmp_pulse_time >= TELEFUNKEN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= TELEFUNKEN_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= TELEFUNKEN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= TELEFUNKEN_START_BIT_PAUSE_LEN_MAX) - { + if (irmp_pulse_time >= TELEFUNKEN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= TELEFUNKEN_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= TELEFUNKEN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= TELEFUNKEN_START_BIT_PAUSE_LEN_MAX) + { #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = TELEFUNKEN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - TELEFUNKEN_START_BIT_PULSE_LEN_MIN, TELEFUNKEN_START_BIT_PULSE_LEN_MAX, - TELEFUNKEN_START_BIT_PAUSE_LEN_MIN, TELEFUNKEN_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = TELEFUNKEN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + TELEFUNKEN_START_BIT_PULSE_LEN_MIN, TELEFUNKEN_START_BIT_PULSE_LEN_MAX, + TELEFUNKEN_START_BIT_PAUSE_LEN_MIN, TELEFUNKEN_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &telefunken_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &telefunken_param; + } + else #endif // IRMP_SUPPORT_TELEFUNKEN_PROTOCOL == 1 #if IRMP_SUPPORT_ROOMBA_PROTOCOL == 1 - if (irmp_pulse_time >= ROOMBA_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= ROOMBA_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= ROOMBA_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= ROOMBA_START_BIT_PAUSE_LEN_MAX) - { + if (irmp_pulse_time >= ROOMBA_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= ROOMBA_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= ROOMBA_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= ROOMBA_START_BIT_PAUSE_LEN_MAX) + { #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = ROOMBA, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - ROOMBA_START_BIT_PULSE_LEN_MIN, ROOMBA_START_BIT_PULSE_LEN_MAX, - ROOMBA_START_BIT_PAUSE_LEN_MIN, ROOMBA_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = ROOMBA, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + ROOMBA_START_BIT_PULSE_LEN_MIN, ROOMBA_START_BIT_PULSE_LEN_MAX, + ROOMBA_START_BIT_PAUSE_LEN_MIN, ROOMBA_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &roomba_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &roomba_param; + } + else #endif // IRMP_SUPPORT_ROOMBA_PROTOCOL == 1 #if IRMP_SUPPORT_ACP24_PROTOCOL == 1 - if (irmp_pulse_time >= ACP24_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= ACP24_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= ACP24_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= ACP24_START_BIT_PAUSE_LEN_MAX) - { + if (irmp_pulse_time >= ACP24_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= ACP24_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= ACP24_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= ACP24_START_BIT_PAUSE_LEN_MAX) + { #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = ACP24, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - ACP24_START_BIT_PULSE_LEN_MIN, ACP24_START_BIT_PULSE_LEN_MAX, - ACP24_START_BIT_PAUSE_LEN_MIN, ACP24_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = ACP24, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + ACP24_START_BIT_PULSE_LEN_MIN, ACP24_START_BIT_PULSE_LEN_MAX, + ACP24_START_BIT_PAUSE_LEN_MIN, ACP24_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &acp24_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &acp24_param; + } + else #endif // IRMP_SUPPORT_ROOMBA_PROTOCOL == 1 #if IRMP_SUPPORT_PENTAX_PROTOCOL == 1 - if (irmp_pulse_time >= PENTAX_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= PENTAX_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= PENTAX_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= PENTAX_START_BIT_PAUSE_LEN_MAX) - { + if (irmp_pulse_time >= PENTAX_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= PENTAX_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= PENTAX_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= PENTAX_START_BIT_PAUSE_LEN_MAX) + { #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = PENTAX, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - PENTAX_START_BIT_PULSE_LEN_MIN, PENTAX_START_BIT_PULSE_LEN_MAX, - PENTAX_START_BIT_PAUSE_LEN_MIN, PENTAX_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = PENTAX, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + PENTAX_START_BIT_PULSE_LEN_MIN, PENTAX_START_BIT_PULSE_LEN_MAX, + PENTAX_START_BIT_PAUSE_LEN_MIN, PENTAX_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &pentax_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &pentax_param; + } + else #endif // IRMP_SUPPORT_PENTAX_PROTOCOL == 1 #if IRMP_SUPPORT_NIKON_PROTOCOL == 1 - if (irmp_pulse_time >= NIKON_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NIKON_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= NIKON_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NIKON_START_BIT_PAUSE_LEN_MAX) - { + if (irmp_pulse_time >= NIKON_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NIKON_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= NIKON_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NIKON_START_BIT_PAUSE_LEN_MAX) + { #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = NIKON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - NIKON_START_BIT_PULSE_LEN_MIN, NIKON_START_BIT_PULSE_LEN_MAX, - NIKON_START_BIT_PAUSE_LEN_MIN, NIKON_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = NIKON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + NIKON_START_BIT_PULSE_LEN_MIN, NIKON_START_BIT_PULSE_LEN_MAX, + NIKON_START_BIT_PAUSE_LEN_MIN, NIKON_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &nikon_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &nikon_param; + } + else #endif // IRMP_SUPPORT_NIKON_PROTOCOL == 1 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 - if (irmp_pulse_time >= SAMSUNG_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= SAMSUNG_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_START_BIT_PAUSE_LEN_MAX) - { // it's SAMSUNG + if (irmp_pulse_time >= SAMSUNG_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= SAMSUNG_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_START_BIT_PAUSE_LEN_MAX) + { // it's SAMSUNG #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = SAMSUNG, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - SAMSUNG_START_BIT_PULSE_LEN_MIN, SAMSUNG_START_BIT_PULSE_LEN_MAX, - SAMSUNG_START_BIT_PAUSE_LEN_MIN, SAMSUNG_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = SAMSUNG, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + SAMSUNG_START_BIT_PULSE_LEN_MIN, SAMSUNG_START_BIT_PULSE_LEN_MAX, + SAMSUNG_START_BIT_PAUSE_LEN_MIN, SAMSUNG_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &samsung_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &samsung_param; + } + else #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 #if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1 - if (irmp_pulse_time >= MATSUSHITA_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= MATSUSHITA_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= MATSUSHITA_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= MATSUSHITA_START_BIT_PAUSE_LEN_MAX) - { // it's MATSUSHITA + if (irmp_pulse_time >= MATSUSHITA_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= MATSUSHITA_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= MATSUSHITA_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= MATSUSHITA_START_BIT_PAUSE_LEN_MAX) + { // it's MATSUSHITA #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = MATSUSHITA, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - MATSUSHITA_START_BIT_PULSE_LEN_MIN, MATSUSHITA_START_BIT_PULSE_LEN_MAX, - MATSUSHITA_START_BIT_PAUSE_LEN_MIN, MATSUSHITA_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = MATSUSHITA, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + MATSUSHITA_START_BIT_PULSE_LEN_MIN, MATSUSHITA_START_BIT_PULSE_LEN_MAX, + MATSUSHITA_START_BIT_PAUSE_LEN_MIN, MATSUSHITA_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &matsushita_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &matsushita_param; + } + else #endif // IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1 #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 - if (irmp_pulse_time >= KASEIKYO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= KASEIKYO_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= KASEIKYO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KASEIKYO_START_BIT_PAUSE_LEN_MAX) - { // it's KASEIKYO + if (irmp_pulse_time >= KASEIKYO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= KASEIKYO_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= KASEIKYO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KASEIKYO_START_BIT_PAUSE_LEN_MAX) + { // it's KASEIKYO #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = KASEIKYO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - KASEIKYO_START_BIT_PULSE_LEN_MIN, KASEIKYO_START_BIT_PULSE_LEN_MAX, - KASEIKYO_START_BIT_PAUSE_LEN_MIN, KASEIKYO_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = KASEIKYO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + KASEIKYO_START_BIT_PULSE_LEN_MIN, KASEIKYO_START_BIT_PULSE_LEN_MAX, + KASEIKYO_START_BIT_PAUSE_LEN_MIN, KASEIKYO_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &kaseikyo_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &kaseikyo_param; + } + else #endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 +#if IRMP_SUPPORT_PANASONIC_PROTOCOL == 1 + if (irmp_pulse_time >= PANASONIC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= PANASONIC_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= PANASONIC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= PANASONIC_START_BIT_PAUSE_LEN_MAX) + { // it's PANASONIC +#ifdef ANALYZE + ANALYZE_PRINTF ("protocol = PANASONIC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + PANASONIC_START_BIT_PULSE_LEN_MIN, PANASONIC_START_BIT_PULSE_LEN_MAX, + PANASONIC_START_BIT_PAUSE_LEN_MIN, PANASONIC_START_BIT_PAUSE_LEN_MAX); +#endif // ANALYZE + irmp_param_p = (IRMP_PARAMETER *) &panasonic_param; + } + else +#endif // IRMP_SUPPORT_PANASONIC_PROTOCOL == 1 + #if IRMP_SUPPORT_RADIO1_PROTOCOL == 1 - if (irmp_pulse_time >= RADIO1_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RADIO1_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= RADIO1_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RADIO1_START_BIT_PAUSE_LEN_MAX) - { + if (irmp_pulse_time >= RADIO1_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RADIO1_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= RADIO1_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RADIO1_START_BIT_PAUSE_LEN_MAX) + { #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = RADIO1, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - RADIO1_START_BIT_PULSE_LEN_MIN, RADIO1_START_BIT_PULSE_LEN_MAX, - RADIO1_START_BIT_PAUSE_LEN_MIN, RADIO1_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = RADIO1, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + RADIO1_START_BIT_PULSE_LEN_MIN, RADIO1_START_BIT_PULSE_LEN_MAX, + RADIO1_START_BIT_PAUSE_LEN_MIN, RADIO1_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &radio1_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &radio1_param; + } + else #endif // IRMP_SUPPORT_RRADIO1_PROTOCOL == 1 #if IRMP_SUPPORT_RECS80_PROTOCOL == 1 - if (irmp_pulse_time >= RECS80_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RECS80_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= RECS80_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RECS80_START_BIT_PAUSE_LEN_MAX) - { // it's RECS80 + if (irmp_pulse_time >= RECS80_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RECS80_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= RECS80_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RECS80_START_BIT_PAUSE_LEN_MAX) + { // it's RECS80 #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = RECS80, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - RECS80_START_BIT_PULSE_LEN_MIN, RECS80_START_BIT_PULSE_LEN_MAX, - RECS80_START_BIT_PAUSE_LEN_MIN, RECS80_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = RECS80, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + RECS80_START_BIT_PULSE_LEN_MIN, RECS80_START_BIT_PULSE_LEN_MAX, + RECS80_START_BIT_PAUSE_LEN_MIN, RECS80_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &recs80_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &recs80_param; + } + else #endif // IRMP_SUPPORT_RECS80_PROTOCOL == 1 #if IRMP_SUPPORT_S100_PROTOCOL == 1 - if (((irmp_pulse_time >= S100_START_BIT_LEN_MIN && irmp_pulse_time <= S100_START_BIT_LEN_MAX) || - (irmp_pulse_time >= 2 * S100_START_BIT_LEN_MIN && irmp_pulse_time <= 2 * S100_START_BIT_LEN_MAX)) && - ((irmp_pause_time >= S100_START_BIT_LEN_MIN && irmp_pause_time <= S100_START_BIT_LEN_MAX) || - (irmp_pause_time >= 2 * S100_START_BIT_LEN_MIN && irmp_pause_time <= 2 * S100_START_BIT_LEN_MAX))) - { // it's S100 -#ifdef ANALYZE - ANALYZE_PRINTF ("protocol = S100, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or pulse: %3d - %3d, pause: %3d - %3d\n", - S100_START_BIT_LEN_MIN, S100_START_BIT_LEN_MAX, - 2 * S100_START_BIT_LEN_MIN, 2 * S100_START_BIT_LEN_MAX, - S100_START_BIT_LEN_MIN, S100_START_BIT_LEN_MAX, - 2 * S100_START_BIT_LEN_MIN, 2 * S100_START_BIT_LEN_MAX); -#endif // ANALYZE - - irmp_param_p = (IRMP_PARAMETER *) &s100_param; - last_pause = irmp_pause_time; - - if ((irmp_pulse_time > S100_START_BIT_LEN_MAX && irmp_pulse_time <= 2 * S100_START_BIT_LEN_MAX) || - (irmp_pause_time > S100_START_BIT_LEN_MAX && irmp_pause_time <= 2 * S100_START_BIT_LEN_MAX)) - { - last_value = 0; - rc5_cmd_bit6 = 1<<6; - } - else - { - last_value = 1; - } - } - else + if (((irmp_pulse_time >= S100_START_BIT_LEN_MIN && irmp_pulse_time <= S100_START_BIT_LEN_MAX) || + (irmp_pulse_time >= 2 * S100_START_BIT_LEN_MIN && irmp_pulse_time <= 2 * S100_START_BIT_LEN_MAX)) && + ((irmp_pause_time >= S100_START_BIT_LEN_MIN && irmp_pause_time <= S100_START_BIT_LEN_MAX) || + (irmp_pause_time >= 2 * S100_START_BIT_LEN_MIN && irmp_pause_time <= 2 * S100_START_BIT_LEN_MAX))) + { // it's S100 +#ifdef ANALYZE + ANALYZE_PRINTF ("protocol = S100, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or pulse: %3d - %3d, pause: %3d - %3d\n", + S100_START_BIT_LEN_MIN, S100_START_BIT_LEN_MAX, + 2 * S100_START_BIT_LEN_MIN, 2 * S100_START_BIT_LEN_MAX, + S100_START_BIT_LEN_MIN, S100_START_BIT_LEN_MAX, + 2 * S100_START_BIT_LEN_MIN, 2 * S100_START_BIT_LEN_MAX); +#endif // ANALYZE + + irmp_param_p = (IRMP_PARAMETER *) &s100_param; + last_pause = irmp_pause_time; + + if ((irmp_pulse_time > S100_START_BIT_LEN_MAX && irmp_pulse_time <= 2 * S100_START_BIT_LEN_MAX) || + (irmp_pause_time > S100_START_BIT_LEN_MAX && irmp_pause_time <= 2 * S100_START_BIT_LEN_MAX)) + { + last_value = 0; + rc5_cmd_bit6 = 1<<6; + } + else + { + last_value = 1; + } + } + else #endif // IRMP_SUPPORT_S100_PROTOCOL == 1 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 - if (((irmp_pulse_time >= RC5_START_BIT_LEN_MIN && irmp_pulse_time <= RC5_START_BIT_LEN_MAX) || - (irmp_pulse_time >= 2 * RC5_START_BIT_LEN_MIN && irmp_pulse_time <= 2 * RC5_START_BIT_LEN_MAX)) && - ((irmp_pause_time >= RC5_START_BIT_LEN_MIN && irmp_pause_time <= RC5_START_BIT_LEN_MAX) || - (irmp_pause_time >= 2 * RC5_START_BIT_LEN_MIN && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX))) - { // it's RC5 + if (((irmp_pulse_time >= RC5_START_BIT_LEN_MIN && irmp_pulse_time <= RC5_START_BIT_LEN_MAX) || + (irmp_pulse_time >= 2 * RC5_START_BIT_LEN_MIN && irmp_pulse_time <= 2 * RC5_START_BIT_LEN_MAX)) && + ((irmp_pause_time >= RC5_START_BIT_LEN_MIN && irmp_pause_time <= RC5_START_BIT_LEN_MAX) || + (irmp_pause_time >= 2 * RC5_START_BIT_LEN_MIN && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX))) + { // it's RC5 #if IRMP_SUPPORT_FDC_PROTOCOL == 1 - if (irmp_pulse_time >= FDC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= FDC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC_START_BIT_PAUSE_LEN_MAX) - { -#ifdef ANALYZE - ANALYZE_PRINTF ("protocol = RC5 or FDC\n"); - ANALYZE_PRINTF ("FDC start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX, - FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX); - ANALYZE_PRINTF ("RC5 start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX, - RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX); -#endif // ANALYZE - memcpy_P (&irmp_param2, &fdc_param, sizeof (IRMP_PARAMETER)); - } - else + if (irmp_pulse_time >= FDC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= FDC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC_START_BIT_PAUSE_LEN_MAX) + { +#ifdef ANALYZE + ANALYZE_PRINTF ("protocol = RC5 or FDC\n"); + ANALYZE_PRINTF ("FDC start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX, + FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("RC5 start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX, + RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX); +#endif // ANALYZE + memcpy_P (&irmp_param2, &fdc_param, sizeof (IRMP_PARAMETER)); + } + else #endif // IRMP_SUPPORT_FDC_PROTOCOL == 1 #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1 - if (irmp_pulse_time >= RCCAR_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= RCCAR_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_START_BIT_PAUSE_LEN_MAX) - { -#ifdef ANALYZE - ANALYZE_PRINTF ("protocol = RC5 or RCCAR\n"); - ANALYZE_PRINTF ("RCCAR start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX, - RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX); - ANALYZE_PRINTF ("RC5 start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX, - RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX); -#endif // ANALYZE - memcpy_P (&irmp_param2, &rccar_param, sizeof (IRMP_PARAMETER)); - } - else + if (irmp_pulse_time >= RCCAR_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= RCCAR_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_START_BIT_PAUSE_LEN_MAX) + { +#ifdef ANALYZE + ANALYZE_PRINTF ("protocol = RC5 or RCCAR\n"); + ANALYZE_PRINTF ("RCCAR start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX, + RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("RC5 start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX, + RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX); +#endif // ANALYZE + memcpy_P (&irmp_param2, &rccar_param, sizeof (IRMP_PARAMETER)); + } + else #endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1 - { -#ifdef ANALYZE - ANALYZE_PRINTF ("protocol = RC5, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or pulse: %3d - %3d, pause: %3d - %3d\n", - RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX, - 2 * RC5_START_BIT_LEN_MIN, 2 * RC5_START_BIT_LEN_MAX, - RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX, - 2 * RC5_START_BIT_LEN_MIN, 2 * RC5_START_BIT_LEN_MAX); -#endif // ANALYZE - } - - irmp_param_p = (IRMP_PARAMETER *) &rc5_param; - last_pause = irmp_pause_time; - - if ((irmp_pulse_time > RC5_START_BIT_LEN_MAX && irmp_pulse_time <= 2 * RC5_START_BIT_LEN_MAX) || - (irmp_pause_time > RC5_START_BIT_LEN_MAX && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX)) - { - last_value = 0; - rc5_cmd_bit6 = 1<<6; - } - else - { - last_value = 1; - } - } - else + { +#ifdef ANALYZE + ANALYZE_PRINTF ("protocol = RC5, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or pulse: %3d - %3d, pause: %3d - %3d\n", + RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX, + 2 * RC5_START_BIT_LEN_MIN, 2 * RC5_START_BIT_LEN_MAX, + RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX, + 2 * RC5_START_BIT_LEN_MIN, 2 * RC5_START_BIT_LEN_MAX); +#endif // ANALYZE + } + + irmp_param_p = (IRMP_PARAMETER *) &rc5_param; + last_pause = irmp_pause_time; + + if ((irmp_pulse_time > RC5_START_BIT_LEN_MAX && irmp_pulse_time <= 2 * RC5_START_BIT_LEN_MAX) || + (irmp_pause_time > RC5_START_BIT_LEN_MAX && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX)) + { + last_value = 0; + rc5_cmd_bit6 = 1<<6; + } + else + { + last_value = 1; + } + } + else #endif // IRMP_SUPPORT_RC5_PROTOCOL == 1 #if IRMP_SUPPORT_DENON_PROTOCOL == 1 - if ( (irmp_pulse_time >= DENON_PULSE_LEN_MIN && irmp_pulse_time <= DENON_PULSE_LEN_MAX) && - ((irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX) || - (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX))) - { // it's DENON -#ifdef ANALYZE - ANALYZE_PRINTF ("protocol = DENON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n", - DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX, - DENON_1_PAUSE_LEN_MIN, DENON_1_PAUSE_LEN_MAX, - DENON_0_PAUSE_LEN_MIN, DENON_0_PAUSE_LEN_MAX); -#endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &denon_param; - } - else + if ( (irmp_pulse_time >= DENON_PULSE_LEN_MIN && irmp_pulse_time <= DENON_PULSE_LEN_MAX) && + ((irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX) || + (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX))) + { // it's DENON +#ifdef ANALYZE + ANALYZE_PRINTF ("protocol = DENON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n", + DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX, + DENON_1_PAUSE_LEN_MIN, DENON_1_PAUSE_LEN_MAX, + DENON_0_PAUSE_LEN_MIN, DENON_0_PAUSE_LEN_MAX); +#endif // ANALYZE + irmp_param_p = (IRMP_PARAMETER *) &denon_param; + } + else #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1 #if IRMP_SUPPORT_THOMSON_PROTOCOL == 1 - if ( (irmp_pulse_time >= THOMSON_PULSE_LEN_MIN && irmp_pulse_time <= THOMSON_PULSE_LEN_MAX) && - ((irmp_pause_time >= THOMSON_1_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_1_PAUSE_LEN_MAX) || - (irmp_pause_time >= THOMSON_0_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_0_PAUSE_LEN_MAX))) - { // it's THOMSON -#ifdef ANALYZE - ANALYZE_PRINTF ("protocol = THOMSON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n", - THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX, - THOMSON_1_PAUSE_LEN_MIN, THOMSON_1_PAUSE_LEN_MAX, - THOMSON_0_PAUSE_LEN_MIN, THOMSON_0_PAUSE_LEN_MAX); -#endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &thomson_param; - } - else + if ( (irmp_pulse_time >= THOMSON_PULSE_LEN_MIN && irmp_pulse_time <= THOMSON_PULSE_LEN_MAX) && + ((irmp_pause_time >= THOMSON_1_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_1_PAUSE_LEN_MAX) || + (irmp_pause_time >= THOMSON_0_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_0_PAUSE_LEN_MAX))) + { // it's THOMSON +#ifdef ANALYZE + ANALYZE_PRINTF ("protocol = THOMSON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d or %3d - %3d\n", + THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX, + THOMSON_1_PAUSE_LEN_MIN, THOMSON_1_PAUSE_LEN_MAX, + THOMSON_0_PAUSE_LEN_MIN, THOMSON_0_PAUSE_LEN_MAX); +#endif // ANALYZE + irmp_param_p = (IRMP_PARAMETER *) &thomson_param; + } + else #endif // IRMP_SUPPORT_THOMSON_PROTOCOL == 1 #if IRMP_SUPPORT_BOSE_PROTOCOL == 1 - if (irmp_pulse_time >= BOSE_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= BOSE_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= BOSE_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= BOSE_START_BIT_PAUSE_LEN_MAX) - { + if (irmp_pulse_time >= BOSE_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= BOSE_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= BOSE_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= BOSE_START_BIT_PAUSE_LEN_MAX) + { #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = BOSE, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - BOSE_START_BIT_PULSE_LEN_MIN, BOSE_START_BIT_PULSE_LEN_MAX, - BOSE_START_BIT_PAUSE_LEN_MIN, BOSE_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = BOSE, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + BOSE_START_BIT_PULSE_LEN_MIN, BOSE_START_BIT_PULSE_LEN_MAX, + BOSE_START_BIT_PAUSE_LEN_MIN, BOSE_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &bose_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &bose_param; + } + else #endif // IRMP_SUPPORT_BOSE_PROTOCOL == 1 #if IRMP_SUPPORT_RC6_PROTOCOL == 1 - if (irmp_pulse_time >= RC6_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RC6_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= RC6_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RC6_START_BIT_PAUSE_LEN_MAX) - { // it's RC6 -#ifdef ANALYZE - ANALYZE_PRINTF ("protocol = RC6, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - RC6_START_BIT_PULSE_LEN_MIN, RC6_START_BIT_PULSE_LEN_MAX, - RC6_START_BIT_PAUSE_LEN_MIN, RC6_START_BIT_PAUSE_LEN_MAX); -#endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &rc6_param; - last_pause = 0; - last_value = 1; - } - else + if (irmp_pulse_time >= RC6_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RC6_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= RC6_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RC6_START_BIT_PAUSE_LEN_MAX) + { // it's RC6 +#ifdef ANALYZE + ANALYZE_PRINTF ("protocol = RC6, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + RC6_START_BIT_PULSE_LEN_MIN, RC6_START_BIT_PULSE_LEN_MAX, + RC6_START_BIT_PAUSE_LEN_MIN, RC6_START_BIT_PAUSE_LEN_MAX); +#endif // ANALYZE + irmp_param_p = (IRMP_PARAMETER *) &rc6_param; + last_pause = 0; + last_value = 1; + } + else #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1 #if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1 - if (irmp_pulse_time >= RECS80EXT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RECS80EXT_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= RECS80EXT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RECS80EXT_START_BIT_PAUSE_LEN_MAX) - { // it's RECS80EXT + if (irmp_pulse_time >= RECS80EXT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RECS80EXT_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= RECS80EXT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RECS80EXT_START_BIT_PAUSE_LEN_MAX) + { // it's RECS80EXT #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = RECS80EXT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - RECS80EXT_START_BIT_PULSE_LEN_MIN, RECS80EXT_START_BIT_PULSE_LEN_MAX, - RECS80EXT_START_BIT_PAUSE_LEN_MIN, RECS80EXT_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = RECS80EXT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + RECS80EXT_START_BIT_PULSE_LEN_MIN, RECS80EXT_START_BIT_PULSE_LEN_MAX, + RECS80EXT_START_BIT_PAUSE_LEN_MIN, RECS80EXT_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &recs80ext_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &recs80ext_param; + } + else #endif // IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1 #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1 - if (irmp_pulse_time >= NUBERT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NUBERT_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= NUBERT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NUBERT_START_BIT_PAUSE_LEN_MAX) - { // it's NUBERT + if (irmp_pulse_time >= NUBERT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NUBERT_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= NUBERT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NUBERT_START_BIT_PAUSE_LEN_MAX) + { // it's NUBERT #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = NUBERT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - NUBERT_START_BIT_PULSE_LEN_MIN, NUBERT_START_BIT_PULSE_LEN_MAX, - NUBERT_START_BIT_PAUSE_LEN_MIN, NUBERT_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = NUBERT, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + NUBERT_START_BIT_PULSE_LEN_MIN, NUBERT_START_BIT_PULSE_LEN_MAX, + NUBERT_START_BIT_PAUSE_LEN_MIN, NUBERT_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &nubert_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &nubert_param; + } + else #endif // IRMP_SUPPORT_NUBERT_PROTOCOL == 1 #if IRMP_SUPPORT_FAN_PROTOCOL == 1 - if (irmp_pulse_time >= FAN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FAN_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= FAN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FAN_START_BIT_PAUSE_LEN_MAX) - { // it's FAN + if (irmp_pulse_time >= FAN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FAN_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= FAN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FAN_START_BIT_PAUSE_LEN_MAX) + { // it's FAN #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = FAN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - FAN_START_BIT_PULSE_LEN_MIN, FAN_START_BIT_PULSE_LEN_MAX, - FAN_START_BIT_PAUSE_LEN_MIN, FAN_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = FAN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + FAN_START_BIT_PULSE_LEN_MIN, FAN_START_BIT_PULSE_LEN_MAX, + FAN_START_BIT_PAUSE_LEN_MIN, FAN_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &fan_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &fan_param; + } + else #endif // IRMP_SUPPORT_FAN_PROTOCOL == 1 #if IRMP_SUPPORT_SPEAKER_PROTOCOL == 1 - if (irmp_pulse_time >= SPEAKER_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SPEAKER_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= SPEAKER_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SPEAKER_START_BIT_PAUSE_LEN_MAX) - { // it's SPEAKER + if (irmp_pulse_time >= SPEAKER_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SPEAKER_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= SPEAKER_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SPEAKER_START_BIT_PAUSE_LEN_MAX) + { // it's SPEAKER #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = SPEAKER, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - SPEAKER_START_BIT_PULSE_LEN_MIN, SPEAKER_START_BIT_PULSE_LEN_MAX, - SPEAKER_START_BIT_PAUSE_LEN_MIN, SPEAKER_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = SPEAKER, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + SPEAKER_START_BIT_PULSE_LEN_MIN, SPEAKER_START_BIT_PULSE_LEN_MAX, + SPEAKER_START_BIT_PAUSE_LEN_MIN, SPEAKER_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &speaker_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &speaker_param; + } + else #endif // IRMP_SUPPORT_SPEAKER_PROTOCOL == 1 #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 - if (irmp_pulse_time >= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN && irmp_pulse_time <= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX && - irmp_pause_time >= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX) - { // it's BANG_OLUFSEN -#ifdef ANALYZE - ANALYZE_PRINTF ("protocol = BANG_OLUFSEN\n"); - ANALYZE_PRINTF ("start bit 1 timings: pulse: %3d - %3d, pause: %3d - %3d\n", - BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX, - BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX); - ANALYZE_PRINTF ("start bit 2 timings: pulse: %3d - %3d, pause: %3d - %3d\n", - BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX, - BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX); - ANALYZE_PRINTF ("start bit 3 timings: pulse: %3d - %3d, pause: %3d - %3d\n", - BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX, - BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX); - ANALYZE_PRINTF ("start bit 4 timings: pulse: %3d - %3d, pause: %3d - %3d\n", - BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX, - BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX); -#endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &bang_olufsen_param; - last_value = 0; - } - else + if (irmp_pulse_time >= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN && irmp_pulse_time <= BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX && + irmp_pause_time >= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX) + { // it's BANG_OLUFSEN +#ifdef ANALYZE + ANALYZE_PRINTF ("protocol = BANG_OLUFSEN\n"); + ANALYZE_PRINTF ("start bit 1 timings: pulse: %3d - %3d, pause: %3d - %3d\n", + BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX, + BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("start bit 2 timings: pulse: %3d - %3d, pause: %3d - %3d\n", + BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX, + BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("start bit 3 timings: pulse: %3d - %3d, pause: %3d - %3d\n", + BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX, + BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("start bit 4 timings: pulse: %3d - %3d, pause: %3d - %3d\n", + BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX, + BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX); +#endif // ANALYZE + irmp_param_p = (IRMP_PARAMETER *) &bang_olufsen_param; + last_value = 0; + } + else #endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 #if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1 - if (irmp_pulse_time >= GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN && irmp_pulse_time <= GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX && - irmp_pause_time >= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN && irmp_pause_time <= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX) - { // it's GRUNDIG -#ifdef ANALYZE - ANALYZE_PRINTF ("protocol = GRUNDIG, pre bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN, GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX, - GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN, GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX); -#endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &grundig_param; - last_pause = irmp_pause_time; - last_value = 1; - } - else + if (irmp_pulse_time >= GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN && irmp_pulse_time <= GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX && + irmp_pause_time >= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN && irmp_pause_time <= GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX) + { // it's GRUNDIG +#ifdef ANALYZE + ANALYZE_PRINTF ("protocol = GRUNDIG, pre bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN, GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX, + GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN, GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX); +#endif // ANALYZE + irmp_param_p = (IRMP_PARAMETER *) &grundig_param; + last_pause = irmp_pause_time; + last_value = 1; + } + else #endif // IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1 #if IRMP_SUPPORT_MERLIN_PROTOCOL == 1 // check MERLIN before RUWIDO! - 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 -#ifdef ANALYZE - 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); -#endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &merlin_param; - last_pause = 0; - last_value = 1; - } - else + 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 +#ifdef ANALYZE + 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); +#endif // ANALYZE + irmp_param_p = (IRMP_PARAMETER *) &merlin_param; + last_pause = 0; + last_value = 1; + } + else #endif // IRMP_SUPPORT_MERLIN_PROTOCOL == 1 #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1 - if (((irmp_pulse_time >= SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX) || - (irmp_pulse_time >= 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX)) && - ((irmp_pause_time >= SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX) || - (irmp_pause_time >= 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX))) - { // it's RUWIDO or SIEMENS -#ifdef ANALYZE - ANALYZE_PRINTF ("protocol = RUWIDO, start bit timings: pulse: %3d - %3d or %3d - %3d, pause: %3d - %3d or %3d - %3d\n", - SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX, - 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX, - SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX, - 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX); -#endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &ruwido_param; - last_pause = irmp_pause_time; - last_value = 1; - } - else + if (((irmp_pulse_time >= SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX) || + (irmp_pulse_time >= 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX)) && + ((irmp_pause_time >= SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX) || + (irmp_pause_time >= 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX))) + { // it's RUWIDO or SIEMENS +#ifdef ANALYZE + ANALYZE_PRINTF ("protocol = RUWIDO, start bit timings: pulse: %3d - %3d or %3d - %3d, pause: %3d - %3d or %3d - %3d\n", + SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX, + 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX, + SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX, + 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX); +#endif // ANALYZE + irmp_param_p = (IRMP_PARAMETER *) &ruwido_param; + last_pause = irmp_pause_time; + last_value = 1; + } + else #endif // IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1 #if IRMP_SUPPORT_FDC_PROTOCOL == 1 - if (irmp_pulse_time >= FDC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= FDC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC_START_BIT_PAUSE_LEN_MAX) - { + if (irmp_pulse_time >= FDC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= FDC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC_START_BIT_PAUSE_LEN_MAX) + { #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = FDC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX, - FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = FDC, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX, + FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &fdc_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &fdc_param; + } + else #endif // IRMP_SUPPORT_FDC_PROTOCOL == 1 #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1 - if (irmp_pulse_time >= RCCAR_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= RCCAR_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_START_BIT_PAUSE_LEN_MAX) - { + if (irmp_pulse_time >= RCCAR_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= RCCAR_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_START_BIT_PAUSE_LEN_MAX) + { #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = RCCAR, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX, - RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = RCCAR, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX, + RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &rccar_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &rccar_param; + } + else #endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1 #if IRMP_SUPPORT_KATHREIN_PROTOCOL == 1 - if (irmp_pulse_time >= KATHREIN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= KATHREIN_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= KATHREIN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_START_BIT_PAUSE_LEN_MAX) - { // it's KATHREIN + if (irmp_pulse_time >= KATHREIN_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= KATHREIN_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= KATHREIN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_START_BIT_PAUSE_LEN_MAX) + { // it's KATHREIN #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = KATHREIN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - KATHREIN_START_BIT_PULSE_LEN_MIN, KATHREIN_START_BIT_PULSE_LEN_MAX, - KATHREIN_START_BIT_PAUSE_LEN_MIN, KATHREIN_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = KATHREIN, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + KATHREIN_START_BIT_PULSE_LEN_MIN, KATHREIN_START_BIT_PULSE_LEN_MAX, + KATHREIN_START_BIT_PAUSE_LEN_MIN, KATHREIN_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &kathrein_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &kathrein_param; + } + else #endif // IRMP_SUPPORT_KATHREIN_PROTOCOL == 1 #if IRMP_SUPPORT_NETBOX_PROTOCOL == 1 - if (irmp_pulse_time >= NETBOX_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NETBOX_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= NETBOX_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NETBOX_START_BIT_PAUSE_LEN_MAX) - { // it's NETBOX + if (irmp_pulse_time >= NETBOX_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NETBOX_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= NETBOX_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NETBOX_START_BIT_PAUSE_LEN_MAX) + { // it's NETBOX #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = NETBOX, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - NETBOX_START_BIT_PULSE_LEN_MIN, NETBOX_START_BIT_PULSE_LEN_MAX, - NETBOX_START_BIT_PAUSE_LEN_MIN, NETBOX_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = NETBOX, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + NETBOX_START_BIT_PULSE_LEN_MIN, NETBOX_START_BIT_PULSE_LEN_MAX, + NETBOX_START_BIT_PAUSE_LEN_MIN, NETBOX_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &netbox_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &netbox_param; + } + else #endif // IRMP_SUPPORT_NETBOX_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) - { + 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) + { #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = LEGO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - LEGO_START_BIT_PULSE_LEN_MIN, LEGO_START_BIT_PULSE_LEN_MAX, - LEGO_START_BIT_PAUSE_LEN_MIN, LEGO_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = LEGO, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + LEGO_START_BIT_PULSE_LEN_MIN, LEGO_START_BIT_PULSE_LEN_MAX, + LEGO_START_BIT_PAUSE_LEN_MIN, LEGO_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &lego_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &lego_param; + } + else #endif // IRMP_SUPPORT_LEGO_PROTOCOL == 1 #if IRMP_SUPPORT_A1TVBOX_PROTOCOL == 1 - if (irmp_pulse_time >= A1TVBOX_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= A1TVBOX_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= A1TVBOX_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= A1TVBOX_START_BIT_PAUSE_LEN_MAX) - { // it's A1TVBOX -#ifdef ANALYZE - ANALYZE_PRINTF ("protocol = A1TVBOX, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - A1TVBOX_START_BIT_PULSE_LEN_MIN, A1TVBOX_START_BIT_PULSE_LEN_MAX, - A1TVBOX_START_BIT_PAUSE_LEN_MIN, A1TVBOX_START_BIT_PAUSE_LEN_MAX); -#endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &a1tvbox_param; - last_pause = 0; - last_value = 1; - } - else + if (irmp_pulse_time >= A1TVBOX_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= A1TVBOX_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= A1TVBOX_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= A1TVBOX_START_BIT_PAUSE_LEN_MAX) + { // it's A1TVBOX +#ifdef ANALYZE + ANALYZE_PRINTF ("protocol = A1TVBOX, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + A1TVBOX_START_BIT_PULSE_LEN_MIN, A1TVBOX_START_BIT_PULSE_LEN_MAX, + A1TVBOX_START_BIT_PAUSE_LEN_MIN, A1TVBOX_START_BIT_PAUSE_LEN_MAX); +#endif // ANALYZE + irmp_param_p = (IRMP_PARAMETER *) &a1tvbox_param; + last_pause = 0; + last_value = 1; + } + else #endif // IRMP_SUPPORT_A1TVBOX_PROTOCOL == 1 #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1 - if (irmp_pulse_time >= ORTEK_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= ORTEK_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= ORTEK_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= ORTEK_START_BIT_PAUSE_LEN_MAX) - { // it's ORTEK (Hama) -#ifdef ANALYZE - ANALYZE_PRINTF ("protocol = ORTEK, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - ORTEK_START_BIT_PULSE_LEN_MIN, ORTEK_START_BIT_PULSE_LEN_MAX, - ORTEK_START_BIT_PAUSE_LEN_MIN, ORTEK_START_BIT_PAUSE_LEN_MAX); -#endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &ortek_param; - last_pause = 0; - last_value = 1; - parity = 0; - } - else + if (irmp_pulse_time >= ORTEK_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= ORTEK_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= ORTEK_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= ORTEK_START_BIT_PAUSE_LEN_MAX) + { // it's ORTEK (Hama) +#ifdef ANALYZE + ANALYZE_PRINTF ("protocol = ORTEK, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + ORTEK_START_BIT_PULSE_LEN_MIN, ORTEK_START_BIT_PULSE_LEN_MAX, + ORTEK_START_BIT_PAUSE_LEN_MIN, ORTEK_START_BIT_PAUSE_LEN_MAX); +#endif // ANALYZE + irmp_param_p = (IRMP_PARAMETER *) &ortek_param; + last_pause = 0; + last_value = 1; + parity = 0; + } + else #endif // IRMP_SUPPORT_ORTEK_PROTOCOL == 1 #if IRMP_SUPPORT_RCMM_PROTOCOL == 1 - if (irmp_pulse_time >= RCMM32_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCMM32_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= RCMM32_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_START_BIT_PAUSE_LEN_MAX) - { // it's RCMM + if (irmp_pulse_time >= RCMM32_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RCMM32_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= RCMM32_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_START_BIT_PAUSE_LEN_MAX) + { // it's RCMM #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = RCMM, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - RCMM32_START_BIT_PULSE_LEN_MIN, RCMM32_START_BIT_PULSE_LEN_MAX, - RCMM32_START_BIT_PAUSE_LEN_MIN, RCMM32_START_BIT_PAUSE_LEN_MAX); + ANALYZE_PRINTF ("protocol = RCMM, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + RCMM32_START_BIT_PULSE_LEN_MIN, RCMM32_START_BIT_PULSE_LEN_MAX, + RCMM32_START_BIT_PAUSE_LEN_MIN, RCMM32_START_BIT_PAUSE_LEN_MAX); #endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &rcmm_param; - } - else + irmp_param_p = (IRMP_PARAMETER *) &rcmm_param; + } + else #endif // IRMP_SUPPORT_RCMM_PROTOCOL == 1 - { + { #ifdef ANALYZE - ANALYZE_PRINTF ("protocol = UNKNOWN\n"); + ANALYZE_PRINTF ("protocol = UNKNOWN\n"); #endif // ANALYZE - irmp_start_bit_detected = 0; // wait for another start bit... - } + irmp_start_bit_detected = 0; // wait for another start bit... + } - if (irmp_start_bit_detected) - { - memcpy_P (&irmp_param, irmp_param_p, sizeof (IRMP_PARAMETER)); + if (irmp_start_bit_detected) + { + memcpy_P (&irmp_param, irmp_param_p, sizeof (IRMP_PARAMETER)); - if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) - { + if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) + { #ifdef ANALYZE - ANALYZE_PRINTF ("pulse_1: %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max); - ANALYZE_PRINTF ("pause_1: %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max); + ANALYZE_PRINTF ("pulse_1: %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max); + ANALYZE_PRINTF ("pause_1: %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max); #endif // ANALYZE - } - else - { + } + else + { #ifdef ANALYZE - ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max, - 2 * irmp_param.pulse_1_len_min, 2 * irmp_param.pulse_1_len_max); - ANALYZE_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max, - 2 * irmp_param.pause_1_len_min, 2 * irmp_param.pause_1_len_max); + ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max, + 2 * irmp_param.pulse_1_len_min, 2 * irmp_param.pulse_1_len_max); + ANALYZE_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max, + 2 * irmp_param.pause_1_len_min, 2 * irmp_param.pause_1_len_max); #endif // ANALYZE - } + } #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) - if (irmp_param2.protocol) - { + if (irmp_param2.protocol) + { #ifdef ANALYZE - ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", irmp_param2.pulse_0_len_min, irmp_param2.pulse_0_len_max); - ANALYZE_PRINTF ("pause_0: %3d - %3d\n", irmp_param2.pause_0_len_min, irmp_param2.pause_0_len_max); - ANALYZE_PRINTF ("pulse_1: %3d - %3d\n", irmp_param2.pulse_1_len_min, irmp_param2.pulse_1_len_max); - ANALYZE_PRINTF ("pause_1: %3d - %3d\n", irmp_param2.pause_1_len_min, irmp_param2.pause_1_len_max); + ANALYZE_PRINTF ("pulse_0: %3d - %3d\n", irmp_param2.pulse_0_len_min, irmp_param2.pulse_0_len_max); + ANALYZE_PRINTF ("pause_0: %3d - %3d\n", irmp_param2.pause_0_len_min, irmp_param2.pause_0_len_max); + ANALYZE_PRINTF ("pulse_1: %3d - %3d\n", irmp_param2.pulse_1_len_min, irmp_param2.pulse_1_len_max); + ANALYZE_PRINTF ("pause_1: %3d - %3d\n", irmp_param2.pause_1_len_min, irmp_param2.pause_1_len_max); #endif // ANALYZE - } + } #endif #if IRMP_SUPPORT_RC6_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_RC6_PROTOCOL) - { + if (irmp_param.protocol == IRMP_RC6_PROTOCOL) + { #ifdef ANALYZE - ANALYZE_PRINTF ("pulse_toggle: %3d - %3d\n", RC6_TOGGLE_BIT_LEN_MIN, RC6_TOGGLE_BIT_LEN_MAX); + ANALYZE_PRINTF ("pulse_toggle: %3d - %3d\n", RC6_TOGGLE_BIT_LEN_MIN, RC6_TOGGLE_BIT_LEN_MAX); #endif // ANALYZE - } + } #endif - if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) - { + if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) + { #ifdef ANALYZE - 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); + 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); #endif // ANALYZE - } - else - { + } + else + { #ifdef ANALYZE - 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); + 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); #endif // ANALYZE - } + } #ifdef ANALYZE #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL) - { - ANALYZE_PRINTF ("pulse_r: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max); - ANALYZE_PRINTF ("pause_r: %3d - %3d\n", BANG_OLUFSEN_R_PAUSE_LEN_MIN, BANG_OLUFSEN_R_PAUSE_LEN_MAX); - } + if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL) + { + ANALYZE_PRINTF ("pulse_r: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max); + ANALYZE_PRINTF ("pause_r: %3d - %3d\n", BANG_OLUFSEN_R_PAUSE_LEN_MIN, BANG_OLUFSEN_R_PAUSE_LEN_MAX); + } #endif - ANALYZE_PRINTF ("command_offset: %2d\n", irmp_param.command_offset); - ANALYZE_PRINTF ("command_len: %3d\n", irmp_param.command_end - irmp_param.command_offset); - ANALYZE_PRINTF ("complete_len: %3d\n", irmp_param.complete_len); - ANALYZE_PRINTF ("stop_bit: %3d\n", irmp_param.stop_bit); + ANALYZE_PRINTF ("command_offset: %2d\n", irmp_param.command_offset); + ANALYZE_PRINTF ("command_len: %3d\n", irmp_param.command_end - irmp_param.command_offset); + ANALYZE_PRINTF ("complete_len: %3d\n", irmp_param.complete_len); + ANALYZE_PRINTF ("stop_bit: %3d\n", irmp_param.stop_bit); #endif // ANALYZE - } + } - irmp_bit = 0; + irmp_bit = 0; #if IRMP_SUPPORT_MANCHESTER == 1 - if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) && - irmp_param.protocol != IRMP_RUWIDO_PROTOCOL && // Manchester, but not RUWIDO - irmp_param.protocol != IRMP_RC6_PROTOCOL) // Manchester, but not RC6 - { - if (irmp_pause_time > irmp_param.pulse_1_len_max && irmp_pause_time <= 2 * irmp_param.pulse_1_len_max) - { -#ifdef ANALYZE - ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time); - ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1'); - ANALYZE_NEWLINE (); -#endif // ANALYZE - irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1); - } - else if (! last_value) // && irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max) - { -#ifdef ANALYZE - ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time); - ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0'); - ANALYZE_NEWLINE (); -#endif // ANALYZE - irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0); - } - } - else + if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) && + irmp_param.protocol != IRMP_RUWIDO_PROTOCOL && // Manchester, but not RUWIDO + irmp_param.protocol != IRMP_RC6_PROTOCOL) // Manchester, but not RC6 + { + if (irmp_pause_time > irmp_param.pulse_1_len_max && irmp_pause_time <= 2 * irmp_param.pulse_1_len_max) + { +#ifdef ANALYZE + ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time); + ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1'); + ANALYZE_NEWLINE (); +#endif // ANALYZE + irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1); + } + else if (! last_value) // && irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max) + { +#ifdef ANALYZE + ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time); + ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0'); + ANALYZE_NEWLINE (); +#endif // ANALYZE + irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0); + } + } + else #endif // IRMP_SUPPORT_MANCHESTER == 1 #if IRMP_SUPPORT_SERIAL == 1 - if (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) - { - ; // do nothing - } - else + if (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) + { + ; // do nothing + } + else #endif // IRMP_SUPPORT_SERIAL == 1 #if IRMP_SUPPORT_DENON_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_DENON_PROTOCOL) - { + if (irmp_param.protocol == IRMP_DENON_PROTOCOL) + { #ifdef ANALYZE - ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time); + ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time); #endif // ANALYZE - if (irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX) - { // pause timings correct for "1"? + if (irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX) + { // pause timings correct for "1"? #ifdef ANALYZE - ANALYZE_PUTCHAR ('1'); // yes, store 1 - ANALYZE_NEWLINE (); + ANALYZE_PUTCHAR ('1'); // yes, store 1 + ANALYZE_NEWLINE (); #endif // ANALYZE - irmp_store_bit (1); - } - else // if (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX) - { // pause timings correct for "0"? + irmp_store_bit (1); + } + else // if (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX) + { // pause timings correct for "0"? #ifdef ANALYZE - ANALYZE_PUTCHAR ('0'); // yes, store 0 - ANALYZE_NEWLINE (); + ANALYZE_PUTCHAR ('0'); // yes, store 0 + ANALYZE_NEWLINE (); #endif // ANALYZE - irmp_store_bit (0); - } - } - else + irmp_store_bit (0); + } + } + else #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1 #if IRMP_SUPPORT_THOMSON_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_THOMSON_PROTOCOL) - { + if (irmp_param.protocol == IRMP_THOMSON_PROTOCOL) + { #ifdef ANALYZE - ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time); + ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time); #endif // ANALYZE - if (irmp_pause_time >= THOMSON_1_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_1_PAUSE_LEN_MAX) - { // pause timings correct for "1"? + if (irmp_pause_time >= THOMSON_1_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_1_PAUSE_LEN_MAX) + { // pause timings correct for "1"? #ifdef ANALYZE - ANALYZE_PUTCHAR ('1'); // yes, store 1 - ANALYZE_NEWLINE (); + ANALYZE_PUTCHAR ('1'); // yes, store 1 + ANALYZE_NEWLINE (); #endif // ANALYZE - irmp_store_bit (1); - } - else // if (irmp_pause_time >= THOMSON_0_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_0_PAUSE_LEN_MAX) - { // pause timings correct for "0"? + irmp_store_bit (1); + } + else // if (irmp_pause_time >= THOMSON_0_PAUSE_LEN_MIN && irmp_pause_time <= THOMSON_0_PAUSE_LEN_MAX) + { // pause timings correct for "0"? #ifdef ANALYZE - ANALYZE_PUTCHAR ('0'); // yes, store 0 - ANALYZE_NEWLINE (); + ANALYZE_PUTCHAR ('0'); // yes, store 0 + ANALYZE_NEWLINE (); #endif // ANALYZE - irmp_store_bit (0); - } - } - else + irmp_store_bit (0); + } + } + else #endif // IRMP_SUPPORT_THOMSON_PROTOCOL == 1 - { - ; // else do nothing - } - - irmp_pulse_time = 1; // set counter to 1, not 0 - irmp_pause_time = 0; - wait_for_start_space = 0; - } - } - else if (wait_for_space) // the data section.... - { // counting the time of darkness.... - uint_fast8_t got_light = FALSE; - - if (irmp_input) // still dark? - { // yes... - if (irmp_bit == irmp_param.complete_len && irmp_param.stop_bit == 1) - { - if ( + { + ; // else do nothing + } + + irmp_pulse_time = 1; // set counter to 1, not 0 + irmp_pause_time = 0; + wait_for_start_space = 0; + } + } + else if (wait_for_space) // the data section.... + { // counting the time of darkness.... + uint_fast8_t got_light = FALSE; + + if (irmp_input) // still dark? + { // yes... + if (irmp_bit == irmp_param.complete_len && irmp_param.stop_bit == 1) + { + if ( #if IRMP_SUPPORT_MANCHESTER == 1 - (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) || + (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) || #endif #if IRMP_SUPPORT_SERIAL == 1 - (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) || + (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) || #endif - (irmp_pulse_time >= irmp_param.pulse_0_len_min && irmp_pulse_time <= irmp_param.pulse_0_len_max)) - { -#ifdef ANALYZE - if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) - { - ANALYZE_PRINTF ("stop bit detected\n"); - } -#endif // ANALYZE - irmp_param.stop_bit = 0; - } - else - { -#ifdef ANALYZE - 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); -#endif // ANALYZE - irmp_start_bit_detected = 0; // wait for another start bit... - irmp_pulse_time = 0; - irmp_pause_time = 0; - } - } - else - { - irmp_pause_time++; // increment counter + (irmp_pulse_time >= irmp_param.pulse_0_len_min && irmp_pulse_time <= irmp_param.pulse_0_len_max)) + { +#ifdef ANALYZE + if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) + { + ANALYZE_PRINTF ("stop bit detected\n"); + } +#endif // ANALYZE + irmp_param.stop_bit = 0; + } + else + { +#ifdef ANALYZE + 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); +#endif // ANALYZE + irmp_start_bit_detected = 0; // wait for another start bit... + irmp_pulse_time = 0; + irmp_pause_time = 0; + } + } + else + { + irmp_pause_time++; // increment counter #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && // Sony has a variable number of bits: - irmp_pause_time > SIRCS_PAUSE_LEN_MAX && // minimum is 12 - irmp_bit >= 12 - 1) // pause too long? - { // yes, break and close this frame - irmp_param.complete_len = irmp_bit + 1; // set new complete length - got_light = TRUE; // this is a lie, but helps (generates stop bit) - irmp_tmp_address |= (irmp_bit - SIRCS_MINIMUM_DATA_LEN + 1) << 8; // new: store number of additional bits in upper byte of address! - irmp_param.command_end = irmp_param.command_offset + irmp_bit + 1; // correct command length - irmp_pause_time = SIRCS_PAUSE_LEN_MAX - 1; // correct pause length - } - else + if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && // Sony has a variable number of bits: + irmp_pause_time > SIRCS_PAUSE_LEN_MAX && // minimum is 12 + irmp_bit >= 12 - 1) // pause too long? + { // yes, break and close this frame + irmp_param.complete_len = irmp_bit + 1; // set new complete length + got_light = TRUE; // this is a lie, but helps (generates stop bit) + irmp_tmp_address |= (irmp_bit - SIRCS_MINIMUM_DATA_LEN + 1) << 8; // new: store number of additional bits in upper byte of address! + irmp_param.command_end = irmp_param.command_offset + irmp_bit + 1; // correct command length + irmp_pause_time = SIRCS_PAUSE_LEN_MAX - 1; // correct pause length + } + else #endif #if IRMP_SUPPORT_FAN_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_FAN_PROTOCOL && // FAN has no stop bit. - irmp_bit >= FAN_COMPLETE_DATA_LEN - 1) // last bit in frame - { // yes, break and close this frame - if (irmp_pulse_time <= FAN_0_PULSE_LEN_MAX && irmp_pause_time >= FAN_0_PAUSE_LEN_MIN) - { + if (irmp_param.protocol == IRMP_FAN_PROTOCOL && // FAN has no stop bit. + irmp_bit >= FAN_COMPLETE_DATA_LEN - 1) // last bit in frame + { // yes, break and close this frame + if (irmp_pulse_time <= FAN_0_PULSE_LEN_MAX && irmp_pause_time >= FAN_0_PAUSE_LEN_MIN) + { #ifdef ANALYZE - ANALYZE_PRINTF ("Generating virtual stop bit\n"); + ANALYZE_PRINTF ("Generating virtual stop bit\n"); #endif // ANALYZE - got_light = TRUE; // this is a lie, but helps (generates stop bit) - } - else if (irmp_pulse_time >= FAN_1_PULSE_LEN_MIN && irmp_pause_time >= FAN_1_PAUSE_LEN_MIN) - { + got_light = TRUE; // this is a lie, but helps (generates stop bit) + } + else if (irmp_pulse_time >= FAN_1_PULSE_LEN_MIN && irmp_pause_time >= FAN_1_PAUSE_LEN_MIN) + { #ifdef ANALYZE - ANALYZE_PRINTF ("Generating virtual stop bit\n"); + ANALYZE_PRINTF ("Generating virtual stop bit\n"); #endif // ANALYZE - got_light = TRUE; // this is a lie, but helps (generates stop bit) - } - } - else + got_light = TRUE; // this is a lie, but helps (generates stop bit) + } + } + else #endif #if IRMP_SUPPORT_SERIAL == 1 - // NETBOX generates no stop bit, here is the timeout condition: - if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) && irmp_param.protocol == IRMP_NETBOX_PROTOCOL && - irmp_pause_time >= NETBOX_PULSE_LEN * (NETBOX_COMPLETE_DATA_LEN - irmp_bit)) - { - got_light = TRUE; // this is a lie, but helps (generates stop bit) - } - else + // NETBOX generates no stop bit, here is the timeout condition: + if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) && irmp_param.protocol == IRMP_NETBOX_PROTOCOL && + irmp_pause_time >= NETBOX_PULSE_LEN * (NETBOX_COMPLETE_DATA_LEN - irmp_bit)) + { + got_light = TRUE; // this is a lie, but helps (generates stop bit) + } + else #endif #if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && !irmp_param.stop_bit) - { - if (irmp_pause_time > IR60_TIMEOUT_LEN && (irmp_bit == 5 || irmp_bit == 6)) - { -#ifdef ANALYZE - ANALYZE_PRINTF ("Switching to IR60 protocol\n"); -#endif // ANALYZE - got_light = TRUE; // this is a lie, but generates a stop bit ;-) - irmp_param.stop_bit = TRUE; // set flag - - irmp_param.protocol = IRMP_IR60_PROTOCOL; // change protocol - irmp_param.complete_len = IR60_COMPLETE_DATA_LEN; // correct complete len - irmp_param.address_offset = IR60_ADDRESS_OFFSET; - irmp_param.address_end = IR60_ADDRESS_OFFSET + IR60_ADDRESS_LEN; - irmp_param.command_offset = IR60_COMMAND_OFFSET; - irmp_param.command_end = IR60_COMMAND_OFFSET + IR60_COMMAND_LEN; - - irmp_tmp_command <<= 1; - irmp_tmp_command |= first_bit; - } - else if (irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN - 2) - { // special manchester decoder - irmp_param.complete_len = GRUNDIG_COMPLETE_DATA_LEN; // correct complete len - got_light = TRUE; // this is a lie, but generates a stop bit ;-) - irmp_param.stop_bit = TRUE; // set flag - } - else if (irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN) - { -#ifdef ANALYZE - ANALYZE_PRINTF ("Switching to NOKIA protocol, irmp_bit = %d\n", irmp_bit); -#endif // ANALYZE - irmp_param.protocol = IRMP_NOKIA_PROTOCOL; // change protocol - irmp_param.address_offset = NOKIA_ADDRESS_OFFSET; - irmp_param.address_end = NOKIA_ADDRESS_OFFSET + NOKIA_ADDRESS_LEN; - irmp_param.command_offset = NOKIA_COMMAND_OFFSET; - irmp_param.command_end = NOKIA_COMMAND_OFFSET + NOKIA_COMMAND_LEN; - - if (irmp_tmp_command & 0x300) - { - irmp_tmp_address = (irmp_tmp_command >> 8); - irmp_tmp_command &= 0xFF; - } - } - } - else + if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && !irmp_param.stop_bit) + { + if (irmp_pause_time > IR60_TIMEOUT_LEN && (irmp_bit == 5 || irmp_bit == 6)) + { +#ifdef ANALYZE + ANALYZE_PRINTF ("Switching to IR60 protocol\n"); +#endif // ANALYZE + got_light = TRUE; // this is a lie, but generates a stop bit ;-) + irmp_param.stop_bit = TRUE; // set flag + + irmp_param.protocol = IRMP_IR60_PROTOCOL; // change protocol + irmp_param.complete_len = IR60_COMPLETE_DATA_LEN; // correct complete len + irmp_param.address_offset = IR60_ADDRESS_OFFSET; + irmp_param.address_end = IR60_ADDRESS_OFFSET + IR60_ADDRESS_LEN; + irmp_param.command_offset = IR60_COMMAND_OFFSET; + irmp_param.command_end = IR60_COMMAND_OFFSET + IR60_COMMAND_LEN; + + irmp_tmp_command <<= 1; + irmp_tmp_command |= first_bit; + } + else if (irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN - 2) + { // special manchester decoder + irmp_param.complete_len = GRUNDIG_COMPLETE_DATA_LEN; // correct complete len + got_light = TRUE; // this is a lie, but generates a stop bit ;-) + irmp_param.stop_bit = TRUE; // set flag + } + else if (irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN) + { +#ifdef ANALYZE + ANALYZE_PRINTF ("Switching to NOKIA protocol, irmp_bit = %d\n", irmp_bit); +#endif // ANALYZE + irmp_param.protocol = IRMP_NOKIA_PROTOCOL; // change protocol + irmp_param.address_offset = NOKIA_ADDRESS_OFFSET; + irmp_param.address_end = NOKIA_ADDRESS_OFFSET + NOKIA_ADDRESS_LEN; + irmp_param.command_offset = NOKIA_COMMAND_OFFSET; + irmp_param.command_end = NOKIA_COMMAND_OFFSET + NOKIA_COMMAND_LEN; + + if (irmp_tmp_command & 0x300) + { + irmp_tmp_address = (irmp_tmp_command >> 8); + irmp_tmp_command &= 0xFF; + } + } + } + else #endif #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_RUWIDO_PROTOCOL && !irmp_param.stop_bit) - { - if (irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= RUWIDO_COMPLETE_DATA_LEN - 2) - { // special manchester decoder - irmp_param.complete_len = RUWIDO_COMPLETE_DATA_LEN; // correct complete len - got_light = TRUE; // this is a lie, but generates a stop bit ;-) - irmp_param.stop_bit = TRUE; // set flag - } - else if (irmp_bit >= RUWIDO_COMPLETE_DATA_LEN) - { -#ifdef ANALYZE - ANALYZE_PRINTF ("Switching to SIEMENS protocol\n"); -#endif // ANALYZE - irmp_param.protocol = IRMP_SIEMENS_PROTOCOL; // change protocol - irmp_param.address_offset = SIEMENS_ADDRESS_OFFSET; - irmp_param.address_end = SIEMENS_ADDRESS_OFFSET + SIEMENS_ADDRESS_LEN; - irmp_param.command_offset = SIEMENS_COMMAND_OFFSET; - irmp_param.command_end = SIEMENS_COMMAND_OFFSET + SIEMENS_COMMAND_LEN; - - // 76543210 - // RUWIDO: AAAAAAAAACCCCCCCp - // SIEMENS: AAAAAAAAAAACCCCCCCCCCp - irmp_tmp_address <<= 2; - irmp_tmp_address |= (irmp_tmp_command >> 6); - irmp_tmp_command &= 0x003F; + if (irmp_param.protocol == IRMP_RUWIDO_PROTOCOL && !irmp_param.stop_bit) + { + if (irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= RUWIDO_COMPLETE_DATA_LEN - 2) + { // special manchester decoder + irmp_param.complete_len = RUWIDO_COMPLETE_DATA_LEN; // correct complete len + got_light = TRUE; // this is a lie, but generates a stop bit ;-) + irmp_param.stop_bit = TRUE; // set flag + } + else if (irmp_bit >= RUWIDO_COMPLETE_DATA_LEN) + { +#ifdef ANALYZE + ANALYZE_PRINTF ("Switching to SIEMENS protocol\n"); +#endif // ANALYZE + irmp_param.protocol = IRMP_SIEMENS_PROTOCOL; // change protocol + irmp_param.address_offset = SIEMENS_ADDRESS_OFFSET; + irmp_param.address_end = SIEMENS_ADDRESS_OFFSET + SIEMENS_ADDRESS_LEN; + irmp_param.command_offset = SIEMENS_COMMAND_OFFSET; + irmp_param.command_end = SIEMENS_COMMAND_OFFSET + SIEMENS_COMMAND_LEN; + + // 76543210 + // RUWIDO: AAAAAAAAACCCCCCCp + // SIEMENS: AAAAAAAAAAACCCCCCCCCCp + irmp_tmp_address <<= 2; + irmp_tmp_address |= (irmp_tmp_command >> 6); + irmp_tmp_command &= 0x003F; // irmp_tmp_command <<= 4; - irmp_tmp_command |= last_value; - } - } - else + irmp_tmp_command |= last_value; + } + } + else #endif #if IRMP_SUPPORT_ROOMBA_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_ROOMBA_PROTOCOL && // Roomba has no stop bit - irmp_bit >= ROOMBA_COMPLETE_DATA_LEN - 1) // it's the last data bit... - { // break and close this frame - if (irmp_pulse_time >= ROOMBA_1_PULSE_LEN_MIN && irmp_pulse_time <= ROOMBA_1_PULSE_LEN_MAX) - { - irmp_pause_time = ROOMBA_1_PAUSE_LEN_EXACT; - } - else if (irmp_pulse_time >= ROOMBA_0_PULSE_LEN_MIN && irmp_pulse_time <= ROOMBA_0_PULSE_LEN_MAX) - { - irmp_pause_time = ROOMBA_0_PAUSE_LEN; - } - - got_light = TRUE; // this is a lie, but helps (generates stop bit) - } - else + if (irmp_param.protocol == IRMP_ROOMBA_PROTOCOL && // Roomba has no stop bit + irmp_bit >= ROOMBA_COMPLETE_DATA_LEN - 1) // it's the last data bit... + { // break and close this frame + if (irmp_pulse_time >= ROOMBA_1_PULSE_LEN_MIN && irmp_pulse_time <= ROOMBA_1_PULSE_LEN_MAX) + { + irmp_pause_time = ROOMBA_1_PAUSE_LEN_EXACT; + } + else if (irmp_pulse_time >= ROOMBA_0_PULSE_LEN_MIN && irmp_pulse_time <= ROOMBA_0_PULSE_LEN_MAX) + { + irmp_pause_time = ROOMBA_0_PAUSE_LEN; + } + + got_light = TRUE; // this is a lie, but helps (generates stop bit) + } + else #endif #if IRMP_SUPPORT_MANCHESTER == 1 - if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) && - irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= irmp_param.complete_len - 2 && !irmp_param.stop_bit) - { // special manchester decoder - got_light = TRUE; // this is a lie, but generates a stop bit ;-) - irmp_param.stop_bit = TRUE; // set flag - } - else + if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) && + irmp_pause_time >= 2 * irmp_param.pause_1_len_max && irmp_bit >= irmp_param.complete_len - 2 && !irmp_param.stop_bit) + { // special manchester decoder + got_light = TRUE; // this is a lie, but generates a stop bit ;-) + irmp_param.stop_bit = TRUE; // set flag + } + else #endif // IRMP_SUPPORT_MANCHESTER == 1 - if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout? - { // yes... - if (irmp_bit == irmp_param.complete_len - 1 && irmp_param.stop_bit == 0) - { - irmp_bit++; - } + if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout? + { // yes... + if (irmp_bit == irmp_param.complete_len - 1 && irmp_param.stop_bit == 0) + { + irmp_bit++; + } #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 - { -#ifdef ANALYZE - ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit); -#endif // ANALYZE - 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 - irmp_tmp_command = (irmp_tmp_address >> 4); // set command: upper 12 bits are command bits - irmp_tmp_address = irmp_tmp_address & 0x000F; // lower 4 bits are address bits - irmp_start_bit_detected = 1; // tricky: don't wait for another start bit... - } + else if (irmp_param.protocol == IRMP_NEC_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17)) // it was a JVC stop bit + { +#ifdef ANALYZE + ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit); +#endif // ANALYZE + 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 + irmp_tmp_command = (irmp_tmp_address >> 4); // set command: upper 12 bits are command bits + irmp_tmp_address = irmp_tmp_address & 0x000F; // lower 4 bits are address bits + irmp_start_bit_detected = 1; // tricky: don't wait for another start bit... + } #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1 #if IRMP_SUPPORT_LGAIR_PROTOCOL == 1 - else if (irmp_param.protocol == IRMP_NEC_PROTOCOL && (irmp_bit == 28 || irmp_bit == 29)) // it was a LGAIR stop bit - { -#ifdef ANALYZE - ANALYZE_PRINTF ("Switching to LGAIR protocol, irmp_bit = %d\n", irmp_bit); -#endif // ANALYZE - irmp_param.stop_bit = TRUE; // set flag - irmp_param.protocol = IRMP_LGAIR_PROTOCOL; // switch protocol - irmp_param.complete_len = irmp_bit; // patch length: 16 or 17 - irmp_tmp_command = irmp_lgair_command; // set command: upper 8 bits are command bits - irmp_tmp_address = irmp_lgair_address; // lower 4 bits are address bits - irmp_start_bit_detected = 1; // tricky: don't wait for another start bit... - } + else if (irmp_param.protocol == IRMP_NEC_PROTOCOL && (irmp_bit == 28 || irmp_bit == 29)) // it was a LGAIR stop bit + { +#ifdef ANALYZE + ANALYZE_PRINTF ("Switching to LGAIR protocol, irmp_bit = %d\n", irmp_bit); +#endif // ANALYZE + irmp_param.stop_bit = TRUE; // set flag + irmp_param.protocol = IRMP_LGAIR_PROTOCOL; // switch protocol + irmp_param.complete_len = irmp_bit; // patch length: 16 or 17 + irmp_tmp_command = irmp_lgair_command; // set command: upper 8 bits are command bits + irmp_tmp_address = irmp_lgair_address; // lower 4 bits are address bits + irmp_start_bit_detected = 1; // tricky: don't wait for another start bit... + } #endif // IRMP_SUPPORT_LGAIR_PROTOCOL == 1 #if IRMP_SUPPORT_NEC42_PROTOCOL == 1 #if IRMP_SUPPORT_NEC_PROTOCOL == 1 - else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit == 32) // it was a NEC stop bit - { + else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit == 32) // it was a NEC stop bit + { #ifdef ANALYZE - ANALYZE_PRINTF ("Switching to NEC protocol\n"); + ANALYZE_PRINTF ("Switching to NEC protocol\n"); #endif // ANALYZE - irmp_param.stop_bit = TRUE; // set flag - irmp_param.protocol = IRMP_NEC_PROTOCOL; // switch protocol - irmp_param.complete_len = irmp_bit; // patch length: 16 or 17 + irmp_param.stop_bit = TRUE; // set flag + irmp_param.protocol = IRMP_NEC_PROTOCOL; // switch protocol + irmp_param.complete_len = irmp_bit; // patch length: 16 or 17 - // 0123456789ABC0123456789ABC0123456701234567 - // NEC42: AAAAAAAAAAAAAaaaaaaaaaaaaaCCCCCCCCcccccccc - // NEC: AAAAAAAAaaaaaaaaCCCCCCCCcccccccc - irmp_tmp_address |= (irmp_tmp_address2 & 0x0007) << 13; // fm 2012-02-13: 12 -> 13 - irmp_tmp_command = (irmp_tmp_address2 >> 3) | (irmp_tmp_command << 10); - } + // 0123456789ABC0123456789ABC0123456701234567 + // NEC42: AAAAAAAAAAAAAaaaaaaaaaaaaaCCCCCCCCcccccccc + // NEC: AAAAAAAAaaaaaaaaCCCCCCCCcccccccc + irmp_tmp_address |= (irmp_tmp_address2 & 0x0007) << 13; // fm 2012-02-13: 12 -> 13 + irmp_tmp_command = (irmp_tmp_address2 >> 3) | (irmp_tmp_command << 10); + } #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1 #if IRMP_SUPPORT_LGAIR_PROTOCOL == 1 - else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit == 28) // it was a NEC stop bit - { + else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit == 28) // it was a NEC stop bit + { #ifdef ANALYZE - ANALYZE_PRINTF ("Switching to LGAIR protocol\n"); + ANALYZE_PRINTF ("Switching to LGAIR protocol\n"); #endif // ANALYZE - irmp_param.stop_bit = TRUE; // set flag - irmp_param.protocol = IRMP_LGAIR_PROTOCOL; // switch protocol - irmp_param.complete_len = irmp_bit; // patch length: 16 or 17 - irmp_tmp_address = irmp_lgair_address; - irmp_tmp_command = irmp_lgair_command; - } + irmp_param.stop_bit = TRUE; // set flag + irmp_param.protocol = IRMP_LGAIR_PROTOCOL; // switch protocol + irmp_param.complete_len = irmp_bit; // patch length: 16 or 17 + irmp_tmp_address = irmp_lgair_address; + irmp_tmp_command = irmp_lgair_command; + } #endif // IRMP_SUPPORT_LGAIR_PROTOCOL == 1 #if IRMP_SUPPORT_JVC_PROTOCOL == 1 - else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17)) // 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 + { #ifdef ANALYZE - ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit); + ANALYZE_PRINTF ("Switching to JVC protocol, irmp_bit = %d\n", irmp_bit); #endif // ANALYZE - 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 + 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 - // 0123456789ABC0123456789ABC0123456701234567 - // NEC42: AAAAAAAAAAAAAaaaaaaaaaaaaaCCCCCCCCcccccccc - // JVC: AAAACCCCCCCCCCCC - irmp_tmp_command = (irmp_tmp_address >> 4) | (irmp_tmp_address2 << 9); // set command: upper 12 bits are command bits - irmp_tmp_address = irmp_tmp_address & 0x000F; // lower 4 bits are address bits - } + // 0123456789ABC0123456789ABC0123456701234567 + // NEC42: AAAAAAAAAAAAAaaaaaaaaaaaaaCCCCCCCCcccccccc + // JVC: AAAACCCCCCCCCCCC + irmp_tmp_command = (irmp_tmp_address >> 4) | (irmp_tmp_address2 << 9); // set command: upper 12 bits are command bits + irmp_tmp_address = irmp_tmp_address & 0x000F; // lower 4 bits are address bits + } #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1 #endif // IRMP_SUPPORT_NEC42_PROTOCOL == 1 #if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1 - else if (irmp_param.protocol == IRMP_SAMSUNG48_PROTOCOL && irmp_bit == 32) // it was a SAMSUNG32 stop bit - { + else if (irmp_param.protocol == IRMP_SAMSUNG48_PROTOCOL && irmp_bit == 32) // it was a SAMSUNG32 stop bit + { #ifdef ANALYZE - ANALYZE_PRINTF ("Switching to SAMSUNG32 protocol\n"); + ANALYZE_PRINTF ("Switching to SAMSUNG32 protocol\n"); #endif // ANALYZE - irmp_param.protocol = IRMP_SAMSUNG32_PROTOCOL; - irmp_param.command_offset = SAMSUNG32_COMMAND_OFFSET; - irmp_param.command_end = SAMSUNG32_COMMAND_OFFSET + SAMSUNG32_COMMAND_LEN; - irmp_param.complete_len = SAMSUNG32_COMPLETE_DATA_LEN; - } + irmp_param.protocol = IRMP_SAMSUNG32_PROTOCOL; + irmp_param.command_offset = SAMSUNG32_COMMAND_OFFSET; + irmp_param.command_end = SAMSUNG32_COMMAND_OFFSET + SAMSUNG32_COMMAND_LEN; + irmp_param.complete_len = SAMSUNG32_COMPLETE_DATA_LEN; + } #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 #if IRMP_SUPPORT_RCMM_PROTOCOL == 1 - else if (irmp_param.protocol == IRMP_RCMM32_PROTOCOL && (irmp_bit == 12 || irmp_bit == 24)) // it was a RCMM stop bit - { - if (irmp_bit == 12) - { - irmp_tmp_command = (irmp_tmp_address & 0xFF); // set command: lower 8 bits are command bits - irmp_tmp_address >>= 8; // upper 4 bits are address bits + else if (irmp_param.protocol == IRMP_RCMM32_PROTOCOL && (irmp_bit == 12 || irmp_bit == 24)) // it was a RCMM stop bit + { + if (irmp_bit == 12) + { + irmp_tmp_command = (irmp_tmp_address & 0xFF); // set command: lower 8 bits are command bits + irmp_tmp_address >>= 8; // upper 4 bits are address bits #ifdef ANALYZE - ANALYZE_PRINTF ("Switching to RCMM12 protocol, irmp_bit = %d\n", irmp_bit); + ANALYZE_PRINTF ("Switching to RCMM12 protocol, irmp_bit = %d\n", irmp_bit); #endif // ANALYZE - irmp_param.protocol = IRMP_RCMM12_PROTOCOL; // switch protocol - } - else // if ((irmp_bit == 24) - { + irmp_param.protocol = IRMP_RCMM12_PROTOCOL; // switch protocol + } + else // if ((irmp_bit == 24) + { #ifdef ANALYZE - ANALYZE_PRINTF ("Switching to RCMM24 protocol, irmp_bit = %d\n", irmp_bit); + ANALYZE_PRINTF ("Switching to RCMM24 protocol, irmp_bit = %d\n", irmp_bit); #endif // ANALYZE - irmp_param.protocol = IRMP_RCMM24_PROTOCOL; // switch protocol - } - irmp_param.stop_bit = TRUE; // set flag - irmp_param.complete_len = irmp_bit; // patch length - } + irmp_param.protocol = IRMP_RCMM24_PROTOCOL; // switch protocol + } + irmp_param.stop_bit = TRUE; // set flag + irmp_param.complete_len = irmp_bit; // patch length + } #endif // IRMP_SUPPORT_RCMM_PROTOCOL == 1 #if IRMP_SUPPORT_TECHNICS_PROTOCOL == 1 - else if (irmp_param.protocol == IRMP_MATSUSHITA_PROTOCOL && irmp_bit == 22) // it was a TECHNICS stop bit - { -#ifdef ANALYZE - ANALYZE_PRINTF ("Switching to TECHNICS protocol, irmp_bit = %d\n", irmp_bit); -#endif // ANALYZE - // Situation: - // The first 12 bits have been stored in irmp_tmp_command (LSB first) - // The following 10 bits have been stored in irmp_tmp_address (LSB first) - // The code of TECHNICS is: - // cccccccccccCCCCCCCCCCC (11 times c and 11 times C) - // ccccccccccccaaaaaaaaaa - // where C is inverted value of c - - irmp_tmp_address <<= 1; - if (irmp_tmp_command & (1<<11)) - { - irmp_tmp_address |= 1; - irmp_tmp_command &= ~(1<<11); - } - - if (irmp_tmp_command == ((~irmp_tmp_address) & 0x07FF)) - { - irmp_tmp_address = 0; - - irmp_param.protocol = IRMP_TECHNICS_PROTOCOL; // switch protocol - irmp_param.complete_len = irmp_bit; // patch length - } - else - { -#ifdef ANALYZE - ANALYZE_PRINTF ("error 8: TECHNICS frame error\n"); - ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); -#endif // ANALYZE - irmp_start_bit_detected = 0; // wait for another start bit... - irmp_pulse_time = 0; - irmp_pause_time = 0; - } - } + else if (irmp_param.protocol == IRMP_MATSUSHITA_PROTOCOL && irmp_bit == 22) // it was a TECHNICS stop bit + { +#ifdef ANALYZE + ANALYZE_PRINTF ("Switching to TECHNICS protocol, irmp_bit = %d\n", irmp_bit); +#endif // ANALYZE + // Situation: + // The first 12 bits have been stored in irmp_tmp_command (LSB first) + // The following 10 bits have been stored in irmp_tmp_address (LSB first) + // The code of TECHNICS is: + // cccccccccccCCCCCCCCCCC (11 times c and 11 times C) + // ccccccccccccaaaaaaaaaa + // where C is inverted value of c + + irmp_tmp_address <<= 1; + if (irmp_tmp_command & (1<<11)) + { + irmp_tmp_address |= 1; + irmp_tmp_command &= ~(1<<11); + } + + if (irmp_tmp_command == ((~irmp_tmp_address) & 0x07FF)) + { + irmp_tmp_address = 0; + + irmp_param.protocol = IRMP_TECHNICS_PROTOCOL; // switch protocol + irmp_param.complete_len = irmp_bit; // patch length + } + else + { +#ifdef ANALYZE + ANALYZE_PRINTF ("error 8: TECHNICS frame error\n"); + ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); +#endif // ANALYZE + irmp_start_bit_detected = 0; // wait for another start bit... + irmp_pulse_time = 0; + irmp_pause_time = 0; + } + } #endif // IRMP_SUPPORT_TECHNICS_PROTOCOL == 1 - else - { + else + { #ifdef ANALYZE - ANALYZE_PRINTF ("error 2: pause %d after data bit %d too long\n", irmp_pause_time, irmp_bit); - ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); + ANALYZE_PRINTF ("error 2: pause %d after data bit %d too long\n", irmp_pause_time, irmp_bit); + ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); #endif // ANALYZE - irmp_start_bit_detected = 0; // wait for another start bit... - irmp_pulse_time = 0; - irmp_pause_time = 0; - } - } - } - } - else - { // got light now! - got_light = TRUE; - } + irmp_start_bit_detected = 0; // wait for another start bit... + irmp_pulse_time = 0; + irmp_pause_time = 0; + } + } + } + } + else + { // got light now! + got_light = TRUE; + } - if (got_light) - { + if (got_light) + { #ifdef ANALYZE - ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time); + ANALYZE_PRINTF ("%8.3fms [bit %2d: pulse = %3d, pause = %3d] ", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit, irmp_pulse_time, irmp_pause_time); #endif // ANALYZE #if IRMP_SUPPORT_MANCHESTER == 1 - if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) // Manchester - { + if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) // Manchester + { #if 1 - if (irmp_pulse_time > irmp_param.pulse_1_len_max /* && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max */) + if (irmp_pulse_time > irmp_param.pulse_1_len_max /* && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max */) #else // better, but some IR-RCs use asymmetric timings :-/ - if (irmp_pulse_time > irmp_param.pulse_1_len_max && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max && - irmp_pause_time <= 2 * irmp_param.pause_1_len_max) + if (irmp_pulse_time > irmp_param.pulse_1_len_max && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max && + irmp_pause_time <= 2 * irmp_param.pause_1_len_max) #endif - { + { #if IRMP_SUPPORT_RC6_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 4 && irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MIN) // RC6 toggle bit - { -#ifdef ANALYZE - ANALYZE_PUTCHAR ('T'); -#endif // ANALYZE - if (irmp_param.complete_len == RC6_COMPLETE_DATA_LEN_LONG) // RC6 mode 6A - { - irmp_store_bit (1); - last_value = 1; - } - else // RC6 mode 0 - { - irmp_store_bit (0); - last_value = 0; - } -#ifdef ANALYZE - ANALYZE_NEWLINE (); -#endif // ANALYZE - } - else + if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 4 && irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MIN) // RC6 toggle bit + { +#ifdef ANALYZE + ANALYZE_PUTCHAR ('T'); +#endif // ANALYZE + if (irmp_param.complete_len == RC6_COMPLETE_DATA_LEN_LONG) // RC6 mode 6A + { + irmp_store_bit (1); + last_value = 1; + } + else // RC6 mode 0 + { + irmp_store_bit (0); + last_value = 0; + } +#ifdef ANALYZE + ANALYZE_NEWLINE (); +#endif // ANALYZE + } + else #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1 - { + { #ifdef ANALYZE - ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1'); + ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1'); #endif // ANALYZE - irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1 ); + irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1 ); #if IRMP_SUPPORT_RC6_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 4 && irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MIN) // RC6 toggle bit - { + if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 4 && irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MIN) // RC6 toggle bit + { #ifdef ANALYZE - ANALYZE_PUTCHAR ('T'); + ANALYZE_PUTCHAR ('T'); #endif // ANALYZE - irmp_store_bit (1); + irmp_store_bit (1); - if (irmp_pause_time > 2 * irmp_param.pause_1_len_max) - { - last_value = 0; - } - else - { - last_value = 1; - } + if (irmp_pause_time > 2 * irmp_param.pause_1_len_max) + { + last_value = 0; + } + else + { + last_value = 1; + } #ifdef ANALYZE - ANALYZE_NEWLINE (); + ANALYZE_NEWLINE (); #endif // ANALYZE - } - else + } + else #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1 - { + { #ifdef ANALYZE - ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0'); + ANALYZE_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0'); #endif // ANALYZE - irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0 ); + irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0 ); #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) - if (! irmp_param2.protocol) + if (! irmp_param2.protocol) #endif - { + { #ifdef ANALYZE - ANALYZE_NEWLINE (); + ANALYZE_NEWLINE (); #endif // ANALYZE - } - last_value = (irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0; - } - } - } - else if (irmp_pulse_time >= irmp_param.pulse_1_len_min && irmp_pulse_time <= irmp_param.pulse_1_len_max - /* && irmp_pause_time <= 2 * irmp_param.pause_1_len_max */) - { - uint_fast8_t manchester_value; + } + last_value = (irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0; + } + } + } + else if (irmp_pulse_time >= irmp_param.pulse_1_len_min && irmp_pulse_time <= irmp_param.pulse_1_len_max + /* && irmp_pause_time <= 2 * irmp_param.pause_1_len_max */) + { + uint_fast8_t manchester_value; - if (last_pause > irmp_param.pause_1_len_max && last_pause <= 2 * irmp_param.pause_1_len_max) - { - manchester_value = last_value ? 0 : 1; - last_value = manchester_value; - } - else - { - manchester_value = last_value; - } + if (last_pause > irmp_param.pause_1_len_max && last_pause <= 2 * irmp_param.pause_1_len_max) + { + manchester_value = last_value ? 0 : 1; + last_value = manchester_value; + } + else + { + manchester_value = last_value; + } #ifdef ANALYZE - ANALYZE_PUTCHAR (manchester_value + '0'); + ANALYZE_PUTCHAR (manchester_value + '0'); #endif // ANALYZE #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) - if (! irmp_param2.protocol) + if (! irmp_param2.protocol) #endif - { + { #ifdef ANALYZE - ANALYZE_NEWLINE (); + ANALYZE_NEWLINE (); #endif // ANALYZE - } + } #if IRMP_SUPPORT_RC6_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 1 && manchester_value == 1) // RC6 mode != 0 ??? - { -#ifdef ANALYZE - ANALYZE_PRINTF ("Switching to RC6A protocol\n"); -#endif // ANALYZE - irmp_param.complete_len = RC6_COMPLETE_DATA_LEN_LONG; - irmp_param.address_offset = 5; - irmp_param.address_end = irmp_param.address_offset + 15; - irmp_param.command_offset = irmp_param.address_end + 1; // skip 1 system bit, changes like a toggle bit - irmp_param.command_end = irmp_param.command_offset + 16 - 1; - irmp_tmp_address = 0; - } + if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 1 && manchester_value == 1) // RC6 mode != 0 ??? + { +#ifdef ANALYZE + ANALYZE_PRINTF ("Switching to RC6A protocol\n"); +#endif // ANALYZE + irmp_param.complete_len = RC6_COMPLETE_DATA_LEN_LONG; + irmp_param.address_offset = 5; + irmp_param.address_end = irmp_param.address_offset + 15; + irmp_param.command_offset = irmp_param.address_end + 1; // skip 1 system bit, changes like a toggle bit + irmp_param.command_end = irmp_param.command_offset + 16 - 1; + irmp_tmp_address = 0; + } #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1 - irmp_store_bit (manchester_value); - } - else - { + irmp_store_bit (manchester_value); + } + else + { #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_FDC_PROTOCOL == 1 - if (irmp_param2.protocol == IRMP_FDC_PROTOCOL && - irmp_pulse_time >= FDC_PULSE_LEN_MIN && irmp_pulse_time <= FDC_PULSE_LEN_MAX && - ((irmp_pause_time >= FDC_1_PAUSE_LEN_MIN && irmp_pause_time <= FDC_1_PAUSE_LEN_MAX) || - (irmp_pause_time >= FDC_0_PAUSE_LEN_MIN && irmp_pause_time <= FDC_0_PAUSE_LEN_MAX))) - { + if (irmp_param2.protocol == IRMP_FDC_PROTOCOL && + irmp_pulse_time >= FDC_PULSE_LEN_MIN && irmp_pulse_time <= FDC_PULSE_LEN_MAX && + ((irmp_pause_time >= FDC_1_PAUSE_LEN_MIN && irmp_pause_time <= FDC_1_PAUSE_LEN_MAX) || + (irmp_pause_time >= FDC_0_PAUSE_LEN_MIN && irmp_pause_time <= FDC_0_PAUSE_LEN_MAX))) + { #ifdef ANALYZE - ANALYZE_PUTCHAR ('?'); + ANALYZE_PUTCHAR ('?'); #endif // ANALYZE - irmp_param.protocol = 0; // switch to FDC, see below - } - else + irmp_param.protocol = 0; // switch to FDC, see below + } + else #endif // IRMP_SUPPORT_FDC_PROTOCOL == 1 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_RCCAR_PROTOCOL == 1 - if (irmp_param2.protocol == IRMP_RCCAR_PROTOCOL && - irmp_pulse_time >= RCCAR_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_PULSE_LEN_MAX && - ((irmp_pause_time >= RCCAR_1_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_1_PAUSE_LEN_MAX) || - (irmp_pause_time >= RCCAR_0_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_0_PAUSE_LEN_MAX))) - { + if (irmp_param2.protocol == IRMP_RCCAR_PROTOCOL && + irmp_pulse_time >= RCCAR_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_PULSE_LEN_MAX && + ((irmp_pause_time >= RCCAR_1_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_1_PAUSE_LEN_MAX) || + (irmp_pause_time >= RCCAR_0_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_0_PAUSE_LEN_MAX))) + { #ifdef ANALYZE - ANALYZE_PUTCHAR ('?'); + ANALYZE_PUTCHAR ('?'); #endif // ANALYZE - irmp_param.protocol = 0; // switch to RCCAR, see below - } - else + irmp_param.protocol = 0; // switch to RCCAR, see below + } + else #endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1 - { + { #ifdef ANALYZE - ANALYZE_PUTCHAR ('?'); - ANALYZE_NEWLINE (); - ANALYZE_PRINTF ("error 3 manchester: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time); - ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); + ANALYZE_PUTCHAR ('?'); + ANALYZE_NEWLINE (); + ANALYZE_PRINTF ("error 3 manchester: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time); + ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); #endif // ANALYZE - irmp_start_bit_detected = 0; // reset flags and wait for next start bit - irmp_pause_time = 0; - } - } + irmp_start_bit_detected = 0; // reset flags and wait for next start bit + irmp_pause_time = 0; + } + } #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_FDC_PROTOCOL == 1 - if (irmp_param2.protocol == IRMP_FDC_PROTOCOL && irmp_pulse_time >= FDC_PULSE_LEN_MIN && irmp_pulse_time <= FDC_PULSE_LEN_MAX) - { - if (irmp_pause_time >= FDC_1_PAUSE_LEN_MIN && irmp_pause_time <= FDC_1_PAUSE_LEN_MAX) - { + if (irmp_param2.protocol == IRMP_FDC_PROTOCOL && irmp_pulse_time >= FDC_PULSE_LEN_MIN && irmp_pulse_time <= FDC_PULSE_LEN_MAX) + { + if (irmp_pause_time >= FDC_1_PAUSE_LEN_MIN && irmp_pause_time <= FDC_1_PAUSE_LEN_MAX) + { #ifdef ANALYZE - ANALYZE_PRINTF (" 1 (FDC)\n"); + ANALYZE_PRINTF (" 1 (FDC)\n"); #endif // ANALYZE - irmp_store_bit2 (1); - } - else if (irmp_pause_time >= FDC_0_PAUSE_LEN_MIN && irmp_pause_time <= FDC_0_PAUSE_LEN_MAX) - { + irmp_store_bit2 (1); + } + else if (irmp_pause_time >= FDC_0_PAUSE_LEN_MIN && irmp_pause_time <= FDC_0_PAUSE_LEN_MAX) + { #ifdef ANALYZE - ANALYZE_PRINTF (" 0 (FDC)\n"); + ANALYZE_PRINTF (" 0 (FDC)\n"); #endif // ANALYZE - irmp_store_bit2 (0); - } + irmp_store_bit2 (0); + } - if (! irmp_param.protocol) - { + if (! irmp_param.protocol) + { #ifdef ANALYZE - ANALYZE_PRINTF ("Switching to FDC protocol\n"); + ANALYZE_PRINTF ("Switching to FDC protocol\n"); #endif // ANALYZE - memcpy (&irmp_param, &irmp_param2, sizeof (IRMP_PARAMETER)); - irmp_param2.protocol = 0; - irmp_tmp_address = irmp_tmp_address2; - irmp_tmp_command = irmp_tmp_command2; - } - } + memcpy (&irmp_param, &irmp_param2, sizeof (IRMP_PARAMETER)); + irmp_param2.protocol = 0; + irmp_tmp_address = irmp_tmp_address2; + irmp_tmp_command = irmp_tmp_command2; + } + } #endif // IRMP_SUPPORT_FDC_PROTOCOL == 1 #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_RCCAR_PROTOCOL == 1 - if (irmp_param2.protocol == IRMP_RCCAR_PROTOCOL && irmp_pulse_time >= RCCAR_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_PULSE_LEN_MAX) - { - if (irmp_pause_time >= RCCAR_1_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_1_PAUSE_LEN_MAX) - { + if (irmp_param2.protocol == IRMP_RCCAR_PROTOCOL && irmp_pulse_time >= RCCAR_PULSE_LEN_MIN && irmp_pulse_time <= RCCAR_PULSE_LEN_MAX) + { + if (irmp_pause_time >= RCCAR_1_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_1_PAUSE_LEN_MAX) + { #ifdef ANALYZE - ANALYZE_PRINTF (" 1 (RCCAR)\n"); + ANALYZE_PRINTF (" 1 (RCCAR)\n"); #endif // ANALYZE - irmp_store_bit2 (1); - } - else if (irmp_pause_time >= RCCAR_0_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_0_PAUSE_LEN_MAX) - { + irmp_store_bit2 (1); + } + else if (irmp_pause_time >= RCCAR_0_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_0_PAUSE_LEN_MAX) + { #ifdef ANALYZE - ANALYZE_PRINTF (" 0 (RCCAR)\n"); + ANALYZE_PRINTF (" 0 (RCCAR)\n"); #endif // ANALYZE - irmp_store_bit2 (0); - } + irmp_store_bit2 (0); + } - if (! irmp_param.protocol) - { + if (! irmp_param.protocol) + { #ifdef ANALYZE - ANALYZE_PRINTF ("Switching to RCCAR protocol\n"); + ANALYZE_PRINTF ("Switching to RCCAR protocol\n"); #endif // ANALYZE - memcpy (&irmp_param, &irmp_param2, sizeof (IRMP_PARAMETER)); - irmp_param2.protocol = 0; - irmp_tmp_address = irmp_tmp_address2; - irmp_tmp_command = irmp_tmp_command2; - } - } + memcpy (&irmp_param, &irmp_param2, sizeof (IRMP_PARAMETER)); + irmp_param2.protocol = 0; + irmp_tmp_address = irmp_tmp_address2; + irmp_tmp_command = irmp_tmp_command2; + } + } #endif // IRMP_SUPPORT_RCCAR_PROTOCOL == 1 - last_pause = irmp_pause_time; - wait_for_space = 0; - } - else + last_pause = irmp_pause_time; + wait_for_space = 0; + } + else #endif // IRMP_SUPPORT_MANCHESTER == 1 #if IRMP_SUPPORT_SERIAL == 1 - if (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) - { - while (irmp_bit < irmp_param.complete_len && irmp_pulse_time > irmp_param.pulse_1_len_max) - { -#ifdef ANALYZE - ANALYZE_PUTCHAR ('1'); -#endif // ANALYZE - irmp_store_bit (1); - - if (irmp_pulse_time >= irmp_param.pulse_1_len_min) - { - irmp_pulse_time -= irmp_param.pulse_1_len_min; - } - else - { - irmp_pulse_time = 0; - } - } - - while (irmp_bit < irmp_param.complete_len && irmp_pause_time > irmp_param.pause_1_len_max) - { -#ifdef ANALYZE - ANALYZE_PUTCHAR ('0'); -#endif // ANALYZE - irmp_store_bit (0); - - if (irmp_pause_time >= irmp_param.pause_1_len_min) - { - irmp_pause_time -= irmp_param.pause_1_len_min; - } - else - { - irmp_pause_time = 0; - } - } -#ifdef ANALYZE - ANALYZE_NEWLINE (); -#endif // ANALYZE - wait_for_space = 0; - } - else + if (irmp_param.flags & IRMP_PARAM_FLAG_IS_SERIAL) + { + while (irmp_bit < irmp_param.complete_len && irmp_pulse_time > irmp_param.pulse_1_len_max) + { +#ifdef ANALYZE + ANALYZE_PUTCHAR ('1'); +#endif // ANALYZE + irmp_store_bit (1); + + if (irmp_pulse_time >= irmp_param.pulse_1_len_min) + { + irmp_pulse_time -= irmp_param.pulse_1_len_min; + } + else + { + irmp_pulse_time = 0; + } + } + + while (irmp_bit < irmp_param.complete_len && irmp_pause_time > irmp_param.pause_1_len_max) + { +#ifdef ANALYZE + ANALYZE_PUTCHAR ('0'); +#endif // ANALYZE + irmp_store_bit (0); + + if (irmp_pause_time >= irmp_param.pause_1_len_min) + { + irmp_pause_time -= irmp_param.pause_1_len_min; + } + else + { + irmp_pause_time = 0; + } + } +#ifdef ANALYZE + ANALYZE_NEWLINE (); +#endif // ANALYZE + wait_for_space = 0; + } + else #endif // IRMP_SUPPORT_SERIAL == 1 #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_SAMSUNG_PROTOCOL && irmp_bit == 16) // Samsung: 16th bit - { - if (irmp_pulse_time >= SAMSUNG_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_PULSE_LEN_MAX && - irmp_pause_time >= SAMSUNG_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_START_BIT_PAUSE_LEN_MAX) - { -#ifdef ANALYZE - ANALYZE_PRINTF ("SYNC\n"); -#endif // ANALYZE - wait_for_space = 0; - irmp_bit++; - } - else if (irmp_pulse_time >= SAMSUNG_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_PULSE_LEN_MAX) - { + if (irmp_param.protocol == IRMP_SAMSUNG_PROTOCOL && irmp_bit == 16) // Samsung: 16th bit + { + if (irmp_pulse_time >= SAMSUNG_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_PULSE_LEN_MAX && + irmp_pause_time >= SAMSUNG_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_START_BIT_PAUSE_LEN_MAX) + { +#ifdef ANALYZE + ANALYZE_PRINTF ("SYNC\n"); +#endif // ANALYZE + wait_for_space = 0; + irmp_bit++; + } + else if (irmp_pulse_time >= SAMSUNG_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_PULSE_LEN_MAX) + { #if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1 #ifdef ANALYZE - ANALYZE_PRINTF ("Switching to SAMSUNG48 protocol "); + ANALYZE_PRINTF ("Switching to SAMSUNG48 protocol "); #endif // ANALYZE - irmp_param.protocol = IRMP_SAMSUNG48_PROTOCOL; - irmp_param.command_offset = SAMSUNG48_COMMAND_OFFSET; - irmp_param.command_end = SAMSUNG48_COMMAND_OFFSET + SAMSUNG48_COMMAND_LEN; - irmp_param.complete_len = SAMSUNG48_COMPLETE_DATA_LEN; + irmp_param.protocol = IRMP_SAMSUNG48_PROTOCOL; + irmp_param.command_offset = SAMSUNG48_COMMAND_OFFSET; + irmp_param.command_end = SAMSUNG48_COMMAND_OFFSET + SAMSUNG48_COMMAND_LEN; + irmp_param.complete_len = SAMSUNG48_COMPLETE_DATA_LEN; #else #ifdef ANALYZE - ANALYZE_PRINTF ("Switching to SAMSUNG32 protocol "); + ANALYZE_PRINTF ("Switching to SAMSUNG32 protocol "); #endif // ANALYZE - irmp_param.protocol = IRMP_SAMSUNG32_PROTOCOL; - irmp_param.command_offset = SAMSUNG32_COMMAND_OFFSET; - irmp_param.command_end = SAMSUNG32_COMMAND_OFFSET + SAMSUNG32_COMMAND_LEN; - irmp_param.complete_len = SAMSUNG32_COMPLETE_DATA_LEN; + irmp_param.protocol = IRMP_SAMSUNG32_PROTOCOL; + irmp_param.command_offset = SAMSUNG32_COMMAND_OFFSET; + irmp_param.command_end = SAMSUNG32_COMMAND_OFFSET + SAMSUNG32_COMMAND_LEN; + irmp_param.complete_len = SAMSUNG32_COMPLETE_DATA_LEN; #endif - if (irmp_pause_time >= SAMSUNG_1_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_1_PAUSE_LEN_MAX) - { -#ifdef ANALYZE - ANALYZE_PUTCHAR ('1'); - ANALYZE_NEWLINE (); -#endif // ANALYZE - irmp_store_bit (1); - wait_for_space = 0; - } - else - { -#ifdef ANALYZE - ANALYZE_PUTCHAR ('0'); - ANALYZE_NEWLINE (); -#endif // ANALYZE - irmp_store_bit (0); - wait_for_space = 0; - } - } - else - { // timing incorrect! -#ifdef ANALYZE - ANALYZE_PRINTF ("error 3 Samsung: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time); - ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); -#endif // ANALYZE - irmp_start_bit_detected = 0; // reset flags and wait for next start bit - irmp_pause_time = 0; - } - } - else + if (irmp_pause_time >= SAMSUNG_1_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_1_PAUSE_LEN_MAX) + { +#ifdef ANALYZE + ANALYZE_PUTCHAR ('1'); + ANALYZE_NEWLINE (); +#endif // ANALYZE + irmp_store_bit (1); + wait_for_space = 0; + } + else + { +#ifdef ANALYZE + ANALYZE_PUTCHAR ('0'); + ANALYZE_NEWLINE (); +#endif // ANALYZE + irmp_store_bit (0); + wait_for_space = 0; + } + } + else + { // timing incorrect! +#ifdef ANALYZE + ANALYZE_PRINTF ("error 3 Samsung: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time); + ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); +#endif // ANALYZE + irmp_start_bit_detected = 0; // reset flags and wait for next start bit + irmp_pause_time = 0; + } + } + else #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL #if IRMP_SUPPORT_NEC16_PROTOCOL #if IRMP_SUPPORT_NEC42_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && + if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && #else // IRMP_SUPPORT_NEC_PROTOCOL instead - if (irmp_param.protocol == IRMP_NEC_PROTOCOL && + if (irmp_param.protocol == IRMP_NEC_PROTOCOL && #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) - { -#ifdef ANALYZE - ANALYZE_PRINTF ("Switching to NEC16 protocol\n"); -#endif // ANALYZE - 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; - irmp_param.command_end = NEC16_COMMAND_OFFSET + NEC16_COMMAND_LEN; - irmp_param.complete_len = NEC16_COMPLETE_DATA_LEN; - wait_for_space = 0; - } - else + irmp_bit == 8 && irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX) + { +#ifdef ANALYZE + ANALYZE_PRINTF ("Switching to NEC16 protocol\n"); +#endif // ANALYZE + 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; + irmp_param.command_end = NEC16_COMMAND_OFFSET + NEC16_COMMAND_LEN; + irmp_param.complete_len = NEC16_COMPLETE_DATA_LEN; + wait_for_space = 0; + } + else #endif // IRMP_SUPPORT_NEC16_PROTOCOL #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL) - { - if (irmp_pulse_time >= BANG_OLUFSEN_PULSE_LEN_MIN && irmp_pulse_time <= BANG_OLUFSEN_PULSE_LEN_MAX) - { - if (irmp_bit == 1) // Bang & Olufsen: 3rd bit - { - if (irmp_pause_time >= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX) - { -#ifdef ANALYZE - ANALYZE_PRINTF ("3rd start bit\n"); -#endif // ANALYZE - wait_for_space = 0; - irmp_bit++; - } - else - { // timing incorrect! -#ifdef ANALYZE - 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); - ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); -#endif // ANALYZE - irmp_start_bit_detected = 0; // reset flags and wait for next start bit - irmp_pause_time = 0; - } - } - else if (irmp_bit == 19) // Bang & Olufsen: trailer bit - { - if (irmp_pause_time >= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX) - { -#ifdef ANALYZE - ANALYZE_PRINTF ("trailer bit\n"); -#endif // ANALYZE - wait_for_space = 0; - irmp_bit++; - } - else - { // timing incorrect! -#ifdef ANALYZE - 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); - ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); -#endif // ANALYZE - irmp_start_bit_detected = 0; // reset flags and wait for next start bit - irmp_pause_time = 0; - } - } - else - { - if (irmp_pause_time >= BANG_OLUFSEN_1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_1_PAUSE_LEN_MAX) - { // pulse & pause timings correct for "1"? -#ifdef ANALYZE - ANALYZE_PUTCHAR ('1'); - ANALYZE_NEWLINE (); -#endif // ANALYZE - irmp_store_bit (1); - last_value = 1; - wait_for_space = 0; - } - else if (irmp_pause_time >= BANG_OLUFSEN_0_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_0_PAUSE_LEN_MAX) - { // pulse & pause timings correct for "0"? -#ifdef ANALYZE - ANALYZE_PUTCHAR ('0'); - ANALYZE_NEWLINE (); -#endif // ANALYZE - irmp_store_bit (0); - last_value = 0; - wait_for_space = 0; - } - else if (irmp_pause_time >= BANG_OLUFSEN_R_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_R_PAUSE_LEN_MAX) - { -#ifdef ANALYZE - ANALYZE_PUTCHAR (last_value + '0'); - ANALYZE_NEWLINE (); -#endif // ANALYZE - irmp_store_bit (last_value); - wait_for_space = 0; - } - else - { // timing incorrect! -#ifdef ANALYZE - 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); - ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); -#endif // ANALYZE - irmp_start_bit_detected = 0; // reset flags and wait for next start bit - irmp_pause_time = 0; - } - } - } - else - { // timing incorrect! -#ifdef ANALYZE - 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); - ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); -#endif // ANALYZE - irmp_start_bit_detected = 0; // reset flags and wait for next start bit - irmp_pause_time = 0; - } - } - else + if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL) + { + if (irmp_pulse_time >= BANG_OLUFSEN_PULSE_LEN_MIN && irmp_pulse_time <= BANG_OLUFSEN_PULSE_LEN_MAX) + { + if (irmp_bit == 1) // Bang & Olufsen: 3rd bit + { + if (irmp_pause_time >= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX) + { +#ifdef ANALYZE + ANALYZE_PRINTF ("3rd start bit\n"); +#endif // ANALYZE + wait_for_space = 0; + irmp_bit++; + } + else + { // timing incorrect! +#ifdef ANALYZE + 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); + ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); +#endif // ANALYZE + irmp_start_bit_detected = 0; // reset flags and wait for next start bit + irmp_pause_time = 0; + } + } + else if (irmp_bit == 19) // Bang & Olufsen: trailer bit + { + if (irmp_pause_time >= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX) + { +#ifdef ANALYZE + ANALYZE_PRINTF ("trailer bit\n"); +#endif // ANALYZE + wait_for_space = 0; + irmp_bit++; + } + else + { // timing incorrect! +#ifdef ANALYZE + 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); + ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); +#endif // ANALYZE + irmp_start_bit_detected = 0; // reset flags and wait for next start bit + irmp_pause_time = 0; + } + } + else + { + if (irmp_pause_time >= BANG_OLUFSEN_1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_1_PAUSE_LEN_MAX) + { // pulse & pause timings correct for "1"? +#ifdef ANALYZE + ANALYZE_PUTCHAR ('1'); + ANALYZE_NEWLINE (); +#endif // ANALYZE + irmp_store_bit (1); + last_value = 1; + wait_for_space = 0; + } + else if (irmp_pause_time >= BANG_OLUFSEN_0_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_0_PAUSE_LEN_MAX) + { // pulse & pause timings correct for "0"? +#ifdef ANALYZE + ANALYZE_PUTCHAR ('0'); + ANALYZE_NEWLINE (); +#endif // ANALYZE + irmp_store_bit (0); + last_value = 0; + wait_for_space = 0; + } + else if (irmp_pause_time >= BANG_OLUFSEN_R_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_R_PAUSE_LEN_MAX) + { +#ifdef ANALYZE + ANALYZE_PUTCHAR (last_value + '0'); + ANALYZE_NEWLINE (); +#endif // ANALYZE + irmp_store_bit (last_value); + wait_for_space = 0; + } + else + { // timing incorrect! +#ifdef ANALYZE + 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); + ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); +#endif // ANALYZE + irmp_start_bit_detected = 0; // reset flags and wait for next start bit + irmp_pause_time = 0; + } + } + } + else + { // timing incorrect! +#ifdef ANALYZE + 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); + ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); +#endif // ANALYZE + irmp_start_bit_detected = 0; // reset flags and wait for next start bit + irmp_pause_time = 0; + } + } + else #endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL #if IRMP_SUPPORT_RCMM_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_RCMM32_PROTOCOL) - { - if (irmp_pause_time >= RCMM32_BIT_00_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_BIT_00_PAUSE_LEN_MAX) - { -#ifdef ANALYZE - ANALYZE_PUTCHAR ('0'); - ANALYZE_PUTCHAR ('0'); -#endif // ANALYZE - irmp_store_bit (0); - irmp_store_bit (0); - } - else if (irmp_pause_time >= RCMM32_BIT_01_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_BIT_01_PAUSE_LEN_MAX) - { -#ifdef ANALYZE - ANALYZE_PUTCHAR ('0'); - ANALYZE_PUTCHAR ('1'); -#endif // ANALYZE - irmp_store_bit (0); - irmp_store_bit (1); - } - else if (irmp_pause_time >= RCMM32_BIT_10_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_BIT_10_PAUSE_LEN_MAX) - { -#ifdef ANALYZE - ANALYZE_PUTCHAR ('1'); - ANALYZE_PUTCHAR ('0'); -#endif // ANALYZE - irmp_store_bit (1); - irmp_store_bit (0); - } - else if (irmp_pause_time >= RCMM32_BIT_11_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_BIT_11_PAUSE_LEN_MAX) - { -#ifdef ANALYZE - ANALYZE_PUTCHAR ('1'); - ANALYZE_PUTCHAR ('1'); -#endif // ANALYZE - irmp_store_bit (1); - irmp_store_bit (1); - } -#ifdef ANALYZE - ANALYZE_PRINTF ("\n"); -#endif // ANALYZE - wait_for_space = 0; - } - else + if (irmp_param.protocol == IRMP_RCMM32_PROTOCOL) + { + if (irmp_pause_time >= RCMM32_BIT_00_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_BIT_00_PAUSE_LEN_MAX) + { +#ifdef ANALYZE + ANALYZE_PUTCHAR ('0'); + ANALYZE_PUTCHAR ('0'); +#endif // ANALYZE + irmp_store_bit (0); + irmp_store_bit (0); + } + else if (irmp_pause_time >= RCMM32_BIT_01_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_BIT_01_PAUSE_LEN_MAX) + { +#ifdef ANALYZE + ANALYZE_PUTCHAR ('0'); + ANALYZE_PUTCHAR ('1'); +#endif // ANALYZE + irmp_store_bit (0); + irmp_store_bit (1); + } + else if (irmp_pause_time >= RCMM32_BIT_10_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_BIT_10_PAUSE_LEN_MAX) + { +#ifdef ANALYZE + ANALYZE_PUTCHAR ('1'); + ANALYZE_PUTCHAR ('0'); +#endif // ANALYZE + irmp_store_bit (1); + irmp_store_bit (0); + } + else if (irmp_pause_time >= RCMM32_BIT_11_PAUSE_LEN_MIN && irmp_pause_time <= RCMM32_BIT_11_PAUSE_LEN_MAX) + { +#ifdef ANALYZE + ANALYZE_PUTCHAR ('1'); + ANALYZE_PUTCHAR ('1'); +#endif // ANALYZE + irmp_store_bit (1); + irmp_store_bit (1); + } +#ifdef ANALYZE + ANALYZE_PRINTF ("\n"); +#endif // ANALYZE + wait_for_space = 0; + } + else #endif - if (irmp_pulse_time >= irmp_param.pulse_1_len_min && irmp_pulse_time <= irmp_param.pulse_1_len_max && - irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max) - { // pulse & pause timings correct for "1"? + if (irmp_pulse_time >= irmp_param.pulse_1_len_min && irmp_pulse_time <= irmp_param.pulse_1_len_max && + irmp_pause_time >= irmp_param.pause_1_len_min && irmp_pause_time <= irmp_param.pause_1_len_max) + { // pulse & pause timings correct for "1"? #ifdef ANALYZE - ANALYZE_PUTCHAR ('1'); - ANALYZE_NEWLINE (); + ANALYZE_PUTCHAR ('1'); + ANALYZE_NEWLINE (); #endif // ANALYZE - irmp_store_bit (1); - wait_for_space = 0; - } - else if (irmp_pulse_time >= irmp_param.pulse_0_len_min && irmp_pulse_time <= irmp_param.pulse_0_len_max && - irmp_pause_time >= irmp_param.pause_0_len_min && irmp_pause_time <= irmp_param.pause_0_len_max) - { // pulse & pause timings correct for "0"? + irmp_store_bit (1); + wait_for_space = 0; + } + else if (irmp_pulse_time >= irmp_param.pulse_0_len_min && irmp_pulse_time <= irmp_param.pulse_0_len_max && + irmp_pause_time >= irmp_param.pause_0_len_min && irmp_pause_time <= irmp_param.pause_0_len_max) + { // pulse & pause timings correct for "0"? #ifdef ANALYZE - ANALYZE_PUTCHAR ('0'); - ANALYZE_NEWLINE (); + ANALYZE_PUTCHAR ('0'); + ANALYZE_NEWLINE (); #endif // ANALYZE - irmp_store_bit (0); - wait_for_space = 0; - } - else + irmp_store_bit (0); + wait_for_space = 0; + } + else #if IRMP_SUPPORT_KATHREIN_PROTOCOL - if (irmp_param.protocol == IRMP_KATHREIN_PROTOCOL && - irmp_pulse_time >= KATHREIN_1_PULSE_LEN_MIN && irmp_pulse_time <= KATHREIN_1_PULSE_LEN_MAX && - (((irmp_bit == 8 || irmp_bit == 6) && - irmp_pause_time >= KATHREIN_SYNC_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_SYNC_BIT_PAUSE_LEN_MAX) || - (irmp_bit == 12 && - irmp_pause_time >= KATHREIN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_START_BIT_PAUSE_LEN_MAX))) - - { - if (irmp_bit == 8) - { - irmp_bit++; -#ifdef ANALYZE - ANALYZE_PUTCHAR ('S'); - ANALYZE_NEWLINE (); -#endif // ANALYZE - irmp_tmp_command <<= 1; - } - else - { -#ifdef ANALYZE - ANALYZE_PUTCHAR ('S'); - ANALYZE_NEWLINE (); -#endif // ANALYZE - irmp_store_bit (1); - } - wait_for_space = 0; - } - else + if (irmp_param.protocol == IRMP_KATHREIN_PROTOCOL && + irmp_pulse_time >= KATHREIN_1_PULSE_LEN_MIN && irmp_pulse_time <= KATHREIN_1_PULSE_LEN_MAX && + (((irmp_bit == 8 || irmp_bit == 6) && + irmp_pause_time >= KATHREIN_SYNC_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_SYNC_BIT_PAUSE_LEN_MAX) || + (irmp_bit == 12 && + irmp_pause_time >= KATHREIN_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KATHREIN_START_BIT_PAUSE_LEN_MAX))) + + { + if (irmp_bit == 8) + { + irmp_bit++; +#ifdef ANALYZE + ANALYZE_PUTCHAR ('S'); + ANALYZE_NEWLINE (); +#endif // ANALYZE + irmp_tmp_command <<= 1; + } + else + { +#ifdef ANALYZE + ANALYZE_PUTCHAR ('S'); + ANALYZE_NEWLINE (); +#endif // ANALYZE + irmp_store_bit (1); + } + wait_for_space = 0; + } + else #endif // IRMP_SUPPORT_KATHREIN_PROTOCOL - { // timing incorrect! -#ifdef ANALYZE - ANALYZE_PRINTF ("error 3: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time); - ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); -#endif // ANALYZE - irmp_start_bit_detected = 0; // reset flags and wait for next start bit - irmp_pause_time = 0; - } - - irmp_pulse_time = 1; // set counter to 1, not 0 - } - } - else - { // counting the pulse length ... - if (! irmp_input) // still light? - { // yes... - irmp_pulse_time++; // increment counter - } - else - { // now it's dark! - wait_for_space = 1; // let's count the time (see above) - irmp_pause_time = 1; // set pause counter to 1, not 0 - } - } - - if (irmp_start_bit_detected && irmp_bit == irmp_param.complete_len && irmp_param.stop_bit == 0) // enough bits received? - { - if (last_irmp_command == irmp_tmp_command && key_repetition_len < AUTO_FRAME_REPETITION_LEN) - { - repetition_frame_number++; - } - else - { - repetition_frame_number = 0; - } + { // timing incorrect! +#ifdef ANALYZE + ANALYZE_PRINTF ("error 3: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time); + ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); +#endif // ANALYZE + irmp_start_bit_detected = 0; // reset flags and wait for next start bit + irmp_pause_time = 0; + } + + irmp_pulse_time = 1; // set counter to 1, not 0 + } + } + else + { // counting the pulse length ... + if (! irmp_input) // still light? + { // yes... + irmp_pulse_time++; // increment counter + } + else + { // now it's dark! + wait_for_space = 1; // let's count the time (see above) + irmp_pause_time = 1; // set pause counter to 1, not 0 + } + } + + if (irmp_start_bit_detected && irmp_bit == irmp_param.complete_len && irmp_param.stop_bit == 0) // enough bits received? + { + if (last_irmp_command == irmp_tmp_command && key_repetition_len < AUTO_FRAME_REPETITION_LEN) + { + repetition_frame_number++; + } + else + { + repetition_frame_number = 0; + } #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1 - // if SIRCS protocol and the code will be repeated within 50 ms, we will ignore 2nd and 3rd repetition frame - if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && (repetition_frame_number == 1 || repetition_frame_number == 2)) - { + // if SIRCS protocol and the code will be repeated within 50 ms, we will ignore 2nd and 3rd repetition frame + if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && (repetition_frame_number == 1 || repetition_frame_number == 2)) + { #ifdef ANALYZE - ANALYZE_PRINTF ("code skipped: SIRCS auto repetition frame #%d, counter = %d, auto repetition len = %d\n", - repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN); + ANALYZE_PRINTF ("code skipped: SIRCS auto repetition frame #%d, counter = %d, auto repetition len = %d\n", + repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN); #endif // ANALYZE - key_repetition_len = 0; - } - else + key_repetition_len = 0; + } + else #endif #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1 - // if ORTEK protocol and the code will be repeated within 50 ms, we will ignore 2nd repetition frame - if (irmp_param.protocol == IRMP_ORTEK_PROTOCOL && repetition_frame_number == 1) - { + // if ORTEK protocol and the code will be repeated within 50 ms, we will ignore 2nd repetition frame + if (irmp_param.protocol == IRMP_ORTEK_PROTOCOL && repetition_frame_number == 1) + { #ifdef ANALYZE - ANALYZE_PRINTF ("code skipped: ORTEK auto repetition frame #%d, counter = %d, auto repetition len = %d\n", - repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN); + ANALYZE_PRINTF ("code skipped: ORTEK auto repetition frame #%d, counter = %d, auto repetition len = %d\n", + repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN); #endif // ANALYZE - key_repetition_len = 0; - } - else + key_repetition_len = 0; + } + else #endif #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 - // if KASEIKYO protocol and the code will be repeated within 50 ms, we will ignore 2nd repetition frame - if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && repetition_frame_number == 1) - { + // if KASEIKYO protocol and the code will be repeated within 50 ms, we will ignore 2nd repetition frame + if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && repetition_frame_number == 1) + { #ifdef ANALYZE - ANALYZE_PRINTF ("code skipped: KASEIKYO auto repetition frame #%d, counter = %d, auto repetition len = %d\n", - repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN); + ANALYZE_PRINTF ("code skipped: KASEIKYO auto repetition frame #%d, counter = %d, auto repetition len = %d\n", + repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN); #endif // ANALYZE - key_repetition_len = 0; - } - else + key_repetition_len = 0; + } + else #endif #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 - // if SAMSUNG32 or SAMSUNG48 protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame - if ((irmp_param.protocol == IRMP_SAMSUNG32_PROTOCOL || irmp_param.protocol == IRMP_SAMSUNG48_PROTOCOL) && (repetition_frame_number & 0x01)) - { + // if SAMSUNG32 or SAMSUNG48 protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame + if ((irmp_param.protocol == IRMP_SAMSUNG32_PROTOCOL || irmp_param.protocol == IRMP_SAMSUNG48_PROTOCOL) && (repetition_frame_number & 0x01)) + { #ifdef ANALYZE - ANALYZE_PRINTF ("code skipped: SAMSUNG32/SAMSUNG48 auto repetition frame #%d, counter = %d, auto repetition len = %d\n", - repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN); + ANALYZE_PRINTF ("code skipped: SAMSUNG32/SAMSUNG48 auto repetition frame #%d, counter = %d, auto repetition len = %d\n", + repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN); #endif // ANALYZE - key_repetition_len = 0; - } - else + key_repetition_len = 0; + } + else #endif #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1 - // if NUBERT protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame - if (irmp_param.protocol == IRMP_NUBERT_PROTOCOL && (repetition_frame_number & 0x01)) - { + // if NUBERT protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame + if (irmp_param.protocol == IRMP_NUBERT_PROTOCOL && (repetition_frame_number & 0x01)) + { #ifdef ANALYZE - ANALYZE_PRINTF ("code skipped: NUBERT auto repetition frame #%d, counter = %d, auto repetition len = %d\n", - repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN); + ANALYZE_PRINTF ("code skipped: NUBERT auto repetition frame #%d, counter = %d, auto repetition len = %d\n", + repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN); #endif // ANALYZE - key_repetition_len = 0; - } - else + key_repetition_len = 0; + } + else #endif #if IRMP_SUPPORT_SPEAKER_PROTOCOL == 1 - // if SPEAKER protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame - if (irmp_param.protocol == IRMP_SPEAKER_PROTOCOL && (repetition_frame_number & 0x01)) - { + // if SPEAKER protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame + if (irmp_param.protocol == IRMP_SPEAKER_PROTOCOL && (repetition_frame_number & 0x01)) + { #ifdef ANALYZE - ANALYZE_PRINTF ("code skipped: SPEAKER auto repetition frame #%d, counter = %d, auto repetition len = %d\n", - repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN); + ANALYZE_PRINTF ("code skipped: SPEAKER auto repetition frame #%d, counter = %d, auto repetition len = %d\n", + repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN); #endif // ANALYZE - key_repetition_len = 0; - } - else + key_repetition_len = 0; + } + else #endif - { + { #ifdef ANALYZE - ANALYZE_PRINTF ("%8.3fms code detected, length = %d\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit); + ANALYZE_PRINTF ("%8.3fms code detected, length = %d\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit); #endif // ANALYZE - irmp_ir_detected = TRUE; + irmp_ir_detected = TRUE; #if IRMP_SUPPORT_DENON_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_DENON_PROTOCOL) - { // check for repetition frame - if ((~irmp_tmp_command & 0x3FF) == last_irmp_denon_command) // command bits must be inverted - { - irmp_tmp_command = last_irmp_denon_command; // use command received before! - last_irmp_denon_command = 0; - - irmp_protocol = irmp_param.protocol; // store protocol - irmp_address = irmp_tmp_address; // store address - irmp_command = irmp_tmp_command; // store command - } - else - { - if ((irmp_tmp_command & 0x01) == 0x00) - { -#ifdef ANALYZE - ANALYZE_PRINTF ("%8.3fms info Denon: waiting for inverted command repetition\n", (double) (time_counter * 1000) / F_INTERRUPTS); -#endif // ANALYZE - last_irmp_denon_command = irmp_tmp_command; - denon_repetition_len = 0; - irmp_ir_detected = FALSE; - } - else - { -#ifdef ANALYZE - ANALYZE_PRINTF ("%8.3fms warning Denon: got unexpected inverted command, ignoring it\n", (double) (time_counter * 1000) / F_INTERRUPTS); -#endif // ANALYZE - last_irmp_denon_command = 0; - irmp_ir_detected = FALSE; - } - } - } - else + if (irmp_param.protocol == IRMP_DENON_PROTOCOL) + { // check for repetition frame + if ((~irmp_tmp_command & 0x3FF) == last_irmp_denon_command) // command bits must be inverted + { + irmp_tmp_command = last_irmp_denon_command; // use command received before! + last_irmp_denon_command = 0; + + irmp_protocol = irmp_param.protocol; // store protocol + irmp_address = irmp_tmp_address; // store address + irmp_command = irmp_tmp_command; // store command + } + else + { + if ((irmp_tmp_command & 0x01) == 0x00) + { +#ifdef ANALYZE + ANALYZE_PRINTF ("%8.3fms info Denon: waiting for inverted command repetition\n", (double) (time_counter * 1000) / F_INTERRUPTS); +#endif // ANALYZE + last_irmp_denon_command = irmp_tmp_command; + denon_repetition_len = 0; + irmp_ir_detected = FALSE; + } + else + { +#ifdef ANALYZE + ANALYZE_PRINTF ("%8.3fms warning Denon: got unexpected inverted command, ignoring it\n", (double) (time_counter * 1000) / F_INTERRUPTS); +#endif // ANALYZE + last_irmp_denon_command = 0; + irmp_ir_detected = FALSE; + } + } + } + else #endif // IRMP_SUPPORT_DENON_PROTOCOL #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && irmp_tmp_command == 0x01ff) - { // Grundig start frame? + if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && irmp_tmp_command == 0x01ff) + { // Grundig start frame? #ifdef ANALYZE - ANALYZE_PRINTF ("Detected GRUNDIG start frame, ignoring it\n"); + ANALYZE_PRINTF ("Detected GRUNDIG start frame, ignoring it\n"); #endif // ANALYZE - irmp_ir_detected = FALSE; - } - else + irmp_ir_detected = FALSE; + } + else #endif // IRMP_SUPPORT_GRUNDIG_PROTOCOL #if IRMP_SUPPORT_NOKIA_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_NOKIA_PROTOCOL && irmp_tmp_address == 0x00ff && irmp_tmp_command == 0x00fe) - { // Nokia start frame? + if (irmp_param.protocol == IRMP_NOKIA_PROTOCOL && irmp_tmp_address == 0x00ff && irmp_tmp_command == 0x00fe) + { // Nokia start frame? #ifdef ANALYZE - ANALYZE_PRINTF ("Detected NOKIA start frame, ignoring it\n"); + ANALYZE_PRINTF ("Detected NOKIA start frame, ignoring it\n"); #endif // ANALYZE - irmp_ir_detected = FALSE; - } - else + irmp_ir_detected = FALSE; + } + else #endif // IRMP_SUPPORT_NOKIA_PROTOCOL - { + { #if IRMP_SUPPORT_NEC_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_NEC_PROTOCOL && irmp_bit == 0) // repetition frame - { - if (key_repetition_len < NEC_FRAME_REPEAT_PAUSE_LEN_MAX) - { -#ifdef ANALYZE - ANALYZE_PRINTF ("Detected NEC repetition frame, key_repetition_len = %d\n", key_repetition_len); - ANALYZE_ONLY_NORMAL_PRINTF("REPETETION FRAME "); -#endif // ANALYZE - irmp_tmp_address = last_irmp_address; // address is last address - irmp_tmp_command = last_irmp_command; // command is last command - irmp_flags |= IRMP_FLAG_REPETITION; - key_repetition_len = 0; - } - else - { -#ifdef ANALYZE - ANALYZE_PRINTF ("Detected NEC repetition frame, ignoring it: timeout occured, key_repetition_len = %d > %d\n", - key_repetition_len, NEC_FRAME_REPEAT_PAUSE_LEN_MAX); -#endif // ANALYZE - irmp_ir_detected = FALSE; - } - } + if (irmp_param.protocol == IRMP_NEC_PROTOCOL && irmp_bit == 0) // repetition frame + { + if (key_repetition_len < NEC_FRAME_REPEAT_PAUSE_LEN_MAX) + { +#ifdef ANALYZE + ANALYZE_PRINTF ("Detected NEC repetition frame, key_repetition_len = %d\n", key_repetition_len); + ANALYZE_ONLY_NORMAL_PRINTF("REPETETION FRAME "); +#endif // ANALYZE + irmp_tmp_address = last_irmp_address; // address is last address + irmp_tmp_command = last_irmp_command; // command is last command + irmp_flags |= IRMP_FLAG_REPETITION; + key_repetition_len = 0; + } + else + { +#ifdef ANALYZE + ANALYZE_PRINTF ("Detected NEC repetition frame, ignoring it: timeout occured, key_repetition_len = %d > %d\n", + key_repetition_len, NEC_FRAME_REPEAT_PAUSE_LEN_MAX); +#endif // ANALYZE + irmp_ir_detected = FALSE; + } + } #endif // IRMP_SUPPORT_NEC_PROTOCOL #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL) - { - uint_fast8_t xor_value; + if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL) + { + uint_fast8_t xor_value; - xor_value = (xor_check[0] & 0x0F) ^ ((xor_check[0] & 0xF0) >> 4) ^ (xor_check[1] & 0x0F) ^ ((xor_check[1] & 0xF0) >> 4); + xor_value = (xor_check[0] & 0x0F) ^ ((xor_check[0] & 0xF0) >> 4) ^ (xor_check[1] & 0x0F) ^ ((xor_check[1] & 0xF0) >> 4); - if (xor_value != (xor_check[2] & 0x0F)) - { + if (xor_value != (xor_check[2] & 0x0F)) + { #ifdef ANALYZE - ANALYZE_PRINTF ("error 4: wrong XOR check for customer id: 0x%1x 0x%1x\n", xor_value, xor_check[2] & 0x0F); + ANALYZE_PRINTF ("error 4: wrong XOR check for customer id: 0x%1x 0x%1x\n", xor_value, xor_check[2] & 0x0F); #endif // ANALYZE - irmp_ir_detected = FALSE; - } + irmp_ir_detected = FALSE; + } - xor_value = xor_check[2] ^ xor_check[3] ^ xor_check[4]; + xor_value = xor_check[2] ^ xor_check[3] ^ xor_check[4]; - if (xor_value != xor_check[5]) - { + if (xor_value != xor_check[5]) + { #ifdef ANALYZE - ANALYZE_PRINTF ("error 5: wrong XOR check for data bits: 0x%02x 0x%02x\n", xor_value, xor_check[5]); + ANALYZE_PRINTF ("error 5: wrong XOR check for data bits: 0x%02x 0x%02x\n", xor_value, xor_check[5]); #endif // ANALYZE - irmp_ir_detected = FALSE; - } + irmp_ir_detected = FALSE; + } - irmp_flags |= genre2; // write the genre2 bits into MSB of the flag byte - } + irmp_flags |= genre2; // write the genre2 bits into MSB of the flag byte + } #endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 #if IRMP_SUPPORT_ORTEK_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_ORTEK_PROTOCOL) - { - if (parity == PARITY_CHECK_FAILED) - { + if (irmp_param.protocol == IRMP_ORTEK_PROTOCOL) + { + if (parity == PARITY_CHECK_FAILED) + { #ifdef ANALYZE - ANALYZE_PRINTF ("error 6: parity check failed\n"); + ANALYZE_PRINTF ("error 6: parity check failed\n"); #endif // ANALYZE - irmp_ir_detected = FALSE; - } + irmp_ir_detected = FALSE; + } - if ((irmp_tmp_address & 0x03) == 0x02) - { + if ((irmp_tmp_address & 0x03) == 0x02) + { #ifdef ANALYZE - ANALYZE_PRINTF ("code skipped: ORTEK end of transmission frame (key release)\n"); + ANALYZE_PRINTF ("code skipped: ORTEK end of transmission frame (key release)\n"); #endif // ANALYZE - irmp_ir_detected = FALSE; - } - irmp_tmp_address >>= 2; - } + irmp_ir_detected = FALSE; + } + irmp_tmp_address >>= 2; + } #endif // IRMP_SUPPORT_ORTEK_PROTOCOL == 1 #if IRMP_SUPPORT_RC6_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_param.complete_len == RC6_COMPLETE_DATA_LEN_LONG) // RC6 mode = 6? - { - irmp_protocol = IRMP_RC6A_PROTOCOL; - } - else + if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_param.complete_len == RC6_COMPLETE_DATA_LEN_LONG) // RC6 mode = 6? + { + irmp_protocol = IRMP_RC6A_PROTOCOL; + } + else #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1 - { - irmp_protocol = irmp_param.protocol; - } + { + irmp_protocol = irmp_param.protocol; + } #if IRMP_SUPPORT_FDC_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_FDC_PROTOCOL) - { - if (irmp_tmp_command & 0x000F) // released key? - { - irmp_tmp_command = (irmp_tmp_command >> 4) | 0x80; // yes, set bit 7 - } - else - { - irmp_tmp_command >>= 4; // no, it's a pressed key - } - irmp_tmp_command |= (irmp_tmp_address << 2) & 0x0F00; // 000000CCCCAAAAAA -> 0000CCCC00000000 - irmp_tmp_address &= 0x003F; - } + if (irmp_param.protocol == IRMP_FDC_PROTOCOL) + { + if (irmp_tmp_command & 0x000F) // released key? + { + irmp_tmp_command = (irmp_tmp_command >> 4) | 0x80; // yes, set bit 7 + } + else + { + irmp_tmp_command >>= 4; // no, it's a pressed key + } + irmp_tmp_command |= (irmp_tmp_address << 2) & 0x0F00; // 000000CCCCAAAAAA -> 0000CCCC00000000 + irmp_tmp_address &= 0x003F; + } #endif - irmp_address = irmp_tmp_address; // store address + irmp_address = irmp_tmp_address; // store address #if IRMP_SUPPORT_NEC_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_NEC_PROTOCOL) - { - last_irmp_address = irmp_tmp_address; // store as last address, too - } + if (irmp_param.protocol == IRMP_NEC_PROTOCOL) + { + last_irmp_address = irmp_tmp_address; // store as last address, too + } #endif #if IRMP_SUPPORT_RC5_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_RC5_PROTOCOL) - { - irmp_tmp_command |= rc5_cmd_bit6; // store bit 6 - } + if (irmp_param.protocol == IRMP_RC5_PROTOCOL) + { + irmp_tmp_command |= rc5_cmd_bit6; // store bit 6 + } #endif #if IRMP_SUPPORT_S100_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_S100_PROTOCOL) - { - irmp_tmp_command |= rc5_cmd_bit6; // store bit 6 - } + if (irmp_param.protocol == IRMP_S100_PROTOCOL) + { + irmp_tmp_command |= rc5_cmd_bit6; // store bit 6 + } #endif - irmp_command = irmp_tmp_command; // store command + irmp_command = irmp_tmp_command; // store command #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 - irmp_id = irmp_tmp_id; + irmp_id = irmp_tmp_id; #endif - } - } + } + } - if (irmp_ir_detected) - { - if (last_irmp_command == irmp_tmp_command && - last_irmp_address == irmp_tmp_address && - key_repetition_len < IRMP_KEY_REPETITION_LEN) - { - irmp_flags |= IRMP_FLAG_REPETITION; - } + if (irmp_ir_detected) + { + if (last_irmp_command == irmp_tmp_command && + last_irmp_address == irmp_tmp_address && + key_repetition_len < IRMP_KEY_REPETITION_LEN) + { + irmp_flags |= IRMP_FLAG_REPETITION; + } - last_irmp_address = irmp_tmp_address; // store as last address, too - last_irmp_command = irmp_tmp_command; // store as last command, too + last_irmp_address = irmp_tmp_address; // store as last address, too + last_irmp_command = irmp_tmp_command; // store as last command, too - key_repetition_len = 0; - } - else - { + key_repetition_len = 0; + } + else + { #ifdef ANALYZE - ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); + ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); #endif // ANALYZE - } + } - irmp_start_bit_detected = 0; // and wait for next start bit - irmp_tmp_command = 0; - irmp_pulse_time = 0; - irmp_pause_time = 0; + irmp_start_bit_detected = 0; // and wait for next start bit + irmp_tmp_command = 0; + irmp_pulse_time = 0; + irmp_pause_time = 0; #if IRMP_SUPPORT_JVC_PROTOCOL == 1 - if (irmp_protocol == IRMP_JVC_PROTOCOL) // the stop bit of JVC frame is also start bit of next frame - { // set pulse time here! - irmp_pulse_time = ((uint_fast8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME)); - } + if (irmp_protocol == IRMP_JVC_PROTOCOL) // the stop bit of JVC frame is also start bit of next frame + { // set pulse time here! + irmp_pulse_time = ((uint_fast8_t)(F_INTERRUPTS * JVC_START_BIT_PULSE_TIME)); + } #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1 - } - } + } + } } #if defined(STELLARIS_ARM_CORTEX_M4) @@ -4783,166 +4859,16 @@ irmp_ISR (void) * Compile it under linux with: * cc irmp.c -o irmp * - * usage: ./irmp [-v|-s|-a|-l|-p] < file + * usage: ./irmp [-v|-s|-a|-l] < file * * options: * -v verbose * -s silent * -a analyze * -l list pulse/pauses - * -p print timings *--------------------------------------------------------------------------------------------------------------------------------------------------- */ -static void -print_timings (void) -{ - printf ("IRMP_TIMEOUT_LEN: %d [%d byte(s)]\n", IRMP_TIMEOUT_LEN, sizeof (PAUSE_LEN)); - printf ("IRMP_KEY_REPETITION_LEN %d\n", IRMP_KEY_REPETITION_LEN); - puts (""); - printf ("PROTOCOL S S-PULSE S-PAUSE PULSE-0 PAUSE-0 PULSE-1 PAUSE-1\n"); - printf ("====================================================================================\n"); - printf ("SIRCS 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - SIRCS_START_BIT_PULSE_LEN_MIN, SIRCS_START_BIT_PULSE_LEN_MAX, SIRCS_START_BIT_PAUSE_LEN_MIN, SIRCS_START_BIT_PAUSE_LEN_MAX, - SIRCS_0_PULSE_LEN_MIN, SIRCS_0_PULSE_LEN_MAX, SIRCS_PAUSE_LEN_MIN, SIRCS_PAUSE_LEN_MAX, - SIRCS_1_PULSE_LEN_MIN, SIRCS_1_PULSE_LEN_MAX, SIRCS_PAUSE_LEN_MIN, SIRCS_PAUSE_LEN_MAX); - - printf ("NEC 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX, NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX, - NEC_PULSE_LEN_MIN, NEC_PULSE_LEN_MAX, NEC_0_PAUSE_LEN_MIN, NEC_0_PAUSE_LEN_MAX, - NEC_PULSE_LEN_MIN, NEC_PULSE_LEN_MAX, NEC_1_PAUSE_LEN_MIN, NEC_1_PAUSE_LEN_MAX); - - printf ("NEC (rep) 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %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, - NEC_PULSE_LEN_MIN, NEC_PULSE_LEN_MAX, NEC_0_PAUSE_LEN_MIN, NEC_0_PAUSE_LEN_MAX, - NEC_PULSE_LEN_MIN, NEC_PULSE_LEN_MAX, NEC_1_PAUSE_LEN_MIN, NEC_1_PAUSE_LEN_MAX); - - printf ("SAMSUNG 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - SAMSUNG_START_BIT_PULSE_LEN_MIN, SAMSUNG_START_BIT_PULSE_LEN_MAX, SAMSUNG_START_BIT_PAUSE_LEN_MIN, SAMSUNG_START_BIT_PAUSE_LEN_MAX, - SAMSUNG_PULSE_LEN_MIN, SAMSUNG_PULSE_LEN_MAX, SAMSUNG_0_PAUSE_LEN_MIN, SAMSUNG_0_PAUSE_LEN_MAX, - SAMSUNG_PULSE_LEN_MIN, SAMSUNG_PULSE_LEN_MAX, SAMSUNG_1_PAUSE_LEN_MIN, SAMSUNG_1_PAUSE_LEN_MAX); - - printf ("MATSUSHITA 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - MATSUSHITA_START_BIT_PULSE_LEN_MIN, MATSUSHITA_START_BIT_PULSE_LEN_MAX, MATSUSHITA_START_BIT_PAUSE_LEN_MIN, MATSUSHITA_START_BIT_PAUSE_LEN_MAX, - MATSUSHITA_PULSE_LEN_MIN, MATSUSHITA_PULSE_LEN_MAX, MATSUSHITA_0_PAUSE_LEN_MIN, MATSUSHITA_0_PAUSE_LEN_MAX, - MATSUSHITA_PULSE_LEN_MIN, MATSUSHITA_PULSE_LEN_MAX, MATSUSHITA_1_PAUSE_LEN_MIN, MATSUSHITA_1_PAUSE_LEN_MAX); - - printf ("KASEIKYO 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - KASEIKYO_START_BIT_PULSE_LEN_MIN, KASEIKYO_START_BIT_PULSE_LEN_MAX, KASEIKYO_START_BIT_PAUSE_LEN_MIN, KASEIKYO_START_BIT_PAUSE_LEN_MAX, - KASEIKYO_PULSE_LEN_MIN, KASEIKYO_PULSE_LEN_MAX, KASEIKYO_0_PAUSE_LEN_MIN, KASEIKYO_0_PAUSE_LEN_MAX, - KASEIKYO_PULSE_LEN_MIN, KASEIKYO_PULSE_LEN_MAX, KASEIKYO_1_PAUSE_LEN_MIN, KASEIKYO_1_PAUSE_LEN_MAX); - - printf ("RECS80 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - RECS80_START_BIT_PULSE_LEN_MIN, RECS80_START_BIT_PULSE_LEN_MAX, RECS80_START_BIT_PAUSE_LEN_MIN, RECS80_START_BIT_PAUSE_LEN_MAX, - RECS80_PULSE_LEN_MIN, RECS80_PULSE_LEN_MAX, RECS80_0_PAUSE_LEN_MIN, RECS80_0_PAUSE_LEN_MAX, - RECS80_PULSE_LEN_MIN, RECS80_PULSE_LEN_MAX, RECS80_1_PAUSE_LEN_MIN, RECS80_1_PAUSE_LEN_MAX); - - printf ("RC5 1 %3d - %3d %3d - %3d %3d - %3d\n", - RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX, RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX, - RC5_BIT_LEN_MIN, RC5_BIT_LEN_MAX); - - printf ("DENON 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX, - DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX, DENON_0_PAUSE_LEN_MIN, DENON_0_PAUSE_LEN_MAX, - DENON_PULSE_LEN_MIN, DENON_PULSE_LEN_MAX, DENON_1_PAUSE_LEN_MIN, DENON_1_PAUSE_LEN_MAX); - - printf ("THOMSON 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX, - THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX, THOMSON_0_PAUSE_LEN_MIN, THOMSON_0_PAUSE_LEN_MAX, - THOMSON_PULSE_LEN_MIN, THOMSON_PULSE_LEN_MAX, THOMSON_1_PAUSE_LEN_MIN, THOMSON_1_PAUSE_LEN_MAX); - - printf ("RC6 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - RC6_START_BIT_PULSE_LEN_MIN, RC6_START_BIT_PULSE_LEN_MAX, RC6_START_BIT_PAUSE_LEN_MIN, RC6_START_BIT_PAUSE_LEN_MAX, - RC6_BIT_PULSE_LEN_MIN, RC6_BIT_PULSE_LEN_MAX, RC6_BIT_PAUSE_LEN_MIN, RC6_BIT_PAUSE_LEN_MAX); - - printf ("RECS80EXT 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - RECS80EXT_START_BIT_PULSE_LEN_MIN, RECS80EXT_START_BIT_PULSE_LEN_MAX, RECS80EXT_START_BIT_PAUSE_LEN_MIN, RECS80EXT_START_BIT_PAUSE_LEN_MAX, - RECS80EXT_PULSE_LEN_MIN, RECS80EXT_PULSE_LEN_MAX, RECS80EXT_0_PAUSE_LEN_MIN, RECS80EXT_0_PAUSE_LEN_MAX, - RECS80EXT_PULSE_LEN_MIN, RECS80EXT_PULSE_LEN_MAX, RECS80EXT_1_PAUSE_LEN_MIN, RECS80EXT_1_PAUSE_LEN_MAX); - - printf ("NUBERT 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - NUBERT_START_BIT_PULSE_LEN_MIN, NUBERT_START_BIT_PULSE_LEN_MAX, NUBERT_START_BIT_PAUSE_LEN_MIN, NUBERT_START_BIT_PAUSE_LEN_MAX, - NUBERT_0_PULSE_LEN_MIN, NUBERT_0_PULSE_LEN_MAX, NUBERT_0_PAUSE_LEN_MIN, NUBERT_0_PAUSE_LEN_MAX, - NUBERT_1_PULSE_LEN_MIN, NUBERT_1_PULSE_LEN_MAX, NUBERT_1_PAUSE_LEN_MIN, NUBERT_1_PAUSE_LEN_MAX); - - printf ("FAN 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - FAN_START_BIT_PULSE_LEN_MIN, FAN_START_BIT_PULSE_LEN_MAX, FAN_START_BIT_PAUSE_LEN_MIN, FAN_START_BIT_PAUSE_LEN_MAX, - FAN_0_PULSE_LEN_MIN, FAN_0_PULSE_LEN_MAX, FAN_0_PAUSE_LEN_MIN, FAN_0_PAUSE_LEN_MAX, - FAN_1_PULSE_LEN_MIN, FAN_1_PULSE_LEN_MAX, FAN_1_PAUSE_LEN_MIN, FAN_1_PAUSE_LEN_MAX); - - printf ("SPEAKER 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - SPEAKER_START_BIT_PULSE_LEN_MIN, SPEAKER_START_BIT_PULSE_LEN_MAX, SPEAKER_START_BIT_PAUSE_LEN_MIN, SPEAKER_START_BIT_PAUSE_LEN_MAX, - SPEAKER_0_PULSE_LEN_MIN, SPEAKER_0_PULSE_LEN_MAX, SPEAKER_0_PAUSE_LEN_MIN, SPEAKER_0_PAUSE_LEN_MAX, - SPEAKER_1_PULSE_LEN_MIN, SPEAKER_1_PULSE_LEN_MAX, SPEAKER_1_PAUSE_LEN_MIN, SPEAKER_1_PAUSE_LEN_MAX); - - printf ("BANG_OLUFSEN 1 %3d - %3d %3d - %3d\n", - BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX, - BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX); - - printf ("BANG_OLUFSEN 2 %3d - %3d %3d - %3d\n", - BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX, - BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX); - - printf ("BANG_OLUFSEN 3 %3d - %3d %3d - %3d\n", - BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX, - BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX); - - printf ("BANG_OLUFSEN 4 %3d - %3d %3d - %3d\n", - BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX, - BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX); - - printf ("BANG_OLUFSEN - %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - BANG_OLUFSEN_PULSE_LEN_MIN, BANG_OLUFSEN_PULSE_LEN_MAX, BANG_OLUFSEN_0_PAUSE_LEN_MIN, BANG_OLUFSEN_0_PAUSE_LEN_MAX, - BANG_OLUFSEN_PULSE_LEN_MIN, BANG_OLUFSEN_PULSE_LEN_MAX, BANG_OLUFSEN_1_PAUSE_LEN_MIN, BANG_OLUFSEN_1_PAUSE_LEN_MAX); - - printf ("GRUNDIG/NOKIA 1 %3d - %3d %3d - %3d %3d - %3d\n", - GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN, GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX, - GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN, GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX, - GRUNDIG_NOKIA_IR60_BIT_LEN_MIN, GRUNDIG_NOKIA_IR60_BIT_LEN_MAX); - - printf ("SIEMENS/RUWIDO 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX, - SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN, SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX, - SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN, SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX, - SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN, SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX, - 2 * SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX, - 2 * SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN, 2 * SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX); - - printf ("FDC 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - FDC_START_BIT_PULSE_LEN_MIN, FDC_START_BIT_PULSE_LEN_MAX, FDC_START_BIT_PAUSE_LEN_MIN, FDC_START_BIT_PAUSE_LEN_MAX, - FDC_PULSE_LEN_MIN, FDC_PULSE_LEN_MAX, FDC_0_PAUSE_LEN_MIN, FDC_0_PAUSE_LEN_MAX, - FDC_PULSE_LEN_MIN, FDC_PULSE_LEN_MAX, FDC_1_PAUSE_LEN_MIN, FDC_1_PAUSE_LEN_MAX); - - printf ("RCCAR 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - RCCAR_START_BIT_PULSE_LEN_MIN, RCCAR_START_BIT_PULSE_LEN_MAX, RCCAR_START_BIT_PAUSE_LEN_MIN, RCCAR_START_BIT_PAUSE_LEN_MAX, - RCCAR_PULSE_LEN_MIN, RCCAR_PULSE_LEN_MAX, RCCAR_0_PAUSE_LEN_MIN, RCCAR_0_PAUSE_LEN_MAX, - RCCAR_PULSE_LEN_MIN, RCCAR_PULSE_LEN_MAX, RCCAR_1_PAUSE_LEN_MIN, RCCAR_1_PAUSE_LEN_MAX); - - printf ("NIKON 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - NIKON_START_BIT_PULSE_LEN_MIN, NIKON_START_BIT_PULSE_LEN_MAX, NIKON_START_BIT_PAUSE_LEN_MIN, NIKON_START_BIT_PAUSE_LEN_MAX, - NIKON_PULSE_LEN_MIN, NIKON_PULSE_LEN_MAX, NIKON_0_PAUSE_LEN_MIN, NIKON_0_PAUSE_LEN_MAX, - NIKON_PULSE_LEN_MIN, NIKON_PULSE_LEN_MAX, NIKON_1_PAUSE_LEN_MIN, NIKON_1_PAUSE_LEN_MAX); - - printf ("LEGO 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - LEGO_START_BIT_PULSE_LEN_MIN, LEGO_START_BIT_PULSE_LEN_MAX, LEGO_START_BIT_PAUSE_LEN_MIN, LEGO_START_BIT_PAUSE_LEN_MAX, - LEGO_PULSE_LEN_MIN, LEGO_PULSE_LEN_MAX, LEGO_0_PAUSE_LEN_MIN, LEGO_0_PAUSE_LEN_MAX, - LEGO_PULSE_LEN_MIN, LEGO_PULSE_LEN_MAX, LEGO_1_PAUSE_LEN_MIN, LEGO_1_PAUSE_LEN_MAX); - - printf ("\n"); - printf ("PROTOCOL S S-PULSE S-PAUSE PULSE PAUSE-00 PAUSE-01 PAUSE-10 PAUSE-11\n"); - printf ("================================================================================================\n"); - printf ("RCMM 1 %3d %3d %3d %3d %3d %3d %3d\n", - (uint_fast8_t)(F_INTERRUPTS * RCMM32_START_BIT_PULSE_TIME), (uint_fast8_t)(F_INTERRUPTS * RCMM32_START_BIT_PAUSE_TIME), - (uint_fast8_t)(F_INTERRUPTS * RCMM32_PULSE_TIME), - (uint_fast8_t)(F_INTERRUPTS * RCMM32_00_PAUSE_TIME), (uint_fast8_t)(F_INTERRUPTS * RCMM32_01_PAUSE_TIME), - (uint_fast8_t)(F_INTERRUPTS * RCMM32_10_PAUSE_TIME), (uint_fast8_t)(F_INTERRUPTS * RCMM32_11_PAUSE_TIME)); - printf ("RCMM 1 %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d %3d - %3d\n", - RCMM32_START_BIT_PULSE_LEN_MIN, RCMM32_START_BIT_PULSE_LEN_MAX, RCMM32_START_BIT_PAUSE_LEN_MIN, RCMM32_START_BIT_PAUSE_LEN_MAX, - RCMM32_BIT_PULSE_LEN_MIN, RCMM32_BIT_PULSE_LEN_MAX, RCMM32_BIT_00_PAUSE_LEN_MIN, RCMM32_BIT_00_PAUSE_LEN_MAX, - RCMM32_BIT_01_PAUSE_LEN_MIN, RCMM32_BIT_01_PAUSE_LEN_MAX, RCMM32_BIT_10_PAUSE_LEN_MIN, RCMM32_BIT_10_PAUSE_LEN_MAX, - RCMM32_BIT_11_PAUSE_LEN_MIN, RCMM32_BIT_11_PAUSE_LEN_MAX); -} - void print_spectrum (char * text, int * buf, int is_pulse) { @@ -4962,64 +4888,64 @@ print_spectrum (char * text, int * buf, int is_pulse) for (i = 0; i < 256; i++) { - if (buf[i] > max_value) - { - max_value = buf[i]; - } + if (buf[i] > max_value) + { + max_value = buf[i]; + } } for (i = 1; i < 200; i++) { - if (buf[i] > 0) - { - printf ("%3d ", i); - value = (buf[i] * 60) / max_value; - - for (j = 0; j < value; j++) - { - putchar ('o'); - } - printf (" %d\n", buf[i]); - - sum += i * buf[i]; - counter += buf[i]; - } - else - { - max = i - 1; - - if (counter > 0) - { - average = (float) sum / (float) counter; - - if (is_pulse) - { - printf ("pulse "); - } - else - { - printf ("pause "); - } - - printf ("avg: %4.1f=%6.1f us, ", average, (1000000. * average) / (float) F_INTERRUPTS); - printf ("min: %2d=%6.1f us, ", min, (1000000. * min) / (float) F_INTERRUPTS); - printf ("max: %2d=%6.1f us, ", max, (1000000. * max) / (float) F_INTERRUPTS); - - tolerance = (max - average); - - if (average - min > tolerance) - { - tolerance = average - min; - } - - tolerance = tolerance * 100 / average; - printf ("tol: %4.1f%%\n", tolerance); - } - - counter = 0; - sum = 0; - min = i + 1; - } + if (buf[i] > 0) + { + printf ("%3d ", i); + value = (buf[i] * 60) / max_value; + + for (j = 0; j < value; j++) + { + putchar ('o'); + } + printf (" %d\n", buf[i]); + + sum += i * buf[i]; + counter += buf[i]; + } + else + { + max = i - 1; + + if (counter > 0) + { + average = (float) sum / (float) counter; + + if (is_pulse) + { + printf ("pulse "); + } + else + { + printf ("pause "); + } + + printf ("avg: %4.1f=%6.1f us, ", average, (1000000. * average) / (float) F_INTERRUPTS); + printf ("min: %2d=%6.1f us, ", min, (1000000. * min) / (float) F_INTERRUPTS); + printf ("max: %2d=%6.1f us, ", max, (1000000. * max) / (float) F_INTERRUPTS); + + tolerance = (max - average); + + if (average - min > tolerance) + { + tolerance = average - min; + } + + tolerance = tolerance * 100 / average; + printf ("tol: %4.1f%%\n", tolerance); + } + + counter = 0; + sum = 0; + min = i + 1; + } } } @@ -5064,12 +4990,12 @@ get_fdc_key (uint_fast16_t cmd) static uint8_t key_table[128] = { // 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, '^', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'ß', '´', 0, '\b', + 0, '^', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'ß', '´', 0, '\b', '\t','q', 'w', 'e', 'r', 't', 'z', 'u', 'i', 'o', 'p', 'ü', '+', 0, 0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'ö', 'ä', '#', '\r', 0, '<', 'y', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '-', 0, 0, 0, 0, 0, ' ', 0, 0, - 0, '°', '!', '"', '§', '$', '%', '&', '/', '(', ')', '=', '?', '`', 0, '\b', + 0, '°', '!', '"', '§', '$', '%', '&', '/', '(', ')', '=', '?', '`', 0, '\b', '\t','Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I', 'O', 'P', 'Ü', '*', 0, 0, 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Ö', 'Ä', '\'','\r', 0, '>', 'Y', 'X', 'C', 'V', 'B', 'N', 'M', ';', ':', '_', 0, 0, 0, 0, 0, ' ', 0, 0 @@ -5080,80 +5006,80 @@ get_fdc_key (uint_fast16_t cmd) switch (cmd) { - case 0x002C: state |= STATE_LEFT_SHIFT; break; // pressed left shift - case 0x00AC: state &= ~STATE_LEFT_SHIFT; break; // released left shift - case 0x0039: state |= STATE_RIGHT_SHIFT; break; // pressed right shift - case 0x00B9: state &= ~STATE_RIGHT_SHIFT; break; // released right shift - case 0x003A: state |= STATE_LEFT_CTRL; break; // pressed left ctrl - case 0x00BA: state &= ~STATE_LEFT_CTRL; break; // released left ctrl - case 0x003C: state |= STATE_LEFT_ALT; break; // pressed left alt - case 0x00BC: state &= ~STATE_LEFT_ALT; break; // released left alt - case 0x003E: state |= STATE_RIGHT_ALT; break; // pressed left alt - case 0x00BE: state &= ~STATE_RIGHT_ALT; break; // released left alt - - case 0x006e: key = KEY_ESCAPE; break; - case 0x004b: key = KEY_INSERT; break; - case 0x004c: key = KEY_DELETE; break; - case 0x004f: key = KEY_LEFT; break; - case 0x0050: key = KEY_HOME; break; - case 0x0051: key = KEY_END; break; - case 0x0053: key = KEY_UP; break; - case 0x0054: key = KEY_DOWN; break; - case 0x0055: key = KEY_PAGE_UP; break; - case 0x0056: key = KEY_PAGE_DOWN; break; - case 0x0059: key = KEY_RIGHT; break; - case 0x0400: key = KEY_MOUSE_1; break; - case 0x0800: key = KEY_MOUSE_2; break; - - default: - { - if (!(cmd & 0x80)) // pressed key - { - if (cmd >= 0x70 && cmd <= 0x7F) // function keys - { - key = cmd + 0x10; // 7x -> 8x - } - else if (cmd < 64) // key listed in key_table - { - if (state & (STATE_LEFT_ALT | STATE_RIGHT_ALT)) - { - switch (cmd) - { - case 0x0003: key = '²'; break; - case 0x0008: key = '{'; break; - case 0x0009: key = '['; break; - case 0x000A: key = ']'; break; - case 0x000B: key = '}'; break; - case 0x000C: key = '\\'; break; - case 0x001C: key = '~'; break; - case 0x002D: key = '|'; break; - case 0x0034: key = 0xB5; break; // Mu - } - } - else if (state & (STATE_LEFT_CTRL)) - { - if (key_table[cmd] >= 'a' && key_table[cmd] <= 'z') - { - key = key_table[cmd] - 'a' + 1; - } - else - { - key = key_table[cmd]; - } - } - else - { - int idx = cmd + ((state & (STATE_LEFT_SHIFT | STATE_RIGHT_SHIFT)) ? 64 : 0); - - if (key_table[idx]) - { - key = key_table[idx]; - } - } - } - } - break; - } + case 0x002C: state |= STATE_LEFT_SHIFT; break; // pressed left shift + case 0x00AC: state &= ~STATE_LEFT_SHIFT; break; // released left shift + case 0x0039: state |= STATE_RIGHT_SHIFT; break; // pressed right shift + case 0x00B9: state &= ~STATE_RIGHT_SHIFT; break; // released right shift + case 0x003A: state |= STATE_LEFT_CTRL; break; // pressed left ctrl + case 0x00BA: state &= ~STATE_LEFT_CTRL; break; // released left ctrl + case 0x003C: state |= STATE_LEFT_ALT; break; // pressed left alt + case 0x00BC: state &= ~STATE_LEFT_ALT; break; // released left alt + case 0x003E: state |= STATE_RIGHT_ALT; break; // pressed left alt + case 0x00BE: state &= ~STATE_RIGHT_ALT; break; // released left alt + + case 0x006e: key = KEY_ESCAPE; break; + case 0x004b: key = KEY_INSERT; break; + case 0x004c: key = KEY_DELETE; break; + case 0x004f: key = KEY_LEFT; break; + case 0x0050: key = KEY_HOME; break; + case 0x0051: key = KEY_END; break; + case 0x0053: key = KEY_UP; break; + case 0x0054: key = KEY_DOWN; break; + case 0x0055: key = KEY_PAGE_UP; break; + case 0x0056: key = KEY_PAGE_DOWN; break; + case 0x0059: key = KEY_RIGHT; break; + case 0x0400: key = KEY_MOUSE_1; break; + case 0x0800: key = KEY_MOUSE_2; break; + + default: + { + if (!(cmd & 0x80)) // pressed key + { + if (cmd >= 0x70 && cmd <= 0x7F) // function keys + { + key = cmd + 0x10; // 7x -> 8x + } + else if (cmd < 64) // key listed in key_table + { + if (state & (STATE_LEFT_ALT | STATE_RIGHT_ALT)) + { + switch (cmd) + { + case 0x0003: key = '²'; break; + case 0x0008: key = '{'; break; + case 0x0009: key = '['; break; + case 0x000A: key = ']'; break; + case 0x000B: key = '}'; break; + case 0x000C: key = '\\'; break; + case 0x001C: key = '~'; break; + case 0x002D: key = '|'; break; + case 0x0034: key = 0xB5; break; // Mu + } + } + else if (state & (STATE_LEFT_CTRL)) + { + if (key_table[cmd] >= 'a' && key_table[cmd] <= 'z') + { + key = key_table[cmd] - 'a' + 1; + } + else + { + key = key_table[cmd]; + } + } + else + { + int idx = cmd + ((state & (STATE_LEFT_SHIFT | STATE_RIGHT_SHIFT)) ? 64 : 0); + + if (key_table[idx]) + { + key = key_table[idx]; + } + } + } + } + break; + } } return (key); @@ -5172,107 +5098,107 @@ next_tick (void) { if (! analyze && ! list) { - (void) irmp_ISR (); - - if (irmp_get_data (&irmp_data)) - { - uint_fast8_t key; - - ANALYZE_ONLY_NORMAL_PUTCHAR (' '); - - if (verbose) - { - printf ("%8.3fms ", (double) (time_counter * 1000) / F_INTERRUPTS); - } - - if (irmp_data.protocol == IRMP_ACP24_PROTOCOL) - { - uint16_t temp = (irmp_data.command & 0x000F) + 15; - - printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, temp=%d", - irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, temp); - } - else if (irmp_data.protocol == IRMP_FDC_PROTOCOL && (key = get_fdc_key (irmp_data.command)) != 0) - { - if ((key >= 0x20 && key < 0x7F) || key >= 0xA0) - { - printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, asc=0x%02x, key='%c'", - irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, key, key); - } - else if (key == '\r' || key == '\t' || key == KEY_ESCAPE || (key >= 0x80 && key <= 0x9F)) // function keys - { - char * p = (char *) NULL; - - switch (key) - { - case '\t' : p = "TAB"; break; - case '\r' : p = "CR"; break; - case KEY_ESCAPE : p = "ESCAPE"; break; - case KEY_MENUE : p = "MENUE"; break; - case KEY_BACK : p = "BACK"; break; - case KEY_FORWARD : p = "FORWARD"; break; - case KEY_ADDRESS : p = "ADDRESS"; break; - case KEY_WINDOW : p = "WINDOW"; break; - case KEY_1ST_PAGE : p = "1ST_PAGE"; break; - case KEY_STOP : p = "STOP"; break; - case KEY_MAIL : p = "MAIL"; break; - case KEY_FAVORITES : p = "FAVORITES"; break; - case KEY_NEW_PAGE : p = "NEW_PAGE"; break; - case KEY_SETUP : p = "SETUP"; break; - case KEY_FONT : p = "FONT"; break; - case KEY_PRINT : p = "PRINT"; break; - case KEY_ON_OFF : p = "ON_OFF"; break; - - case KEY_INSERT : p = "INSERT"; break; - case KEY_DELETE : p = "DELETE"; break; - case KEY_LEFT : p = "LEFT"; break; - case KEY_HOME : p = "HOME"; break; - case KEY_END : p = "END"; break; - case KEY_UP : p = "UP"; break; - case KEY_DOWN : p = "DOWN"; break; - case KEY_PAGE_UP : p = "PAGE_UP"; break; - case KEY_PAGE_DOWN : p = "PAGE_DOWN"; break; - case KEY_RIGHT : p = "RIGHT"; break; - case KEY_MOUSE_1 : p = "KEY_MOUSE_1"; break; - case KEY_MOUSE_2 : p = "KEY_MOUSE_2"; break; - default : p = ""; break; - } - - printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, asc=0x%02x, key=%s", - irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, key, p); - } - else - { - printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, asc=0x%02x", - irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, key); - } - } - else - { - printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x", - irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags); - } - - if (do_check_expected_values) - { - if (irmp_data.protocol != expected_protocol || - irmp_data.address != expected_address || - irmp_data.command != expected_command) - { - printf ("\nerror 7: expected values differ: p=%2d (%s), a=0x%04x, c=0x%04x\n", - expected_protocol, irmp_protocol_names[expected_protocol], expected_address, expected_command); - } - else - { - printf (" checked!\n"); - } - do_check_expected_values = FALSE; // only check 1st frame in a line! - } - else - { - putchar ('\n'); - } - } + (void) irmp_ISR (); + + if (irmp_get_data (&irmp_data)) + { + uint_fast8_t key; + + ANALYZE_ONLY_NORMAL_PUTCHAR (' '); + + if (verbose) + { + printf ("%8.3fms ", (double) (time_counter * 1000) / F_INTERRUPTS); + } + + if (irmp_data.protocol == IRMP_ACP24_PROTOCOL) + { + uint16_t temp = (irmp_data.command & 0x000F) + 15; + + printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, temp=%d", + irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, temp); + } + else if (irmp_data.protocol == IRMP_FDC_PROTOCOL && (key = get_fdc_key (irmp_data.command)) != 0) + { + if ((key >= 0x20 && key < 0x7F) || key >= 0xA0) + { + printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, asc=0x%02x, key='%c'", + irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, key, key); + } + else if (key == '\r' || key == '\t' || key == KEY_ESCAPE || (key >= 0x80 && key <= 0x9F)) // function keys + { + char * p = (char *) NULL; + + switch (key) + { + case '\t' : p = "TAB"; break; + case '\r' : p = "CR"; break; + case KEY_ESCAPE : p = "ESCAPE"; break; + case KEY_MENUE : p = "MENUE"; break; + case KEY_BACK : p = "BACK"; break; + case KEY_FORWARD : p = "FORWARD"; break; + case KEY_ADDRESS : p = "ADDRESS"; break; + case KEY_WINDOW : p = "WINDOW"; break; + case KEY_1ST_PAGE : p = "1ST_PAGE"; break; + case KEY_STOP : p = "STOP"; break; + case KEY_MAIL : p = "MAIL"; break; + case KEY_FAVORITES : p = "FAVORITES"; break; + case KEY_NEW_PAGE : p = "NEW_PAGE"; break; + case KEY_SETUP : p = "SETUP"; break; + case KEY_FONT : p = "FONT"; break; + case KEY_PRINT : p = "PRINT"; break; + case KEY_ON_OFF : p = "ON_OFF"; break; + + case KEY_INSERT : p = "INSERT"; break; + case KEY_DELETE : p = "DELETE"; break; + case KEY_LEFT : p = "LEFT"; break; + case KEY_HOME : p = "HOME"; break; + case KEY_END : p = "END"; break; + case KEY_UP : p = "UP"; break; + case KEY_DOWN : p = "DOWN"; break; + case KEY_PAGE_UP : p = "PAGE_UP"; break; + case KEY_PAGE_DOWN : p = "PAGE_DOWN"; break; + case KEY_RIGHT : p = "RIGHT"; break; + case KEY_MOUSE_1 : p = "KEY_MOUSE_1"; break; + case KEY_MOUSE_2 : p = "KEY_MOUSE_2"; break; + default : p = ""; break; + } + + printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, asc=0x%02x, key=%s", + irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, key, p); + } + else + { + printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x, asc=0x%02x", + irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags, key); + } + } + else + { + printf ("p=%2d (%s), a=0x%04x, c=0x%04x, f=0x%02x", + irmp_data.protocol, irmp_protocol_names[irmp_data.protocol], irmp_data.address, irmp_data.command, irmp_data.flags); + } + + if (do_check_expected_values) + { + if (irmp_data.protocol != expected_protocol || + irmp_data.address != expected_address || + irmp_data.command != expected_command) + { + printf ("\nerror 7: expected values differ: p=%2d (%s), a=0x%04x, c=0x%04x\n", + expected_protocol, irmp_protocol_names[expected_protocol], expected_address, expected_command); + } + else + { + printf (" checked!\n"); + } + do_check_expected_values = FALSE; // only check 1st frame in a line! + } + else + { + putchar ('\n'); + } + } } } @@ -5295,242 +5221,237 @@ main (int argc, char ** argv) if (argc == 2) { - if (! strcmp (argv[1], "-v")) - { - verbose = TRUE; - } - else if (! strcmp (argv[1], "-l")) - { - list = TRUE; - } - else if (! strcmp (argv[1], "-a")) - { - analyze = TRUE; - } - else if (! strcmp (argv[1], "-s")) - { - silent = TRUE; - } - else if (! strcmp (argv[1], "-p")) - { - print_timings (); - return (0); - } - else if (! strcmp (argv[1], "-r")) - { - radio = TRUE; - } + if (! strcmp (argv[1], "-v")) + { + verbose = TRUE; + } + else if (! strcmp (argv[1], "-l")) + { + list = TRUE; + } + else if (! strcmp (argv[1], "-a")) + { + analyze = TRUE; + } + else if (! strcmp (argv[1], "-s")) + { + silent = TRUE; + } + else if (! strcmp (argv[1], "-r")) + { + radio = TRUE; + } } for (i = 0; i < 256; i++) { - start_pulses[i] = 0; - start_pauses[i] = 0; - pulses[i] = 0; - pauses[i] = 0; + start_pulses[i] = 0; + start_pauses[i] = 0; + pulses[i] = 0; + pauses[i] = 0; } IRMP_PIN = 0xFF; while ((ch = getchar ()) != EOF) { - if (ch == '_' || ch == '0') - { - if (last_ch != ch) - { - if (pause > 0) - { - if (list) - { - printf ("pause: %d\n", pause); - } - - if (analyze) - { - if (first_pause) - { - if (pause < 256) - { - start_pauses[pause]++; - } - first_pause = FALSE; - } - else - { - if (pause < 256) - { - pauses[pause]++; - } - } - } - } - pause = 0; - } - pulse++; - IRMP_PIN = 0x00; - } - else if (ch == 0xaf || ch == '-' || ch == '1') - { - if (last_ch != ch) - { - if (list) - { - printf ("pulse: %d ", pulse); - } - - if (analyze) - { - if (first_pulse) - { - if (pulse < 256) - { - start_pulses[pulse]++; - } - first_pulse = FALSE; - } - else - { - if (pulse < 256) - { - pulses[pulse]++; - } - } - } - pulse = 0; - } - - pause++; - IRMP_PIN = 0xff; - } - else if (ch == '\n') - { - IRMP_PIN = 0xff; - time_counter = 0; - - if (list && pause > 0) - { - printf ("pause: %d\n", pause); - } - pause = 0; - - if (! analyze) - { - for (i = 0; i < (int) ((10000.0 * F_INTERRUPTS) / 10000); i++) // newline: long pause of 10000 msec - { - next_tick (); - } - } - first_pulse = TRUE; - first_pause = TRUE; - } - else if (ch == '#') - { - time_counter = 0; - - if (analyze) - { - while ((ch = getchar()) != '\n' && ch != EOF) - { - ; - } - } - else - { - char buf[1024]; - char * p; - int idx = -1; - - puts ("----------------------------------------------------------------------"); - putchar (ch); - - - while ((ch = getchar()) != '\n' && ch != EOF) - { - if (ch != '\r') // ignore CR in DOS/Windows files - { - if (ch == '[' && idx == -1) - { - idx = 0; - } - else if (idx >= 0) - { - if (ch == ']') - { - do_check_expected_values = FALSE; - buf[idx] = '\0'; - idx = -1; - - expected_protocol = atoi (buf); - - if (expected_protocol > 0) - { - p = buf; - while (*p) - { - if (*p == 'x') - { - p++; - - if (sscanf (p, "%x", &expected_address) == 1) - { - do_check_expected_values = TRUE; - } - break; - } - p++; - } - - if (do_check_expected_values) - { - do_check_expected_values = FALSE; - - while (*p) - { - if (*p == 'x') - { - p++; - - if (sscanf (p, "%x", &expected_command) == 1) - { - do_check_expected_values = TRUE; - } - break; - } - p++; - } - - if (do_check_expected_values) - { - // printf ("!%2d %04x %04x!\n", expected_protocol, expected_address, expected_command); - } - } - } - } - else if (idx < 1024 - 2) - { - buf[idx++] = ch; - } - } - putchar (ch); - } - } - putchar ('\n'); - } - - } - - last_ch = ch; - - next_tick (); + if (ch == '_' || ch == '0') + { + if (last_ch != ch) + { + if (pause > 0) + { + if (list) + { + printf ("pause: %d\n", pause); + } + + if (analyze) + { + if (first_pause) + { + if (pause < 256) + { + start_pauses[pause]++; + } + first_pause = FALSE; + } + else + { + if (pause < 256) + { + pauses[pause]++; + } + } + } + } + pause = 0; + } + pulse++; + IRMP_PIN = 0x00; + } + else if (ch == 0xaf || ch == '-' || ch == '1') + { + if (last_ch != ch) + { + if (list) + { + printf ("pulse: %d ", pulse); + } + + if (analyze) + { + if (first_pulse) + { + if (pulse < 256) + { + start_pulses[pulse]++; + } + first_pulse = FALSE; + } + else + { + if (pulse < 256) + { + pulses[pulse]++; + } + } + } + pulse = 0; + } + + pause++; + IRMP_PIN = 0xff; + } + else if (ch == '\n') + { + IRMP_PIN = 0xff; + time_counter = 0; + + if (list && pause > 0) + { + printf ("pause: %d\n", pause); + } + pause = 0; + + if (! analyze) + { + for (i = 0; i < (int) ((10000.0 * F_INTERRUPTS) / 10000); i++) // newline: long pause of 10000 msec + { + next_tick (); + } + } + first_pulse = TRUE; + first_pause = TRUE; + } + else if (ch == '#') + { + time_counter = 0; + + if (analyze) + { + while ((ch = getchar()) != '\n' && ch != EOF) + { + ; + } + } + else + { + char buf[1024]; + char * p; + int idx = -1; + + puts ("----------------------------------------------------------------------"); + putchar (ch); + + + while ((ch = getchar()) != '\n' && ch != EOF) + { + if (ch != '\r') // ignore CR in DOS/Windows files + { + if (ch == '[' && idx == -1) + { + idx = 0; + } + else if (idx >= 0) + { + if (ch == ']') + { + do_check_expected_values = FALSE; + buf[idx] = '\0'; + idx = -1; + + expected_protocol = atoi (buf); + + if (expected_protocol > 0) + { + p = buf; + while (*p) + { + if (*p == 'x') + { + p++; + + if (sscanf (p, "%x", &expected_address) == 1) + { + do_check_expected_values = TRUE; + } + break; + } + p++; + } + + if (do_check_expected_values) + { + do_check_expected_values = FALSE; + + while (*p) + { + if (*p == 'x') + { + p++; + + if (sscanf (p, "%x", &expected_command) == 1) + { + do_check_expected_values = TRUE; + } + break; + } + p++; + } + + if (do_check_expected_values) + { + // printf ("!%2d %04x %04x!\n", expected_protocol, expected_address, expected_command); + } + } + } + } + else if (idx < 1024 - 2) + { + buf[idx++] = ch; + } + } + putchar (ch); + } + } + putchar ('\n'); + } + + } + + last_ch = ch; + + next_tick (); } if (analyze) { - print_spectrum ("START PULSES", start_pulses, TRUE); - print_spectrum ("START PAUSES", start_pauses, FALSE); - print_spectrum ("PULSES", pulses, TRUE); - print_spectrum ("PAUSES", pauses, FALSE); - puts ("-----------------------------------------------------------------------------"); + print_spectrum ("START PULSES", start_pulses, TRUE); + print_spectrum ("START PAUSES", start_pauses, FALSE); + print_spectrum ("PULSES", pulses, TRUE); + print_spectrum ("PAUSES", pauses, FALSE); + puts ("-----------------------------------------------------------------------------"); } return 0; } diff --git a/irmp.h b/irmp.h index fd027b9..eec62de 100644 --- a/irmp.h +++ b/irmp.h @@ -3,7 +3,7 @@ * * Copyright (c) 2009-2015 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp.h,v 1.98 2015/11/10 08:39:27 fm Exp $ + * $Id: irmp.h,v 1.100 2015/11/17 13:51:45 fm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -80,6 +80,12 @@ # define IRMP_BIT IRMP_BIT_NUMBER # define input(x) ((x) & (1 << IRMP_BIT)) +#elif defined (TEENSY_ARM_CORTEX_M4) +# define input(x) ((uint8_t)(digitalReadFast(x))) + +#elif defined(__xtensa__) +# define IRMP_BIT IRMP_BIT_NUMBER +# define input(x) GPIO_INPUT_GET(IRMP_BIT_NUMBER) #endif #if IRMP_SUPPORT_TECHNICS_PROTOCOL == 1 @@ -94,6 +100,13 @@ # define IRMP_SUPPORT_RUWIDO_PROTOCOL 0 #endif +#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 && IRMP_SUPPORT_PANASONIC_PROTOCOL == 1 +# warning KASEIKYO protocol conflicts wih PANASONIC, please enable only one of both protocols +# warning PANASONIC protocol disabled +# undef IRMP_SUPPORT_PANASONIC_PROTOCOL +# define IRMP_SUPPORT_PANASONIC_PROTOCOL 0 +#endif + #if IRMP_SUPPORT_DENON_PROTOCOL == 1 && IRMP_SUPPORT_ACP24_PROTOCOL == 1 # warning DENON protocol conflicts wih ACP24, please enable only one of both protocols # warning ACP24 protocol disabled @@ -217,6 +230,11 @@ #define IRMP_FLAG_REPETITION 0x01 +#ifdef __cplusplus +extern "C" +{ +#endif + extern void irmp_init (void); extern uint_fast8_t irmp_get_data (IRMP_DATA *); extern uint_fast8_t irmp_ISR (void); @@ -229,4 +247,8 @@ extern const char * const irmp_protocol_names[IRMP_N_PROTOCOLS + 1 extern void irmp_set_callback_ptr (void (*cb)(uint_fast8_t)); #endif // IRMP_USE_CALLBACK == 1 +#ifdef __cplusplus +} +#endif + #endif /* _IRMP_H_ */ diff --git a/irmpconfig.h b/irmpconfig.h index bc5b412..3517fca 100644 --- a/irmpconfig.h +++ b/irmpconfig.h @@ -6,7 +6,7 @@ * Copyright (c) 2009-2015 Frank Meyer - frank(at)fli4l.de * Extensions for PIC 12F1820 W.Strobl 2014-07-20 * - * $Id: irmpconfig.h,v 1.138 2015/11/10 08:47:56 fm Exp $ + * $Id: irmpconfig.h,v 1.144 2015/11/17 13:54:09 fm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -96,6 +96,7 @@ #define IRMP_SUPPORT_S100_PROTOCOL 0 // S100 >= 10000 ~250 bytes #define IRMP_SUPPORT_ACP24_PROTOCOL 0 // ACP24 >= 10000 ~250 bytes #define IRMP_SUPPORT_TECHNICS_PROTOCOL 0 // TECHNICS >= 10000 ~250 bytes +#define IRMP_SUPPORT_PANASONIC_PROTOCOL 0 // PANASONIC Beamer >= 10000 ~250 bytes #define IRMP_SUPPORT_RADIO1_PROTOCOL 0 // RADIO, e.g. TEVION >= 10000 ~250 bytes (experimental) /*--------------------------------------------------------------------------------------------------------------------------------------------------- @@ -148,6 +149,20 @@ # define IRMP_PORT_LETTER A # define IRMP_BIT_NUMBER 1 +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * Change hardware pin here for ESP8266 + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ +#elif defined (__xtensa__) +# define IRMP_BIT_NUMBER 12 // use GPIO12 (Pin 7 UEXT) on ESP8266-EVB evaluation board + +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * Change hardware pin here for Teensy 3.x with teensyduino gcc compiler + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ +#elif defined (TEENSY_ARM_CORTEX_M4) +# define IRMP_PIN 1 // use Digital pin 1 as IR input on Teensy + /*--------------------------------------------------------------------------------------------------------------------------------------------------- * Handling of unknown target system: DON'T CHANGE *--------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/irmpextlog.h b/irmpextlog.h index efbea47..fb5f100 100644 --- a/irmpextlog.h +++ b/irmpextlog.h @@ -1,7 +1,16 @@ #ifndef _IRMPEXTLOG_H #define _IRMPEXTLOG_H +#ifdef __cplusplus +extern "C" +{ +#endif + void initextlog (void); void sendextlog (unsigned char); +#ifdef __cplusplus +} +#endif + #endif diff --git a/irmpprotocols.h b/irmpprotocols.h index 127268d..9a379be 100644 --- a/irmpprotocols.h +++ b/irmpprotocols.h @@ -5,7 +5,7 @@ * * Copyright (c) 2013-2015 Frank Meyer - frank(at)fli4l.de * - * $Id: irmpprotocols.h,v 1.38 2015/09/20 10:51:37 fm Exp $ + * $Id: irmpprotocols.h,v 1.42 2015/11/13 15:13:23 fm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -72,9 +72,11 @@ #define IRMP_S100_PROTOCOL 45 // very similar to RC5, but 14 instead of 13 data bits #define IRMP_ACP24_PROTOCOL 46 // Stiebel Eltron ACP24 air conditioner #define IRMP_TECHNICS_PROTOCOL 47 // Technics, similar to Matsushita, but 22 instead of 24 bits -#define IRMP_RADIO1_PROTOCOL 48 // Radio protocol (experimental status), do not use it yet! +#define IRMP_PANASONIC_PROTOCOL 48 // Panasonic (Beamer), start bits similar to KASEIKYO -#define IRMP_N_PROTOCOLS 48 // number of supported protocols +#define IRMP_RADIO1_PROTOCOL 49 // Radio protocol (experimental status), do not use it yet! + +#define IRMP_N_PROTOCOLS 50 // number of supported protocols /*--------------------------------------------------------------------------------------------------------------------------------------------------- * timing constants: @@ -251,6 +253,27 @@ typedef uint8_t PAUSE_LEN; #define KASEIKYO_FRAMES 2 // KASEIKYO sends 1st frame 2 times #define KASEIKYO_FLAGS 0 // flags +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * PANASONIC (Beamer), start bit timings similar to KASEIKYO + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ +#define PANASONIC_START_BIT_PULSE_TIME 3600.0e-6 // 3600 usec pulse +#define PANASONIC_START_BIT_PAUSE_TIME 1600.0e-6 // 1690 usec pause +#define PANASONIC_PULSE_TIME 565.0e-6 // 565 usec pulse +#define PANASONIC_1_PAUSE_TIME 1140.0e-6 // 1140 usec pause +#define PANASONIC_0_PAUSE_TIME 316.0e-6 // 316 usec pause +#define PANASONIC_AUTO_REPETITION_PAUSE_TIME 40.0e-3 // repetition after 40 ms? +#define PANASONIC_FRAME_REPEAT_PAUSE_TIME 40.0e-3 // frame repeat after 40 ms +#define PANASONIC_ADDRESS_OFFSET 24 // skip 24 bits: 010000000000010000000001 +#define PANASONIC_ADDRESS_LEN 16 // read 16 address bits +#define PANASONIC_COMMAND_OFFSET 40 // skip 40 bits +#define PANASONIC_COMMAND_LEN 16 // read 16 command bits +#define PANASONIC_COMPLETE_DATA_LEN 56 // complete length +#define PANASONIC_STOP_BIT 1 // has stop bit +#define PANASONIC_LSB 1 // LSB...MSB? +#define PANASONIC_FRAMES 1 // PANASONIC sends 1 frame +#define PANASONIC_FLAGS 0 // flags + /*--------------------------------------------------------------------------------------------------------------------------------------------------- * RECS80: *--------------------------------------------------------------------------------------------------------------------------------------------------- @@ -310,8 +333,8 @@ typedef uint8_t PAUSE_LEN; #define DENON_1_PAUSE_TIME 1780.0e-6 // 1780 usec pause in practice, 1900 in theory #define DENON_0_PAUSE_TIME 745.0e-6 // 745 usec pause in practice, 775 in theory #define DENON_FRAMES 2 // DENON sends each frame 2 times -#define DENON_AUTO_REPETITION_PAUSE_TIME 65.0e-3 // inverted repetition after 65ms -#define DENON_FRAME_REPEAT_PAUSE_TIME 130.0e-3 // frame repeat after 2 * 65ms +#define DENON_AUTO_REPETITION_PAUSE_TIME 45.0e-3 // inverted repetition after 45ms +#define DENON_FRAME_REPEAT_PAUSE_TIME 45.0e-3 // frame repeat after 45ms #define DENON_ADDRESS_OFFSET 0 // skip 0 bits #define DENON_ADDRESS_LEN 5 // read 5 address bits #define DENON_COMMAND_OFFSET 5 // skip 5 @@ -328,7 +351,9 @@ typedef uint8_t PAUSE_LEN; #define RC6_START_BIT_PULSE_TIME 2666.0e-6 // 2.666 msec pulse #define RC6_START_BIT_PAUSE_TIME 889.0e-6 // 889 usec pause #define RC6_TOGGLE_BIT_TIME 889.0e-6 // 889 msec pulse/pause -#define RC6_BIT_TIME 444.0e-6 // 889 usec pulse/pause +#define RC6_BIT_TIME 444.0e-6 // 444 usec pulse/pause +#define RC6_BIT_2_TIME 889.0e-6 // 889 usec pulse/pause +#define RC6_BIT_3_TIME 1333.0e-6 // 1333 usec pulse/pause #define RC6_FRAME_REPEAT_PAUSE_TIME 45.0e-3 // frame repeat after 45ms #define RC6_ADDRESS_OFFSET 5 // skip "1" + 3 mode bits + 1 toggle bit #define RC6_ADDRESS_LEN 8 // read 8 address bits @@ -403,7 +428,7 @@ typedef uint8_t PAUSE_LEN; #define FAN_COMMAND_OFFSET 0 // skip 0 bits #define FAN_COMMAND_LEN 11 // read 10 bits #define FAN_COMPLETE_DATA_LEN 11 // complete length -#define FAN_STOP_BIT 0 // has NO stop bit +#define FAN_STOP_BIT 0 // has NO stop bit (fm: this seems to be wrong) #define FAN_LSB 0 // MSB #define FAN_FLAGS 0 // flags @@ -700,7 +725,9 @@ typedef uint8_t PAUSE_LEN; #define BOSE_PULSE_TIME 550.0e-6 // 550 usec pulse #define BOSE_1_PAUSE_TIME 1425.0e-6 // 1425 usec pause #define BOSE_0_PAUSE_TIME 437.0e-6 // 437 usec pause -#define BOSE_FRAME_REPEAT_PAUSE_TIME 40.0e-3 // frame repeat after 40ms??? +#define BOSE_FRAMES 1 +#define BOSE_AUTO_REPETITION_PAUSE_TIME 40.0e-3 // repetition after 40ms? +#define BOSE_FRAME_REPEAT_PAUSE_TIME 40.0e-3 // frame repeat after 40ms? #define BOSE_ADDRESS_OFFSET 0 // skip 0 bits #define BOSE_ADDRESS_LEN 0 // read 16 address bits #define BOSE_COMMAND_OFFSET 0 // skip 16 bits (8 address + 8 /address) @@ -807,7 +834,7 @@ typedef uint8_t PAUSE_LEN; #define ROOMBA_COMMAND_OFFSET 0 // skip 0 bits #define ROOMBA_COMMAND_LEN 7 // read 7 bits #define ROOMBA_COMPLETE_DATA_LEN 7 // complete length -#define ROOMBA_STOP_BIT 0 // has stop bit +#define ROOMBA_STOP_BIT 0 // has stop bit (fm: sure?) #define ROOMBA_LSB 0 // MSB...LSB #define ROOMBA_FLAGS 0 // flags #define ROOMBA_FRAMES 8 // ROOMBA sends 8 frames (this is a lie, but more comfortable) diff --git a/irmpsystem.h b/irmpsystem.h index 07e4ef1..afa3c8c 100644 --- a/irmpsystem.h +++ b/irmpsystem.h @@ -3,7 +3,7 @@ * * Copyright (c) 2009-2015 Frank Meyer - frank(at)fli4l.de * - * $Id: irmpsystem.h,v 1.19 2015/11/10 08:39:28 fm Exp $ + * $Id: irmpsystem.h,v 1.20 2015/11/17 13:51:45 fm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -48,6 +48,17 @@ #elif defined(TARGET_IS_BLIZZARD_RA2) // TI Stellaris (tested on Stellaris Launchpad with Code Composer Studio) # define STELLARIS_ARM_CORTEX_M4 # define F_CPU (SysCtlClockGet()) +#elif defined(__xtensa__) +# include "ets_sys.h" +# include "osapi.h" +# include "gpio.h" +# include "os_type.h" +# include "c_types.h" +# define uint_fast8_t uint8_t +# define uint_fast16_t uint16_t +#elif defined(TEENSYDUINO) && (defined(__MK20DX256__) || defined(__MK20DX128__)) // Teensy 3.x (tested on Teensy 3.1 in Arduino 1.6.5 / Teensyduino 1.2.5) +# include +# define TEENSY_ARM_CORTEX_M4 #elif defined(unix) || defined(WIN32) || defined(__APPLE__) // Unix/Linux or Windows or Apple # define UNIX_OR_WINDOWS #else @@ -127,8 +138,11 @@ typedef unsigned short uint16_t; # define uint_fast8_t uint8_t # define uint_fast16_t uint16_t -#else +#elif defined(TEENSY_ARM_CORTEX_M4) +# define PROGMEM +# define memcpy_P memcpy +#else # define PROGMEM # define memcpy_P memcpy @@ -156,10 +170,10 @@ typedef unsigned short uint16_t; typedef struct __attribute__ ((__packed__)) { - uint8_t protocol; // protocol, e.g. NEC_PROTOCOL - uint16_t address; // address - uint16_t command; // command - uint8_t flags; // flags, e.g. repetition + uint8_t protocol; // protocol, e.g. NEC_PROTOCOL + uint16_t address; // address + uint16_t command; // command + uint8_t flags; // flags, e.g. repetition } IRMP_DATA; #endif // _IRMPSYSTEM_H_ diff --git a/irsnd.c b/irsnd.c index 8420675..4057060 100644 --- a/irsnd.c +++ b/irsnd.c @@ -13,7 +13,7 @@ * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284, ATmega1284P * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P * - * $Id: irsnd.c,v 1.91 2015/09/20 10:51:37 fm Exp $ + * $Id: irsnd.c,v 1.96 2015/11/17 13:51:45 fm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -166,6 +166,10 @@ //Nothing here to do here -> See irsndconfig.h #elif defined (ARM_STM32) //STM32 //Nothing here to do here -> See irsndconfig.h +#elif defined (TEENSY_ARM_CORTEX_M4) // Teensy3 +# if !digitalPinHasPWM(IRSND_PIN) +# error need pin with PWM output. +# endif #else # if !defined (unix) && !defined (WIN32) # error mikrocontroller not defined, please fill in definitions here. @@ -241,6 +245,14 @@ #define KASEIKYO_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * KASEIKYO_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! #define KASEIKYO_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * KASEIKYO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define PANASONIC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PULSE_TIME + 0.5) +#define PANASONIC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PAUSE_TIME + 0.5) +#define PANASONIC_PULSE_LEN (uint8_t)(F_INTERRUPTS * PANASONIC_PULSE_TIME + 0.5) +#define PANASONIC_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * PANASONIC_1_PAUSE_TIME + 0.5) +#define PANASONIC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * PANASONIC_0_PAUSE_TIME + 0.5) +#define PANASONIC_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * PANASONIC_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! +#define PANASONIC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * PANASONIC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! + #define RECS80_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME + 0.5) #define RECS80_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME + 0.5) #define RECS80_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME + 0.5) @@ -254,8 +266,9 @@ #define RC6_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME + 0.5) #define RC6_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME + 0.5) -#define RC6_TOGGLE_BIT_LEN (uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME + 0.5) #define RC6_BIT_LEN (uint8_t)(F_INTERRUPTS * RC6_BIT_TIME + 0.5) +#define RC6_BIT_2_LEN (uint8_t)(F_INTERRUPTS * RC6_BIT_2_TIME + 0.5) +#define RC6_BIT_3_LEN (uint8_t)(F_INTERRUPTS * RC6_BIT_3_TIME + 0.5) #define RC6_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * RC6_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! #define DENON_PULSE_LEN (uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME + 0.5) @@ -285,6 +298,14 @@ #define TELEFUNKEN_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * TELEFUNKEN_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! #define TELEFUNKEN_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * TELEFUNKEN_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define BOSE_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * BOSE_START_BIT_PULSE_TIME + 0.5) +#define BOSE_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BOSE_START_BIT_PAUSE_TIME + 0.5) +#define BOSE_PULSE_LEN (uint8_t)(F_INTERRUPTS * BOSE_PULSE_TIME + 0.5) +#define BOSE_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BOSE_1_PAUSE_TIME + 0.5) +#define BOSE_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * BOSE_0_PAUSE_TIME + 0.5) +#define BOSE_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * BOSE_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! +#define BOSE_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * BOSE_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! + #define NUBERT_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME + 0.5) #define NUBERT_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME + 0.5) #define NUBERT_1_PULSE_LEN (uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME + 0.5) @@ -361,6 +382,15 @@ # define IRSND_FREQ_40_KHZ (IRSND_FREQ_TYPE) (40000) # define IRSND_FREQ_56_KHZ (IRSND_FREQ_TYPE) (56000) # define IRSND_FREQ_455_KHZ (IRSND_FREQ_TYPE) (455000) +#elif defined (TEENSY_ARM_CORTEX_M4) // TEENSY +# define IRSND_FREQ_TYPE float +# define IRSND_FREQ_30_KHZ (IRSND_FREQ_TYPE) (30000) +# define IRSND_FREQ_32_KHZ (IRSND_FREQ_TYPE) (32000) +# define IRSND_FREQ_36_KHZ (IRSND_FREQ_TYPE) (36000) +# define IRSND_FREQ_38_KHZ (IRSND_FREQ_TYPE) (38000) +# define IRSND_FREQ_40_KHZ (IRSND_FREQ_TYPE) (40000) +# define IRSND_FREQ_56_KHZ (IRSND_FREQ_TYPE) (56000) +# define IRSND_FREQ_455_KHZ (IRSND_FREQ_TYPE) (455000) #else // AVR # if F_CPU >= 16000000L # define AVR_PRESCALER 8 @@ -467,44 +497,47 @@ irsnd_on (void) { #ifndef ANALYZE # if defined(PIC_C18) // PIC C18 - PWMon(); - // IRSND_PIN = 0; // output mode -> enable PWM outout pin (0=PWM on, 1=PWM off) + PWMon(); + // IRSND_PIN = 0; // output mode -> enable PWM outout pin (0=PWM on, 1=PWM off) # elif defined (ARM_STM32) // STM32 - TIM_SelectOCxM(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_OCMode_PWM1); // enable PWM as OC-mode - TIM_CCxCmd(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_CCx_Enable); // enable OC-output (is being disabled in TIM_SelectOCxM()) - TIM_Cmd(IRSND_TIMER, ENABLE); // enable counter + TIM_SelectOCxM(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_OCMode_PWM1); // enable PWM as OC-mode + TIM_CCxCmd(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_CCx_Enable); // enable OC-output (is being disabled in TIM_SelectOCxM()) + TIM_Cmd(IRSND_TIMER, ENABLE); // enable counter + +# elif defined (TEENSY_ARM_CORTEX_M4) // TEENSY + analogWrite(IRSND_PIN, 33 * 255 / 100); // pwm 33% # elif defined (__AVR_XMEGA__) # if (IRSND_OCx == IRSND_XMEGA_OC0A) // use OC0A - XMEGA_Timer.CTRLB |= (1< disbale PWM output pin (0=PWM on, 1=PWM off) + PWMoff(); + // IRSND_PIN = 1; //input mode -> disbale PWM output pin (0=PWM on, 1=PWM off) # elif defined (ARM_STM32) // STM32 - TIM_Cmd(IRSND_TIMER, DISABLE); // disable counter - TIM_SelectOCxM(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_ForcedAction_InActive); // force output inactive - TIM_CCxCmd(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_CCx_Enable); // enable OC-output (is being disabled in TIM_SelectOCxM()) - TIM_SetCounter(IRSND_TIMER, 0); // reset counter value + TIM_Cmd(IRSND_TIMER, DISABLE); // disable counter + TIM_SelectOCxM(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_ForcedAction_InActive); // force output inactive + TIM_CCxCmd(IRSND_TIMER, IRSND_TIMER_CHANNEL, TIM_CCx_Enable); // enable OC-output (is being disabled in TIM_SelectOCxM()) + TIM_SetCounter(IRSND_TIMER, 0); // reset counter value + +# elif defined (TEENSY_ARM_CORTEX_M4) // TEENSY + analogWrite(IRSND_PIN, 0); // pwm off, LOW level # elif defined (__AVR_XMEGA__) # if (IRSND_OCx == IRSND_XMEGA_OC0A) // use OC0A - XMEGA_Timer.CTRLB &= ~(1<= 2) && (IRSND_TIMER_NUMBER <= 5)) || ((IRSND_TIMER_NUMBER >= 12) && (IRSND_TIMER_NUMBER <= 14)) - if (RCC_ClocksStructure.PCLK1_Frequency == RCC_ClocksStructure.HCLK_Frequency) - { - TimeBaseFreq = RCC_ClocksStructure.PCLK1_Frequency; - } - else - { - TimeBaseFreq = RCC_ClocksStructure.PCLK1_Frequency * 2; - } + if (RCC_ClocksStructure.PCLK1_Frequency == RCC_ClocksStructure.HCLK_Frequency) + { + TimeBaseFreq = RCC_ClocksStructure.PCLK1_Frequency; + } + else + { + TimeBaseFreq = RCC_ClocksStructure.PCLK1_Frequency * 2; + } # else - if (RCC_ClocksStructure.PCLK2_Frequency == RCC_ClocksStructure.HCLK_Frequency) - { - TimeBaseFreq = RCC_ClocksStructure.PCLK2_Frequency; - } - else - { - TimeBaseFreq = RCC_ClocksStructure.PCLK2_Frequency * 2; - } + if (RCC_ClocksStructure.PCLK2_Frequency == RCC_ClocksStructure.HCLK_Frequency) + { + TimeBaseFreq = RCC_ClocksStructure.PCLK2_Frequency; + } + else + { + TimeBaseFreq = RCC_ClocksStructure.PCLK2_Frequency * 2; + } # endif - } + } + + freq = TimeBaseFreq/freq; - freq = TimeBaseFreq/freq; + /* Set frequency */ + TIM_SetAutoreload(IRSND_TIMER, freq - 1); + /* Set duty cycle */ + TIM_SetCompare1(IRSND_TIMER, (freq + 1) / 2); - /* Set frequency */ - TIM_SetAutoreload(IRSND_TIMER, freq - 1); - /* Set duty cycle */ - TIM_SetCompare1(IRSND_TIMER, (freq + 1) / 2); +# elif defined (TEENSY_ARM_CORTEX_M4) + analogWriteResolution(8); // 8 bit + analogWriteFrequency(IRSND_PIN, freq); + analogWrite(IRSND_PIN, 0); // pwm off, LOW level # elif defined (__AVR_XMEGA__) - XMEGA_Timer.CCA = freq; + XMEGA_Timer.CCA = freq; # else // AVR # if IRSND_OCx == IRSND_OC2 - OCR2 = freq; // use register OCR2 for OC2 + OCR2 = freq; // use register OCR2 for OC2 # elif IRSND_OCx == IRSND_OC2A // use OC2A - OCR2A = freq; // use register OCR2A for OC2A and OC2B! + OCR2A = freq; // use register OCR2A for OC2A and OC2B! # elif IRSND_OCx == IRSND_OC2B // use OC2B - OCR2A = freq; // use register OCR2A for OC2A and OC2B! + OCR2A = freq; // use register OCR2A for OC2A and OC2B! # elif IRSND_OCx == IRSND_OC0 // use OC0 - OCR0 = freq; // use register OCR2 for OC2 + OCR0 = freq; // use register OCR2 for OC2 # elif IRSND_OCx == IRSND_OC0A // use OC0A - OCR0A = freq; // use register OCR0A for OC0A and OC0B! + OCR0A = freq; // use register OCR0A for OC0A and OC0B! # elif IRSND_OCx == IRSND_OC0B // use OC0B - OCR0A = freq; // use register OCR0A for OC0A and OC0B! + OCR0A = freq; // use register OCR0A for OC0A and OC0B! # else # error wrong value of IRSND_OCx # endif @@ -697,118 +738,124 @@ irsnd_init (void) #ifndef ANALYZE # if defined(PIC_C18) // PIC C18 or XC8 compiler # if ! defined(__12F1840) // only C18: - OpenTimer; + OpenTimer; # endif - irsnd_set_freq (IRSND_FREQ_36_KHZ); // default frequency - IRSND_PIN = 0; // set IO to outout - PWMoff(); + irsnd_set_freq (IRSND_FREQ_36_KHZ); // default frequency + IRSND_PIN = 0; // set IO to outout + PWMoff(); # elif defined (ARM_STM32) // STM32 - GPIO_InitTypeDef GPIO_InitStructure; - TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; - TIM_OCInitTypeDef TIM_OCInitStructure; + GPIO_InitTypeDef GPIO_InitStructure; + TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; + TIM_OCInitTypeDef TIM_OCInitStructure; /* GPIOx clock enable */ # if defined (ARM_STM32L1XX) - RCC_AHBPeriphClockCmd(IRSND_PORT_RCC, ENABLE); + RCC_AHBPeriphClockCmd(IRSND_PORT_RCC, ENABLE); # elif defined (ARM_STM32F10X) - RCC_APB2PeriphClockCmd(IRSND_PORT_RCC, ENABLE); - // RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); // only in case of remapping, not necessary for default port-timer mapping + RCC_APB2PeriphClockCmd(IRSND_PORT_RCC, ENABLE); + // RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); // only in case of remapping, not necessary for default port-timer mapping # elif defined (ARM_STM32F4XX) - RCC_AHB1PeriphClockCmd(IRSND_PORT_RCC, ENABLE); + RCC_AHB1PeriphClockCmd(IRSND_PORT_RCC, ENABLE); # endif - /* GPIO Configuration */ - GPIO_InitStructure.GPIO_Pin = IRSND_BIT; + /* GPIO Configuration */ + GPIO_InitStructure.GPIO_Pin = IRSND_BIT; # if defined (ARM_STM32L1XX) || defined (ARM_STM32F4XX) - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; - GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; - GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_Init(IRSND_PORT, &GPIO_InitStructure); - GPIO_PinAFConfig(IRSND_PORT, (uint8_t)IRSND_BIT_NUMBER, IRSND_GPIO_AF); + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; + GPIO_Init(IRSND_PORT, &GPIO_InitStructure); + GPIO_PinAFConfig(IRSND_PORT, (uint8_t)IRSND_BIT_NUMBER, IRSND_GPIO_AF); # elif defined (ARM_STM32F10X) - GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; - GPIO_Init(IRSND_PORT, &GPIO_InitStructure); - // GPIO_PinRemapConfig(GPIO_*Remap*_TIM[IRSND_TIMER_NUMBER], ENABLE); // only in case of remapping, not necessary for default port-timer mapping + GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; + GPIO_Init(IRSND_PORT, &GPIO_InitStructure); + // GPIO_PinRemapConfig(GPIO_*Remap*_TIM[IRSND_TIMER_NUMBER], ENABLE); // only in case of remapping, not necessary for default port-timer mapping # endif - /* TIMx clock enable */ + /* TIMx clock enable */ # if ((IRSND_TIMER_NUMBER >= 2) && (IRSND_TIMER_NUMBER <= 5)) || ((IRSND_TIMER_NUMBER >= 12) && (IRSND_TIMER_NUMBER <= 14)) - RCC_APB1PeriphClockCmd(IRSND_TIMER_RCC, ENABLE); + RCC_APB1PeriphClockCmd(IRSND_TIMER_RCC, ENABLE); # else - RCC_APB2PeriphClockCmd(IRSND_TIMER_RCC, ENABLE); + RCC_APB2PeriphClockCmd(IRSND_TIMER_RCC, ENABLE); # endif - /* Time base configuration */ - TIM_TimeBaseStructure.TIM_Period = -1; // set dummy value (don't set to 0), will be initialized later - TIM_TimeBaseStructure.TIM_Prescaler = 0; - TIM_TimeBaseStructure.TIM_ClockDivision = 0; - TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; - TIM_TimeBaseInit(IRSND_TIMER, &TIM_TimeBaseStructure); - - /* PWM1 Mode configuration */ - TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; - TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; - TIM_OCInitStructure.TIM_Pulse = 0; // will be initialized later - TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; - TIM_OC1Init(IRSND_TIMER, &TIM_OCInitStructure); - - /* Preload configuration */ - TIM_ARRPreloadConfig(IRSND_TIMER, ENABLE); - TIM_OC1PreloadConfig(IRSND_TIMER, TIM_OCPreload_Enable); - - irsnd_set_freq (IRSND_FREQ_36_KHZ); // set default frequency + /* Time base configuration */ + TIM_TimeBaseStructure.TIM_Period = -1; // set dummy value (don't set to 0), will be initialized later + TIM_TimeBaseStructure.TIM_Prescaler = 0; + TIM_TimeBaseStructure.TIM_ClockDivision = 0; + TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; + TIM_TimeBaseInit(IRSND_TIMER, &TIM_TimeBaseStructure); + + /* PWM1 Mode configuration */ + TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; + TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable; + TIM_OCInitStructure.TIM_Pulse = 0; // will be initialized later + TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; + TIM_OC1Init(IRSND_TIMER, &TIM_OCInitStructure); + + /* Preload configuration */ + TIM_ARRPreloadConfig(IRSND_TIMER, ENABLE); + TIM_OC1PreloadConfig(IRSND_TIMER, TIM_OCPreload_Enable); + + irsnd_set_freq (IRSND_FREQ_36_KHZ); // set default frequency + +# elif defined (TEENSY_ARM_CORTEX_M4) + if (!digitalPinHasPWM(IRSND_PIN)) + { + return; + } -# elif defined (__AVR_XMEGA__) - IRSND_PORT &= ~(1<>= 1; - len--; + xx <<= 1; + if (x & 1) + { + xx |= 1; + } + x >>= 1; + len--; } return xx; } @@ -873,14 +920,14 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) if (do_wait) { - while (irsnd_busy) - { - // do nothing; - } + while (irsnd_busy) + { + // do nothing; + } } else if (irsnd_busy) { - return (FALSE); + return (FALSE); } irsnd_protocol = irmp_data_p->protocol; @@ -889,552 +936,581 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) switch (irsnd_protocol) { #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 - case IRMP_SIRCS_PROTOCOL: - { - // uint8_t sircs_additional_command_len; - uint8_t sircs_additional_address_len; - - sircs_additional_bitlen = (irmp_data_p->address & 0xFF00) >> 8; // additional bitlen - - if (sircs_additional_bitlen > 15 - SIRCS_MINIMUM_DATA_LEN) - { - // sircs_additional_command_len = 15 - SIRCS_MINIMUM_DATA_LEN; - sircs_additional_address_len = sircs_additional_bitlen - (15 - SIRCS_MINIMUM_DATA_LEN); - } - else - { - // sircs_additional_command_len = sircs_additional_bitlen; - sircs_additional_address_len = 0; - } - - command = bitsrevervse (irmp_data_p->command, 15); - - irsnd_buffer[0] = (command & 0x7F80) >> 7; // CCCCCCCC - irsnd_buffer[1] = (command & 0x007F) << 1; // CCCC**** - - if (sircs_additional_address_len > 0) - { - address = bitsrevervse (irmp_data_p->address, 5); - irsnd_buffer[1] |= (address & 0x0010) >> 4; - irsnd_buffer[2] = (address & 0x000F) << 4; - } - irsnd_busy = TRUE; - break; - } + case IRMP_SIRCS_PROTOCOL: + { + // uint8_t sircs_additional_command_len; + uint8_t sircs_additional_address_len; + + sircs_additional_bitlen = (irmp_data_p->address & 0xFF00) >> 8; // additional bitlen + + if (sircs_additional_bitlen > 15 - SIRCS_MINIMUM_DATA_LEN) + { + // sircs_additional_command_len = 15 - SIRCS_MINIMUM_DATA_LEN; + sircs_additional_address_len = sircs_additional_bitlen - (15 - SIRCS_MINIMUM_DATA_LEN); + } + else + { + // sircs_additional_command_len = sircs_additional_bitlen; + sircs_additional_address_len = 0; + } + + command = bitsrevervse (irmp_data_p->command, 15); + + irsnd_buffer[0] = (command & 0x7F80) >> 7; // CCCCCCCC + irsnd_buffer[1] = (command & 0x007F) << 1; // CCCC**** + + if (sircs_additional_address_len > 0) + { + address = bitsrevervse (irmp_data_p->address, 5); + irsnd_buffer[1] |= (address & 0x0010) >> 4; + irsnd_buffer[2] = (address & 0x000F) << 4; + } + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_NEC_PROTOCOL == 1 - case IRMP_APPLE_PROTOCOL: - { - command = irmp_data_p->command | (irmp_data_p->address << 8); // store address as ID in upper byte of command - address = 0x87EE; // set fixed NEC-lookalike address (customer ID of apple) - - address = bitsrevervse (address, NEC_ADDRESS_LEN); - command = bitsrevervse (command, NEC_COMMAND_LEN); - - irsnd_protocol = IRMP_NEC_PROTOCOL; // APPLE protocol is NEC with id instead of inverted command - - irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA - irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA - irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC - irsnd_buffer[3] = 0x8B; // 10001011 (id) - irsnd_busy = TRUE; - break; - } - case IRMP_NEC_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, NEC_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, NEC_COMMAND_LEN); - - irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA - irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA - irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC - irsnd_buffer[3] = ~((command & 0xFF00) >> 8); // cccccccc - irsnd_busy = TRUE; - break; - } + case IRMP_APPLE_PROTOCOL: + { + command = irmp_data_p->command | (irmp_data_p->address << 8); // store address as ID in upper byte of command + address = 0x87EE; // set fixed NEC-lookalike address (customer ID of apple) + + address = bitsrevervse (address, NEC_ADDRESS_LEN); + command = bitsrevervse (command, NEC_COMMAND_LEN); + + irsnd_protocol = IRMP_NEC_PROTOCOL; // APPLE protocol is NEC with id instead of inverted command + + irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA + irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA + irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC + irsnd_buffer[3] = 0x8B; // 10001011 (id) + irsnd_busy = TRUE; + break; + } + case IRMP_NEC_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, NEC_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, NEC_COMMAND_LEN); + + irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA + irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA + irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC + irsnd_buffer[3] = ~((command & 0xFF00) >> 8); // cccccccc + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_NEC16_PROTOCOL == 1 - case IRMP_NEC16_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, NEC16_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, NEC16_COMMAND_LEN); - - irsnd_buffer[0] = (address & 0x00FF); // AAAAAAAA - irsnd_buffer[1] = (command & 0x00FF); // CCCCCCCC - irsnd_busy = TRUE; - break; - } + case IRMP_NEC16_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, NEC16_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, NEC16_COMMAND_LEN); + + irsnd_buffer[0] = (address & 0x00FF); // AAAAAAAA + irsnd_buffer[1] = (command & 0x00FF); // CCCCCCCC + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_NEC42_PROTOCOL == 1 - case IRMP_NEC42_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, NEC42_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, NEC42_COMMAND_LEN); - - irsnd_buffer[0] = ( (address & 0x1FE0) >> 5); // AAAAAAAA - irsnd_buffer[1] = ( (address & 0x001F) << 3) | ((~address & 0x1C00) >> 10); // AAAAAaaa - irsnd_buffer[2] = ((~address & 0x03FC) >> 2); // aaaaaaaa - irsnd_buffer[3] = ((~address & 0x0003) << 6) | ( (command & 0x00FC) >> 2); // aaCCCCCC - irsnd_buffer[4] = ( (command & 0x0003) << 6) | ((~command & 0x00FC) >> 2); // CCcccccc - irsnd_buffer[5] = ((~command & 0x0003) << 6); // cc - irsnd_busy = TRUE; - break; - } + case IRMP_NEC42_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, NEC42_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, NEC42_COMMAND_LEN); + + irsnd_buffer[0] = ( (address & 0x1FE0) >> 5); // AAAAAAAA + irsnd_buffer[1] = ( (address & 0x001F) << 3) | ((~address & 0x1C00) >> 10); // AAAAAaaa + irsnd_buffer[2] = ((~address & 0x03FC) >> 2); // aaaaaaaa + irsnd_buffer[3] = ((~address & 0x0003) << 6) | ( (command & 0x00FC) >> 2); // aaCCCCCC + irsnd_buffer[4] = ( (command & 0x0003) << 6) | ((~command & 0x00FC) >> 2); // CCcccccc + irsnd_buffer[5] = ((~command & 0x0003) << 6); // cc + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_LGAIR_PROTOCOL == 1 - case IRMP_LGAIR_PROTOCOL: - { - address = irmp_data_p->address; - command = irmp_data_p->command; - - irsnd_buffer[0] = ( (address & 0x00FF)); // AAAAAAAA - irsnd_buffer[1] = ( (command & 0xFF00) >> 8); // CCCCCCCC - irsnd_buffer[2] = ( (command & 0x00FF)); // CCCCCCCC - irsnd_buffer[3] = (( ((command & 0xF000) >> 12) + // checksum - ((command & 0x0F00) >> 8) + - ((command & 0x00F0) >>4 ) + - ((command & 0x000F))) & 0x000F) << 4; - irsnd_busy = TRUE; - break; - } + case IRMP_LGAIR_PROTOCOL: + { + address = irmp_data_p->address; + command = irmp_data_p->command; + + irsnd_buffer[0] = ( (address & 0x00FF)); // AAAAAAAA + irsnd_buffer[1] = ( (command & 0xFF00) >> 8); // CCCCCCCC + irsnd_buffer[2] = ( (command & 0x00FF)); // CCCCCCCC + irsnd_buffer[3] = (( ((command & 0xF000) >> 12) + // checksum + ((command & 0x0F00) >> 8) + + ((command & 0x00F0) >>4 ) + + ((command & 0x000F))) & 0x000F) << 4; + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 - case IRMP_SAMSUNG_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, SAMSUNG_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, SAMSUNG_COMMAND_LEN); - - irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA - irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA - irsnd_buffer[2] = (command & 0x00F0) | ((command & 0xF000) >> 12); // IIIICCCC - irsnd_buffer[3] = ((command & 0x0F00) >> 4) | ((~(command & 0xF000) >> 12) & 0x0F); // CCCCcccc - irsnd_buffer[4] = (~(command & 0x0F00) >> 4) & 0xF0; // cccc0000 - irsnd_busy = TRUE; - break; - } - case IRMP_SAMSUNG32_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, SAMSUNG_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, SAMSUNG32_COMMAND_LEN); - - irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA - irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA - irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC - irsnd_buffer[3] = (command & 0x00FF); // CCCCCCCC - irsnd_busy = TRUE; - break; - } + case IRMP_SAMSUNG_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, SAMSUNG_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, SAMSUNG_COMMAND_LEN); + + irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA + irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA + irsnd_buffer[2] = (command & 0x00F0) | ((command & 0xF000) >> 12); // IIIICCCC + irsnd_buffer[3] = ((command & 0x0F00) >> 4) | ((~(command & 0xF000) >> 12) & 0x0F); // CCCCcccc + irsnd_buffer[4] = (~(command & 0x0F00) >> 4) & 0xF0; // cccc0000 + irsnd_busy = TRUE; + break; + } + case IRMP_SAMSUNG32_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, SAMSUNG_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, SAMSUNG32_COMMAND_LEN); + + irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA + irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA + irsnd_buffer[2] = (command & 0xFF00) >> 8; // CCCCCCCC + irsnd_buffer[3] = (command & 0x00FF); // CCCCCCCC + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_SAMSUNG48_PROTOCOL == 1 - case IRMP_SAMSUNG48_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, SAMSUNG_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, 16); - - irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA - irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA - irsnd_buffer[2] = ((command & 0xFF00) >> 8); // CCCCCCCC - irsnd_buffer[3] = ~((command & 0xFF00) >> 8); // cccccccc - irsnd_buffer[4] = (command & 0x00FF); // CCCCCCCC - irsnd_buffer[5] = ~(command & 0x00FF); // cccccccc - irsnd_busy = TRUE; - break; - } + case IRMP_SAMSUNG48_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, SAMSUNG_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, 16); + + irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA + irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA + irsnd_buffer[2] = ((command & 0xFF00) >> 8); // CCCCCCCC + irsnd_buffer[3] = ~((command & 0xFF00) >> 8); // cccccccc + irsnd_buffer[4] = (command & 0x00FF); // CCCCCCCC + irsnd_buffer[5] = ~(command & 0x00FF); // cccccccc + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 - case IRMP_MATSUSHITA_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, MATSUSHITA_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, MATSUSHITA_COMMAND_LEN); - - irsnd_buffer[0] = (command & 0x0FF0) >> 4; // CCCCCCCC - irsnd_buffer[1] = ((command & 0x000F) << 4) | ((address & 0x0F00) >> 8); // CCCCAAAA - irsnd_buffer[2] = (address & 0x00FF); // AAAAAAAA - irsnd_busy = TRUE; - break; - } + case IRMP_MATSUSHITA_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, MATSUSHITA_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, MATSUSHITA_COMMAND_LEN); + + irsnd_buffer[0] = (command & 0x0FF0) >> 4; // CCCCCCCC + irsnd_buffer[1] = ((command & 0x000F) << 4) | ((address & 0x0F00) >> 8); // CCCCAAAA + irsnd_buffer[2] = (address & 0x00FF); // AAAAAAAA + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_TECHNICS_PROTOCOL == 1 - case IRMP_TECHNICS_PROTOCOL: - { - command = bitsrevervse (irmp_data_p->command, TECHNICS_COMMAND_LEN); - - irsnd_buffer[0] = (command & 0x07FC) >> 3; // CCCCCCCC - irsnd_buffer[1] = ((command & 0x0007) << 5) | ((~command & 0x07C0) >> 6); // CCCccccc - irsnd_buffer[2] = (~command & 0x003F) << 2; // cccccc - irsnd_busy = TRUE; - break; - } + case IRMP_TECHNICS_PROTOCOL: + { + command = bitsrevervse (irmp_data_p->command, TECHNICS_COMMAND_LEN); + + irsnd_buffer[0] = (command & 0x07FC) >> 3; // CCCCCCCC + irsnd_buffer[1] = ((command & 0x0007) << 5) | ((~command & 0x07C0) >> 6); // CCCccccc + irsnd_buffer[2] = (~command & 0x003F) << 2; // cccccc + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 - case IRMP_KASEIKYO_PROTOCOL: - { - uint8_t xor_value; - uint16_t genre2; - - address = bitsrevervse (irmp_data_p->address, KASEIKYO_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, KASEIKYO_COMMAND_LEN + 4); - genre2 = bitsrevervse ((irmp_data_p->flags & ~IRSND_REPETITION_MASK) >> 4, 4); - - xor_value = ((address & 0x000F) ^ ((address & 0x00F0) >> 4) ^ ((address & 0x0F00) >> 8) ^ ((address & 0xF000) >> 12)) & 0x0F; - - irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA - irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA - irsnd_buffer[2] = xor_value << 4 | (command & 0x000F); // XXXXCCCC - irsnd_buffer[3] = (genre2 << 4) | (command & 0xF000) >> 12; // ggggCCCC - irsnd_buffer[4] = (command & 0x0FF0) >> 4; // CCCCCCCC - - xor_value = irsnd_buffer[2] ^ irsnd_buffer[3] ^ irsnd_buffer[4]; - - irsnd_buffer[5] = xor_value; - irsnd_busy = TRUE; - break; - } + case IRMP_KASEIKYO_PROTOCOL: + { + uint8_t xor_value; + uint16_t genre2; + + address = bitsrevervse (irmp_data_p->address, KASEIKYO_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, KASEIKYO_COMMAND_LEN + 4); + genre2 = bitsrevervse ((irmp_data_p->flags & ~IRSND_REPETITION_MASK) >> 4, 4); + + xor_value = ((address & 0x000F) ^ ((address & 0x00F0) >> 4) ^ ((address & 0x0F00) >> 8) ^ ((address & 0xF000) >> 12)) & 0x0F; + + irsnd_buffer[0] = (address & 0xFF00) >> 8; // AAAAAAAA + irsnd_buffer[1] = (address & 0x00FF); // AAAAAAAA + irsnd_buffer[2] = xor_value << 4 | (command & 0x000F); // XXXXCCCC + irsnd_buffer[3] = (genre2 << 4) | (command & 0xF000) >> 12; // ggggCCCC + irsnd_buffer[4] = (command & 0x0FF0) >> 4; // CCCCCCCC + + xor_value = irsnd_buffer[2] ^ irsnd_buffer[3] ^ irsnd_buffer[4]; + + irsnd_buffer[5] = xor_value; + irsnd_busy = TRUE; + break; + } +#endif +#if IRSND_SUPPORT_PANASONIC_PROTOCOL == 1 + case IRMP_PANASONIC_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, PANASONIC_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, PANASONIC_COMMAND_LEN); + + irsnd_buffer[0] = 0x40; // 01000000 + irsnd_buffer[1] = 0x04; // 00000100 + irsnd_buffer[2] = 0x01; // 00000001 + irsnd_buffer[3] = (address & 0xFF00) >> 8; // AAAAAAAA + irsnd_buffer[4] = (address & 0x00FF); // AAAAAAAA + irsnd_buffer[5] = (command & 0xFF00) >> 8; // CCCCCCCC + irsnd_buffer[6] = (command & 0x00FF); // CCCCCCCC + + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_RECS80_PROTOCOL == 1 - case IRMP_RECS80_PROTOCOL: - { - toggle_bit_recs80 = toggle_bit_recs80 ? 0x00 : 0x40; - - irsnd_buffer[0] = 0x80 | toggle_bit_recs80 | ((irmp_data_p->address & 0x0007) << 3) | - ((irmp_data_p->command & 0x0038) >> 3); // STAAACCC - irsnd_buffer[1] = (irmp_data_p->command & 0x07) << 5; // CCC00000 - irsnd_busy = TRUE; - break; - } + case IRMP_RECS80_PROTOCOL: + { + toggle_bit_recs80 = toggle_bit_recs80 ? 0x00 : 0x40; + + irsnd_buffer[0] = 0x80 | toggle_bit_recs80 | ((irmp_data_p->address & 0x0007) << 3) | + ((irmp_data_p->command & 0x0038) >> 3); // STAAACCC + irsnd_buffer[1] = (irmp_data_p->command & 0x07) << 5; // CCC00000 + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 - case IRMP_RECS80EXT_PROTOCOL: - { - toggle_bit_recs80ext = toggle_bit_recs80ext ? 0x00 : 0x40; - - irsnd_buffer[0] = 0x80 | toggle_bit_recs80ext | ((irmp_data_p->address & 0x000F) << 2) | - ((irmp_data_p->command & 0x0030) >> 4); // STAAAACC - irsnd_buffer[1] = (irmp_data_p->command & 0x0F) << 4; // CCCC0000 - irsnd_busy = TRUE; - break; - } + case IRMP_RECS80EXT_PROTOCOL: + { + toggle_bit_recs80ext = toggle_bit_recs80ext ? 0x00 : 0x40; + + irsnd_buffer[0] = 0x80 | toggle_bit_recs80ext | ((irmp_data_p->address & 0x000F) << 2) | + ((irmp_data_p->command & 0x0030) >> 4); // STAAAACC + irsnd_buffer[1] = (irmp_data_p->command & 0x0F) << 4; // CCCC0000 + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_RC5_PROTOCOL == 1 - case IRMP_RC5_PROTOCOL: - { - toggle_bit_rc5 = toggle_bit_rc5 ? 0x00 : 0x40; - - irsnd_buffer[0] = ((irmp_data_p->command & 0x40) ? 0x00 : 0x80) | toggle_bit_rc5 | - ((irmp_data_p->address & 0x001F) << 1) | ((irmp_data_p->command & 0x20) >> 5); // CTAAAAAC - irsnd_buffer[1] = (irmp_data_p->command & 0x1F) << 3; // CCCCC000 - irsnd_busy = TRUE; - break; - } + case IRMP_RC5_PROTOCOL: + { + toggle_bit_rc5 = toggle_bit_rc5 ? 0x00 : 0x40; + + irsnd_buffer[0] = ((irmp_data_p->command & 0x40) ? 0x00 : 0x80) | toggle_bit_rc5 | + ((irmp_data_p->address & 0x001F) << 1) | ((irmp_data_p->command & 0x20) >> 5); // CTAAAAAC + irsnd_buffer[1] = (irmp_data_p->command & 0x1F) << 3; // CCCCC000 + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_RC6_PROTOCOL == 1 - case IRMP_RC6_PROTOCOL: - { - toggle_bit_rc6 = toggle_bit_rc6 ? 0x00 : 0x08; - - irsnd_buffer[0] = 0x80 | toggle_bit_rc6 | ((irmp_data_p->address & 0x00E0) >> 5); // 1MMMTAAA, MMM = 000 - irsnd_buffer[1] = ((irmp_data_p->address & 0x001F) << 3) | ((irmp_data_p->command & 0xE0) >> 5); // AAAAACCC - irsnd_buffer[2] = (irmp_data_p->command & 0x1F) << 3; // CCCCC - irsnd_busy = TRUE; - break; - } + case IRMP_RC6_PROTOCOL: + { + toggle_bit_rc6 = toggle_bit_rc6 ? 0x00 : 0x08; + + irsnd_buffer[0] = 0x80 | toggle_bit_rc6 | ((irmp_data_p->address & 0x00E0) >> 5); // 1MMMTAAA, MMM = 000 + irsnd_buffer[1] = ((irmp_data_p->address & 0x001F) << 3) | ((irmp_data_p->command & 0xE0) >> 5); // AAAAACCC + irsnd_buffer[2] = (irmp_data_p->command & 0x1F) << 3; // CCCCC + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_RC6A_PROTOCOL == 1 - case IRMP_RC6A_PROTOCOL: - { - toggle_bit_rc6 = toggle_bit_rc6 ? 0x00 : 0x08; - - irsnd_buffer[0] = 0x80 | 0x60 | ((irmp_data_p->address & 0x3000) >> 12); // 1MMMT0AA, MMM = 110 - irsnd_buffer[1] = ((irmp_data_p->address & 0x0FFF) >> 4) ; // AAAAAAAA - irsnd_buffer[2] = ((irmp_data_p->address & 0x000F) << 4) | ((irmp_data_p->command & 0xF000) >> 12) | toggle_bit_rc6; // AAAACCCC - irsnd_buffer[3] = (irmp_data_p->command & 0x0FF0) >> 4; // CCCCCCCC - irsnd_buffer[4] = (irmp_data_p->command & 0x000F) << 4; // CCCC - irsnd_busy = TRUE; - break; - } + case IRMP_RC6A_PROTOCOL: + { + toggle_bit_rc6 = toggle_bit_rc6 ? 0x00 : 0x08; + + irsnd_buffer[0] = 0x80 | 0x60 | ((irmp_data_p->address & 0x3000) >> 12); // 1MMMT0AA, MMM = 110 + irsnd_buffer[1] = ((irmp_data_p->address & 0x0FFF) >> 4) ; // AAAAAAAA + irsnd_buffer[2] = ((irmp_data_p->address & 0x000F) << 4) | ((irmp_data_p->command & 0xF000) >> 12) | toggle_bit_rc6; // AAAACCCC + irsnd_buffer[3] = (irmp_data_p->command & 0x0FF0) >> 4; // CCCCCCCC + irsnd_buffer[4] = (irmp_data_p->command & 0x000F) << 4; // CCCC + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_DENON_PROTOCOL == 1 - case IRMP_DENON_PROTOCOL: - { - irsnd_buffer[0] = ((irmp_data_p->address & 0x1F) << 3) | ((irmp_data_p->command & 0x0380) >> 7); // AAAAACCC (1st frame) - irsnd_buffer[1] = (irmp_data_p->command & 0x7F) << 1; // CCCCCCC - irsnd_buffer[2] = ((irmp_data_p->address & 0x1F) << 3) | (((~irmp_data_p->command) & 0x0380) >> 7); // AAAAAccc (2nd frame) - irsnd_buffer[3] = (~(irmp_data_p->command) & 0x7F) << 1; // ccccccc - irsnd_busy = TRUE; - break; - } + case IRMP_DENON_PROTOCOL: + { + irsnd_buffer[0] = ((irmp_data_p->address & 0x1F) << 3) | ((irmp_data_p->command & 0x0380) >> 7); // AAAAACCC (1st frame) + irsnd_buffer[1] = (irmp_data_p->command & 0x7F) << 1; // CCCCCCC + irsnd_buffer[2] = ((irmp_data_p->address & 0x1F) << 3) | (((~irmp_data_p->command) & 0x0380) >> 7); // AAAAAccc (2nd frame) + irsnd_buffer[3] = (~(irmp_data_p->command) & 0x7F) << 1; // ccccccc + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1 - case IRMP_THOMSON_PROTOCOL: - { - toggle_bit_thomson = toggle_bit_thomson ? 0x00 : 0x08; - - irsnd_buffer[0] = ((irmp_data_p->address & 0x0F) << 4) | toggle_bit_thomson | ((irmp_data_p->command & 0x0070) >> 4); // AAAATCCC (1st frame) - irsnd_buffer[1] = (irmp_data_p->command & 0x0F) << 4; // CCCC - irsnd_busy = TRUE; - break; - } + case IRMP_THOMSON_PROTOCOL: + { + toggle_bit_thomson = toggle_bit_thomson ? 0x00 : 0x08; + + irsnd_buffer[0] = ((irmp_data_p->address & 0x0F) << 4) | toggle_bit_thomson | ((irmp_data_p->command & 0x0070) >> 4); // AAAATCCC (1st frame) + irsnd_buffer[1] = (irmp_data_p->command & 0x0F) << 4; // CCCC + irsnd_busy = TRUE; + break; + } +#endif +#if IRSND_SUPPORT_BOSE_PROTOCOL == 1 + case IRMP_BOSE_PROTOCOL: + { + command = bitsrevervse (irmp_data_p->command, BOSE_COMMAND_LEN); + + irsnd_buffer[0] = (command & 0xFF00) >> 8; // CCCCCCCC + irsnd_buffer[1] = ~((command & 0xFF00) >> 8); // cccccccc + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1 - case IRMP_NUBERT_PROTOCOL: - { - irsnd_buffer[0] = irmp_data_p->command >> 2; // CCCCCCCC - irsnd_buffer[1] = (irmp_data_p->command & 0x0003) << 6; // CC000000 - irsnd_busy = TRUE; - break; - } + case IRMP_NUBERT_PROTOCOL: + { + irsnd_buffer[0] = irmp_data_p->command >> 2; // CCCCCCCC + irsnd_buffer[1] = (irmp_data_p->command & 0x0003) << 6; // CC000000 + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_FAN_PROTOCOL == 1 - case IRMP_FAN_PROTOCOL: - { - irsnd_buffer[0] = irmp_data_p->command >> 3; // CCCCCCCC - irsnd_buffer[1] = (irmp_data_p->command & 0x0007) << 5; // CCC00000 - irsnd_busy = TRUE; - break; - } + case IRMP_FAN_PROTOCOL: + { + irsnd_buffer[0] = irmp_data_p->command >> 3; // CCCCCCCC + irsnd_buffer[1] = (irmp_data_p->command & 0x0007) << 5; // CCC00000 + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_SPEAKER_PROTOCOL == 1 - case IRMP_SPEAKER_PROTOCOL: - { - irsnd_buffer[0] = irmp_data_p->command >> 2; // CCCCCCCC - irsnd_buffer[1] = (irmp_data_p->command & 0x0003) << 6; // CC000000 - irsnd_busy = TRUE; - break; - } + case IRMP_SPEAKER_PROTOCOL: + { + irsnd_buffer[0] = irmp_data_p->command >> 2; // CCCCCCCC + irsnd_buffer[1] = (irmp_data_p->command & 0x0003) << 6; // CC000000 + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 - case IRMP_BANG_OLUFSEN_PROTOCOL: - { - irsnd_buffer[0] = irmp_data_p->command >> 11; // SXSCCCCC - irsnd_buffer[1] = irmp_data_p->command >> 3; // CCCCCCCC - irsnd_buffer[2] = (irmp_data_p->command & 0x0007) << 5; // CCC00000 - irsnd_busy = TRUE; - break; - } + case IRMP_BANG_OLUFSEN_PROTOCOL: + { + irsnd_buffer[0] = irmp_data_p->command >> 11; // SXSCCCCC + irsnd_buffer[1] = irmp_data_p->command >> 3; // CCCCCCCC + irsnd_buffer[2] = (irmp_data_p->command & 0x0007) << 5; // CCC00000 + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 - case IRMP_GRUNDIG_PROTOCOL: - { - command = bitsrevervse (irmp_data_p->command, TELEFUNKEN_COMMAND_LEN); + case IRMP_GRUNDIG_PROTOCOL: + { + command = bitsrevervse (irmp_data_p->command, TELEFUNKEN_COMMAND_LEN); - irsnd_buffer[0] = 0xFF; // S1111111 (1st frame) - irsnd_buffer[1] = 0xC0; // 11 - irsnd_buffer[2] = 0x80 | (command >> 2); // SCCCCCCC (2nd frame) - irsnd_buffer[3] = (command << 6) & 0xC0; // CC + irsnd_buffer[0] = 0xFF; // S1111111 (1st frame) + irsnd_buffer[1] = 0xC0; // 11 + irsnd_buffer[2] = 0x80 | (command >> 2); // SCCCCCCC (2nd frame) + irsnd_buffer[3] = (command << 6) & 0xC0; // CC - irsnd_busy = TRUE; - break; - } + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_TELEFUNKEN_PROTOCOL == 1 - case IRMP_TELEFUNKEN_PROTOCOL: - { - irsnd_buffer[0] = irmp_data_p->command >> 7; // CCCCCCCC - irsnd_buffer[1] = (irmp_data_p->command << 1) & 0xff; // CCCCCCC + case IRMP_TELEFUNKEN_PROTOCOL: + { + irsnd_buffer[0] = irmp_data_p->command >> 7; // CCCCCCCC + irsnd_buffer[1] = (irmp_data_p->command << 1) & 0xff; // CCCCCCC - irsnd_busy = TRUE; - break; - } + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_IR60_PROTOCOL == 1 - case IRMP_IR60_PROTOCOL: - { - command = (bitsrevervse (0x7d, IR60_COMMAND_LEN) << 7) | bitsrevervse (irmp_data_p->command, IR60_COMMAND_LEN); + case IRMP_IR60_PROTOCOL: + { + command = (bitsrevervse (0x7d, IR60_COMMAND_LEN) << 7) | bitsrevervse (irmp_data_p->command, IR60_COMMAND_LEN); #if 0 - irsnd_buffer[0] = command >> 6 | 0x01; // 1011111S (start instruction frame) - irsnd_buffer[1] = (command & 0x7F) << 1; // CCCCCCC_ (2nd frame) + irsnd_buffer[0] = command >> 6 | 0x01; // 1011111S (start instruction frame) + irsnd_buffer[1] = (command & 0x7F) << 1; // CCCCCCC_ (2nd frame) #else - irsnd_buffer[0] = ((command & 0x7F) << 1) | 0x01; // CCCCCCCS (1st frame) - irsnd_buffer[1] = command >> 6; // 1011111_ (start instruction frame) + irsnd_buffer[0] = ((command & 0x7F) << 1) | 0x01; // CCCCCCCS (1st frame) + irsnd_buffer[1] = command >> 6; // 1011111_ (start instruction frame) #endif - irsnd_busy = TRUE; - break; - } + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - case IRMP_NOKIA_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, NOKIA_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, NOKIA_COMMAND_LEN); - - irsnd_buffer[0] = 0xBF; // S0111111 (1st + 3rd frame) - irsnd_buffer[1] = 0xFF; // 11111111 - irsnd_buffer[2] = 0x80; // 1 - irsnd_buffer[3] = 0x80 | command >> 1; // SCCCCCCC (2nd frame) - irsnd_buffer[4] = (command << 7) | (address >> 1); // CAAAAAAA - irsnd_buffer[5] = (address << 7); // A - - irsnd_busy = TRUE; - break; - } + case IRMP_NOKIA_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, NOKIA_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, NOKIA_COMMAND_LEN); + + irsnd_buffer[0] = 0xBF; // S0111111 (1st + 3rd frame) + irsnd_buffer[1] = 0xFF; // 11111111 + irsnd_buffer[2] = 0x80; // 1 + irsnd_buffer[3] = 0x80 | command >> 1; // SCCCCCCC (2nd frame) + irsnd_buffer[4] = (command << 7) | (address >> 1); // CAAAAAAA + irsnd_buffer[5] = (address << 7); // A + + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 - case IRMP_SIEMENS_PROTOCOL: - { - irsnd_buffer[0] = ((irmp_data_p->address & 0x07FF) >> 3); // AAAAAAAA - irsnd_buffer[1] = ((irmp_data_p->address & 0x0007) << 5) | ((irmp_data_p->command >> 5) & 0x1F); // AAACCCCC - irsnd_buffer[2] = ((irmp_data_p->command & 0x001F) << 3) | ((~irmp_data_p->command & 0x01) << 2); // CCCCCc - - irsnd_busy = TRUE; - break; - } + case IRMP_SIEMENS_PROTOCOL: + { + irsnd_buffer[0] = ((irmp_data_p->address & 0x07FF) >> 3); // AAAAAAAA + irsnd_buffer[1] = ((irmp_data_p->address & 0x0007) << 5) | ((irmp_data_p->command >> 5) & 0x1F); // AAACCCCC + irsnd_buffer[2] = ((irmp_data_p->command & 0x001F) << 3) | ((~irmp_data_p->command & 0x01) << 2); // CCCCCc + + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_RUWIDO_PROTOCOL == 1 - case IRMP_RUWIDO_PROTOCOL: - { - irsnd_buffer[0] = ((irmp_data_p->address & 0x01FF) >> 1); // AAAAAAAA - irsnd_buffer[1] = ((irmp_data_p->address & 0x0001) << 7) | ((irmp_data_p->command & 0x7F)); // ACCCCCCC - irsnd_buffer[2] = ((~irmp_data_p->command & 0x01) << 7); // c - irsnd_busy = TRUE; - break; - } + case IRMP_RUWIDO_PROTOCOL: + { + irsnd_buffer[0] = ((irmp_data_p->address & 0x01FF) >> 1); // AAAAAAAA + irsnd_buffer[1] = ((irmp_data_p->address & 0x0001) << 7) | ((irmp_data_p->command & 0x7F)); // ACCCCCCC + irsnd_buffer[2] = ((~irmp_data_p->command & 0x01) << 7); // c + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_FDC_PROTOCOL == 1 - case IRMP_FDC_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, FDC_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, FDC_COMMAND_LEN); - - irsnd_buffer[0] = (address & 0xFF); // AAAAAAAA - irsnd_buffer[1] = 0; // 00000000 - irsnd_buffer[2] = 0; // 0000RRRR - irsnd_buffer[3] = (command & 0xFF); // CCCCCCCC - irsnd_buffer[4] = ~(command & 0xFF); // cccccccc - irsnd_busy = TRUE; - break; - } + case IRMP_FDC_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, FDC_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, FDC_COMMAND_LEN); + + irsnd_buffer[0] = (address & 0xFF); // AAAAAAAA + irsnd_buffer[1] = 0; // 00000000 + irsnd_buffer[2] = 0; // 0000RRRR + irsnd_buffer[3] = (command & 0xFF); // CCCCCCCC + irsnd_buffer[4] = ~(command & 0xFF); // cccccccc + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1 - case IRMP_RCCAR_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, 2); // A0 A1 - command = bitsrevervse (irmp_data_p->command, RCCAR_COMMAND_LEN - 2); // D0 D1 D2 D3 D4 D5 D6 D7 C0 C1 V - - irsnd_buffer[0] = ((command & 0x06) << 5) | ((address & 0x0003) << 4) | ((command & 0x0780) >> 7); // C0 C1 A0 A1 D0 D1 D2 D3 - irsnd_buffer[1] = ((command & 0x78) << 1) | ((command & 0x0001) << 3); // D4 D5 D6 D7 V 0 0 0 - - irsnd_busy = TRUE; - break; - } + case IRMP_RCCAR_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, 2); // A0 A1 + command = bitsrevervse (irmp_data_p->command, RCCAR_COMMAND_LEN - 2); // D0 D1 D2 D3 D4 D5 D6 D7 C0 C1 V + + irsnd_buffer[0] = ((command & 0x06) << 5) | ((address & 0x0003) << 4) | ((command & 0x0780) >> 7); // C0 C1 A0 A1 D0 D1 D2 D3 + irsnd_buffer[1] = ((command & 0x78) << 1) | ((command & 0x0001) << 3); // D4 D5 D6 D7 V 0 0 0 + + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_JVC_PROTOCOL == 1 - case IRMP_JVC_PROTOCOL: - { - address = bitsrevervse (irmp_data_p->address, JVC_ADDRESS_LEN); - command = bitsrevervse (irmp_data_p->command, JVC_COMMAND_LEN); + case IRMP_JVC_PROTOCOL: + { + address = bitsrevervse (irmp_data_p->address, JVC_ADDRESS_LEN); + command = bitsrevervse (irmp_data_p->command, JVC_COMMAND_LEN); - irsnd_buffer[0] = ((address & 0x000F) << 4) | (command & 0x0F00) >> 8; // AAAACCCC - irsnd_buffer[1] = (command & 0x00FF); // CCCCCCCC + irsnd_buffer[0] = ((address & 0x000F) << 4) | (command & 0x0F00) >> 8; // AAAACCCC + irsnd_buffer[1] = (command & 0x00FF); // CCCCCCCC - irsnd_busy = TRUE; - break; - } + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_NIKON_PROTOCOL == 1 - case IRMP_NIKON_PROTOCOL: - { - irsnd_buffer[0] = (irmp_data_p->command & 0x0003) << 6; // CC - irsnd_busy = TRUE; - break; - } + case IRMP_NIKON_PROTOCOL: + { + irsnd_buffer[0] = (irmp_data_p->command & 0x0003) << 6; // CC + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_LEGO_PROTOCOL == 1 - case IRMP_LEGO_PROTOCOL: - { - uint8_t crc = 0x0F ^ ((irmp_data_p->command & 0x0F00) >> 8) ^ ((irmp_data_p->command & 0x00F0) >> 4) ^ (irmp_data_p->command & 0x000F); - - irsnd_buffer[0] = (irmp_data_p->command & 0x0FF0) >> 4; // CCCCCCCC - irsnd_buffer[1] = ((irmp_data_p->command & 0x000F) << 4) | crc; // CCCCcccc - irsnd_busy = TRUE; - break; - } + case IRMP_LEGO_PROTOCOL: + { + uint8_t crc = 0x0F ^ ((irmp_data_p->command & 0x0F00) >> 8) ^ ((irmp_data_p->command & 0x00F0) >> 4) ^ (irmp_data_p->command & 0x000F); + + irsnd_buffer[0] = (irmp_data_p->command & 0x0FF0) >> 4; // CCCCCCCC + irsnd_buffer[1] = ((irmp_data_p->command & 0x000F) << 4) | crc; // CCCCcccc + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_A1TVBOX_PROTOCOL == 1 - case IRMP_A1TVBOX_PROTOCOL: - { - irsnd_buffer[0] = 0x80 | (irmp_data_p->address >> 2); // 10AAAAAA - irsnd_buffer[1] = (irmp_data_p->address << 6) | (irmp_data_p->command >> 2); // AACCCCCC - irsnd_buffer[2] = (irmp_data_p->command << 6); // CC - - irsnd_busy = TRUE; - break; - } + case IRMP_A1TVBOX_PROTOCOL: + { + irsnd_buffer[0] = 0x80 | (irmp_data_p->address >> 2); // 10AAAAAA + irsnd_buffer[1] = (irmp_data_p->address << 6) | (irmp_data_p->command >> 2); // AACCCCCC + irsnd_buffer[2] = (irmp_data_p->command << 6); // CC + + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_ROOMBA_PROTOCOL == 1 - case IRMP_ROOMBA_PROTOCOL: - { - irsnd_buffer[0] = (irmp_data_p->command & 0x7F) << 1; // CCCCCCC. - irsnd_busy = TRUE; - break; - } + case IRMP_ROOMBA_PROTOCOL: + { + irsnd_buffer[0] = (irmp_data_p->command & 0x7F) << 1; // CCCCCCC. + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_PENTAX_PROTOCOL == 1 - case IRMP_PENTAX_PROTOCOL: - { - irsnd_buffer[0] = (irmp_data_p->command & 0x3F) << 2; // CCCCCC.. - irsnd_busy = TRUE; - break; - } + case IRMP_PENTAX_PROTOCOL: + { + irsnd_buffer[0] = (irmp_data_p->command & 0x3F) << 2; // CCCCCC.. + irsnd_busy = TRUE; + break; + } #endif #if IRSND_SUPPORT_ACP24_PROTOCOL == 1 # define ACP_SET_BIT(acp24_bitno, c, irmp_bitno) \ - do \ - { \ - if ((c) & (1<<(irmp_bitno))) \ - { \ - irsnd_buffer[((acp24_bitno)>>3)] |= 1 << (((7 - (acp24_bitno)) & 0x07)); \ - } \ - } while (0) - - case IRMP_ACP24_PROTOCOL: - { - uint16_t cmd = irmp_data_p->command; - uint8_t i; - - address = bitsrevervse (irmp_data_p->address, ACP24_ADDRESS_LEN); - - for (i = 0; i < 8; i++) - { - irsnd_buffer[i] = 0x00; // CCCCCCCC - } - - // ACP24-Frame: - // 1 2 3 4 5 6 - // 0123456789012345678901234567890123456789012345678901234567890123456789 - // N VVMMM ? ??? t vmA x y TTTT - // - // irmp_data_p->command: - // - // 5432109876543210 - // NAVVvMMMmtxyTTTT - - ACP_SET_BIT( 0, cmd, 15); - ACP_SET_BIT(24, cmd, 14); - ACP_SET_BIT( 2, cmd, 13); - ACP_SET_BIT( 3, cmd, 12); - ACP_SET_BIT(22, cmd, 11); - ACP_SET_BIT( 4, cmd, 10); - ACP_SET_BIT( 5, cmd, 9); - ACP_SET_BIT( 6, cmd, 8); - ACP_SET_BIT(23, cmd, 7); - ACP_SET_BIT(20, cmd, 6); - ACP_SET_BIT(26, cmd, 5); - ACP_SET_BIT(44, cmd, 4); - ACP_SET_BIT(66, cmd, 3); - ACP_SET_BIT(67, cmd, 2); - ACP_SET_BIT(68, cmd, 1); - ACP_SET_BIT(69, cmd, 0); - - irsnd_busy = TRUE; - break; - } -#endif - - default: - { - break; - } + do \ + { \ + if ((c) & (1<<(irmp_bitno))) \ + { \ + irsnd_buffer[((acp24_bitno)>>3)] |= 1 << (((7 - (acp24_bitno)) & 0x07)); \ + } \ + } while (0) + + case IRMP_ACP24_PROTOCOL: + { + uint16_t cmd = irmp_data_p->command; + uint8_t i; + + address = bitsrevervse (irmp_data_p->address, ACP24_ADDRESS_LEN); + + for (i = 0; i < 8; i++) + { + irsnd_buffer[i] = 0x00; // CCCCCCCC + } + + // ACP24-Frame: + // 1 2 3 4 5 6 + // 0123456789012345678901234567890123456789012345678901234567890123456789 + // N VVMMM ? ??? t vmA x y TTTT + // + // irmp_data_p->command: + // + // 5432109876543210 + // NAVVvMMMmtxyTTTT + + ACP_SET_BIT( 0, cmd, 15); + ACP_SET_BIT(24, cmd, 14); + ACP_SET_BIT( 2, cmd, 13); + ACP_SET_BIT( 3, cmd, 12); + ACP_SET_BIT(22, cmd, 11); + ACP_SET_BIT( 4, cmd, 10); + ACP_SET_BIT( 5, cmd, 9); + ACP_SET_BIT( 6, cmd, 8); + ACP_SET_BIT(23, cmd, 7); + ACP_SET_BIT(20, cmd, 6); + ACP_SET_BIT(26, cmd, 5); + ACP_SET_BIT(44, cmd, 4); + ACP_SET_BIT(66, cmd, 3); + ACP_SET_BIT(67, cmd, 2); + ACP_SET_BIT(68, cmd, 1); + ACP_SET_BIT(69, cmd, 0); + + irsnd_busy = TRUE; + break; + } +#endif + + default: + { + break; + } } return irsnd_busy; @@ -1483,878 +1559,913 @@ irsnd_ISR (void) if (irsnd_busy) { - if (current_bit == 0xFF && new_frame) // start of transmission... - { - if (auto_repetition_counter > 0) - { - auto_repetition_pause_counter++; - -#if IRSND_SUPPORT_DENON_PROTOCOL == 1 - if (repeat_frame_pause_len > 0) // frame repeat distance counts from beginning of 1st frame! - { - repeat_frame_pause_len--; - } -#endif + if (current_bit == 0xFF && new_frame) // start of transmission... + { + if (auto_repetition_counter > 0) + { + auto_repetition_pause_counter++; - if (auto_repetition_pause_counter >= auto_repetition_pause_len) - { - auto_repetition_pause_counter = 0; + if (auto_repetition_pause_counter >= auto_repetition_pause_len) + { + auto_repetition_pause_counter = 0; #if IRSND_SUPPORT_DENON_PROTOCOL == 1 - if (irsnd_protocol == IRMP_DENON_PROTOCOL) // n'th denon frame - { - current_bit = 16; - complete_data_len = 2 * DENON_COMPLETE_DATA_LEN + 1; - } - else + if (irsnd_protocol == IRMP_DENON_PROTOCOL) // n'th denon frame + { + current_bit = 16; + complete_data_len = 2 * DENON_COMPLETE_DATA_LEN + 1; + } + else #endif #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 - if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL) // n'th grundig frame - { - current_bit = 15; - complete_data_len = 16 + GRUNDIG_COMPLETE_DATA_LEN; - } - else + if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL) // n'th grundig frame + { + current_bit = 15; + complete_data_len = 16 + GRUNDIG_COMPLETE_DATA_LEN; + } + else #endif #if IRSND_SUPPORT_IR60_PROTOCOL == 1 - if (irsnd_protocol == IRMP_IR60_PROTOCOL) // n'th IR60 frame - { - current_bit = 7; - complete_data_len = 2 * IR60_COMPLETE_DATA_LEN + 1; - } - else + if (irsnd_protocol == IRMP_IR60_PROTOCOL) // n'th IR60 frame + { + current_bit = 7; + complete_data_len = 2 * IR60_COMPLETE_DATA_LEN + 1; + } + else #endif #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - if (irsnd_protocol == IRMP_NOKIA_PROTOCOL) // n'th nokia frame - { - if (auto_repetition_counter + 1 < n_auto_repetitions) - { - current_bit = 23; - complete_data_len = 24 + NOKIA_COMPLETE_DATA_LEN; - } - else // nokia stop frame - { - current_bit = 0xFF; - complete_data_len = NOKIA_COMPLETE_DATA_LEN; - } - } - else -#endif - { - ; - } - } - else - { + if (irsnd_protocol == IRMP_NOKIA_PROTOCOL) // n'th nokia frame + { + if (auto_repetition_counter + 1 < n_auto_repetitions) + { + current_bit = 23; + complete_data_len = 24 + NOKIA_COMPLETE_DATA_LEN; + } + else // nokia stop frame + { + current_bit = 0xFF; + complete_data_len = NOKIA_COMPLETE_DATA_LEN; + } + } + else +#endif + { + ; + } + } + else + { #ifdef ANALYZE - if (irsnd_is_on) - { - putchar ('0'); - } - else - { - putchar ('1'); - } -#endif - return irsnd_busy; - } - } - else if (packet_repeat_pause_counter < repeat_frame_pause_len) - { - packet_repeat_pause_counter++; + if (irsnd_is_on) + { + putchar ('0'); + } + else + { + putchar ('1'); + } +#endif + return irsnd_busy; + } + } + else if (packet_repeat_pause_counter < repeat_frame_pause_len) + { + packet_repeat_pause_counter++; #ifdef ANALYZE - if (irsnd_is_on) - { - putchar ('0'); - } - else - { - putchar ('1'); - } -#endif - return irsnd_busy; - } - else - { - if (send_trailer) - { - irsnd_busy = FALSE; - send_trailer = FALSE; - return irsnd_busy; - } - - n_repeat_frames = irsnd_repeat; - - if (n_repeat_frames == IRSND_ENDLESS_REPETITION) - { - n_repeat_frames = 255; - } - - packet_repeat_pause_counter = 0; - pulse_counter = 0; - pause_counter = 0; - - switch (irsnd_protocol) - { + if (irsnd_is_on) + { + putchar ('0'); + } + else + { + putchar ('1'); + } +#endif + return irsnd_busy; + } + else + { + if (send_trailer) + { + irsnd_busy = FALSE; + send_trailer = FALSE; + return irsnd_busy; + } + + n_repeat_frames = irsnd_repeat; + + if (n_repeat_frames == IRSND_ENDLESS_REPETITION) + { + n_repeat_frames = 255; + } + + packet_repeat_pause_counter = 0; + pulse_counter = 0; + pause_counter = 0; + + switch (irsnd_protocol) + { #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 - case IRMP_SIRCS_PROTOCOL: - { - startbit_pulse_len = SIRCS_START_BIT_PULSE_LEN; - startbit_pause_len = SIRCS_START_BIT_PAUSE_LEN - 1; - pulse_1_len = SIRCS_1_PULSE_LEN; - pause_1_len = SIRCS_PAUSE_LEN - 1; - pulse_0_len = SIRCS_0_PULSE_LEN; - pause_0_len = SIRCS_PAUSE_LEN - 1; - has_stop_bit = SIRCS_STOP_BIT; - complete_data_len = SIRCS_MINIMUM_DATA_LEN + sircs_additional_bitlen; - n_auto_repetitions = (repeat_counter == 0) ? SIRCS_FRAMES : 1; // 3 frames auto repetition if first frame - auto_repetition_pause_len = SIRCS_AUTO_REPETITION_PAUSE_LEN; // 25ms pause - repeat_frame_pause_len = SIRCS_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_40_KHZ); - break; - } + case IRMP_SIRCS_PROTOCOL: + { + startbit_pulse_len = SIRCS_START_BIT_PULSE_LEN; + startbit_pause_len = SIRCS_START_BIT_PAUSE_LEN - 1; + pulse_1_len = SIRCS_1_PULSE_LEN; + pause_1_len = SIRCS_PAUSE_LEN - 1; + pulse_0_len = SIRCS_0_PULSE_LEN; + pause_0_len = SIRCS_PAUSE_LEN - 1; + has_stop_bit = SIRCS_STOP_BIT; + complete_data_len = SIRCS_MINIMUM_DATA_LEN + sircs_additional_bitlen; + n_auto_repetitions = (repeat_counter == 0) ? SIRCS_FRAMES : 1; // 3 frames auto repetition if first frame + auto_repetition_pause_len = SIRCS_AUTO_REPETITION_PAUSE_LEN; // 25ms pause + repeat_frame_pause_len = SIRCS_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_40_KHZ); + break; + } #endif #if IRSND_SUPPORT_NEC_PROTOCOL == 1 - case IRMP_NEC_PROTOCOL: - { - startbit_pulse_len = NEC_START_BIT_PULSE_LEN; - - if (repeat_counter > 0) - { - startbit_pause_len = NEC_REPEAT_START_BIT_PAUSE_LEN - 1; - complete_data_len = 0; - } - else - { - startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1; - complete_data_len = NEC_COMPLETE_DATA_LEN; - } - - pulse_1_len = NEC_PULSE_LEN; - pause_1_len = NEC_1_PAUSE_LEN - 1; - pulse_0_len = NEC_PULSE_LEN; - pause_0_len = NEC_0_PAUSE_LEN - 1; - has_stop_bit = NEC_STOP_BIT; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_NEC_PROTOCOL: + { + startbit_pulse_len = NEC_START_BIT_PULSE_LEN; + + if (repeat_counter > 0) + { + startbit_pause_len = NEC_REPEAT_START_BIT_PAUSE_LEN - 1; + complete_data_len = 0; + } + else + { + startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1; + complete_data_len = NEC_COMPLETE_DATA_LEN; + } + + pulse_1_len = NEC_PULSE_LEN; + pause_1_len = NEC_1_PAUSE_LEN - 1; + pulse_0_len = NEC_PULSE_LEN; + pause_0_len = NEC_0_PAUSE_LEN - 1; + has_stop_bit = NEC_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_NEC16_PROTOCOL == 1 - case IRMP_NEC16_PROTOCOL: - { - startbit_pulse_len = NEC_START_BIT_PULSE_LEN; - startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1; - pulse_1_len = NEC_PULSE_LEN; - pause_1_len = NEC_1_PAUSE_LEN - 1; - pulse_0_len = NEC_PULSE_LEN; - pause_0_len = NEC_0_PAUSE_LEN - 1; - has_stop_bit = NEC_STOP_BIT; - complete_data_len = NEC16_COMPLETE_DATA_LEN + 1; // 1 more: sync bit - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_NEC16_PROTOCOL: + { + startbit_pulse_len = NEC_START_BIT_PULSE_LEN; + startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1; + pulse_1_len = NEC_PULSE_LEN; + pause_1_len = NEC_1_PAUSE_LEN - 1; + pulse_0_len = NEC_PULSE_LEN; + pause_0_len = NEC_0_PAUSE_LEN - 1; + has_stop_bit = NEC_STOP_BIT; + complete_data_len = NEC16_COMPLETE_DATA_LEN + 1; // 1 more: sync bit + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_NEC42_PROTOCOL == 1 - case IRMP_NEC42_PROTOCOL: - { - startbit_pulse_len = NEC_START_BIT_PULSE_LEN; - startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1; - pulse_1_len = NEC_PULSE_LEN; - pause_1_len = NEC_1_PAUSE_LEN - 1; - pulse_0_len = NEC_PULSE_LEN; - pause_0_len = NEC_0_PAUSE_LEN - 1; - has_stop_bit = NEC_STOP_BIT; - complete_data_len = NEC42_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_NEC42_PROTOCOL: + { + startbit_pulse_len = NEC_START_BIT_PULSE_LEN; + startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1; + pulse_1_len = NEC_PULSE_LEN; + pause_1_len = NEC_1_PAUSE_LEN - 1; + pulse_0_len = NEC_PULSE_LEN; + pause_0_len = NEC_0_PAUSE_LEN - 1; + has_stop_bit = NEC_STOP_BIT; + complete_data_len = NEC42_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_LGAIR_PROTOCOL == 1 - case IRMP_LGAIR_PROTOCOL: - { - startbit_pulse_len = NEC_START_BIT_PULSE_LEN; - startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1; - pulse_1_len = NEC_PULSE_LEN; - pause_1_len = NEC_1_PAUSE_LEN - 1; - pulse_0_len = NEC_PULSE_LEN; - pause_0_len = NEC_0_PAUSE_LEN - 1; - has_stop_bit = NEC_STOP_BIT; - complete_data_len = LGAIR_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_LGAIR_PROTOCOL: + { + startbit_pulse_len = NEC_START_BIT_PULSE_LEN; + startbit_pause_len = NEC_START_BIT_PAUSE_LEN - 1; + pulse_1_len = NEC_PULSE_LEN; + pause_1_len = NEC_1_PAUSE_LEN - 1; + pulse_0_len = NEC_PULSE_LEN; + pause_0_len = NEC_0_PAUSE_LEN - 1; + has_stop_bit = NEC_STOP_BIT; + complete_data_len = LGAIR_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = NEC_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 - case IRMP_SAMSUNG_PROTOCOL: - { - startbit_pulse_len = SAMSUNG_START_BIT_PULSE_LEN; - startbit_pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1; - pulse_1_len = SAMSUNG_PULSE_LEN; - pause_1_len = SAMSUNG_1_PAUSE_LEN - 1; - pulse_0_len = SAMSUNG_PULSE_LEN; - pause_0_len = SAMSUNG_0_PAUSE_LEN - 1; - has_stop_bit = SAMSUNG_STOP_BIT; - complete_data_len = SAMSUNG_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = SAMSUNG_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } - - case IRMP_SAMSUNG32_PROTOCOL: - { - startbit_pulse_len = SAMSUNG_START_BIT_PULSE_LEN; - startbit_pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1; - pulse_1_len = SAMSUNG_PULSE_LEN; - pause_1_len = SAMSUNG_1_PAUSE_LEN - 1; - pulse_0_len = SAMSUNG_PULSE_LEN; - pause_0_len = SAMSUNG_0_PAUSE_LEN - 1; - has_stop_bit = SAMSUNG_STOP_BIT; - complete_data_len = SAMSUNG32_COMPLETE_DATA_LEN; - n_auto_repetitions = SAMSUNG32_FRAMES; // 1 frame - auto_repetition_pause_len = SAMSUNG32_AUTO_REPETITION_PAUSE_LEN; // 47 ms pause - repeat_frame_pause_len = SAMSUNG32_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_SAMSUNG_PROTOCOL: + { + startbit_pulse_len = SAMSUNG_START_BIT_PULSE_LEN; + startbit_pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1; + pulse_1_len = SAMSUNG_PULSE_LEN; + pause_1_len = SAMSUNG_1_PAUSE_LEN - 1; + pulse_0_len = SAMSUNG_PULSE_LEN; + pause_0_len = SAMSUNG_0_PAUSE_LEN - 1; + has_stop_bit = SAMSUNG_STOP_BIT; + complete_data_len = SAMSUNG_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = SAMSUNG_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } + + case IRMP_SAMSUNG32_PROTOCOL: + { + startbit_pulse_len = SAMSUNG_START_BIT_PULSE_LEN; + startbit_pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1; + pulse_1_len = SAMSUNG_PULSE_LEN; + pause_1_len = SAMSUNG_1_PAUSE_LEN - 1; + pulse_0_len = SAMSUNG_PULSE_LEN; + pause_0_len = SAMSUNG_0_PAUSE_LEN - 1; + has_stop_bit = SAMSUNG_STOP_BIT; + complete_data_len = SAMSUNG32_COMPLETE_DATA_LEN; + n_auto_repetitions = SAMSUNG32_FRAMES; // 1 frame + auto_repetition_pause_len = SAMSUNG32_AUTO_REPETITION_PAUSE_LEN; // 47 ms pause + repeat_frame_pause_len = SAMSUNG32_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_SAMSUNG48_PROTOCOL == 1 - case IRMP_SAMSUNG48_PROTOCOL: - { - startbit_pulse_len = SAMSUNG_START_BIT_PULSE_LEN; - startbit_pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1; - pulse_1_len = SAMSUNG_PULSE_LEN; - pause_1_len = SAMSUNG_1_PAUSE_LEN - 1; - pulse_0_len = SAMSUNG_PULSE_LEN; - pause_0_len = SAMSUNG_0_PAUSE_LEN - 1; - has_stop_bit = SAMSUNG_STOP_BIT; - complete_data_len = SAMSUNG48_COMPLETE_DATA_LEN; - n_auto_repetitions = SAMSUNG48_FRAMES; // 1 frame - auto_repetition_pause_len = SAMSUNG48_AUTO_REPETITION_PAUSE_LEN; // 47 ms pause - repeat_frame_pause_len = SAMSUNG48_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_SAMSUNG48_PROTOCOL: + { + startbit_pulse_len = SAMSUNG_START_BIT_PULSE_LEN; + startbit_pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1; + pulse_1_len = SAMSUNG_PULSE_LEN; + pause_1_len = SAMSUNG_1_PAUSE_LEN - 1; + pulse_0_len = SAMSUNG_PULSE_LEN; + pause_0_len = SAMSUNG_0_PAUSE_LEN - 1; + has_stop_bit = SAMSUNG_STOP_BIT; + complete_data_len = SAMSUNG48_COMPLETE_DATA_LEN; + n_auto_repetitions = SAMSUNG48_FRAMES; // 1 frame + auto_repetition_pause_len = SAMSUNG48_AUTO_REPETITION_PAUSE_LEN; // 47 ms pause + repeat_frame_pause_len = SAMSUNG48_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 - case IRMP_MATSUSHITA_PROTOCOL: - { - startbit_pulse_len = MATSUSHITA_START_BIT_PULSE_LEN; - startbit_pause_len = MATSUSHITA_START_BIT_PAUSE_LEN - 1; - pulse_1_len = MATSUSHITA_PULSE_LEN; - pause_1_len = MATSUSHITA_1_PAUSE_LEN - 1; - pulse_0_len = MATSUSHITA_PULSE_LEN; - pause_0_len = MATSUSHITA_0_PAUSE_LEN - 1; - has_stop_bit = MATSUSHITA_STOP_BIT; - complete_data_len = MATSUSHITA_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = MATSUSHITA_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_36_KHZ); - break; - } + case IRMP_MATSUSHITA_PROTOCOL: + { + startbit_pulse_len = MATSUSHITA_START_BIT_PULSE_LEN; + startbit_pause_len = MATSUSHITA_START_BIT_PAUSE_LEN - 1; + pulse_1_len = MATSUSHITA_PULSE_LEN; + pause_1_len = MATSUSHITA_1_PAUSE_LEN - 1; + pulse_0_len = MATSUSHITA_PULSE_LEN; + pause_0_len = MATSUSHITA_0_PAUSE_LEN - 1; + has_stop_bit = MATSUSHITA_STOP_BIT; + complete_data_len = MATSUSHITA_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = MATSUSHITA_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } #endif #if IRSND_SUPPORT_TECHNICS_PROTOCOL == 1 - case IRMP_TECHNICS_PROTOCOL: - { - startbit_pulse_len = MATSUSHITA_START_BIT_PULSE_LEN; - startbit_pause_len = MATSUSHITA_START_BIT_PAUSE_LEN - 1; - pulse_1_len = MATSUSHITA_PULSE_LEN; - pause_1_len = MATSUSHITA_1_PAUSE_LEN - 1; - pulse_0_len = MATSUSHITA_PULSE_LEN; - pause_0_len = MATSUSHITA_0_PAUSE_LEN - 1; - has_stop_bit = MATSUSHITA_STOP_BIT; - complete_data_len = TECHNICS_COMPLETE_DATA_LEN; // here TECHNICS - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = MATSUSHITA_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_36_KHZ); - break; - } + case IRMP_TECHNICS_PROTOCOL: + { + startbit_pulse_len = MATSUSHITA_START_BIT_PULSE_LEN; + startbit_pause_len = MATSUSHITA_START_BIT_PAUSE_LEN - 1; + pulse_1_len = MATSUSHITA_PULSE_LEN; + pause_1_len = MATSUSHITA_1_PAUSE_LEN - 1; + pulse_0_len = MATSUSHITA_PULSE_LEN; + pause_0_len = MATSUSHITA_0_PAUSE_LEN - 1; + has_stop_bit = MATSUSHITA_STOP_BIT; + complete_data_len = TECHNICS_COMPLETE_DATA_LEN; // here TECHNICS + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = MATSUSHITA_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } #endif #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 - case IRMP_KASEIKYO_PROTOCOL: - { - startbit_pulse_len = KASEIKYO_START_BIT_PULSE_LEN; - startbit_pause_len = KASEIKYO_START_BIT_PAUSE_LEN - 1; - pulse_1_len = KASEIKYO_PULSE_LEN; - pause_1_len = KASEIKYO_1_PAUSE_LEN - 1; - pulse_0_len = KASEIKYO_PULSE_LEN; - pause_0_len = KASEIKYO_0_PAUSE_LEN - 1; - has_stop_bit = KASEIKYO_STOP_BIT; - complete_data_len = KASEIKYO_COMPLETE_DATA_LEN; - n_auto_repetitions = (repeat_counter == 0) ? KASEIKYO_FRAMES : 1; // 2 frames auto repetition if first frame - auto_repetition_pause_len = KASEIKYO_AUTO_REPETITION_PAUSE_LEN; // 75 ms pause - repeat_frame_pause_len = KASEIKYO_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_KASEIKYO_PROTOCOL: + { + startbit_pulse_len = KASEIKYO_START_BIT_PULSE_LEN; + startbit_pause_len = KASEIKYO_START_BIT_PAUSE_LEN - 1; + pulse_1_len = KASEIKYO_PULSE_LEN; + pause_1_len = KASEIKYO_1_PAUSE_LEN - 1; + pulse_0_len = KASEIKYO_PULSE_LEN; + pause_0_len = KASEIKYO_0_PAUSE_LEN - 1; + has_stop_bit = KASEIKYO_STOP_BIT; + complete_data_len = KASEIKYO_COMPLETE_DATA_LEN; + n_auto_repetitions = (repeat_counter == 0) ? KASEIKYO_FRAMES : 1; // 2 frames auto repetition if first frame + auto_repetition_pause_len = KASEIKYO_AUTO_REPETITION_PAUSE_LEN; // 75 ms pause + repeat_frame_pause_len = KASEIKYO_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } +#endif +#if IRSND_SUPPORT_PANASONIC_PROTOCOL == 1 + case IRMP_PANASONIC_PROTOCOL: + { + startbit_pulse_len = PANASONIC_START_BIT_PULSE_LEN; + startbit_pause_len = PANASONIC_START_BIT_PAUSE_LEN - 1; + pulse_1_len = PANASONIC_PULSE_LEN; + pause_1_len = PANASONIC_1_PAUSE_LEN - 1; + pulse_0_len = PANASONIC_PULSE_LEN; + pause_0_len = PANASONIC_0_PAUSE_LEN - 1; + has_stop_bit = PANASONIC_STOP_BIT; + complete_data_len = PANASONIC_COMPLETE_DATA_LEN; + n_auto_repetitions = PANASONIC_FRAMES; // 1 frame + auto_repetition_pause_len = PANASONIC_AUTO_REPETITION_PAUSE_LEN; // 40 ms pause + repeat_frame_pause_len = PANASONIC_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_RECS80_PROTOCOL == 1 - case IRMP_RECS80_PROTOCOL: - { - startbit_pulse_len = RECS80_START_BIT_PULSE_LEN; - startbit_pause_len = RECS80_START_BIT_PAUSE_LEN - 1; - pulse_1_len = RECS80_PULSE_LEN; - pause_1_len = RECS80_1_PAUSE_LEN - 1; - pulse_0_len = RECS80_PULSE_LEN; - pause_0_len = RECS80_0_PAUSE_LEN - 1; - has_stop_bit = RECS80_STOP_BIT; - complete_data_len = RECS80_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = RECS80_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_RECS80_PROTOCOL: + { + startbit_pulse_len = RECS80_START_BIT_PULSE_LEN; + startbit_pause_len = RECS80_START_BIT_PAUSE_LEN - 1; + pulse_1_len = RECS80_PULSE_LEN; + pause_1_len = RECS80_1_PAUSE_LEN - 1; + pulse_0_len = RECS80_PULSE_LEN; + pause_0_len = RECS80_0_PAUSE_LEN - 1; + has_stop_bit = RECS80_STOP_BIT; + complete_data_len = RECS80_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = RECS80_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 - case IRMP_RECS80EXT_PROTOCOL: - { - startbit_pulse_len = RECS80EXT_START_BIT_PULSE_LEN; - startbit_pause_len = RECS80EXT_START_BIT_PAUSE_LEN - 1; - pulse_1_len = RECS80EXT_PULSE_LEN; - pause_1_len = RECS80EXT_1_PAUSE_LEN - 1; - pulse_0_len = RECS80EXT_PULSE_LEN; - pause_0_len = RECS80EXT_0_PAUSE_LEN - 1; - has_stop_bit = RECS80EXT_STOP_BIT; - complete_data_len = RECS80EXT_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = RECS80EXT_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_RECS80EXT_PROTOCOL: + { + startbit_pulse_len = RECS80EXT_START_BIT_PULSE_LEN; + startbit_pause_len = RECS80EXT_START_BIT_PAUSE_LEN - 1; + pulse_1_len = RECS80EXT_PULSE_LEN; + pause_1_len = RECS80EXT_1_PAUSE_LEN - 1; + pulse_0_len = RECS80EXT_PULSE_LEN; + pause_0_len = RECS80EXT_0_PAUSE_LEN - 1; + has_stop_bit = RECS80EXT_STOP_BIT; + complete_data_len = RECS80EXT_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = RECS80EXT_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_TELEFUNKEN_PROTOCOL == 1 - case IRMP_TELEFUNKEN_PROTOCOL: - { - startbit_pulse_len = TELEFUNKEN_START_BIT_PULSE_LEN; - startbit_pause_len = TELEFUNKEN_START_BIT_PAUSE_LEN - 1; - pulse_1_len = TELEFUNKEN_PULSE_LEN; - pause_1_len = TELEFUNKEN_1_PAUSE_LEN - 1; - pulse_0_len = TELEFUNKEN_PULSE_LEN; - pause_0_len = TELEFUNKEN_0_PAUSE_LEN - 1; - has_stop_bit = TELEFUNKEN_STOP_BIT; - complete_data_len = TELEFUNKEN_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frames - auto_repetition_pause_len = 0; // TELEFUNKEN_AUTO_REPETITION_PAUSE_LEN; // xx ms pause - repeat_frame_pause_len = TELEFUNKEN_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_TELEFUNKEN_PROTOCOL: + { + startbit_pulse_len = TELEFUNKEN_START_BIT_PULSE_LEN; + startbit_pause_len = TELEFUNKEN_START_BIT_PAUSE_LEN - 1; + pulse_1_len = TELEFUNKEN_PULSE_LEN; + pause_1_len = TELEFUNKEN_1_PAUSE_LEN - 1; + pulse_0_len = TELEFUNKEN_PULSE_LEN; + pause_0_len = TELEFUNKEN_0_PAUSE_LEN - 1; + has_stop_bit = TELEFUNKEN_STOP_BIT; + complete_data_len = TELEFUNKEN_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frames + auto_repetition_pause_len = 0; // TELEFUNKEN_AUTO_REPETITION_PAUSE_LEN; // xx ms pause + repeat_frame_pause_len = TELEFUNKEN_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_RC5_PROTOCOL == 1 - case IRMP_RC5_PROTOCOL: - { - startbit_pulse_len = RC5_BIT_LEN; - startbit_pause_len = RC5_BIT_LEN; - pulse_len = RC5_BIT_LEN; - pause_len = RC5_BIT_LEN; - has_stop_bit = RC5_STOP_BIT; - complete_data_len = RC5_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = RC5_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_36_KHZ); - break; - } + case IRMP_RC5_PROTOCOL: + { + startbit_pulse_len = RC5_BIT_LEN; + startbit_pause_len = RC5_BIT_LEN; + pulse_len = RC5_BIT_LEN; + pause_len = RC5_BIT_LEN; + has_stop_bit = RC5_STOP_BIT; + complete_data_len = RC5_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = RC5_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } #endif #if IRSND_SUPPORT_RC6_PROTOCOL == 1 - case IRMP_RC6_PROTOCOL: - { - startbit_pulse_len = RC6_START_BIT_PULSE_LEN; - startbit_pause_len = RC6_START_BIT_PAUSE_LEN - 1; - pulse_len = RC6_BIT_LEN; - pause_len = RC6_BIT_LEN; - has_stop_bit = RC6_STOP_BIT; - complete_data_len = RC6_COMPLETE_DATA_LEN_SHORT; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = RC6_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_36_KHZ); - break; - } + case IRMP_RC6_PROTOCOL: + { + startbit_pulse_len = RC6_START_BIT_PULSE_LEN; + startbit_pause_len = RC6_START_BIT_PAUSE_LEN - 1; + pulse_len = RC6_BIT_LEN; + pause_len = RC6_BIT_LEN; + has_stop_bit = RC6_STOP_BIT; + complete_data_len = RC6_COMPLETE_DATA_LEN_SHORT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = RC6_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } #endif #if IRSND_SUPPORT_RC6A_PROTOCOL == 1 - case IRMP_RC6A_PROTOCOL: - { - startbit_pulse_len = RC6_START_BIT_PULSE_LEN; - startbit_pause_len = RC6_START_BIT_PAUSE_LEN - 1; - pulse_len = RC6_BIT_LEN; - pause_len = RC6_BIT_LEN; - has_stop_bit = RC6_STOP_BIT; - complete_data_len = RC6_COMPLETE_DATA_LEN_LONG; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = RC6_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_36_KHZ); - break; - } + case IRMP_RC6A_PROTOCOL: + { + startbit_pulse_len = RC6_START_BIT_PULSE_LEN; + startbit_pause_len = RC6_START_BIT_PAUSE_LEN - 1; + pulse_len = RC6_BIT_LEN; + pause_len = RC6_BIT_LEN; + has_stop_bit = RC6_STOP_BIT; + complete_data_len = RC6_COMPLETE_DATA_LEN_LONG; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = RC6_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } #endif #if IRSND_SUPPORT_DENON_PROTOCOL == 1 - case IRMP_DENON_PROTOCOL: - { - startbit_pulse_len = 0x00; - startbit_pause_len = 0x00; - pulse_1_len = DENON_PULSE_LEN; - pause_1_len = DENON_1_PAUSE_LEN - 1; - pulse_0_len = DENON_PULSE_LEN; - pause_0_len = DENON_0_PAUSE_LEN - 1; - has_stop_bit = DENON_STOP_BIT; - complete_data_len = DENON_COMPLETE_DATA_LEN; - n_auto_repetitions = DENON_FRAMES; // 2 frames, 2nd with inverted command - auto_repetition_pause_len = DENON_AUTO_REPETITION_PAUSE_LEN; // 65 ms pause after 1st frame - repeat_frame_pause_len = DENON_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_36_KHZ); // in theory 32kHz, in practice 36kHz is better - break; - } + case IRMP_DENON_PROTOCOL: + { + startbit_pulse_len = 0x00; + startbit_pause_len = 0x00; + pulse_1_len = DENON_PULSE_LEN; + pause_1_len = DENON_1_PAUSE_LEN - 1; + pulse_0_len = DENON_PULSE_LEN; + pause_0_len = DENON_0_PAUSE_LEN - 1; + has_stop_bit = DENON_STOP_BIT; + complete_data_len = DENON_COMPLETE_DATA_LEN; + n_auto_repetitions = DENON_FRAMES; // 2 frames, 2nd with inverted command + auto_repetition_pause_len = DENON_AUTO_REPETITION_PAUSE_LEN; // 65 ms pause after 1st frame + repeat_frame_pause_len = DENON_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); // in theory 32kHz, in practice 36kHz is better + break; + } #endif #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1 - case IRMP_THOMSON_PROTOCOL: - { - startbit_pulse_len = 0x00; - startbit_pause_len = 0x00; - pulse_1_len = THOMSON_PULSE_LEN; - pause_1_len = THOMSON_1_PAUSE_LEN - 1; - pulse_0_len = THOMSON_PULSE_LEN; - pause_0_len = THOMSON_0_PAUSE_LEN - 1; - has_stop_bit = THOMSON_STOP_BIT; - complete_data_len = THOMSON_COMPLETE_DATA_LEN; - n_auto_repetitions = THOMSON_FRAMES; // only 1 frame - auto_repetition_pause_len = THOMSON_AUTO_REPETITION_PAUSE_LEN; - repeat_frame_pause_len = DENON_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_THOMSON_PROTOCOL: + { + startbit_pulse_len = 0x00; + startbit_pause_len = 0x00; + pulse_1_len = THOMSON_PULSE_LEN; + pause_1_len = THOMSON_1_PAUSE_LEN - 1; + pulse_0_len = THOMSON_PULSE_LEN; + pause_0_len = THOMSON_0_PAUSE_LEN - 1; + has_stop_bit = THOMSON_STOP_BIT; + complete_data_len = THOMSON_COMPLETE_DATA_LEN; + n_auto_repetitions = THOMSON_FRAMES; // only 1 frame + auto_repetition_pause_len = THOMSON_AUTO_REPETITION_PAUSE_LEN; + repeat_frame_pause_len = THOMSON_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } +#endif +#if IRSND_SUPPORT_BOSE_PROTOCOL == 1 + case IRMP_BOSE_PROTOCOL: + { + startbit_pulse_len = BOSE_START_BIT_PULSE_LEN; + startbit_pause_len = BOSE_START_BIT_PAUSE_LEN - 1; + pulse_1_len = BOSE_PULSE_LEN; + pause_1_len = BOSE_1_PAUSE_LEN - 1; + pulse_0_len = BOSE_PULSE_LEN; + pause_0_len = BOSE_0_PAUSE_LEN - 1; + has_stop_bit = BOSE_STOP_BIT; + complete_data_len = BOSE_COMPLETE_DATA_LEN; + n_auto_repetitions = BOSE_FRAMES; // 1 frame + auto_repetition_pause_len = BOSE_AUTO_REPETITION_PAUSE_LEN; // 40 ms pause + repeat_frame_pause_len = BOSE_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } #endif #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1 - case IRMP_NUBERT_PROTOCOL: - { - startbit_pulse_len = NUBERT_START_BIT_PULSE_LEN; - startbit_pause_len = NUBERT_START_BIT_PAUSE_LEN - 1; - pulse_1_len = NUBERT_1_PULSE_LEN; - pause_1_len = NUBERT_1_PAUSE_LEN - 1; - pulse_0_len = NUBERT_0_PULSE_LEN; - pause_0_len = NUBERT_0_PAUSE_LEN - 1; - has_stop_bit = NUBERT_STOP_BIT; - complete_data_len = NUBERT_COMPLETE_DATA_LEN; - n_auto_repetitions = NUBERT_FRAMES; // 2 frames - auto_repetition_pause_len = NUBERT_AUTO_REPETITION_PAUSE_LEN; // 35 ms pause - repeat_frame_pause_len = NUBERT_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_36_KHZ); - break; - } + case IRMP_NUBERT_PROTOCOL: + { + startbit_pulse_len = NUBERT_START_BIT_PULSE_LEN; + startbit_pause_len = NUBERT_START_BIT_PAUSE_LEN - 1; + pulse_1_len = NUBERT_1_PULSE_LEN; + pause_1_len = NUBERT_1_PAUSE_LEN - 1; + pulse_0_len = NUBERT_0_PULSE_LEN; + pause_0_len = NUBERT_0_PAUSE_LEN - 1; + has_stop_bit = NUBERT_STOP_BIT; + complete_data_len = NUBERT_COMPLETE_DATA_LEN; + n_auto_repetitions = NUBERT_FRAMES; // 2 frames + auto_repetition_pause_len = NUBERT_AUTO_REPETITION_PAUSE_LEN; // 35 ms pause + repeat_frame_pause_len = NUBERT_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } #endif #if IRSND_SUPPORT_FAN_PROTOCOL == 1 - case IRMP_FAN_PROTOCOL: - { - startbit_pulse_len = FAN_START_BIT_PULSE_LEN; - startbit_pause_len = FAN_START_BIT_PAUSE_LEN - 1; - pulse_1_len = FAN_1_PULSE_LEN; - pause_1_len = FAN_1_PAUSE_LEN - 1; - pulse_0_len = FAN_0_PULSE_LEN; - pause_0_len = FAN_0_PAUSE_LEN - 1; - has_stop_bit = FAN_STOP_BIT; - complete_data_len = FAN_COMPLETE_DATA_LEN; - n_auto_repetitions = FAN_FRAMES; // only 1 frame - auto_repetition_pause_len = FAN_AUTO_REPETITION_PAUSE_LEN; // 35 ms pause - repeat_frame_pause_len = FAN_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_36_KHZ); - break; - } + case IRMP_FAN_PROTOCOL: + { + startbit_pulse_len = FAN_START_BIT_PULSE_LEN; + startbit_pause_len = FAN_START_BIT_PAUSE_LEN - 1; + pulse_1_len = FAN_1_PULSE_LEN; + pause_1_len = FAN_1_PAUSE_LEN - 1; + pulse_0_len = FAN_0_PULSE_LEN; + pause_0_len = FAN_0_PAUSE_LEN - 1; + has_stop_bit = FAN_STOP_BIT; + complete_data_len = FAN_COMPLETE_DATA_LEN; + n_auto_repetitions = FAN_FRAMES; // only 1 frame + auto_repetition_pause_len = FAN_AUTO_REPETITION_PAUSE_LEN; // 35 ms pause + repeat_frame_pause_len = FAN_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } #endif #if IRSND_SUPPORT_SPEAKER_PROTOCOL == 1 - case IRMP_SPEAKER_PROTOCOL: - { - startbit_pulse_len = SPEAKER_START_BIT_PULSE_LEN; - startbit_pause_len = SPEAKER_START_BIT_PAUSE_LEN - 1; - pulse_1_len = SPEAKER_1_PULSE_LEN; - pause_1_len = SPEAKER_1_PAUSE_LEN - 1; - pulse_0_len = SPEAKER_0_PULSE_LEN; - pause_0_len = SPEAKER_0_PAUSE_LEN - 1; - has_stop_bit = SPEAKER_STOP_BIT; - complete_data_len = SPEAKER_COMPLETE_DATA_LEN; - n_auto_repetitions = SPEAKER_FRAMES; // 2 frames - auto_repetition_pause_len = SPEAKER_AUTO_REPETITION_PAUSE_LEN; // 35 ms pause - repeat_frame_pause_len = SPEAKER_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_SPEAKER_PROTOCOL: + { + startbit_pulse_len = SPEAKER_START_BIT_PULSE_LEN; + startbit_pause_len = SPEAKER_START_BIT_PAUSE_LEN - 1; + pulse_1_len = SPEAKER_1_PULSE_LEN; + pause_1_len = SPEAKER_1_PAUSE_LEN - 1; + pulse_0_len = SPEAKER_0_PULSE_LEN; + pause_0_len = SPEAKER_0_PAUSE_LEN - 1; + has_stop_bit = SPEAKER_STOP_BIT; + complete_data_len = SPEAKER_COMPLETE_DATA_LEN; + n_auto_repetitions = SPEAKER_FRAMES; // 2 frames + auto_repetition_pause_len = SPEAKER_AUTO_REPETITION_PAUSE_LEN; // 35 ms pause + repeat_frame_pause_len = SPEAKER_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 - case IRMP_BANG_OLUFSEN_PROTOCOL: - { - startbit_pulse_len = BANG_OLUFSEN_START_BIT1_PULSE_LEN; - startbit_pause_len = BANG_OLUFSEN_START_BIT1_PAUSE_LEN - 1; - pulse_1_len = BANG_OLUFSEN_PULSE_LEN; - pause_1_len = BANG_OLUFSEN_1_PAUSE_LEN - 1; - pulse_0_len = BANG_OLUFSEN_PULSE_LEN; - pause_0_len = BANG_OLUFSEN_0_PAUSE_LEN - 1; - has_stop_bit = BANG_OLUFSEN_STOP_BIT; - complete_data_len = BANG_OLUFSEN_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = BANG_OLUFSEN_FRAME_REPEAT_PAUSE_LEN; - last_bit_value = 0; - irsnd_set_freq (IRSND_FREQ_455_KHZ); - break; - } + case IRMP_BANG_OLUFSEN_PROTOCOL: + { + startbit_pulse_len = BANG_OLUFSEN_START_BIT1_PULSE_LEN; + startbit_pause_len = BANG_OLUFSEN_START_BIT1_PAUSE_LEN - 1; + pulse_1_len = BANG_OLUFSEN_PULSE_LEN; + pause_1_len = BANG_OLUFSEN_1_PAUSE_LEN - 1; + pulse_0_len = BANG_OLUFSEN_PULSE_LEN; + pause_0_len = BANG_OLUFSEN_0_PAUSE_LEN - 1; + has_stop_bit = BANG_OLUFSEN_STOP_BIT; + complete_data_len = BANG_OLUFSEN_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = BANG_OLUFSEN_FRAME_REPEAT_PAUSE_LEN; + last_bit_value = 0; + irsnd_set_freq (IRSND_FREQ_455_KHZ); + break; + } #endif #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 - case IRMP_GRUNDIG_PROTOCOL: - { - startbit_pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - startbit_pause_len = GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN - 1; - pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - has_stop_bit = GRUNDIG_NOKIA_IR60_STOP_BIT; - complete_data_len = GRUNDIG_COMPLETE_DATA_LEN; - n_auto_repetitions = GRUNDIG_FRAMES; // 2 frames - auto_repetition_pause_len = GRUNDIG_AUTO_REPETITION_PAUSE_LEN; // 20m sec pause - repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_GRUNDIG_PROTOCOL: + { + startbit_pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + startbit_pause_len = GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN - 1; + pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + has_stop_bit = GRUNDIG_NOKIA_IR60_STOP_BIT; + complete_data_len = GRUNDIG_COMPLETE_DATA_LEN; + n_auto_repetitions = GRUNDIG_FRAMES; // 2 frames + auto_repetition_pause_len = GRUNDIG_AUTO_REPETITION_PAUSE_LEN; // 20m sec pause + repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_IR60_PROTOCOL == 1 - case IRMP_IR60_PROTOCOL: - { - startbit_pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - startbit_pause_len = GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN - 1; - pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - has_stop_bit = GRUNDIG_NOKIA_IR60_STOP_BIT; - complete_data_len = IR60_COMPLETE_DATA_LEN; - n_auto_repetitions = IR60_FRAMES; // 2 frames - auto_repetition_pause_len = IR60_AUTO_REPETITION_PAUSE_LEN; // 20m sec pause - repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause - irsnd_set_freq (IRSND_FREQ_30_KHZ); - break; - } + case IRMP_IR60_PROTOCOL: + { + startbit_pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + startbit_pause_len = GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN - 1; + pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + has_stop_bit = GRUNDIG_NOKIA_IR60_STOP_BIT; + complete_data_len = IR60_COMPLETE_DATA_LEN; + n_auto_repetitions = IR60_FRAMES; // 2 frames + auto_repetition_pause_len = IR60_AUTO_REPETITION_PAUSE_LEN; // 20m sec pause + repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause + irsnd_set_freq (IRSND_FREQ_30_KHZ); + break; + } #endif #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - case IRMP_NOKIA_PROTOCOL: - { - startbit_pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - startbit_pause_len = GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN - 1; - pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - has_stop_bit = GRUNDIG_NOKIA_IR60_STOP_BIT; - complete_data_len = NOKIA_COMPLETE_DATA_LEN; - n_auto_repetitions = NOKIA_FRAMES; // 2 frames - auto_repetition_pause_len = NOKIA_AUTO_REPETITION_PAUSE_LEN; // 20 msec pause - repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_NOKIA_PROTOCOL: + { + startbit_pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + startbit_pause_len = GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN - 1; + pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + has_stop_bit = GRUNDIG_NOKIA_IR60_STOP_BIT; + complete_data_len = NOKIA_COMPLETE_DATA_LEN; + n_auto_repetitions = NOKIA_FRAMES; // 2 frames + auto_repetition_pause_len = NOKIA_AUTO_REPETITION_PAUSE_LEN; // 20 msec pause + repeat_frame_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; // 117 msec pause + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 - case IRMP_SIEMENS_PROTOCOL: - { - startbit_pulse_len = SIEMENS_BIT_LEN; - startbit_pause_len = SIEMENS_BIT_LEN; - pulse_len = SIEMENS_BIT_LEN; - pause_len = SIEMENS_BIT_LEN; - has_stop_bit = SIEMENS_OR_RUWIDO_STOP_BIT; - complete_data_len = SIEMENS_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = SIEMENS_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_36_KHZ); - break; - } + case IRMP_SIEMENS_PROTOCOL: + { + startbit_pulse_len = SIEMENS_BIT_LEN; + startbit_pause_len = SIEMENS_BIT_LEN; + pulse_len = SIEMENS_BIT_LEN; + pause_len = SIEMENS_BIT_LEN; + has_stop_bit = SIEMENS_OR_RUWIDO_STOP_BIT; + complete_data_len = SIEMENS_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = SIEMENS_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } #endif #if IRSND_SUPPORT_RUWIDO_PROTOCOL == 1 - case IRMP_RUWIDO_PROTOCOL: - { - startbit_pulse_len = RUWIDO_START_BIT_PULSE_LEN; - startbit_pause_len = RUWIDO_START_BIT_PAUSE_LEN; - pulse_len = RUWIDO_BIT_PULSE_LEN; - pause_len = RUWIDO_BIT_PAUSE_LEN; - has_stop_bit = SIEMENS_OR_RUWIDO_STOP_BIT; - complete_data_len = RUWIDO_COMPLETE_DATA_LEN; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = RUWIDO_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_36_KHZ); - break; - } + case IRMP_RUWIDO_PROTOCOL: + { + startbit_pulse_len = RUWIDO_START_BIT_PULSE_LEN; + startbit_pause_len = RUWIDO_START_BIT_PAUSE_LEN; + pulse_len = RUWIDO_BIT_PULSE_LEN; + pause_len = RUWIDO_BIT_PAUSE_LEN; + has_stop_bit = SIEMENS_OR_RUWIDO_STOP_BIT; + complete_data_len = RUWIDO_COMPLETE_DATA_LEN; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = RUWIDO_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_36_KHZ); + break; + } #endif #if IRSND_SUPPORT_FDC_PROTOCOL == 1 - case IRMP_FDC_PROTOCOL: - { - startbit_pulse_len = FDC_START_BIT_PULSE_LEN; - startbit_pause_len = FDC_START_BIT_PAUSE_LEN - 1; - complete_data_len = FDC_COMPLETE_DATA_LEN; - pulse_1_len = FDC_PULSE_LEN; - pause_1_len = FDC_1_PAUSE_LEN - 1; - pulse_0_len = FDC_PULSE_LEN; - pause_0_len = FDC_0_PAUSE_LEN - 1; - has_stop_bit = FDC_STOP_BIT; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = FDC_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_FDC_PROTOCOL: + { + startbit_pulse_len = FDC_START_BIT_PULSE_LEN; + startbit_pause_len = FDC_START_BIT_PAUSE_LEN - 1; + complete_data_len = FDC_COMPLETE_DATA_LEN; + pulse_1_len = FDC_PULSE_LEN; + pause_1_len = FDC_1_PAUSE_LEN - 1; + pulse_0_len = FDC_PULSE_LEN; + pause_0_len = FDC_0_PAUSE_LEN - 1; + has_stop_bit = FDC_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = FDC_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1 - case IRMP_RCCAR_PROTOCOL: - { - startbit_pulse_len = RCCAR_START_BIT_PULSE_LEN; - startbit_pause_len = RCCAR_START_BIT_PAUSE_LEN - 1; - complete_data_len = RCCAR_COMPLETE_DATA_LEN; - pulse_1_len = RCCAR_PULSE_LEN; - pause_1_len = RCCAR_1_PAUSE_LEN - 1; - pulse_0_len = RCCAR_PULSE_LEN; - pause_0_len = RCCAR_0_PAUSE_LEN - 1; - has_stop_bit = RCCAR_STOP_BIT; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = RCCAR_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_RCCAR_PROTOCOL: + { + startbit_pulse_len = RCCAR_START_BIT_PULSE_LEN; + startbit_pause_len = RCCAR_START_BIT_PAUSE_LEN - 1; + complete_data_len = RCCAR_COMPLETE_DATA_LEN; + pulse_1_len = RCCAR_PULSE_LEN; + pause_1_len = RCCAR_1_PAUSE_LEN - 1; + pulse_0_len = RCCAR_PULSE_LEN; + pause_0_len = RCCAR_0_PAUSE_LEN - 1; + has_stop_bit = RCCAR_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = RCCAR_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_JVC_PROTOCOL == 1 - case IRMP_JVC_PROTOCOL: - { - if (repeat_counter != 0) // skip start bit if repetition frame - { - current_bit = 0; - } - - startbit_pulse_len = JVC_START_BIT_PULSE_LEN; - startbit_pause_len = JVC_START_BIT_PAUSE_LEN - 1; - complete_data_len = JVC_COMPLETE_DATA_LEN; - pulse_1_len = JVC_PULSE_LEN; - pause_1_len = JVC_1_PAUSE_LEN - 1; - pulse_0_len = JVC_PULSE_LEN; - pause_0_len = JVC_0_PAUSE_LEN - 1; - has_stop_bit = JVC_STOP_BIT; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = JVC_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_JVC_PROTOCOL: + { + if (repeat_counter != 0) // skip start bit if repetition frame + { + current_bit = 0; + } + + startbit_pulse_len = JVC_START_BIT_PULSE_LEN; + startbit_pause_len = JVC_START_BIT_PAUSE_LEN - 1; + complete_data_len = JVC_COMPLETE_DATA_LEN; + pulse_1_len = JVC_PULSE_LEN; + pause_1_len = JVC_1_PAUSE_LEN - 1; + pulse_0_len = JVC_PULSE_LEN; + pause_0_len = JVC_0_PAUSE_LEN - 1; + has_stop_bit = JVC_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = JVC_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_NIKON_PROTOCOL == 1 - case IRMP_NIKON_PROTOCOL: - { - startbit_pulse_len = NIKON_START_BIT_PULSE_LEN; - startbit_pause_len = NIKON_START_BIT_PAUSE_LEN; - complete_data_len = NIKON_COMPLETE_DATA_LEN; - pulse_1_len = NIKON_PULSE_LEN; - pause_1_len = NIKON_1_PAUSE_LEN - 1; - pulse_0_len = NIKON_PULSE_LEN; - pause_0_len = NIKON_0_PAUSE_LEN - 1; - has_stop_bit = NIKON_STOP_BIT; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = NIKON_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_NIKON_PROTOCOL: + { + startbit_pulse_len = NIKON_START_BIT_PULSE_LEN; + startbit_pause_len = NIKON_START_BIT_PAUSE_LEN; + complete_data_len = NIKON_COMPLETE_DATA_LEN; + pulse_1_len = NIKON_PULSE_LEN; + pause_1_len = NIKON_1_PAUSE_LEN - 1; + pulse_0_len = NIKON_PULSE_LEN; + pause_0_len = NIKON_0_PAUSE_LEN - 1; + has_stop_bit = NIKON_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = NIKON_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_LEGO_PROTOCOL == 1 - case IRMP_LEGO_PROTOCOL: - { - startbit_pulse_len = LEGO_START_BIT_PULSE_LEN; - startbit_pause_len = LEGO_START_BIT_PAUSE_LEN - 1; - complete_data_len = LEGO_COMPLETE_DATA_LEN; - pulse_1_len = LEGO_PULSE_LEN; - pause_1_len = LEGO_1_PAUSE_LEN - 1; - pulse_0_len = LEGO_PULSE_LEN; - pause_0_len = LEGO_0_PAUSE_LEN - 1; - has_stop_bit = LEGO_STOP_BIT; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = LEGO_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_LEGO_PROTOCOL: + { + startbit_pulse_len = LEGO_START_BIT_PULSE_LEN; + startbit_pause_len = LEGO_START_BIT_PAUSE_LEN - 1; + complete_data_len = LEGO_COMPLETE_DATA_LEN; + pulse_1_len = LEGO_PULSE_LEN; + pause_1_len = LEGO_1_PAUSE_LEN - 1; + pulse_0_len = LEGO_PULSE_LEN; + pause_0_len = LEGO_0_PAUSE_LEN - 1; + has_stop_bit = LEGO_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = LEGO_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_A1TVBOX_PROTOCOL == 1 - case IRMP_A1TVBOX_PROTOCOL: - { - startbit_pulse_len = A1TVBOX_BIT_PULSE_LEN; // don't use A1TVBOX_START_BIT_PULSE_LEN - startbit_pause_len = A1TVBOX_BIT_PAUSE_LEN; // don't use A1TVBOX_START_BIT_PAUSE_LEN - pulse_len = A1TVBOX_BIT_PULSE_LEN; - pause_len = A1TVBOX_BIT_PAUSE_LEN; - has_stop_bit = A1TVBOX_STOP_BIT; - complete_data_len = A1TVBOX_COMPLETE_DATA_LEN + 1; // we send stop bit as data - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = A1TVBOX_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_A1TVBOX_PROTOCOL: + { + startbit_pulse_len = A1TVBOX_BIT_PULSE_LEN; // don't use A1TVBOX_START_BIT_PULSE_LEN + startbit_pause_len = A1TVBOX_BIT_PAUSE_LEN; // don't use A1TVBOX_START_BIT_PAUSE_LEN + pulse_len = A1TVBOX_BIT_PULSE_LEN; + pause_len = A1TVBOX_BIT_PAUSE_LEN; + has_stop_bit = A1TVBOX_STOP_BIT; + complete_data_len = A1TVBOX_COMPLETE_DATA_LEN + 1; // we send stop bit as data + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = A1TVBOX_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_ROOMBA_PROTOCOL == 1 - case IRMP_ROOMBA_PROTOCOL: - { - startbit_pulse_len = ROOMBA_START_BIT_PULSE_LEN; - startbit_pause_len = ROOMBA_START_BIT_PAUSE_LEN; - pulse_1_len = ROOMBA_1_PULSE_LEN; - pause_1_len = ROOMBA_1_PAUSE_LEN - 1; - pulse_0_len = ROOMBA_0_PULSE_LEN; - pause_0_len = ROOMBA_0_PAUSE_LEN - 1; - has_stop_bit = ROOMBA_STOP_BIT; - complete_data_len = ROOMBA_COMPLETE_DATA_LEN; - n_auto_repetitions = ROOMBA_FRAMES; // 8 frames - auto_repetition_pause_len = ROOMBA_FRAME_REPEAT_PAUSE_LEN; - repeat_frame_pause_len = ROOMBA_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_ROOMBA_PROTOCOL: + { + startbit_pulse_len = ROOMBA_START_BIT_PULSE_LEN; + startbit_pause_len = ROOMBA_START_BIT_PAUSE_LEN; + pulse_1_len = ROOMBA_1_PULSE_LEN; + pause_1_len = ROOMBA_1_PAUSE_LEN - 1; + pulse_0_len = ROOMBA_0_PULSE_LEN; + pause_0_len = ROOMBA_0_PAUSE_LEN - 1; + has_stop_bit = ROOMBA_STOP_BIT; + complete_data_len = ROOMBA_COMPLETE_DATA_LEN; + n_auto_repetitions = ROOMBA_FRAMES; // 8 frames + auto_repetition_pause_len = ROOMBA_FRAME_REPEAT_PAUSE_LEN; + repeat_frame_pause_len = ROOMBA_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_PENTAX_PROTOCOL == 1 - case IRMP_PENTAX_PROTOCOL: - { - startbit_pulse_len = PENTAX_START_BIT_PULSE_LEN; - startbit_pause_len = PENTAX_START_BIT_PAUSE_LEN; - complete_data_len = PENTAX_COMPLETE_DATA_LEN; - pulse_1_len = PENTAX_PULSE_LEN; - pause_1_len = PENTAX_1_PAUSE_LEN - 1; - pulse_0_len = PENTAX_PULSE_LEN; - pause_0_len = PENTAX_0_PAUSE_LEN - 1; - has_stop_bit = PENTAX_STOP_BIT; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = PENTAX_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } + case IRMP_PENTAX_PROTOCOL: + { + startbit_pulse_len = PENTAX_START_BIT_PULSE_LEN; + startbit_pause_len = PENTAX_START_BIT_PAUSE_LEN; + complete_data_len = PENTAX_COMPLETE_DATA_LEN; + pulse_1_len = PENTAX_PULSE_LEN; + pause_1_len = PENTAX_1_PAUSE_LEN - 1; + pulse_0_len = PENTAX_PULSE_LEN; + pause_0_len = PENTAX_0_PAUSE_LEN - 1; + has_stop_bit = PENTAX_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = PENTAX_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } #endif #if IRSND_SUPPORT_ACP24_PROTOCOL == 1 - case IRMP_ACP24_PROTOCOL: - { - startbit_pulse_len = ACP24_START_BIT_PULSE_LEN; - startbit_pause_len = ACP24_START_BIT_PAUSE_LEN - 1; - complete_data_len = ACP24_COMPLETE_DATA_LEN; - pulse_1_len = ACP24_PULSE_LEN; - pause_1_len = ACP24_1_PAUSE_LEN - 1; - pulse_0_len = ACP24_PULSE_LEN; - pause_0_len = ACP24_0_PAUSE_LEN - 1; - has_stop_bit = ACP24_STOP_BIT; - n_auto_repetitions = 1; // 1 frame - auto_repetition_pause_len = 0; - repeat_frame_pause_len = ACP24_FRAME_REPEAT_PAUSE_LEN; - irsnd_set_freq (IRSND_FREQ_38_KHZ); - break; - } -#endif - default: - { - irsnd_busy = FALSE; - break; - } - } - } - } - - if (irsnd_busy) - { - new_frame = FALSE; - - switch (irsnd_protocol) - { + case IRMP_ACP24_PROTOCOL: + { + startbit_pulse_len = ACP24_START_BIT_PULSE_LEN; + startbit_pause_len = ACP24_START_BIT_PAUSE_LEN - 1; + complete_data_len = ACP24_COMPLETE_DATA_LEN; + pulse_1_len = ACP24_PULSE_LEN; + pause_1_len = ACP24_1_PAUSE_LEN - 1; + pulse_0_len = ACP24_PULSE_LEN; + pause_0_len = ACP24_0_PAUSE_LEN - 1; + has_stop_bit = ACP24_STOP_BIT; + n_auto_repetitions = 1; // 1 frame + auto_repetition_pause_len = 0; + repeat_frame_pause_len = ACP24_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_38_KHZ); + break; + } +#endif + default: + { + irsnd_busy = FALSE; + break; + } + } + } + } + + if (irsnd_busy) + { + new_frame = FALSE; + + switch (irsnd_protocol) + { #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 - case IRMP_SIRCS_PROTOCOL: + case IRMP_SIRCS_PROTOCOL: #endif #if IRSND_SUPPORT_NEC_PROTOCOL == 1 - case IRMP_NEC_PROTOCOL: + case IRMP_NEC_PROTOCOL: #endif #if IRSND_SUPPORT_NEC16_PROTOCOL == 1 - case IRMP_NEC16_PROTOCOL: + case IRMP_NEC16_PROTOCOL: #endif #if IRSND_SUPPORT_NEC42_PROTOCOL == 1 - case IRMP_NEC42_PROTOCOL: + case IRMP_NEC42_PROTOCOL: #endif #if IRSND_SUPPORT_LGAIR_PROTOCOL == 1 - case IRMP_LGAIR_PROTOCOL: + case IRMP_LGAIR_PROTOCOL: #endif #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 - case IRMP_SAMSUNG_PROTOCOL: - case IRMP_SAMSUNG32_PROTOCOL: + case IRMP_SAMSUNG_PROTOCOL: + case IRMP_SAMSUNG32_PROTOCOL: #endif #if IRSND_SUPPORT_SAMSUNG48_PROTOCOL == 1 - case IRMP_SAMSUNG48_PROTOCOL: + case IRMP_SAMSUNG48_PROTOCOL: #endif #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 - case IRMP_MATSUSHITA_PROTOCOL: + case IRMP_MATSUSHITA_PROTOCOL: #endif #if IRSND_SUPPORT_MATSUSHITA_PROTOCOL == 1 - case IRMP_TECHNICS_PROTOCOL: + case IRMP_TECHNICS_PROTOCOL: #endif #if IRSND_SUPPORT_KASEIKYO_PROTOCOL == 1 - case IRMP_KASEIKYO_PROTOCOL: + case IRMP_KASEIKYO_PROTOCOL: +#endif +#if IRSND_SUPPORT_PANASONIC_PROTOCOL == 1 + case IRMP_PANASONIC_PROTOCOL: #endif #if IRSND_SUPPORT_RECS80_PROTOCOL == 1 - case IRMP_RECS80_PROTOCOL: + case IRMP_RECS80_PROTOCOL: #endif #if IRSND_SUPPORT_RECS80EXT_PROTOCOL == 1 - case IRMP_RECS80EXT_PROTOCOL: + case IRMP_RECS80EXT_PROTOCOL: #endif #if IRSND_SUPPORT_TELEFUNKEN_PROTOCOL == 1 - case IRMP_TELEFUNKEN_PROTOCOL: + case IRMP_TELEFUNKEN_PROTOCOL: #endif #if IRSND_SUPPORT_DENON_PROTOCOL == 1 - case IRMP_DENON_PROTOCOL: + case IRMP_DENON_PROTOCOL: +#endif +#if IRSND_SUPPORT_BOSE_PROTOCOL == 1 + case IRMP_BOSE_PROTOCOL: #endif #if IRSND_SUPPORT_NUBERT_PROTOCOL == 1 - case IRMP_NUBERT_PROTOCOL: + case IRMP_NUBERT_PROTOCOL: #endif #if IRSND_SUPPORT_FAN_PROTOCOL == 1 - case IRMP_FAN_PROTOCOL: + case IRMP_FAN_PROTOCOL: #endif #if IRSND_SUPPORT_SPEAKER_PROTOCOL == 1 - case IRMP_SPEAKER_PROTOCOL: + case IRMP_SPEAKER_PROTOCOL: #endif #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 - case IRMP_BANG_OLUFSEN_PROTOCOL: + case IRMP_BANG_OLUFSEN_PROTOCOL: #endif #if IRSND_SUPPORT_FDC_PROTOCOL == 1 - case IRMP_FDC_PROTOCOL: + case IRMP_FDC_PROTOCOL: #endif #if IRSND_SUPPORT_RCCAR_PROTOCOL == 1 - case IRMP_RCCAR_PROTOCOL: + case IRMP_RCCAR_PROTOCOL: #endif #if IRSND_SUPPORT_JVC_PROTOCOL == 1 - case IRMP_JVC_PROTOCOL: + case IRMP_JVC_PROTOCOL: #endif #if IRSND_SUPPORT_NIKON_PROTOCOL == 1 - case IRMP_NIKON_PROTOCOL: + case IRMP_NIKON_PROTOCOL: #endif #if IRSND_SUPPORT_LEGO_PROTOCOL == 1 - case IRMP_LEGO_PROTOCOL: + case IRMP_LEGO_PROTOCOL: #endif #if IRSND_SUPPORT_THOMSON_PROTOCOL == 1 - case IRMP_THOMSON_PROTOCOL: + case IRMP_THOMSON_PROTOCOL: #endif #if IRSND_SUPPORT_ROOMBA_PROTOCOL == 1 - case IRMP_ROOMBA_PROTOCOL: + case IRMP_ROOMBA_PROTOCOL: #endif #if IRSND_SUPPORT_PENTAX_PROTOCOL == 1 - case IRMP_PENTAX_PROTOCOL: + case IRMP_PENTAX_PROTOCOL: #endif #if IRSND_SUPPORT_ACP24_PROTOCOL == 1 - case IRMP_ACP24_PROTOCOL: + case IRMP_ACP24_PROTOCOL: #endif #if IRSND_SUPPORT_SIRCS_PROTOCOL == 1 || IRSND_SUPPORT_NEC_PROTOCOL == 1 || IRSND_SUPPORT_NEC16_PROTOCOL == 1 || IRSND_SUPPORT_NEC42_PROTOCOL == 1 || \ @@ -2363,217 +2474,202 @@ irsnd_ISR (void) IRSND_SUPPORT_NUBERT_PROTOCOL == 1 || IRSND_SUPPORT_FAN_PROTOCOL == 1 || IRSND_SUPPORT_SPEAKER_PROTOCOL == 1 || IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 || \ IRSND_SUPPORT_FDC_PROTOCOL == 1 || IRSND_SUPPORT_RCCAR_PROTOCOL == 1 || IRSND_SUPPORT_JVC_PROTOCOL == 1 || IRSND_SUPPORT_NIKON_PROTOCOL == 1 || \ IRSND_SUPPORT_LEGO_PROTOCOL == 1 || IRSND_SUPPORT_THOMSON_PROTOCOL == 1 || IRSND_SUPPORT_ROOMBA_PROTOCOL == 1 || IRSND_SUPPORT_TELEFUNKEN_PROTOCOL == 1 || \ - IRSND_SUPPORT_PENTAX_PROTOCOL == 1 || IRSND_SUPPORT_ACP24_PROTOCOL == 1 - { -#if IRSND_SUPPORT_DENON_PROTOCOL == 1 - if (irsnd_protocol == IRMP_DENON_PROTOCOL) - { - if (auto_repetition_pause_len > 0) // 2nd frame distance counts from beginning of 1st frame! - { - auto_repetition_pause_len--; - } - - if (repeat_frame_pause_len > 0) // frame repeat distance counts from beginning of 1st frame! - { - repeat_frame_pause_len--; - } - } -#endif - - if (pulse_counter == 0) - { - if (current_bit == 0xFF) // send start bit - { - pulse_len = startbit_pulse_len; - pause_len = startbit_pause_len; - } - else if (current_bit < complete_data_len) // send n'th bit - { + IRSND_SUPPORT_PENTAX_PROTOCOL == 1 || IRSND_SUPPORT_ACP24_PROTOCOL == 1 || IRSND_SUPPORT_PANASONIC_PROTOCOL == 1 + { + if (pulse_counter == 0) + { + if (current_bit == 0xFF) // send start bit + { + pulse_len = startbit_pulse_len; + pause_len = startbit_pause_len; + } + else if (current_bit < complete_data_len) // send n'th bit + { #if IRSND_SUPPORT_SAMSUNG_PROTOCOL == 1 - if (irsnd_protocol == IRMP_SAMSUNG_PROTOCOL) - { - if (current_bit < SAMSUNG_ADDRESS_LEN) // send address bits - { - pulse_len = SAMSUNG_PULSE_LEN; - pause_len = (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) ? - (SAMSUNG_1_PAUSE_LEN - 1) : (SAMSUNG_0_PAUSE_LEN - 1); - } - else if (current_bit == SAMSUNG_ADDRESS_LEN) // send SYNC bit (16th bit) - { - pulse_len = SAMSUNG_PULSE_LEN; - pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1; - } - else if (current_bit < SAMSUNG_COMPLETE_DATA_LEN) // send n'th bit - { - uint8_t cur_bit = current_bit - 1; // sync skipped, offset = -1 ! - - pulse_len = SAMSUNG_PULSE_LEN; - pause_len = (irsnd_buffer[cur_bit >> 3] & (1<<(7-(cur_bit & 7)))) ? - (SAMSUNG_1_PAUSE_LEN - 1) : (SAMSUNG_0_PAUSE_LEN - 1); - } - } - else + if (irsnd_protocol == IRMP_SAMSUNG_PROTOCOL) + { + if (current_bit < SAMSUNG_ADDRESS_LEN) // send address bits + { + pulse_len = SAMSUNG_PULSE_LEN; + pause_len = (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) ? + (SAMSUNG_1_PAUSE_LEN - 1) : (SAMSUNG_0_PAUSE_LEN - 1); + } + else if (current_bit == SAMSUNG_ADDRESS_LEN) // send SYNC bit (16th bit) + { + pulse_len = SAMSUNG_PULSE_LEN; + pause_len = SAMSUNG_START_BIT_PAUSE_LEN - 1; + } + else if (current_bit < SAMSUNG_COMPLETE_DATA_LEN) // send n'th bit + { + uint8_t cur_bit = current_bit - 1; // sync skipped, offset = -1 ! + + pulse_len = SAMSUNG_PULSE_LEN; + pause_len = (irsnd_buffer[cur_bit >> 3] & (1<<(7-(cur_bit & 7)))) ? + (SAMSUNG_1_PAUSE_LEN - 1) : (SAMSUNG_0_PAUSE_LEN - 1); + } + } + else #endif #if IRSND_SUPPORT_NEC16_PROTOCOL == 1 - if (irsnd_protocol == IRMP_NEC16_PROTOCOL) - { - if (current_bit < NEC16_ADDRESS_LEN) // send address bits - { - pulse_len = NEC_PULSE_LEN; - pause_len = (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) ? - (NEC_1_PAUSE_LEN - 1) : (NEC_0_PAUSE_LEN - 1); - } - else if (current_bit == NEC16_ADDRESS_LEN) // send SYNC bit (8th bit) - { - pulse_len = NEC_PULSE_LEN; - pause_len = NEC_START_BIT_PAUSE_LEN - 1; - } - else if (current_bit < NEC16_COMPLETE_DATA_LEN + 1) // send n'th bit - { - uint8_t cur_bit = current_bit - 1; // sync skipped, offset = -1 ! - - pulse_len = NEC_PULSE_LEN; - pause_len = (irsnd_buffer[cur_bit >> 3] & (1<<(7-(cur_bit & 7)))) ? - (NEC_1_PAUSE_LEN - 1) : (NEC_0_PAUSE_LEN - 1); - } - } - else + if (irsnd_protocol == IRMP_NEC16_PROTOCOL) + { + if (current_bit < NEC16_ADDRESS_LEN) // send address bits + { + pulse_len = NEC_PULSE_LEN; + pause_len = (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) ? + (NEC_1_PAUSE_LEN - 1) : (NEC_0_PAUSE_LEN - 1); + } + else if (current_bit == NEC16_ADDRESS_LEN) // send SYNC bit (8th bit) + { + pulse_len = NEC_PULSE_LEN; + pause_len = NEC_START_BIT_PAUSE_LEN - 1; + } + else if (current_bit < NEC16_COMPLETE_DATA_LEN + 1) // send n'th bit + { + uint8_t cur_bit = current_bit - 1; // sync skipped, offset = -1 ! + + pulse_len = NEC_PULSE_LEN; + pause_len = (irsnd_buffer[cur_bit >> 3] & (1<<(7-(cur_bit & 7)))) ? + (NEC_1_PAUSE_LEN - 1) : (NEC_0_PAUSE_LEN - 1); + } + } + else #endif #if IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 - if (irsnd_protocol == IRMP_BANG_OLUFSEN_PROTOCOL) - { - if (current_bit == 0) // send 2nd start bit - { - pulse_len = BANG_OLUFSEN_START_BIT2_PULSE_LEN; - pause_len = BANG_OLUFSEN_START_BIT2_PAUSE_LEN - 1; - } - else if (current_bit == 1) // send 3rd start bit - { - pulse_len = BANG_OLUFSEN_START_BIT3_PULSE_LEN; - pause_len = BANG_OLUFSEN_START_BIT3_PAUSE_LEN - 1; - } - else if (current_bit == 2) // send 4th start bit - { - pulse_len = BANG_OLUFSEN_START_BIT2_PULSE_LEN; - pause_len = BANG_OLUFSEN_START_BIT2_PAUSE_LEN - 1; - } - else if (current_bit == 19) // send trailer bit - { - pulse_len = BANG_OLUFSEN_PULSE_LEN; - pause_len = BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN - 1; - } - else if (current_bit < BANG_OLUFSEN_COMPLETE_DATA_LEN) // send n'th bit - { - uint8_t cur_bit_value = (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) ? 1 : 0; - pulse_len = BANG_OLUFSEN_PULSE_LEN; - - if (cur_bit_value == last_bit_value) - { - pause_len = BANG_OLUFSEN_R_PAUSE_LEN - 1; - } - else - { - pause_len = cur_bit_value ? (BANG_OLUFSEN_1_PAUSE_LEN - 1) : (BANG_OLUFSEN_0_PAUSE_LEN - 1); - last_bit_value = cur_bit_value; - } - } - } - else -#endif - if (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) - { - pulse_len = pulse_1_len; - pause_len = pause_1_len; - } - else - { - pulse_len = pulse_0_len; - pause_len = pause_0_len; - } - } - else if (has_stop_bit) // send stop bit - { - pulse_len = pulse_0_len; - - if (auto_repetition_counter < n_auto_repetitions) - { - pause_len = pause_0_len; - } - else - { - pause_len = 255; // last frame: pause of 255 - } - } - } - - if (pulse_counter < pulse_len) - { - if (pulse_counter == 0) - { - irsnd_on (); - } - pulse_counter++; - } - else if (pause_counter < pause_len) - { - if (pause_counter == 0) - { - irsnd_off (); - } - pause_counter++; - } - else - { - current_bit++; - - if (current_bit >= complete_data_len + has_stop_bit) - { - current_bit = 0xFF; - auto_repetition_counter++; - - if (auto_repetition_counter == n_auto_repetitions) - { - irsnd_busy = FALSE; - auto_repetition_counter = 0; - } - new_frame = TRUE; - } - - pulse_counter = 0; - pause_counter = 0; - } - break; - } + if (irsnd_protocol == IRMP_BANG_OLUFSEN_PROTOCOL) + { + if (current_bit == 0) // send 2nd start bit + { + pulse_len = BANG_OLUFSEN_START_BIT2_PULSE_LEN; + pause_len = BANG_OLUFSEN_START_BIT2_PAUSE_LEN - 1; + } + else if (current_bit == 1) // send 3rd start bit + { + pulse_len = BANG_OLUFSEN_START_BIT3_PULSE_LEN; + pause_len = BANG_OLUFSEN_START_BIT3_PAUSE_LEN - 1; + } + else if (current_bit == 2) // send 4th start bit + { + pulse_len = BANG_OLUFSEN_START_BIT2_PULSE_LEN; + pause_len = BANG_OLUFSEN_START_BIT2_PAUSE_LEN - 1; + } + else if (current_bit == 19) // send trailer bit + { + pulse_len = BANG_OLUFSEN_PULSE_LEN; + pause_len = BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN - 1; + } + else if (current_bit < BANG_OLUFSEN_COMPLETE_DATA_LEN) // send n'th bit + { + uint8_t cur_bit_value = (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) ? 1 : 0; + pulse_len = BANG_OLUFSEN_PULSE_LEN; + + if (cur_bit_value == last_bit_value) + { + pause_len = BANG_OLUFSEN_R_PAUSE_LEN - 1; + } + else + { + pause_len = cur_bit_value ? (BANG_OLUFSEN_1_PAUSE_LEN - 1) : (BANG_OLUFSEN_0_PAUSE_LEN - 1); + last_bit_value = cur_bit_value; + } + } + } + else +#endif + if (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) + { + pulse_len = pulse_1_len; + pause_len = pause_1_len; + } + else + { + pulse_len = pulse_0_len; + pause_len = pause_0_len; + } + } + else if (has_stop_bit) // send stop bit + { + pulse_len = pulse_0_len; + + if (auto_repetition_counter < n_auto_repetitions) + { + pause_len = pause_0_len; + } + else + { + pause_len = 255; // last frame: pause of 255 + } + } + } + + if (pulse_counter < pulse_len) + { + if (pulse_counter == 0) + { + irsnd_on (); + } + pulse_counter++; + } + else if (pause_counter < pause_len) + { + if (pause_counter == 0) + { + irsnd_off (); + } + pause_counter++; + } + else + { + current_bit++; + + if (current_bit >= complete_data_len + has_stop_bit) + { + current_bit = 0xFF; + auto_repetition_counter++; + + if (auto_repetition_counter == n_auto_repetitions) + { + irsnd_busy = FALSE; + auto_repetition_counter = 0; + } + new_frame = TRUE; + } + + pulse_counter = 0; + pause_counter = 0; + } + break; + } #endif #if IRSND_SUPPORT_RC5_PROTOCOL == 1 - case IRMP_RC5_PROTOCOL: + case IRMP_RC5_PROTOCOL: #endif #if IRSND_SUPPORT_RC6_PROTOCOL == 1 - case IRMP_RC6_PROTOCOL: + case IRMP_RC6_PROTOCOL: #endif #if IRSND_SUPPORT_RC6A_PROTOCOL == 1 - case IRMP_RC6A_PROTOCOL: + case IRMP_RC6A_PROTOCOL: #endif #if IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 - case IRMP_SIEMENS_PROTOCOL: + case IRMP_SIEMENS_PROTOCOL: #endif #if IRSND_SUPPORT_RUWIDO_PROTOCOL == 1 - case IRMP_RUWIDO_PROTOCOL: + case IRMP_RUWIDO_PROTOCOL: #endif #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 - case IRMP_GRUNDIG_PROTOCOL: + case IRMP_GRUNDIG_PROTOCOL: #endif #if IRSND_SUPPORT_IR60_PROTOCOL == 1 - case IRMP_IR60_PROTOCOL: + case IRMP_IR60_PROTOCOL: #endif #if IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - case IRMP_NOKIA_PROTOCOL: + case IRMP_NOKIA_PROTOCOL: #endif #if IRSND_SUPPORT_A1TVBOX_PROTOCOL == 1 - case IRMP_A1TVBOX_PROTOCOL: + case IRMP_A1TVBOX_PROTOCOL: #endif #if IRSND_SUPPORT_RC5_PROTOCOL == 1 || \ @@ -2585,226 +2681,226 @@ irsnd_ISR (void) IRSND_SUPPORT_IR60_PROTOCOL == 1 || \ IRSND_SUPPORT_NOKIA_PROTOCOL == 1 || \ IRSND_SUPPORT_A1TVBOX_PROTOCOL == 1 - { - if (pulse_counter == pulse_len && pause_counter == pause_len) - { - current_bit++; + { + if (pulse_counter == pulse_len && pause_counter == pause_len) + { + current_bit++; - if (current_bit >= complete_data_len) - { - current_bit = 0xFF; + if (current_bit >= complete_data_len) + { + current_bit = 0xFF; #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_IR60_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL) - { - auto_repetition_counter++; - - if (repeat_counter > 0) - { // set 117 msec pause time - auto_repetition_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; - } - - if (repeat_counter < n_repeat_frames) // tricky: repeat n info frames per auto repetition before sending last stop frame - { - n_auto_repetitions++; // increment number of auto repetitions - repeat_counter++; - } - else if (auto_repetition_counter == n_auto_repetitions) - { - irsnd_busy = FALSE; - auto_repetition_counter = 0; - } - } - else -#endif - { - irsnd_busy = FALSE; - } - - new_frame = TRUE; - irsnd_off (); - } - - pulse_counter = 0; - pause_counter = 0; - } - - if (! new_frame) - { - uint8_t first_pulse; + if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_IR60_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL) + { + auto_repetition_counter++; + + if (repeat_counter > 0) + { // set 117 msec pause time + auto_repetition_pause_len = GRUNDIG_NOKIA_IR60_FRAME_REPEAT_PAUSE_LEN; + } + + if (repeat_counter < n_repeat_frames) // tricky: repeat n info frames per auto repetition before sending last stop frame + { + n_auto_repetitions++; // increment number of auto repetitions + repeat_counter++; + } + else if (auto_repetition_counter == n_auto_repetitions) + { + irsnd_busy = FALSE; + auto_repetition_counter = 0; + } + } + else +#endif + { + irsnd_busy = FALSE; + } + + new_frame = TRUE; + irsnd_off (); + } + + pulse_counter = 0; + pause_counter = 0; + } + + if (! new_frame) + { + uint8_t first_pulse; #if IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_IR60_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL) - { - if (current_bit == 0xFF || // start bit of start-frame - (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL && current_bit == 15) || // start bit of info-frame (Grundig) - (irsnd_protocol == IRMP_IR60_PROTOCOL && current_bit == 7) || // start bit of data frame (IR60) - (irsnd_protocol == IRMP_NOKIA_PROTOCOL && (current_bit == 23 || current_bit == 47))) // start bit of info- or stop-frame (Nokia) - { - pulse_len = startbit_pulse_len; - pause_len = startbit_pause_len; - first_pulse = TRUE; - } - else // send n'th bit - { - pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN; - first_pulse = (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) ? TRUE : FALSE; - } - } - else // if (irsnd_protocol == IRMP_RC5_PROTOCOL || irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL || - // irsnd_protocol == IRMP_SIEMENS_PROTOCOL || irsnd_protocol == IRMP_RUWIDO_PROTOCOL) -#endif - { - if (current_bit == 0xFF) // 1 start bit - { + if (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL || irsnd_protocol == IRMP_IR60_PROTOCOL || irsnd_protocol == IRMP_NOKIA_PROTOCOL) + { + if (current_bit == 0xFF || // start bit of start-frame + (irsnd_protocol == IRMP_GRUNDIG_PROTOCOL && current_bit == 15) || // start bit of info-frame (Grundig) + (irsnd_protocol == IRMP_IR60_PROTOCOL && current_bit == 7) || // start bit of data frame (IR60) + (irsnd_protocol == IRMP_NOKIA_PROTOCOL && (current_bit == 23 || current_bit == 47))) // start bit of info- or stop-frame (Nokia) + { + pulse_len = startbit_pulse_len; + pause_len = startbit_pause_len; + first_pulse = TRUE; + } + else // send n'th bit + { + pulse_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + pause_len = GRUNDIG_NOKIA_IR60_BIT_LEN; + first_pulse = (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) ? TRUE : FALSE; + } + } + else // if (irsnd_protocol == IRMP_RC5_PROTOCOL || irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL || + // irsnd_protocol == IRMP_SIEMENS_PROTOCOL || irsnd_protocol == IRMP_RUWIDO_PROTOCOL) +#endif + { + if (current_bit == 0xFF) // 1 start bit + { #if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1 - if (irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL) - { - pulse_len = startbit_pulse_len; - pause_len = startbit_pause_len; - } - else + if (irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL) + { + pulse_len = startbit_pulse_len; + pause_len = startbit_pause_len; + } + else #endif #if IRSND_SUPPORT_A1TVBOX_PROTOCOL == 1 - if (irsnd_protocol == IRMP_A1TVBOX_PROTOCOL) - { - current_bit = 0; - } - else -#endif - { - ; - } - - first_pulse = TRUE; - } - else // send n'th bit - { + if (irsnd_protocol == IRMP_A1TVBOX_PROTOCOL) + { + current_bit = 0; + } + else +#endif + { + ; + } + + first_pulse = TRUE; + } + else // send n'th bit + { #if IRSND_SUPPORT_RC6_PROTOCOL == 1 || IRSND_SUPPORT_RC6A_PROTOCOL == 1 - if (irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL) - { - pulse_len = RC6_BIT_LEN; - pause_len = RC6_BIT_LEN; - - if (irsnd_protocol == IRMP_RC6_PROTOCOL) - { - if (current_bit == 4) // toggle bit (double len) - { - pulse_len = 2 * RC6_BIT_LEN; - pause_len = 2 * RC6_BIT_LEN; - } - } - else // if (irsnd_protocol == IRMP_RC6A_PROTOCOL) - { - if (current_bit == 4) // toggle bit (double len) - { - pulse_len = 2 * RC6_BIT_LEN + RC6_BIT_LEN; // hack! - pause_len = 2 * RC6_BIT_LEN; - } - else if (current_bit == 5) // toggle bit (double len) - { - pause_len = 2 * RC6_BIT_LEN; - } - } - } -#endif - first_pulse = (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) ? TRUE : FALSE; - } - - if (irsnd_protocol == IRMP_RC5_PROTOCOL) - { - first_pulse = first_pulse ? FALSE : TRUE; - } - } - - if (first_pulse) - { - // printf ("first_pulse: current_bit: %d %d < %d %d < %d\n", current_bit, pause_counter, pause_len, pulse_counter, pulse_len); - - if (pulse_counter < pulse_len) - { - if (pulse_counter == 0) - { - irsnd_on (); - } - pulse_counter++; - } - else // if (pause_counter < pause_len) - { - if (pause_counter == 0) - { - irsnd_off (); - } - pause_counter++; - } - } - else - { - // printf ("first_pause: current_bit: %d %d < %d %d < %d\n", current_bit, pause_counter, pause_len, pulse_counter, pulse_len); - - if (pause_counter < pause_len) - { - if (pause_counter == 0) - { - irsnd_off (); - } - pause_counter++; - } - else // if (pulse_counter < pulse_len) - { - if (pulse_counter == 0) - { - irsnd_on (); - } - pulse_counter++; - } - } - } - break; - } + if (irsnd_protocol == IRMP_RC6_PROTOCOL || irsnd_protocol == IRMP_RC6A_PROTOCOL) + { + pulse_len = RC6_BIT_LEN; + pause_len = RC6_BIT_LEN; + + if (irsnd_protocol == IRMP_RC6_PROTOCOL) + { + if (current_bit == 4) // toggle bit (double len) + { + pulse_len = RC6_BIT_2_LEN; // = 2 * RC_BIT_LEN + pause_len = RC6_BIT_2_LEN; // = 2 * RC_BIT_LEN + } + } + else // if (irsnd_protocol == IRMP_RC6A_PROTOCOL) + { + if (current_bit == 4) // toggle bit (double len) + { + pulse_len = RC6_BIT_3_LEN; // = 3 * RC6_BIT_LEN + pause_len = RC6_BIT_2_LEN; // = 2 * RC6_BIT_LEN + } + else if (current_bit == 5) // toggle bit (double len) + { + pause_len = RC6_BIT_2_LEN; // = 2 * RC6_BIT_LEN + } + } + } +#endif + first_pulse = (irsnd_buffer[current_bit >> 3] & (1<<(7-(current_bit & 7)))) ? TRUE : FALSE; + } + + if (irsnd_protocol == IRMP_RC5_PROTOCOL) + { + first_pulse = first_pulse ? FALSE : TRUE; + } + } + + if (first_pulse) + { + // printf ("first_pulse: current_bit: %d %d < %d %d < %d\n", current_bit, pause_counter, pause_len, pulse_counter, pulse_len); + + if (pulse_counter < pulse_len) + { + if (pulse_counter == 0) + { + irsnd_on (); + } + pulse_counter++; + } + else // if (pause_counter < pause_len) + { + if (pause_counter == 0) + { + irsnd_off (); + } + pause_counter++; + } + } + else + { + // printf ("first_pause: current_bit: %d %d < %d %d < %d\n", current_bit, pause_counter, pause_len, pulse_counter, pulse_len); + + if (pause_counter < pause_len) + { + if (pause_counter == 0) + { + irsnd_off (); + } + pause_counter++; + } + else // if (pulse_counter < pulse_len) + { + if (pulse_counter == 0) + { + irsnd_on (); + } + pulse_counter++; + } + } + } + break; + } #endif // IRSND_SUPPORT_RC5_PROTOCOL == 1 || IRSND_SUPPORT_RC6_PROTOCOL == 1 || || IRSND_SUPPORT_RC6A_PROTOCOL == 1 || IRSND_SUPPORT_SIEMENS_PROTOCOL == 1 || // IRSND_SUPPORT_RUWIDO_PROTOCOL == 1 || IRSND_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRSND_SUPPORT_IR60_PROTOCOL == 1 || IRSND_SUPPORT_NOKIA_PROTOCOL == 1 - default: - { - irsnd_busy = FALSE; - break; - } - } - } - - if (! irsnd_busy) - { - if (repeat_counter < n_repeat_frames) - { + default: + { + irsnd_busy = FALSE; + break; + } + } + } + + if (! irsnd_busy) + { + if (repeat_counter < n_repeat_frames) + { #if IRSND_SUPPORT_FDC_PROTOCOL == 1 - if (irsnd_protocol == IRMP_FDC_PROTOCOL) - { - irsnd_buffer[2] |= 0x0F; - } -#endif - repeat_counter++; - irsnd_busy = TRUE; - } - else - { - irsnd_busy = TRUE; //Rainer - send_trailer = TRUE; - n_repeat_frames = 0; - repeat_counter = 0; - } - } + if (irsnd_protocol == IRMP_FDC_PROTOCOL) + { + irsnd_buffer[2] |= 0x0F; + } +#endif + repeat_counter++; + irsnd_busy = TRUE; + } + else + { + irsnd_busy = TRUE; //Rainer + send_trailer = TRUE; + n_repeat_frames = 0; + repeat_counter = 0; + } + } } #ifdef ANALYZE if (irsnd_is_on) { - putchar ('0'); + putchar ('0'); } else { - putchar ('1'); + putchar ('1'); } #endif @@ -2830,53 +2926,53 @@ main (int argc, char ** argv) if (argc != 4 && argc != 5) { - fprintf (stderr, "usage: %s protocol hex-address hex-command [repeat] > filename\n", argv[0]); - return 1; + fprintf (stderr, "usage: %s protocol hex-address hex-command [repeat] > filename\n", argv[0]); + return 1; } if (sscanf (argv[1], "%d", &protocol) == 1 && - sscanf (argv[2], "%x", &address) == 1 && - sscanf (argv[3], "%x", &command) == 1) + sscanf (argv[2], "%x", &address) == 1 && + sscanf (argv[3], "%x", &command) == 1) { - irmp_data.protocol = protocol; - irmp_data.address = address; - irmp_data.command = command; + irmp_data.protocol = protocol; + irmp_data.address = address; + irmp_data.command = command; - if (argc == 5) - { - irmp_data.flags = atoi (argv[4]); - } - else - { - irmp_data.flags = 0; - } + if (argc == 5) + { + irmp_data.flags = atoi (argv[4]); + } + else + { + irmp_data.flags = 0; + } - irsnd_init (); + irsnd_init (); - (void) irsnd_send_data (&irmp_data, TRUE); + (void) irsnd_send_data (&irmp_data, TRUE); - while (irsnd_busy) - { - irsnd_ISR (); - } + while (irsnd_busy) + { + irsnd_ISR (); + } - putchar ('\n'); + putchar ('\n'); #if 1 // enable here to send twice - (void) irsnd_send_data (&irmp_data, TRUE); + (void) irsnd_send_data (&irmp_data, TRUE); - while (irsnd_busy) - { - irsnd_ISR (); - } + while (irsnd_busy) + { + irsnd_ISR (); + } - putchar ('\n'); + putchar ('\n'); #endif } else { - fprintf (stderr, "%s: wrong arguments\n", argv[0]); - return 1; + fprintf (stderr, "%s: wrong arguments\n", argv[0]); + return 1; } return 0; } diff --git a/irsnd.h b/irsnd.h index 91d8810..9a50bb8 100644 --- a/irsnd.h +++ b/irsnd.h @@ -3,7 +3,7 @@ * * Copyright (c) 2010-2015 Frank Meyer - frank(at)fli4l.de * - * $Id: irsnd.h,v 1.21 2015/01/26 13:09:28 fm Exp $ + * $Id: irsnd.h,v 1.22 2015/11/17 13:51:45 fm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,19 +52,19 @@ # if defined(__12F1840) // Do not change lines below unless you have a different HW. This example is for 12F1840 // setup macro for PWM used PWM module - + //~ # define PWMon() TMR2=0,IRSND_PIN=1 //~ # define PWMoff() CCP1CON &=(~0b1100) //~ # define PWMon() TMR2ON=1 //~ # define PWMoff() TMR2ON=0 #if defined(IRSND_DEBUG) - #define PWMon() LATA0=1 - #define PWMoff() LATA0=0 - #define IRSND_PIN LATA0 + #define PWMon() LATA0=1 + #define PWMoff() LATA0=0 + #define IRSND_PIN LATA0 #else - # define PWMon() TMR2=0,CCP1CON |=0b1100 - # define PWMoff() CCP1CON &=(~0b1100) - # define IRSND_PIN RA2 + # define PWMon() TMR2=0,CCP1CON |=0b1100 + # define PWMoff() CCP1CON &=(~0b1100) + # define IRSND_PIN RA2 #endif #else @@ -126,6 +126,11 @@ #define IRSND_ENDLESS_REPETITION 15 // endless repetions #define IRSND_REPETITION_MASK 0x0F // lower nibble of flags +#ifdef __cplusplus +extern "C" +{ +#endif + extern void irsnd_init (void); extern uint8_t irsnd_is_busy (void); extern uint8_t irsnd_send_data (IRMP_DATA *, uint8_t); @@ -136,4 +141,8 @@ extern uint8_t irsnd_ISR (void); extern void irsnd_set_callback_ptr (void (*cb)(uint8_t)); #endif // IRSND_USE_CALLBACK == 1 +#ifdef __cplusplus +} +#endif + #endif /* _IRSND_H_ */ diff --git a/irsndconfig.h b/irsndconfig.h index 69d1561..a004f79 100644 --- a/irsndconfig.h +++ b/irsndconfig.h @@ -5,7 +5,7 @@ * * Copyright (c) 2010-2015 Frank Meyer - frank(at)fli4l.de * - * $Id: irsndconfig.h,v 1.78 2015/11/10 08:47:56 fm Exp $ + * $Id: irsndconfig.h,v 1.85 2015/11/17 13:54:09 fm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,6 +60,7 @@ #define IRSND_SUPPORT_NOKIA_PROTOCOL 0 // Nokia >= 10000 ~400 bytes // exotic protocols, enable here! Enable Remarks F_INTERRUPTS Program Space +#define IRSND_SUPPORT_BOSE_PROTOCOL 1 // BOSE >= 10000 ~100 bytes #define IRSND_SUPPORT_KATHREIN_PROTOCOL 0 // Kathrein >= 10000 DON'T CHANGE, NOT SUPPORTED YET! #define IRSND_SUPPORT_NUBERT_PROTOCOL 0 // NUBERT >= 10000 ~100 bytes #define IRSND_SUPPORT_FAN_PROTOCOL 0 // FAN (ventilator) >= 10000 ~100 bytes @@ -84,7 +85,8 @@ #define IRSND_SUPPORT_PENTAX_PROTOCOL 0 // Pentax >= 10000 ~150 bytes #define IRSND_SUPPORT_S100_PROTOCOL 0 // S100 >= 10000 ~150 bytes #define IRSND_SUPPORT_ACP24_PROTOCOL 0 // ACP24 >= 10000 ~150 bytes -#define IRSND_SUPPORT_TECHNICS_PROTOCOL 0 // TECHNICS >= 10000 ~150 bytes +#define IRSND_SUPPORT_TECHNICS_PROTOCOL 0 // TECHNICS >= 10000 DON'T CHANGE, NOT SUPPORTED YET! +#define IRSND_SUPPORT_PANASONIC_PROTOCOL 0 // PANASONIC Beamer >= 10000 ~150 bytes /*--------------------------------------------------------------------------------------------------------------------------------------------------- @@ -132,7 +134,7 @@ # else // C18 compiler # define IRSND_OCx IRSND_PIC_CCP2 // Use PWMx for PIC - // change other PIC C18 specific settings: + // change other PIC C18 specific settings: # define F_CPU 48000000UL // PIC frequency: set your freq here # define Pre_Scaler 4 // define prescaler for timer2 e.g. 1,4,16 # define PIC_Scaler 2 // PIC needs /2 extra in IRSND_FREQ_32_KHZ calculation for right value @@ -148,6 +150,13 @@ # define IRSND_TIMER_NUMBER 4 # define IRSND_TIMER_CHANNEL_NUMBER 1 // only channel 1 can be used at the moment, others won't work +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * Teensy 3.x with teensyduino gcc compiler + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ +#elif defined (TEENSY_ARM_CORTEX_M4) +# define IRSND_PIN 5 // choose an arduino pin with PWM function! + /*--------------------------------------------------------------------------------------------------------------------------------------------------- * Other target systems *---------------------------------------------------------------------------------------------------------------------------------------------------