X-Git-Url: http://cloudbase.mooo.com/gitweb/irmp.git/blobdiff_plain/f50e01e79ba83c2142178a0e2431034c410d7fd0..8aaafe9d1b78f92e33e2791a8aa5e0aa877975b9:/irmp.c diff --git a/irmp.c b/irmp.c index 46e56c5..018bb7f 100644 --- a/irmp.c +++ b/irmp.c @@ -1,284 +1,19 @@ /*--------------------------------------------------------------------------------------------------------------------------------------------------- * irmp.c - infrared multi-protocol decoder, supports several remote control protocols * - * Copyright (c) 2009-2011 Frank Meyer - frank(at)fli4l.de + * Copyright (c) 2009-2014 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp.c,v 1.100 2011/04/11 12:54:24 fm Exp $ + * $Id: irmp.c,v 1.164 2014/09/15 12:36:28 fm Exp $ * - * ATMEGA88 @ 8 MHz + * Supported AVR mikrocontrollers: * - * Typical manufacturers: - * - * SIRCS - Sony - * NEC - NEC, Yamaha, Canon, Tevion, Harman/Kardon, Hitachi, JVC, Pioneer, Toshiba, Xoro, Orion, and many other Japanese manufacturers - * SAMSUNG - Samsung - * SAMSUNG32 - Samsung - * MATSUSHITA - Matsushita - * KASEIKYO - Panasonic, Denon & other Japanese manufacturers (members of "Japan's Association for Electric Home Application") - * RECS80 - Philips, Nokia, Thomson, Nordmende, Telefunken, Saba - * RC5 - Philips and other European manufacturers - * DENON - Denon, Sharp - * RC6 - Philips and other European manufacturers - * APPLE - Apple - * NUBERT - Nubert Subwoofer System - * B&O - Bang & Olufsen - * PANASONIC - Panasonic (older, yet not implemented) - * GRUNDIG - Grundig - * NOKIA - Nokia - * SIEMENS - Siemens, e.g. Gigaset M740AV - * FDC - FDC IR keyboard - * RCCAR - IR remote control for RC cars - * JVC - JVC - * NIKON - Nikon cameras - * RUWIDO - T-Home - * KATHREIN - Kathrein - * LEGO - Lego Power Functions RC - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * SIRCS - * ----- - * - * frame: 1 start bit + 12-20 data bits + no stop bit - * data: 7 command bits + 5 address bits + 0 to 8 additional bits - * - * start bit: data "0": data "1": stop bit: - * -----------------_________ ------_____ ------------______ - * 2400us 600us 600us 600us 1200us 600 us no stop bit - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * NEC + extended NEC - * ------------------------- - * - * frame: 1 start bit + 32 data bits + 1 stop bit - * data NEC: 8 address bits + 8 inverted address bits + 8 command bits + 8 inverted command bits - * data extended NEC: 16 address bits + 8 command bits + 8 inverted command bits - * - * start bit: data "0": data "1": stop bit: - * -----------------_________ ------______ ------________________ ------______.... - * 9000us 4500us 560us 560us 560us 1690 us 560us - * - * - * Repetition frame: - * - * -----------------_________------______ .... ~100ms Pause, then repeat - * 9000us 2250us 560us - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * SAMSUNG - * ------- - * - * frame: 1 start bit + 16 data(1) bits + 1 sync bit + additional 20 data(2) bits + 1 stop bit - * data(1): 16 address bits - * data(2): 4 ID bits + 8 command bits + 8 inverted command bits - * - * start bit: data "0": data "1": sync bit: stop bit: - * ----------______________ ------______ ------________________ ------______________ ------______.... - * 4500us 4500us 550us 450us 550us 1450us 550us 4500us 550us - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * SAMSUNG32 - * ---------- - * - * frame: 1 start bit + 32 data bits + 1 stop bit - * data: 16 address bits + 16 command bits - * - * start bit: data "0": data "1": stop bit: - * ----------______________ ------______ ------________________ ------______.... - * 4500us 4500us 550us 450us 550us 1450us 550us - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * MATSUSHITA - * ---------- - * - * frame: 1 start bit + 24 data bits + 1 stop bit - * data: 6 custom bits + 6 command bits + 12 address bits - * - * start bit: data "0": data "1": stop bit: - * ----------_________ ------______ ------________________ ------______.... - * 3488us 3488us 872us 872us 872us 2616us 872us - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * KASEIKYO - * -------- - * - * frame: 1 start bit + 48 data bits + 1 stop bit - * data: 16 manufacturer bits + 4 parity bits + 4 genre1 bits + 4 genre2 bits + 10 command bits + 2 id bits + 8 parity bits - * - * start bit: data "0": data "1": stop bit: - * ----------______ ------______ ------________________ ------______.... - * 3380us 1690us 423us 423us 423us 1269us 423us - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * RECS80 - * ------ - * - * frame: 2 start bits + 10 data bits + 1 stop bit - * data: 1 toggle bit + 3 address bits + 6 command bits - * - * start bit: data "0": data "1": stop bit: - * -----_____________________ -----____________ -----______________ ------_______.... - * 158us 7432us 158us 4902us 158us 7432us 158us - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * RECS80EXT - * --------- - * - * frame: 2 start bits + 11 data bits + 1 stop bit - * data: 1 toggle bit + 4 address bits + 6 command bits - * - * start bit: data "0": data "1": stop bit: - * -----_____________________ -----____________ -----______________ ------_______.... - * 158us 3637us 158us 4902us 158us 7432us 158us - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * RC5 + RC5X - * ---------- - * - * RC5 frame: 2 start bits + 12 data bits + no stop bit - * RC5 data: 1 toggle bit + 5 address bits + 6 command bits - * RC5X frame: 1 start bit + 13 data bits + no stop bit - * RC5X data: 1 inverted command bit + 1 toggle bit + 5 address bits + 6 command bits - * - * start bit: data "0": data "1": - * ______----- ------______ ______------ - * 889us 889us 889us 889us 889us 889us - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * DENON - * ----- - * - * frame: 0 start bits + 16 data bits + stop bit + 65ms pause + 16 inverted data bits + stop bit - * data: 5 address bits + 10 command bits - * - * Theory: - * - * data "0": data "1": - * ------________________ ------______________ - * 275us 775us 275us 1900us - * - * Practice: - * - * data "0": data "1": - * ------________________ ------______________ - * 310us 745us 310us 1780us - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * RC6 - * --- - * - * RC6 frame: 1 start bit + 1 bit "1" + 3 mode bits + 1 toggle bit + 16 data bits + 2666 us pause - * RC6 data: 8 address bits + 8 command bits - * - * start bit toggle bit "0": toggle bit "1": data/mode "0": data/mode "1": - * ____________------- _______------- -------_______ _______------- -------_______ - * 2666us 889us 889us 889us 889us 889us 444us 444us 444us 444us - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * APPLE - * ----- - * - * frame: 1 start bit + 32 data bits + 1 stop bit - * data: 16 address bits + 11100000 + 8 command bits - * - * start bit: data "0": data "1": stop bit: - * -----------------_________ ------______ ------________________ ------______.... - * 9000us 4500us 560us 560us 560us 1690 us 560us - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * NUBERT (subwoofer system) - * ------------------------- - * - * frame: 1 start bit + 10 data bits + 1 stop bit - * data: 0 address bits + 10 command bits ? - * - * start bit: data "0": data "1": stop bit: - * ----------_____ ------______ ------________________ ------______.... - * 1340us 340us 500us 1300us 1340us 340us 500us - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * BANG_OLUFSEN - * ------------ - * - * frame: 4 start bits + 16 data bits + 1 trailer bit + 1 stop bit - * data: 0 address bits + 16 command bits - * - * 1st start bit: 2nd start bit: 3rd start bit: 4th start bit: - * -----________ -----________ -----_____________ -----________ - * 210us 3000us 210us 3000us 210us 15000us 210us 3000us - * - * data "0": data "1": data "repeat bit": trailer bit: stop bit: - * -----________ -----_____________ -----___________ -----_____________ -----____... - * 210us 3000us 210us 9000us 210us 6000us 210us 12000us 210us - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * GRUNDIG - * ------- - * - * packet: 1 start frame + 19,968ms pause + N info frames + 117,76ms pause + 1 stop frame - * frame: 1 pre bit + 1 start bit + 9 data bits + no stop bit - * pause between info frames: 117,76ms - * - * data of start frame: 9 x 1 - * data of info frame: 9 command bits - * data of stop frame: 9 x 1 - * - * pre bit: start bit data "0": data "1": - * ------____________ ------______ ______------ ------______ - * 528us 2639us 528us 528us 528us 528us 528us 528us - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * NOKIA: - * ------ - * - * Timing similar to Grundig, but 16 data bits: - * frame: 1 pre bit + 1 start bit + 8 command bits + 8 address bits + no stop bit - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * SIEMENS or RUWIDO: - * ------------------ - * - * SIEMENS frame: 1 start bit + 22 data bits + no stop bit - * SIEMENS data: 13 address bits + 1 repeat bit + 7 data bits + 1 unknown bit - * - * start bit data "0": data "1": - * -------_______ _______------- -------_______ - * 250us 250us 250us 250us 250us 250us - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- - * - * PANASONIC (older protocol, yet not implemented, see also MATSUSHITA, timing very similar) - * ----------------------------------------------------------------------------------------- - * - * frame: 1 start bit + 22 data bits + 1 stop bit - * 22 data bits = 5 custom bits + 6 data bits + 5 inverted custom bits + 6 inverted data bits - * - * European version: T = 456us - * USA & Canada version: T = 422us - * - * start bit: data "0": data "1": stop bit: - * 8T 8T 2T 2T 2T 6T 2T - * -------------____________ ------_____ ------_____________ ------_______.... - * 3648us 3648us 912us 912us 912us 2736us 912us (Europe) - * 3376us 3376us 844us 844us 844us 2532us 844us (US) - * - *--------------------------------------------------------------------------------------------------------------------------------------------------- + * ATtiny87, ATtiny167 + * ATtiny45, ATtiny85 + * ATtiny44, ATtiny84 + * ATmega8, ATmega16, ATmega32 + * ATmega162 + * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284, ATmega1284P + * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P * * 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 @@ -287,91 +22,36 @@ *--------------------------------------------------------------------------------------------------------------------------------------------------- */ -#if defined(__PCM__) || defined(__PCB__) || defined(__PCH__) // CCS PIC Compiler instead of AVR -#define PIC_CCS_COMPILER -#endif - -#ifdef unix // test on linux/unix -#include -#include -#include -#include -#include - -#define ANALYZE -#define PROGMEM -#define memcpy_P memcpy - -#else // not unix: - -#ifdef WIN32 -#include -#include -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -#define ANALYZE -#define PROGMEM -#define memcpy_P memcpy - -#else - -#ifndef CODEVISION - -#ifdef PIC_CCS_COMPILER - -#include -typedef unsigned int8 uint8_t; -typedef unsigned int16 uint16_t; -#define PROGMEM -#define memcpy_P memcpy - -#else // AVR: - -#include -#include -#include -#include -#include -#include - -#endif // PIC_CCS_COMPILER -#endif // CODEVISION - -#endif // windows -#endif // unix - -#ifndef IRMP_USE_AS_LIB -#include "irmpconfig.h" -#endif #include "irmp.h" #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRMP_SUPPORT_NOKIA_PROTOCOL == 1 || IRMP_SUPPORT_IR60_PROTOCOL == 1 -#define IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL 1 +# define IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL 1 #else -#define IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL 0 +# define IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL 0 #endif #if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1 || IRMP_SUPPORT_RUWIDO_PROTOCOL == 1 -#define IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL 1 +# define IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL 1 #else -#define IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL 0 +# define IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL 0 #endif #if IRMP_SUPPORT_RC5_PROTOCOL == 1 || \ IRMP_SUPPORT_RC6_PROTOCOL == 1 || \ IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1 || \ IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1 || \ - IRMP_SUPPORT_IR60_PROTOCOL -#define IRMP_SUPPORT_MANCHESTER 1 + IRMP_SUPPORT_IR60_PROTOCOL == 1 || \ + IRMP_SUPPORT_A1TVBOX_PROTOCOL == 1 || \ + IRMP_SUPPORT_ORTEK_PROTOCOL == 1 +# define IRMP_SUPPORT_MANCHESTER 1 #else -#define IRMP_SUPPORT_MANCHESTER 0 +# define IRMP_SUPPORT_MANCHESTER 0 #endif -#if IRMP_SUPPORT_NETBOX_PROTOCOL == 1 || \ - IRMP_SUPPORT_IMON_PROTOCOL == 1 -#define IRMP_SUPPORT_SERIAL 1 +#if IRMP_SUPPORT_NETBOX_PROTOCOL == 1 +# define IRMP_SUPPORT_SERIAL 1 #else -#define IRMP_SUPPORT_SERIAL 0 +# define IRMP_SUPPORT_SERIAL 0 #endif #define IRMP_KEY_REPETITION_LEN (uint16_t)(F_INTERRUPTS * 150.0e-3 + 0.5) // autodetect key repetition within 150 msec @@ -410,9 +90,9 @@ typedef unsigned int16 uint16_t; #define SIRCS_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) #define SIRCS_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) #if IRMP_SUPPORT_NETBOX_PROTOCOL // only 5% to avoid conflict with NETBOX: -#define SIRCS_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5)) +# define SIRCS_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5)) #else // only 5% + 1 to avoid conflict with RC6: -#define SIRCS_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) +# define SIRCS_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) #endif #define SIRCS_1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define SIRCS_1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) @@ -421,18 +101,18 @@ typedef unsigned int16 uint16_t; #define SIRCS_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define SIRCS_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#define NEC_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) -#define NEC_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) -#define NEC_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) -#define NEC_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) -#define NEC_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) -#define NEC_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) -#define NEC_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) -#define NEC_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) -#define NEC_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) -#define NEC_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) -#define NEC_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) -#define NEC_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) +#define NEC_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define NEC_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define NEC_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define NEC_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define NEC_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define NEC_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define NEC_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define NEC_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define NEC_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define NEC_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define NEC_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define NEC_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) // autodetect nec repetition frame within 50 msec: // NEC seems to send the first repetition frame after 40ms, further repetition frames after 100 ms #if 0 @@ -463,10 +143,10 @@ typedef unsigned int16 uint16_t; #define MATSUSHITA_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) #define MATSUSHITA_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) -#define KASEIKYO_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define KASEIKYO_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#define KASEIKYO_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define KASEIKYO_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define KASEIKYO_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define KASEIKYO_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define KASEIKYO_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define KASEIKYO_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) #define KASEIKYO_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1) #define KASEIKYO_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1) #define KASEIKYO_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) @@ -474,36 +154,44 @@ typedef unsigned int16 uint16_t; #define KASEIKYO_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1) #define KASEIKYO_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1) -#define RECS80_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MIN_TOLERANCE_00 + 0.5) - 1) -#define RECS80_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define RECS80_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define RECS80_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) #define RECS80_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define RECS80_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#define RECS80_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define RECS80_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define RECS80_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define RECS80_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) #define RECS80_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define RECS80_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) #define RECS80_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define RECS80_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) + +#if IRMP_SUPPORT_BOSE_PROTOCOL == 1 // BOSE conflicts with RC5, so keep tolerance for RC5 minimal here: +#define RC5_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_05 + 0.5) - 1) +#define RC5_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_05 + 0.5) + 1) +#else #define RC5_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define RC5_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#define RC5_START_BIT_LEN_MIN_2 ((uint8_t)(F_INTERRUPTS * 2 * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define RC5_START_BIT_LEN_MAX_2 ((uint8_t)(F_INTERRUPTS * 2 * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#endif + #define RC5_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define RC5_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#define RC5_BIT_LEN_MIN_2 ((uint8_t)(F_INTERRUPTS * 2 * RC5_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define RC5_BIT_LEN_MAX_2 ((uint8_t)(F_INTERRUPTS * 2 * RC5_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1) #define DENON_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define DENON_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define DENON_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) #define DENON_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define DENON_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1 -#define DENON_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5)) // no -1, avoid conflict with RUWIDO -#else -#define DENON_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) // be more tolerant -#endif +// RUWIDO (see t-home-mediareceiver-15kHz.txt) conflicts here with DENON +#define DENON_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define DENON_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define DENON_AUTO_REPETITION_PAUSE_LEN ((uint16_t)(F_INTERRUPTS * DENON_AUTO_REPETITION_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) + +#define THOMSON_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * THOMSON_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define THOMSON_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * THOMSON_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define THOMSON_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * THOMSON_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define THOMSON_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * THOMSON_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define THOMSON_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * THOMSON_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define THOMSON_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * THOMSON_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) #define RC6_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define RC6_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) @@ -512,21 +200,16 @@ typedef unsigned int16 uint16_t; #define RC6_TOGGLE_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define RC6_TOGGLE_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1) #define RC6_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define RC6_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_30 + 0.5) + 1) // pulses: 300 - 700 -#define RC6_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) // pauses: 300 - 600 -#define RC6_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1) - -#define RC6_BIT_PULSE_LEN_MIN_2 ((uint8_t)(F_INTERRUPTS * 2 * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define RC6_BIT_PULSE_LEN_MAX_2 ((uint8_t)(F_INTERRUPTS * 2 * RC6_BIT_TIME * MAX_TOLERANCE_60 + 0.5) + 1) // pulses: 600 - 1400 -#define RC6_BIT_PAUSE_LEN_MIN_2 ((uint8_t)(F_INTERRUPTS * 2 * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) // pauses: 600 - 1200 -#define RC6_BIT_PAUSE_LEN_MAX_2 ((uint8_t)(F_INTERRUPTS * 2 * RC6_BIT_TIME * MAX_TOLERANCE_60 + 0.5) + 1) - -#define RECS80EXT_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MIN_TOLERANCE_00 + 0.5) - 1) -#define RECS80EXT_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MAX_TOLERANCE_00 + 0.5) + 1) -#define RECS80EXT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1) -#define RECS80EXT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) -#define RECS80EXT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define RECS80EXT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define RC6_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_60 + 0.5) + 1) // pulses: 300 - 800 +#define RC6_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define RC6_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1) // pauses: 300 - 600 + +#define RECS80EXT_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define RECS80EXT_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define RECS80EXT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define RECS80EXT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define RECS80EXT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define RECS80EXT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) #define RECS80EXT_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define RECS80EXT_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) #define RECS80EXT_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) @@ -545,6 +228,19 @@ typedef unsigned int16 uint16_t; #define NUBERT_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) #define NUBERT_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define SPEAKER_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SPEAKER_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define SPEAKER_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SPEAKER_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define SPEAKER_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SPEAKER_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define SPEAKER_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SPEAKER_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define SPEAKER_1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SPEAKER_1_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define SPEAKER_1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SPEAKER_1_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define SPEAKER_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SPEAKER_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define SPEAKER_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SPEAKER_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define SPEAKER_0_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SPEAKER_0_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define SPEAKER_0_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SPEAKER_0_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define SPEAKER_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SPEAKER_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define SPEAKER_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SPEAKER_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) + #define BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) #define BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) @@ -573,12 +269,10 @@ typedef unsigned int16 uint16_t; #define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) #define IR60_TIMEOUT_LEN ((uint8_t)(F_INTERRUPTS * IR60_TIMEOUT_TIME * 0.5)) -#define GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MIN_TOLERANCE_20 + 0.5) - 1) -#define GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1) -#define GRUNDIG_NOKIA_IR60_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MIN_TOLERANCE_20 + 0.5) - 1) -#define GRUNDIG_NOKIA_IR60_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1) -#define GRUNDIG_NOKIA_IR60_BIT_LEN_MIN_2 ((uint8_t)(F_INTERRUPTS * 2 * GRUNDIG_NOKIA_IR60_BIT_TIME * MIN_TOLERANCE_20 + 0.5) - 1) -#define GRUNDIG_NOKIA_IR60_BIT_LEN_MAX_2 ((uint8_t)(F_INTERRUPTS * 2 * GRUNDIG_NOKIA_IR60_BIT_TIME * MAX_TOLERANCE_50 + 0.5) + 1) +#define GRUNDIG_NOKIA_IR60_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define GRUNDIG_NOKIA_IR60_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define GRUNDIG_NOKIA_IR60_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define GRUNDIG_NOKIA_IR60_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1) #define GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_PRE_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) + 1) #define GRUNDIG_NOKIA_IR60_PRE_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_NOKIA_IR60_PRE_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) @@ -586,18 +280,10 @@ typedef unsigned int16 uint16_t; #define SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) #define SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#define SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN_2 ((uint8_t)(F_INTERRUPTS * 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX_2 ((uint8_t)(F_INTERRUPTS * 2 * SIEMENS_OR_RUWIDO_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#define SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN_2 ((uint8_t)(F_INTERRUPTS * 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX_2 ((uint8_t)(F_INTERRUPTS * 2 * SIEMENS_OR_RUWIDO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) #define SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) #define SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#define SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN_2 ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME_2 * MIN_TOLERANCE_10 + 0.5) - 1) -#define SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX_2 ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PULSE_TIME_2 * MAX_TOLERANCE_60 + 0.5) + 1) -#define SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN_2 ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PAUSE_TIME_2 * MIN_TOLERANCE_10 + 0.5) - 1) -#define SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX_2 ((uint8_t)(F_INTERRUPTS * SIEMENS_OR_RUWIDO_BIT_PAUSE_TIME_2 * MAX_TOLERANCE_60 + 0.5) + 1) #define FDC_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1) // 5%: avoid conflict with NETBOX #define FDC_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC_START_BIT_PULSE_TIME * MAX_TOLERANCE_05 + 0.5)) @@ -687,35 +373,249 @@ typedef unsigned int16 uint16_t; #define LEGO_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * LEGO_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) #define LEGO_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * LEGO_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) -#define IMON_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * IMON_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define IMON_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * IMON_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#define IMON_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * IMON_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) -#define IMON_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * IMON_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) -#define IMON_PULSE_LEN ((uint8_t)(F_INTERRUPTS * IMON_PULSE_TIME)) -#define IMON_PAUSE_LEN ((uint8_t)(F_INTERRUPTS * IMON_PAUSE_TIME)) -#define IMON_PULSE_REST_LEN ((uint8_t)(F_INTERRUPTS * IMON_PULSE_TIME / 4)) -#define IMON_PAUSE_REST_LEN ((uint8_t)(F_INTERRUPTS * IMON_PAUSE_TIME / 4)) +#define BOSE_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BOSE_START_BIT_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define BOSE_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BOSE_START_BIT_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define BOSE_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BOSE_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define BOSE_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BOSE_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define BOSE_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BOSE_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define BOSE_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BOSE_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define BOSE_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BOSE_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define BOSE_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BOSE_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define BOSE_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BOSE_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define BOSE_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BOSE_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define BOSE_FRAME_REPEAT_PAUSE_LEN_MAX (uint16_t)(F_INTERRUPTS * 100.0e-3 * MAX_TOLERANCE_20 + 0.5) + +#define A1TVBOX_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * A1TVBOX_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define A1TVBOX_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * A1TVBOX_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define A1TVBOX_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * A1TVBOX_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define A1TVBOX_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * A1TVBOX_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define A1TVBOX_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * A1TVBOX_BIT_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define A1TVBOX_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * A1TVBOX_BIT_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define A1TVBOX_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * A1TVBOX_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define A1TVBOX_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * A1TVBOX_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) + +#define ORTEK_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * ORTEK_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define ORTEK_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * ORTEK_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define ORTEK_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * ORTEK_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define ORTEK_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * ORTEK_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define ORTEK_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * ORTEK_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define ORTEK_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * ORTEK_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define ORTEK_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * ORTEK_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define ORTEK_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * ORTEK_BIT_TIME * MAX_TOLERANCE_10 + 0.5) + 1) + +#define TELEFUNKEN_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * TELEFUNKEN_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define TELEFUNKEN_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * TELEFUNKEN_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define TELEFUNKEN_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * (TELEFUNKEN_START_BIT_PAUSE_TIME) * MIN_TOLERANCE_10 + 0.5) - 1) +#define TELEFUNKEN_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * (TELEFUNKEN_START_BIT_PAUSE_TIME) * MAX_TOLERANCE_10 + 0.5) - 1) +#define TELEFUNKEN_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * TELEFUNKEN_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define TELEFUNKEN_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * TELEFUNKEN_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define TELEFUNKEN_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * TELEFUNKEN_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define TELEFUNKEN_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * TELEFUNKEN_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define TELEFUNKEN_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * TELEFUNKEN_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define TELEFUNKEN_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * TELEFUNKEN_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +// autodetect TELEFUNKEN repetition frame within 50 msec: +// #define TELEFUNKEN_FRAME_REPEAT_PAUSE_LEN_MAX (uint16_t)(F_INTERRUPTS * TELEFUNKEN_FRAME_REPEAT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + +#define ROOMBA_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * ROOMBA_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define ROOMBA_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * ROOMBA_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define ROOMBA_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * ROOMBA_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define ROOMBA_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * ROOMBA_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define ROOMBA_1_PAUSE_LEN_EXACT ((uint8_t)(F_INTERRUPTS * ROOMBA_1_PAUSE_TIME + 0.5)) +#define ROOMBA_1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * ROOMBA_1_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define ROOMBA_1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * ROOMBA_1_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define ROOMBA_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * ROOMBA_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define ROOMBA_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * ROOMBA_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define ROOMBA_0_PAUSE_LEN ((uint8_t)(F_INTERRUPTS * ROOMBA_0_PAUSE_TIME)) +#define ROOMBA_0_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * ROOMBA_0_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define ROOMBA_0_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * ROOMBA_0_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define ROOMBA_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * ROOMBA_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define ROOMBA_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * ROOMBA_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) + +#define RCMM32_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCMM32_START_BIT_PULSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1) +#define RCMM32_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCMM32_START_BIT_PULSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) +#define RCMM32_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCMM32_START_BIT_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1) +#define RCMM32_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCMM32_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) +#define RCMM32_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCMM32_PULSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1) +#define RCMM32_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCMM32_PULSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) +#define RCMM32_BIT_00_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCMM32_00_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1) +#define RCMM32_BIT_00_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCMM32_00_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) +#define RCMM32_BIT_01_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCMM32_01_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1) +#define RCMM32_BIT_01_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCMM32_01_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) +#define RCMM32_BIT_10_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCMM32_10_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1) +#define RCMM32_BIT_10_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCMM32_10_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) +#define RCMM32_BIT_11_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RCMM32_11_PAUSE_TIME * MIN_TOLERANCE_05 + 0.5) - 1) +#define RCMM32_BIT_11_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RCMM32_11_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) + +#define RADIO1_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RADIO1_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define RADIO1_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RADIO1_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define RADIO1_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RADIO1_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define RADIO1_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RADIO1_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define RADIO1_1_PAUSE_LEN_EXACT ((uint8_t)(F_INTERRUPTS * RADIO1_1_PAUSE_TIME + 0.5)) +#define RADIO1_1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RADIO1_1_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define RADIO1_1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RADIO1_1_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define RADIO1_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RADIO1_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define RADIO1_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RADIO1_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define RADIO1_0_PAUSE_LEN ((uint8_t)(F_INTERRUPTS * RADIO1_0_PAUSE_TIME)) +#define RADIO1_0_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RADIO1_0_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define RADIO1_0_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RADIO1_0_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define RADIO1_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RADIO1_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define RADIO1_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RADIO1_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) #define AUTO_FRAME_REPETITION_LEN (uint16_t)(F_INTERRUPTS * AUTO_FRAME_REPETITION_TIME + 0.5) // use uint16_t! #ifdef ANALYZE -#define ANALYZE_PUTCHAR(a) { if (! silent) { putchar (a); } } -#define ANALYZE_ONLY_NORMAL_PUTCHAR(a) { if (! silent && !verbose) { putchar (a); } } -#define ANALYZE_PRINTF(...) { if (verbose) { printf (__VA_ARGS__); } } -#define ANALYZE_NEWLINE() { if (verbose) { putchar ('\n'); } } -static int silent; -static int time_counter; -static int verbose; +# define ANALYZE_PUTCHAR(a) { if (! silent) { putchar (a); } } +# define ANALYZE_ONLY_NORMAL_PUTCHAR(a) { if (! silent && !verbose) { putchar (a); } } +# define ANALYZE_PRINTF(...) { if (verbose) { printf (__VA_ARGS__); } } +# define ANALYZE_ONLY_NORMAL_PRINTF(...) { if (! silent && !verbose) { printf (__VA_ARGS__); } } +# define ANALYZE_NEWLINE() { if (verbose) { putchar ('\n'); } } +static int silent; +static int time_counter; +static int verbose; + +/******************************* not every PIC compiler knows variadic macros :-( #else -#define ANALYZE_PUTCHAR(a) -#define ANALYZE_ONLY_NORMAL_PUTCHAR(a) -#define ANALYZE_PRINTF(...) -#define ANALYZE_NEWLINE() +# define ANALYZE_PUTCHAR(a) +# define ANALYZE_ONLY_NORMAL_PUTCHAR(a) +# define ANALYZE_PRINTF(...) +# define ANALYZE_ONLY_NORMAL_PRINTF(...) +# endif +# define ANALYZE_NEWLINE() +*********************************/ #endif -#if IRMP_LOGGING == 1 -#define BAUD 9600L -#include +#if IRMP_USE_CALLBACK == 1 +static void (*irmp_callback_ptr) (uint8_t); +#endif // IRMP_USE_CALLBACK == 1 + +#define PARITY_CHECK_OK 1 +#define PARITY_CHECK_FAILED 0 + +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * Protocol names + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ +#if defined(UNIX_OR_WINDOWS) || IRMP_PROTOCOL_NAMES == 1 +static const char proto_unknown[] PROGMEM = "UNKNOWN"; +static const char proto_sircs[] PROGMEM = "SIRCS"; +static const char proto_nec[] PROGMEM = "NEC"; +static const char proto_samsung[] PROGMEM = "SAMSUNG"; +static const char proto_matsushita[] PROGMEM = "MATSUSH"; +static const char proto_kaseikyo[] PROGMEM = "KASEIKYO"; +static const char proto_recs80[] PROGMEM = "RECS80"; +static const char proto_rc5[] PROGMEM = "RC5"; +static const char proto_denon[] PROGMEM = "DENON"; +static const char proto_rc6[] PROGMEM = "RC6"; +static const char proto_samsung32[] PROGMEM = "SAMSG32"; +static const char proto_apple[] PROGMEM = "APPLE"; +static const char proto_recs80ext[] PROGMEM = "RECS80EX"; +static const char proto_nubert[] PROGMEM = "NUBERT"; +static const char proto_bang_olufsen[] PROGMEM = "BANG OLU"; +static const char proto_grundig[] PROGMEM = "GRUNDIG"; +static const char proto_nokia[] PROGMEM = "NOKIA"; +static const char proto_siemens[] PROGMEM = "SIEMENS"; +static const char proto_fdc[] PROGMEM = "FDC"; +static const char proto_rccar[] PROGMEM = "RCCAR"; +static const char proto_jvc[] PROGMEM = "JVC"; +static const char proto_rc6a[] PROGMEM = "RC6A"; +static const char proto_nikon[] PROGMEM = "NIKON"; +static const char proto_ruwido[] PROGMEM = "RUWIDO"; +static const char proto_ir60[] PROGMEM = "IR60"; +static const char proto_kathrein[] PROGMEM = "KATHREIN"; +static const char proto_netbox[] PROGMEM = "NETBOX"; +static const char proto_nec16[] PROGMEM = "NEC16"; +static const char proto_nec42[] PROGMEM = "NEC42"; +static const char proto_lego[] PROGMEM = "LEGO"; +static const char proto_thomson[] PROGMEM = "THOMSON"; +static const char proto_bose[] PROGMEM = "BOSE"; +static const char proto_a1tvbox[] PROGMEM = "A1TVBOX"; +static const char proto_ortek[] PROGMEM = "ORTEK"; +static const char proto_telefunken[] PROGMEM = "TELEFUNKEN"; +static const char proto_roomba[] PROGMEM = "ROOMBA"; +static const char proto_rcmm32[] PROGMEM = "RCMM32"; +static const char proto_rcmm24[] PROGMEM = "RCMM24"; +static const char proto_rcmm12[] PROGMEM = "RCMM12"; +static const char proto_speaker[] PROGMEM = "SPEAKER"; +static const char proto_lgair[] PROGMEM = "LGAIR"; +static const char proto_samsung48[] PROGMEM = "SAMSG48"; + +static const char proto_radio1[] PROGMEM = "RADIO1"; + +const char * const +irmp_protocol_names[IRMP_N_PROTOCOLS + 1] PROGMEM = +{ + proto_unknown, + proto_sircs, + proto_nec, + proto_samsung, + proto_matsushita, + proto_kaseikyo, + proto_recs80, + proto_rc5, + proto_denon, + proto_rc6, + proto_samsung32, + proto_apple, + proto_recs80ext, + proto_nubert, + proto_bang_olufsen, + proto_grundig, + proto_nokia, + proto_siemens, + proto_fdc, + proto_rccar, + proto_jvc, + proto_rc6a, + proto_nikon, + proto_ruwido, + proto_ir60, + proto_kathrein, + proto_netbox, + proto_nec16, + proto_nec42, + proto_lego, + proto_thomson, + proto_bose, + proto_a1tvbox, + proto_ortek, + proto_telefunken, + proto_roomba, + proto_rcmm32, + proto_rcmm24, + proto_rcmm12, + proto_speaker, + proto_lgair, + proto_samsung48, + + proto_radio1 +}; + +#endif + +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * Logging + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ +#if IRMP_LOGGING == 1 // logging via UART + +#if defined(ARM_STM32F4XX) +# define STM32_GPIO_CLOCK RCC_AHB1Periph_GPIOA // per UART2 an PA2 +# define STM32_UART_CLOCK RCC_APB1Periph_USART2 +# define STM32_GPIO_PORT GPIOA +# define STM32_GPIO_PIN GPIO_Pin_2 +# define STM32_GPIO_SOURCE GPIO_PinSource2 +# define STM32_UART_AF GPIO_AF_USART2 +# define STM32_UART_COM USART2 +# define STM32_UART_BAUD 115200 // mit 115200 Baud +# include "stm32f4xx_usart.h" +#else +# if IRMP_EXT_LOGGING == 1 // use external logging +# include "irmpextlog.h" +# else // normal UART log (IRMP_EXT_LOGGING == 0) +# define BAUD 9600L +# ifndef UNIX_OR_WINDOWS +# include +# endif #ifdef UBRR0H @@ -735,7 +635,7 @@ static int verbose; #define UART0_TXEN_BIT_VALUE (1< ENDBITS) + if (val && cnt > ENDBITS) // if high received then look at log-stop condition { // if stop condition is true, output on uart - uint16_t i; + uint8_t i8; + uint16_t i; + uint16_t j; + uint8_t v = '1'; + uint16_t d; - for (i = 0; i < STARTCYCLES; i++) + for (i8 = 0; i8 < STARTCYCLES; i8++) { irmp_uart_putc ('0'); // the ignored starting zeros } - for (i = 0; i < (buf_idx - ENDBITS + 20) / 8; i++) // transform bitset into uart chars + for (i = 0; i < buf_idx; i++) { - uint8_t d = buf[i]; - uint8_t j; + d = buf[i]; + + if (d == 0xff) + { + i++; + d = buf[i]; + i++; + d |= ((uint16_t) buf[i] << 8); + } - for (j = 0; j < 8; j++) + for (j = 0; j < d; j++) { - irmp_uart_putc ((d & 1) + '0'); - d >>= 1; + 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 + else if (buf_idx < DATALEN - 3) { - cnt = 0; + 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; } } } @@ -875,7 +871,7 @@ irmp_log (uint8_t val) #else #define irmp_log(val) -#endif +#endif //IRMP_LOGGING typedef struct { @@ -900,7 +896,7 @@ typedef struct #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER sircs_param = +static const PROGMEM IRMP_PARAMETER sircs_param = { IRMP_SIRCS_PROTOCOL, // protocol: ir protocol SIRCS_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 @@ -925,7 +921,7 @@ static PROGMEM IRMP_PARAMETER sircs_param = #if IRMP_SUPPORT_NEC_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER nec_param = +static const PROGMEM IRMP_PARAMETER nec_param = { IRMP_NEC_PROTOCOL, // protocol: ir protocol NEC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 @@ -946,7 +942,7 @@ static PROGMEM IRMP_PARAMETER nec_param = NEC_FLAGS // flags: some flags }; -static PROGMEM IRMP_PARAMETER nec_rep_param = +static const PROGMEM IRMP_PARAMETER nec_rep_param = { IRMP_NEC_PROTOCOL, // protocol: ir protocol NEC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 @@ -971,7 +967,7 @@ static PROGMEM IRMP_PARAMETER nec_rep_param = #if IRMP_SUPPORT_NEC42_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER nec42_param = +static const PROGMEM IRMP_PARAMETER nec42_param = { IRMP_NEC42_PROTOCOL, // protocol: ir protocol NEC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 @@ -983,9 +979,9 @@ static PROGMEM IRMP_PARAMETER nec42_param = NEC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 NEC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 NEC42_ADDRESS_OFFSET, // address_offset: address offset - NEC42_ADDRESS_OFFSET + NEC_ADDRESS_LEN, // address_end: end of address + NEC42_ADDRESS_OFFSET + NEC42_ADDRESS_LEN, // address_end: end of address NEC42_COMMAND_OFFSET, // command_offset: command offset - NEC42_COMMAND_OFFSET + NEC_COMMAND_LEN, // command_end: end of command + NEC42_COMMAND_OFFSET + NEC42_COMMAND_LEN, // command_end: end of command NEC42_COMPLETE_DATA_LEN, // complete_len: complete length of frame NEC_STOP_BIT, // stop_bit: flag: frame has stop bit NEC_LSB, // lsb_first: flag: LSB first @@ -994,9 +990,34 @@ static PROGMEM IRMP_PARAMETER nec42_param = #endif +#if IRMP_SUPPORT_LGAIR_PROTOCOL == 1 + +static const PROGMEM IRMP_PARAMETER lgair_param = +{ + IRMP_LGAIR_PROTOCOL, // protocol: ir protocol + NEC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + NEC_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + NEC_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + NEC_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + NEC_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + NEC_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + NEC_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + NEC_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + LGAIR_ADDRESS_OFFSET, // address_offset: address offset + LGAIR_ADDRESS_OFFSET + LGAIR_ADDRESS_LEN, // address_end: end of address + LGAIR_COMMAND_OFFSET, // command_offset: command offset + LGAIR_COMMAND_OFFSET + LGAIR_COMMAND_LEN, // command_end: end of command + LGAIR_COMPLETE_DATA_LEN, // complete_len: complete length of frame + NEC_STOP_BIT, // stop_bit: flag: frame has stop bit + NEC_LSB, // lsb_first: flag: LSB first + NEC_FLAGS // flags: some flags +}; + +#endif + #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER samsung_param = +static const PROGMEM IRMP_PARAMETER samsung_param = { IRMP_SAMSUNG_PROTOCOL, // protocol: ir protocol SAMSUNG_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 @@ -1019,9 +1040,34 @@ static PROGMEM IRMP_PARAMETER samsung_param = #endif +#if IRMP_SUPPORT_TELEFUNKEN_PROTOCOL == 1 + +static const PROGMEM IRMP_PARAMETER telefunken_param = +{ + IRMP_TELEFUNKEN_PROTOCOL, // protocol: ir protocol + TELEFUNKEN_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + TELEFUNKEN_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + TELEFUNKEN_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + TELEFUNKEN_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + TELEFUNKEN_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + TELEFUNKEN_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + TELEFUNKEN_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + TELEFUNKEN_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + TELEFUNKEN_ADDRESS_OFFSET, // address_offset: address offset + TELEFUNKEN_ADDRESS_OFFSET + TELEFUNKEN_ADDRESS_LEN, // address_end: end of address + TELEFUNKEN_COMMAND_OFFSET, // command_offset: command offset + TELEFUNKEN_COMMAND_OFFSET + TELEFUNKEN_COMMAND_LEN, // command_end: end of command + TELEFUNKEN_COMPLETE_DATA_LEN, // complete_len: complete length of frame + TELEFUNKEN_STOP_BIT, // stop_bit: flag: frame has stop bit + TELEFUNKEN_LSB, // lsb_first: flag: LSB first + TELEFUNKEN_FLAGS // flags: some flags +}; + +#endif + #if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER matsushita_param = +static const PROGMEM IRMP_PARAMETER matsushita_param = { IRMP_MATSUSHITA_PROTOCOL, // protocol: ir protocol MATSUSHITA_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 @@ -1046,7 +1092,7 @@ static PROGMEM IRMP_PARAMETER matsushita_param = #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER kaseikyo_param = +static const PROGMEM IRMP_PARAMETER kaseikyo_param = { IRMP_KASEIKYO_PROTOCOL, // protocol: ir protocol KASEIKYO_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 @@ -1071,7 +1117,7 @@ static PROGMEM IRMP_PARAMETER kaseikyo_param = #if IRMP_SUPPORT_RECS80_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER recs80_param = +static const PROGMEM IRMP_PARAMETER recs80_param = { IRMP_RECS80_PROTOCOL, // protocol: ir protocol RECS80_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 @@ -1096,17 +1142,17 @@ static PROGMEM IRMP_PARAMETER recs80_param = #if IRMP_SUPPORT_RC5_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER rc5_param = +static const PROGMEM IRMP_PARAMETER rc5_param = { IRMP_RC5_PROTOCOL, // protocol: ir protocol RC5_BIT_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse RC5_BIT_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse RC5_BIT_LEN_MIN, // pause_1_len_min: here: minimum length of short pause RC5_BIT_LEN_MAX, // pause_1_len_max: here: maximum length of short pause - RC5_BIT_LEN_MIN_2, // pulse_0_len_min: here: minimum length of long pulse - RC5_BIT_LEN_MAX_2, // pulse_0_len_max: here: maximum length of long pulse - RC5_BIT_LEN_MIN_2, // pause_0_len_min: here: minimum length of long pause - RC5_BIT_LEN_MAX_2, // pause_0_len_max: here: maximum length of long pause + 0, // pulse_0_len_min: here: not used + 0, // pulse_0_len_max: here: not used + 0, // pause_0_len_min: here: not used + 0, // pause_0_len_max: here: not used RC5_ADDRESS_OFFSET, // address_offset: address offset RC5_ADDRESS_OFFSET + RC5_ADDRESS_LEN, // address_end: end of address RC5_COMMAND_OFFSET, // command_offset: command offset @@ -1121,7 +1167,7 @@ static PROGMEM IRMP_PARAMETER rc5_param = #if IRMP_SUPPORT_DENON_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER denon_param = +static const PROGMEM IRMP_PARAMETER denon_param = { IRMP_DENON_PROTOCOL, // protocol: ir protocol DENON_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 @@ -1146,7 +1192,7 @@ static PROGMEM IRMP_PARAMETER denon_param = #if IRMP_SUPPORT_RC6_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER rc6_param = +static const PROGMEM IRMP_PARAMETER rc6_param = { IRMP_RC6_PROTOCOL, // protocol: ir protocol @@ -1154,10 +1200,10 @@ static PROGMEM IRMP_PARAMETER rc6_param = RC6_BIT_PULSE_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse RC6_BIT_PAUSE_LEN_MIN, // pause_1_len_min: here: minimum length of short pause RC6_BIT_PAUSE_LEN_MAX, // pause_1_len_max: here: maximum length of short pause - RC6_BIT_PULSE_LEN_MIN_2, // pulse_0_len_min: here: minimum length of long pulse - RC6_BIT_PULSE_LEN_MAX_2, // pulse_0_len_max: here: maximum length of long pulse - RC6_BIT_PAUSE_LEN_MIN_2, // pause_0_len_min: here: minimum length of long pause - RC6_BIT_PAUSE_LEN_MAX_2, // pause_0_len_max: here: maximum length of long pause + 0, // pulse_0_len_min: here: not used + 0, // pulse_0_len_max: here: not used + 0, // pause_0_len_min: here: not used + 0, // pause_0_len_max: here: not used RC6_ADDRESS_OFFSET, // address_offset: address offset RC6_ADDRESS_OFFSET + RC6_ADDRESS_LEN, // address_end: end of address RC6_COMMAND_OFFSET, // command_offset: command offset @@ -1172,7 +1218,7 @@ static PROGMEM IRMP_PARAMETER rc6_param = #if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER recs80ext_param = +static const PROGMEM IRMP_PARAMETER recs80ext_param = { IRMP_RECS80EXT_PROTOCOL, // protocol: ir protocol RECS80EXT_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 @@ -1197,7 +1243,7 @@ static PROGMEM IRMP_PARAMETER recs80ext_param = #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER nubert_param = +static const PROGMEM IRMP_PARAMETER nubert_param = { IRMP_NUBERT_PROTOCOL, // protocol: ir protocol NUBERT_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 @@ -1220,9 +1266,34 @@ static PROGMEM IRMP_PARAMETER nubert_param = #endif +#if IRMP_SUPPORT_SPEAKER_PROTOCOL == 1 + +static const PROGMEM IRMP_PARAMETER speaker_param = +{ + IRMP_SPEAKER_PROTOCOL, // protocol: ir protocol + SPEAKER_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + SPEAKER_1_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + SPEAKER_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + SPEAKER_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + SPEAKER_0_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + SPEAKER_0_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + SPEAKER_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + SPEAKER_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + SPEAKER_ADDRESS_OFFSET, // address_offset: address offset + SPEAKER_ADDRESS_OFFSET + SPEAKER_ADDRESS_LEN, // address_end: end of address + SPEAKER_COMMAND_OFFSET, // command_offset: command offset + SPEAKER_COMMAND_OFFSET + SPEAKER_COMMAND_LEN, // command_end: end of command + SPEAKER_COMPLETE_DATA_LEN, // complete_len: complete length of frame + SPEAKER_STOP_BIT, // stop_bit: flag: frame has stop bit + SPEAKER_LSB, // lsb_first: flag: LSB first + SPEAKER_FLAGS // flags: some flags +}; + +#endif + #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER bang_olufsen_param = +static const PROGMEM IRMP_PARAMETER bang_olufsen_param = { IRMP_BANG_OLUFSEN_PROTOCOL, // protocol: ir protocol BANG_OLUFSEN_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 @@ -1249,7 +1320,7 @@ static PROGMEM IRMP_PARAMETER bang_olufsen_param = static uint8_t first_bit; -static PROGMEM IRMP_PARAMETER grundig_param = +static const PROGMEM IRMP_PARAMETER grundig_param = { IRMP_GRUNDIG_PROTOCOL, // protocol: ir protocol @@ -1257,11 +1328,10 @@ static PROGMEM IRMP_PARAMETER grundig_param = GRUNDIG_NOKIA_IR60_BIT_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse GRUNDIG_NOKIA_IR60_BIT_LEN_MIN, // pause_1_len_min: here: minimum length of short pause GRUNDIG_NOKIA_IR60_BIT_LEN_MAX, // pause_1_len_max: here: maximum length of short pause - GRUNDIG_NOKIA_IR60_BIT_LEN_MIN_2, // pulse_0_len_min: here: minimum length of long pulse - GRUNDIG_NOKIA_IR60_BIT_LEN_MAX_2, // pulse_0_len_max: here: maximum length of long pulse - GRUNDIG_NOKIA_IR60_BIT_LEN_MIN_2, // pause_0_len_min: here: minimum length of long pause - GRUNDIG_NOKIA_IR60_BIT_LEN_MAX_2, // pause_0_len_max: here: maximum length of long pause - + 0, // pulse_0_len_min: here: not used + 0, // pulse_0_len_max: here: not used + 0, // pause_0_len_min: here: not used + 0, // pause_0_len_max: here: not used GRUNDIG_ADDRESS_OFFSET, // address_offset: address offset GRUNDIG_ADDRESS_OFFSET + GRUNDIG_ADDRESS_LEN, // address_end: end of address GRUNDIG_COMMAND_OFFSET, // command_offset: command offset @@ -1276,17 +1346,17 @@ static PROGMEM IRMP_PARAMETER grundig_param = #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER ruwido_param = +static const PROGMEM IRMP_PARAMETER ruwido_param = { IRMP_RUWIDO_PROTOCOL, // protocol: ir protocol SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN, // pause_1_len_min: here: minimum length of short pause SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX, // pause_1_len_max: here: maximum length of short pause - SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MIN_2, // pulse_0_len_min: here: minimum length of long pulse - SIEMENS_OR_RUWIDO_BIT_PULSE_LEN_MAX_2, // pulse_0_len_max: here: maximum length of long pulse - SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MIN_2, // pause_0_len_min: here: minimum length of long pause - SIEMENS_OR_RUWIDO_BIT_PAUSE_LEN_MAX_2, // pause_0_len_max: here: maximum length of long pause + 0, // pulse_0_len_min: here: not used + 0, // pulse_0_len_max: here: not used + 0, // pause_0_len_min: here: not used + 0, // pause_0_len_max: here: not used RUWIDO_ADDRESS_OFFSET, // address_offset: address offset RUWIDO_ADDRESS_OFFSET + RUWIDO_ADDRESS_LEN, // address_end: end of address RUWIDO_COMMAND_OFFSET, // command_offset: command offset @@ -1301,7 +1371,7 @@ static PROGMEM IRMP_PARAMETER ruwido_param = #if IRMP_SUPPORT_FDC_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER fdc_param = +static const PROGMEM IRMP_PARAMETER fdc_param = { IRMP_FDC_PROTOCOL, // protocol: ir protocol FDC_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 @@ -1326,7 +1396,7 @@ static PROGMEM IRMP_PARAMETER fdc_param = #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER rccar_param = +static const PROGMEM IRMP_PARAMETER rccar_param = { IRMP_RCCAR_PROTOCOL, // protocol: ir protocol RCCAR_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 @@ -1351,7 +1421,7 @@ static PROGMEM IRMP_PARAMETER rccar_param = #if IRMP_SUPPORT_NIKON_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER nikon_param = +static const PROGMEM IRMP_PARAMETER nikon_param = { IRMP_NIKON_PROTOCOL, // protocol: ir protocol NIKON_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 @@ -1376,7 +1446,7 @@ static PROGMEM IRMP_PARAMETER nikon_param = #if IRMP_SUPPORT_KATHREIN_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER kathrein_param = +static const PROGMEM IRMP_PARAMETER kathrein_param = { IRMP_KATHREIN_PROTOCOL, // protocol: ir protocol KATHREIN_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 @@ -1401,7 +1471,7 @@ static PROGMEM IRMP_PARAMETER kathrein_param = #if IRMP_SUPPORT_NETBOX_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER netbox_param = +static const PROGMEM IRMP_PARAMETER netbox_param = { IRMP_NETBOX_PROTOCOL, // protocol: ir protocol NETBOX_PULSE_LEN, // pulse_1_len_min: minimum length of pulse with bit value 1, here: exact value @@ -1426,7 +1496,7 @@ static PROGMEM IRMP_PARAMETER netbox_param = #if IRMP_SUPPORT_LEGO_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER lego_param = +static const PROGMEM IRMP_PARAMETER lego_param = { IRMP_LEGO_PROTOCOL, // protocol: ir protocol LEGO_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 @@ -1449,65 +1519,256 @@ static PROGMEM IRMP_PARAMETER lego_param = #endif -#if IRMP_SUPPORT_IMON_PROTOCOL == 1 +#if IRMP_SUPPORT_THOMSON_PROTOCOL == 1 -static PROGMEM IRMP_PARAMETER imon_param = +static const PROGMEM IRMP_PARAMETER thomson_param = { - IRMP_IMON_PROTOCOL, // protocol: ir protocol - IMON_PULSE_LEN, // pulse_1_len_min: minimum length of pulse with bit value 1 - IMON_PULSE_REST_LEN, // pulse_1_len_max: maximum length of pulse with bit value 1 - IMON_PAUSE_LEN, // pause_1_len_min: minimum length of pause with bit value 1 - IMON_PAUSE_REST_LEN, // pause_1_len_max: maximum length of pause with bit value 1 - IMON_PULSE_LEN, // pulse_0_len_min: minimum length of pulse with bit value 0 - IMON_PULSE_REST_LEN, // pulse_0_len_max: maximum length of pulse with bit value 0 - IMON_PAUSE_LEN, // pause_0_len_min: minimum length of pause with bit value 0 - IMON_PAUSE_REST_LEN, // pause_0_len_max: maximum length of pause with bit value 0 - IMON_ADDRESS_OFFSET, // address_offset: address offset - IMON_ADDRESS_OFFSET + IMON_ADDRESS_LEN, // address_end: end of address - IMON_COMMAND_OFFSET, // command_offset: command offset - IMON_COMMAND_OFFSET + IMON_COMMAND_LEN, // command_end: end of command - IMON_COMPLETE_DATA_LEN, // complete_len: complete length of frame - IMON_STOP_BIT, // stop_bit: flag: frame has stop bit - IMON_LSB, // lsb_first: flag: LSB first - IMON_FLAGS // flags: some flags + IRMP_THOMSON_PROTOCOL, // protocol: ir protocol + THOMSON_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + THOMSON_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + THOMSON_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + THOMSON_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + THOMSON_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + THOMSON_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + THOMSON_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + THOMSON_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + THOMSON_ADDRESS_OFFSET, // address_offset: address offset + THOMSON_ADDRESS_OFFSET + THOMSON_ADDRESS_LEN, // address_end: end of address + THOMSON_COMMAND_OFFSET, // command_offset: command offset + THOMSON_COMMAND_OFFSET + THOMSON_COMMAND_LEN, // command_end: end of command + THOMSON_COMPLETE_DATA_LEN, // complete_len: complete length of frame + THOMSON_STOP_BIT, // stop_bit: flag: frame has stop bit + THOMSON_LSB, // lsb_first: flag: LSB first + THOMSON_FLAGS // flags: some flags }; #endif -static uint8_t irmp_bit; // current bit position -static IRMP_PARAMETER irmp_param; +#if IRMP_SUPPORT_BOSE_PROTOCOL == 1 + +static const PROGMEM IRMP_PARAMETER bose_param = +{ + IRMP_BOSE_PROTOCOL, // protocol: ir protocol + BOSE_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + BOSE_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + BOSE_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + BOSE_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + BOSE_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + BOSE_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + BOSE_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + BOSE_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + BOSE_ADDRESS_OFFSET, // address_offset: address offset + BOSE_ADDRESS_OFFSET + BOSE_ADDRESS_LEN, // address_end: end of address + BOSE_COMMAND_OFFSET, // command_offset: command offset + BOSE_COMMAND_OFFSET + BOSE_COMMAND_LEN, // command_end: end of command + BOSE_COMPLETE_DATA_LEN, // complete_len: complete length of frame + BOSE_STOP_BIT, // stop_bit: flag: frame has stop bit + BOSE_LSB, // lsb_first: flag: LSB first + BOSE_FLAGS // flags: some flags +}; -#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) -static IRMP_PARAMETER irmp_param2; #endif -static volatile uint8_t irmp_ir_detected; -static volatile uint8_t irmp_protocol; -static volatile uint16_t irmp_address; -static volatile uint16_t irmp_command; -static volatile uint16_t irmp_id; // only used for SAMSUNG protocol -static volatile uint8_t irmp_flags; +#if IRMP_SUPPORT_A1TVBOX_PROTOCOL == 1 + +static const PROGMEM IRMP_PARAMETER a1tvbox_param = +{ + IRMP_A1TVBOX_PROTOCOL, // protocol: ir protocol + + A1TVBOX_BIT_PULSE_LEN_MIN, // pulse_1_len_min: here: minimum length of short pulse + A1TVBOX_BIT_PULSE_LEN_MAX, // pulse_1_len_max: here: maximum length of short pulse + A1TVBOX_BIT_PAUSE_LEN_MIN, // pause_1_len_min: here: minimum length of short pause + A1TVBOX_BIT_PAUSE_LEN_MAX, // pause_1_len_max: here: maximum length of short pause + 0, // pulse_0_len_min: here: not used + 0, // pulse_0_len_max: here: not used + 0, // pause_0_len_min: here: not used + 0, // pause_0_len_max: here: not used + A1TVBOX_ADDRESS_OFFSET, // address_offset: address offset + A1TVBOX_ADDRESS_OFFSET + A1TVBOX_ADDRESS_LEN, // address_end: end of address + A1TVBOX_COMMAND_OFFSET, // command_offset: command offset + A1TVBOX_COMMAND_OFFSET + A1TVBOX_COMMAND_LEN, // command_end: end of command + A1TVBOX_COMPLETE_DATA_LEN, // complete_len: complete length of frame + A1TVBOX_STOP_BIT, // stop_bit: flag: frame has stop bit + A1TVBOX_LSB, // lsb_first: flag: LSB first + A1TVBOX_FLAGS // flags: some flags +}; -#ifdef ANALYZE -static uint8_t IRMP_PIN; #endif -/*--------------------------------------------------------------------------------------------------------------------------------------------------- - * Initialize IRMP decoder - * @details Configures IRMP input pin - *--------------------------------------------------------------------------------------------------------------------------------------------------- - */ -#ifndef ANALYZE -void -irmp_init (void) +#if IRMP_SUPPORT_ORTEK_PROTOCOL == 1 + +static const PROGMEM IRMP_PARAMETER ortek_param = { -#ifndef PIC_CCS_COMPILER - IRMP_PORT &= ~(1<> 8) == (~irmp_command & 0x00FF)) @@ -1546,7 +1815,9 @@ irmp_get_data (IRMP_DATA * irmp_data_p) } 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; @@ -1554,6 +1825,15 @@ irmp_get_data (IRMP_DATA * irmp_data_p) } 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; +#endif #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1 case IRMP_SIEMENS_PROTOCOL: case IRMP_RUWIDO_PROTOCOL: @@ -1572,12 +1852,24 @@ irmp_get_data (IRMP_DATA * irmp_data_p) } break; #endif +#if IRMP_SUPPORT_RC5_PROTOCOL == 1 + case IRMP_RC5_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; #endif #if IRMP_SUPPORT_RCCAR_PROTOCOL == 1 @@ -1592,8 +1884,8 @@ irmp_get_data (IRMP_DATA * irmp_data_p) rtc = TRUE; // Summe: V C1 C0 D7 D6 D5 D4 D3 D2 D1 D0 break; #endif -#if 1 // squeeze code to 8 bit, upper bit indicates release-key -#if IRMP_SUPPORT_NETBOX_PROTOCOL == 1 + +#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? { @@ -1611,16 +1903,19 @@ irmp_get_data (IRMP_DATA * irmp_data_p) } 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 -#endif // 0 #if IRMP_SUPPORT_LEGO_PROTOCOL == 1 case IRMP_LEGO_PROTOCOL: { @@ -1633,14 +1928,20 @@ irmp_get_data (IRMP_DATA * irmp_data_p) } else { +#ifdef ANALYZE ANALYZE_PRINTF ("CRC error in LEGO protocol\n"); - rtc = TRUE; +#endif // ANALYZE + // rtc = TRUE; // don't accept codes with CRC errors } break; } #endif + default: + { rtc = TRUE; + break; + } } if (rtc) @@ -1660,20 +1961,44 @@ irmp_get_data (IRMP_DATA * irmp_data_p) return rtc; } +// uint8_t +// irmp_is_busy (void) +// { +// return irmp_busy_flag; +// } + +#if IRMP_USE_CALLBACK == 1 +void +irmp_set_callback_ptr (void (*cb)(uint8_t)) +{ + irmp_callback_ptr = cb; +} +#endif // IRMP_USE_CALLBACK == 1 + // these statics must not be volatile, because they are only used by irmp_store_bit(), which is called by irmp_ISR() static uint16_t irmp_tmp_address; // ir address static uint16_t irmp_tmp_command; // ir command -#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) || IRMP_SUPPORT_NEC42_PROTOCOL == 1 +#if (IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)) || IRMP_SUPPORT_NEC42_PROTOCOL == 1 static uint16_t irmp_tmp_address2; // ir address static uint16_t irmp_tmp_command2; // ir command #endif +#if IRMP_SUPPORT_LGAIR_PROTOCOL == 1 +static uint16_t irmp_lgair_address; // ir address +static uint16_t irmp_lgair_command; // ir command +#endif + #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 static uint16_t irmp_tmp_id; // ir id (only SAMSUNG) #endif #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 static uint8_t xor_check[6]; // check kaseikyo "parity" bits +static uint8_t genre2; // save genre2 bits here, later copied to MSB in flags +#endif + +#if IRMP_SUPPORT_ORTEK_PROTOCOL == 1 +static uint8_t parity; // number of '1' of the first 14 bits, check if even. #endif /*--------------------------------------------------------------------------------------------------------------------------------------------------- @@ -1688,6 +2013,44 @@ static uint8_t xor_check[6]; static void irmp_store_bit (uint8_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; + } + } + } + } +#endif + #if IRMP_SUPPORT_GRUNDIG_NOKIA_IR60_PROTOCOL == 1 if (irmp_bit == 0 && irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL) { @@ -1712,7 +2075,16 @@ irmp_store_bit (uint8_t value) { if (irmp_param.lsb_first) { - irmp_tmp_command |= (((uint16_t) (value)) << (irmp_bit - irmp_param.command_offset)); // CV wants cast +#if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1 + if (irmp_param.protocol == IRMP_SAMSUNG48_PROTOCOL && irmp_bit >= 32) + { + irmp_tmp_id |= (((uint16_t) (value)) << (irmp_bit - 32)); // CV wants cast + } + else +#endif + { + irmp_tmp_command |= (((uint16_t) (value)) << (irmp_bit - irmp_param.command_offset)); // CV wants cast + } } else { @@ -1721,39 +2093,68 @@ irmp_store_bit (uint8_t 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; + } + } + // NO else! +#endif + #if IRMP_SUPPORT_NEC42_PROTOCOL == 1 - else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit >= 13 && irmp_bit < 26) + if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit >= 13 && irmp_bit < 26) { irmp_tmp_address2 |= (((uint16_t) (value)) << (irmp_bit - 13)); // CV wants cast } + else #endif #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 - else if (irmp_param.protocol == IRMP_SAMSUNG_PROTOCOL && irmp_bit >= SAMSUNG_ID_OFFSET && irmp_bit < SAMSUNG_ID_OFFSET + SAMSUNG_ID_LEN) + if (irmp_param.protocol == IRMP_SAMSUNG_PROTOCOL && irmp_bit >= SAMSUNG_ID_OFFSET && irmp_bit < SAMSUNG_ID_OFFSET + SAMSUNG_ID_LEN) { irmp_tmp_id |= (((uint16_t) (value)) << (irmp_bit - SAMSUNG_ID_OFFSET)); // store with LSB first } + else #endif #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 - else if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && irmp_bit >= 20 && irmp_bit < 24) + if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL) { - irmp_tmp_command |= (((uint16_t) (value)) << (irmp_bit - 8)); // store 4 system bits in upper nibble with LSB first - } - - if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL && irmp_bit < KASEIKYO_COMPLETE_DATA_LEN) - { - if (value) + if (irmp_bit >= 20 && irmp_bit < 24) { - xor_check[irmp_bit / 8] |= 1 << (irmp_bit % 8); + irmp_tmp_command |= (((uint16_t) (value)) << (irmp_bit - 8)); // store 4 system bits (genre 1) in upper nibble with LSB first } - else + else if (irmp_bit >= 24 && irmp_bit < 28) { - xor_check[irmp_bit / 8] &= ~(1 << (irmp_bit % 8)); + genre2 |= (((uint8_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++; } @@ -1805,10 +2206,11 @@ irmp_ISR (void) static PAUSE_LEN irmp_pause_time; // count bit time for pause static uint16_t last_irmp_address = 0xFFFF; // save last irmp address to recognize key repetition static uint16_t last_irmp_command = 0xFFFF; // save last irmp command to recognize key repetition - static uint16_t repetition_len; // SIRCS repeats frame 2-5 times with 45 ms pause + static uint16_t key_repetition_len; // SIRCS repeats frame 2-5 times with 45 ms pause static uint8_t repetition_frame_number; #if IRMP_SUPPORT_DENON_PROTOCOL == 1 static uint16_t last_irmp_denon_command; // save last irmp command to recognize DENON frame repetition + static uint16_t denon_repetition_len = 0xFFFF; // denon repetition len of 2nd auto generated frame #endif #if IRMP_SUPPORT_RC5_PROTOCOL == 1 static uint8_t rc5_cmd_bit6; // bit 6 of RC5 command is the inverted 2nd start bit @@ -1823,10 +2225,23 @@ irmp_ISR (void) #ifdef ANALYZE time_counter++; -#endif +#endif // ANALYZE irmp_input = input(IRMP_PIN); +#if IRMP_USE_CALLBACK == 1 + if (irmp_callback_ptr) + { + static uint8_t last_inverted_input; + + if (last_inverted_input != !irmp_input) + { + (*irmp_callback_ptr) (! irmp_input); + last_inverted_input = !irmp_input; + } + } +#endif // IRMP_USE_CALLBACK == 1 + irmp_log(irmp_input); // log ir signal, if IRMP_LOGGING defined if (! irmp_ir_detected) // ir code already detected? @@ -1835,12 +2250,13 @@ irmp_ISR (void) { // no... if (! irmp_input) // receiving burst? { // yes... +// irmp_busy_flag = TRUE; #ifdef ANALYZE if (! irmp_pulse_time) { - ANALYZE_PRINTF("%8d [starting pulse]\n", time_counter); + ANALYZE_PRINTF("%8.3fms [starting pulse]\n", (double) (time_counter * 1000) / F_INTERRUPTS); } -#endif +#endif // ANALYZE irmp_pulse_time++; // increment counter } else @@ -1852,12 +2268,21 @@ irmp_ISR (void) wait_for_space = 0; irmp_tmp_command = 0; irmp_tmp_address = 0; +#if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 + genre2 = 0; +#endif +#if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 + 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; #endif - +#if IRMP_SUPPORT_LGAIR_PROTOCOL == 1 + irmp_lgair_command = 0; + irmp_lgair_address = 0; +#endif irmp_bit = 0xff; irmp_pause_time = 1; // 1st pause: set to 1, not to 0! #if IRMP_SUPPORT_RC5_PROTOCOL == 1 @@ -1866,9 +2291,26 @@ irmp_ISR (void) } else { - if (repetition_len < 0xFFFF) // avoid overflow of counter + if (key_repetition_len < 0xFFFF) // avoid overflow of counter { - repetition_len++; + 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 >= 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); +#endif // ANALYZE + last_irmp_denon_command = 0; + denon_repetition_len = 0xFFFF; + } + } +#endif // IRMP_SUPPORT_DENON_PROTOCOL == 1 } } } @@ -1896,9 +2338,12 @@ irmp_ISR (void) else #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1 { - ANALYZE_PRINTF ("%8d error 1: pause after start bit pulse %d too long: %d\n", time_counter, irmp_pulse_time, irmp_pause_time); +#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'); +#endif // ANALYZE } + irmp_start_bit_detected = 0; // reset flags, let's wait for another start bit irmp_pulse_time = 0; irmp_pause_time = 0; @@ -1906,21 +2351,26 @@ irmp_ISR (void) } else { // receiving first data pulse! - IRMP_PARAMETER * irmp_param_p = (IRMP_PARAMETER *) 0; + 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; #endif - ANALYZE_PRINTF ("%8d [start-bit: pulse = %2d, pause = %2d]\n", time_counter, irmp_pulse_time, irmp_pause_time); +#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); +#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 +#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); +#endif // ANALYZE irmp_param_p = (IRMP_PARAMETER *) (IRMP_PARAMETER *) &sircs_param; } else @@ -1931,9 +2381,11 @@ irmp_ISR (void) 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) { - ANALYZE_PRINTF ("protocol = NEC or JVC repeat frame, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", +#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 @@ -1944,37 +2396,102 @@ irmp_ISR (void) 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); +#endif // ANALYZE 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); +#endif // ANALYZE 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 - ANALYZE_PRINTF ("protocol = NEC (repetition frame), start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX, - NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX); +#if IRMP_SUPPORT_JVC_PROTOCOL == 1 + if (irmp_protocol == IRMP_JVC_PROTOCOL) // last protocol was JVC, awaiting repeat frame + { // some jvc remote controls use nec repetition frame for jvc repetition frame +#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); +#endif // ANALYZE + 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); +#endif // ANALYZE - irmp_param_p = (IRMP_PARAMETER *) &nec_rep_param; + irmp_param_p = (IRMP_PARAMETER *) &nec_rep_param; + } } else + +#if IRMP_SUPPORT_JVC_PROTOCOL == 1 + if (irmp_protocol == IRMP_JVC_PROTOCOL && // last protocol was JVC, awaiting repeat frame + irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= NEC_0_PAUSE_LEN_MIN && irmp_pause_time <= NEC_0_PAUSE_LEN_MAX) + { // it's JVC repetition type 3 +#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) + { +#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); +#endif // ANALYZE + 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) + { +#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); +#endif // ANALYZE + irmp_param_p = (IRMP_PARAMETER *) &roomba_param; + } + else +#endif // IRMP_SUPPORT_ROOMBA_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) { +#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); +#endif // ANALYZE irmp_param_p = (IRMP_PARAMETER *) &nikon_param; } else @@ -1984,9 +2501,11 @@ irmp_ISR (void) 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); +#endif // ANALYZE irmp_param_p = (IRMP_PARAMETER *) &samsung_param; } else @@ -1996,9 +2515,11 @@ irmp_ISR (void) 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); +#endif // ANALYZE irmp_param_p = (IRMP_PARAMETER *) &matsushita_param; } else @@ -2008,36 +2529,55 @@ irmp_ISR (void) 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); +#endif // ANALYZE irmp_param_p = (IRMP_PARAMETER *) &kaseikyo_param; } else #endif // IRMP_SUPPORT_KASEIKYO_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) + { +#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); +#endif // ANALYZE + 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 +#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); +#endif // ANALYZE irmp_param_p = (IRMP_PARAMETER *) &recs80_param; } else #endif // IRMP_SUPPORT_RECS80_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 >= RC5_START_BIT_LEN_MIN_2 && irmp_pulse_time <= RC5_START_BIT_LEN_MAX_2)) && - ((irmp_pause_time >= RC5_START_BIT_LEN_MIN && irmp_pause_time <= RC5_START_BIT_LEN_MAX) || - (irmp_pause_time >= RC5_START_BIT_LEN_MIN_2 && irmp_pause_time <= RC5_START_BIT_LEN_MAX_2))) + 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, @@ -2045,6 +2585,7 @@ irmp_ISR (void) 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 @@ -2054,6 +2595,7 @@ irmp_ISR (void) 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, @@ -2061,23 +2603,26 @@ irmp_ISR (void) 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, - RC5_START_BIT_LEN_MIN_2, RC5_START_BIT_LEN_MAX_2, + 2 * RC5_START_BIT_LEN_MIN, 2 * RC5_START_BIT_LEN_MAX, RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX, - RC5_START_BIT_LEN_MIN_2, RC5_START_BIT_LEN_MAX_2); + 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 <= RC5_START_BIT_LEN_MAX_2) || - (irmp_pause_time > RC5_START_BIT_LEN_MAX && irmp_pause_time <= RC5_START_BIT_LEN_MAX_2)) + 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; @@ -2095,22 +2640,56 @@ irmp_ISR (void) ((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 +#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) + { +#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); +#endif // ANALYZE + 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; @@ -2122,9 +2701,11 @@ irmp_ISR (void) 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); +#endif // ANALYZE irmp_param_p = (IRMP_PARAMETER *) &recs80ext_param; } else @@ -2134,18 +2715,35 @@ irmp_ISR (void) 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); +#endif // ANALYZE irmp_param_p = (IRMP_PARAMETER *) &nubert_param; } else #endif // IRMP_SUPPORT_NUBERT_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 +#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); +#endif // ANALYZE + 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, @@ -2159,6 +2757,7 @@ irmp_ISR (void) 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; } @@ -2169,9 +2768,11 @@ irmp_ISR (void) 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; @@ -2181,15 +2782,17 @@ irmp_ISR (void) #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 >= SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN_2 && irmp_pulse_time <= SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX_2)) && + (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 >= SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN_2 && irmp_pause_time <= SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX_2))) + (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, - SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MIN_2, SIEMENS_OR_RUWIDO_START_BIT_PULSE_LEN_MAX_2, + 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, - SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MIN_2, SIEMENS_OR_RUWIDO_START_BIT_PAUSE_LEN_MAX_2); + 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; @@ -2201,9 +2804,11 @@ irmp_ISR (void) 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); +#endif // ANALYZE irmp_param_p = (IRMP_PARAMETER *) &fdc_param; } else @@ -2213,9 +2818,11 @@ irmp_ISR (void) 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); +#endif // ANALYZE irmp_param_p = (IRMP_PARAMETER *) &rccar_param; } else @@ -2225,9 +2832,11 @@ irmp_ISR (void) 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); +#endif // ANALYZE irmp_param_p = (IRMP_PARAMETER *) &kathrein_param; } else @@ -2237,9 +2846,11 @@ irmp_ISR (void) 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); +#endif // ANALYZE irmp_param_p = (IRMP_PARAMETER *) &netbox_param; } else @@ -2249,28 +2860,66 @@ irmp_ISR (void) 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); +#endif // ANALYZE irmp_param_p = (IRMP_PARAMETER *) &lego_param; } else -#endif // IRMP_SUPPORT_NEC_PROTOCOL == 1 +#endif // IRMP_SUPPORT_LEGO_PROTOCOL == 1 -#if IRMP_SUPPORT_IMON_PROTOCOL == 1 - if (irmp_pulse_time >= IMON_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= IMON_START_BIT_PULSE_LEN_MAX && - irmp_pause_time >= IMON_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= IMON_START_BIT_PAUSE_LEN_MAX) - { // it's IMON - ANALYZE_PRINTF ("protocol = IMON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", - IMON_START_BIT_PULSE_LEN_MIN, IMON_START_BIT_PULSE_LEN_MAX, - IMON_START_BIT_PAUSE_LEN_MIN, IMON_START_BIT_PAUSE_LEN_MAX); - irmp_param_p = (IRMP_PARAMETER *) &imon_param; +#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 -#endif // IRMP_SUPPORT_IMON_PROTOCOL == 1 +#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 +#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 +#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); +#endif // ANALYZE + irmp_param_p = (IRMP_PARAMETER *) &rcmm_param; + } + else +#endif // IRMP_SUPPORT_RCMM_PROTOCOL == 1 { +#ifdef ANALYZE ANALYZE_PRINTF ("protocol = UNKNOWN\n"); +#endif // ANALYZE irmp_start_bit_detected = 0; // wait for another start bit... } @@ -2278,27 +2927,32 @@ irmp_ISR (void) { memcpy_P (&irmp_param, irmp_param_p, sizeof (IRMP_PARAMETER)); -#ifdef ANALYZE 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); +#endif // ANALYZE } else { +#ifdef ANALYZE ANALYZE_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max, - irmp_param.pulse_0_len_min, irmp_param.pulse_0_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, - irmp_param.pause_0_len_min, irmp_param.pause_0_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) { +#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); +#endif // ANALYZE } #endif @@ -2306,16 +2960,30 @@ irmp_ISR (void) #if IRMP_SUPPORT_RC6_PROTOCOL == 1 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); +#endif // ANALYZE } #endif 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); +#endif // ANALYZE + } + 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); +#endif // ANALYZE } +#ifdef ANALYZE #if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL) { @@ -2338,19 +3006,22 @@ irmp_ISR (void) 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 <= irmp_param.pulse_0_len_max) // XXXXXXXX!!! + if (irmp_pause_time > irmp_param.pulse_1_len_max && irmp_pause_time <= 2 * irmp_param.pulse_1_len_max) { - ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time); +#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) { - ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time); - +#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); } } @@ -2369,23 +3040,55 @@ irmp_ISR (void) #if IRMP_SUPPORT_DENON_PROTOCOL == 1 if (irmp_param.protocol == IRMP_DENON_PROTOCOL) { - ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time); +#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); +#endif // ANALYZE 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 (); +#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"? +#ifdef ANALYZE + ANALYZE_PUTCHAR ('0'); // yes, store 0 + ANALYZE_NEWLINE (); +#endif // ANALYZE + irmp_store_bit (0); + } + } + else +#endif // IRMP_SUPPORT_DENON_PROTOCOL == 1 +#if IRMP_SUPPORT_THOMSON_PROTOCOL == 1 + 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); +#endif // ANALYZE + + 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 (); +#endif // ANALYZE irmp_store_bit (1); } - else // if (irmp_pause_time >= DENON_0_PAUSE_LEN_MIN && irmp_pause_time <= DENON_0_PAUSE_LEN_MAX) + 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 (); +#endif // ANALYZE irmp_store_bit (0); } } else -#endif // IRMP_SUPPORT_DENON_PROTOCOL == 1 +#endif // IRMP_SUPPORT_THOMSON_PROTOCOL == 1 { ; // else do nothing } @@ -2417,13 +3120,15 @@ irmp_ISR (void) { ANALYZE_PRINTF ("stop bit detected\n"); } -#endif +#endif // ANALYZE irmp_param.stop_bit = 0; } else { - ANALYZE_PRINTF ("error: stop bit timing wrong\n"); - +#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; @@ -2458,9 +3163,11 @@ irmp_ISR (void) #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 == 6) + 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 @@ -2474,7 +3181,7 @@ irmp_ISR (void) irmp_tmp_command <<= 1; irmp_tmp_command |= first_bit; } - else if (irmp_pause_time >= irmp_param.pause_0_len_max && irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN - 2) + 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 ;-) @@ -2482,7 +3189,9 @@ irmp_ISR (void) } else if (irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN) { +#ifdef ANALYZE ANALYZE_PRINTF ("Switching to NOKIA protocol\n"); +#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; @@ -2501,7 +3210,7 @@ irmp_ISR (void) #if IRMP_SUPPORT_SIEMENS_OR_RUWIDO_PROTOCOL == 1 if (irmp_param.protocol == IRMP_RUWIDO_PROTOCOL && !irmp_param.stop_bit) { - if (irmp_pause_time >= irmp_param.pause_0_len_max && irmp_bit >= RUWIDO_COMPLETE_DATA_LEN - 2) + 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 ;-) @@ -2509,7 +3218,9 @@ irmp_ISR (void) } 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; @@ -2522,15 +3233,32 @@ irmp_ISR (void) irmp_tmp_address <<= 2; irmp_tmp_address |= (irmp_tmp_command >> 6); irmp_tmp_command &= 0x003F; - irmp_tmp_command <<= 4; +// irmp_tmp_command <<= 4; 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 +#endif #if IRMP_SUPPORT_MANCHESTER == 1 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) && - irmp_pause_time >= irmp_param.pause_0_len_max && irmp_bit >= irmp_param.complete_len - 2 && !irmp_param.stop_bit) + 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 @@ -2546,7 +3274,9 @@ irmp_ISR (void) #if IRMP_SUPPORT_JVC_PROTOCOL == 1 else if (irmp_param.protocol == IRMP_NEC_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17)) // it was a JVC stop bit { - ANALYZE_PRINTF ("Switching to JVC protocol\n"); +#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 @@ -2555,12 +3285,28 @@ irmp_ISR (void) 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... + } +#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"); +#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 @@ -2568,31 +3314,85 @@ irmp_ISR (void) // 0123456789ABC0123456789ABC0123456701234567 // NEC42: AAAAAAAAAAAAAaaaaaaaaaaaaaCCCCCCCCcccccccc // NEC: AAAAAAAAaaaaaaaaCCCCCCCCcccccccc - irmp_tmp_address |= (irmp_tmp_address2 & 0x0007) << 12; + 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 + { +#ifdef ANALYZE + 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; + } +#endif // IRMP_SUPPORT_LGAIR_PROTOCOL == 1 #if IRMP_SUPPORT_JVC_PROTOCOL == 1 - else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && irmp_bit == 16) // it was a JVC stop bit + else if (irmp_param.protocol == IRMP_NEC42_PROTOCOL && (irmp_bit == 16 || irmp_bit == 17)) // it was a JVC stop bit + { +#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 + + // 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 + { +#ifdef ANALYZE + 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; + } +#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 { - ANALYZE_PRINTF ("Switching to JVC protocol\n"); + 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); +#endif // ANALYZE + 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); +#endif // ANALYZE + irmp_param.protocol = IRMP_RCMM24_PROTOCOL; // switch protocol + } 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 + irmp_param.complete_len = irmp_bit; // patch length } -#endif // IRMP_SUPPORT_JVC_PROTOCOL == 1 -#endif // IRMP_SUPPORT_NEC42_PROTOCOL == 1 +#endif // IRMP_SUPPORT_RCMM_PROTOCOL == 1 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'); - +#endif // ANALYZE irmp_start_bit_detected = 0; // wait for another start bit... irmp_pulse_time = 0; irmp_pause_time = 0; @@ -2607,22 +3407,26 @@ irmp_ISR (void) if (got_light) { - ANALYZE_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time); +#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); +#endif // ANALYZE #if IRMP_SUPPORT_MANCHESTER == 1 if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) // Manchester { -#if 0 - if (irmp_pulse_time > irmp_param.pulse_1_len_max /* && irmp_pulse_time <= irmp_param.pulse_0_len_max */) -#else // better: - if (irmp_pulse_time > irmp_param.pulse_1_len_max && irmp_pulse_time <= irmp_param.pulse_0_len_max && - irmp_pause_time <= irmp_param.pause_0_len_max) +#if 1 + 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) #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); @@ -2633,21 +3437,27 @@ irmp_ISR (void) 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'); +#endif // ANALYZE 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 { +#ifdef ANALYZE ANALYZE_PUTCHAR ('T'); +#endif // ANALYZE irmp_store_bit (1); - if (irmp_pause_time > irmp_param.pause_0_len_max) + if (irmp_pause_time > 2 * irmp_param.pause_1_len_max) { last_value = 0; } @@ -2655,29 +3465,35 @@ irmp_ISR (void) { last_value = 1; } +#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) ? '1' : '0'); +#endif // ANALYZE 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) #endif { +#ifdef ANALYZE 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 <= irmp_param.pause_0_len_max */) + 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 */) { uint8_t manchester_value; - if (last_pause > irmp_param.pause_1_len_max && last_pause <= irmp_param.pause_0_len_max) + 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; @@ -2687,19 +3503,25 @@ irmp_ISR (void) manchester_value = last_value; } +#ifdef ANALYZE 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) #endif { +#ifdef ANALYZE 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; @@ -2719,7 +3541,9 @@ irmp_ISR (void) ((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 ('?'); +#endif // ANALYZE irmp_param.protocol = 0; // switch to FDC, see below } else @@ -2730,16 +3554,20 @@ irmp_ISR (void) ((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 ('?'); +#endif // ANALYZE 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'); +#endif // ANALYZE irmp_start_bit_detected = 0; // reset flags and wait for next start bit irmp_pause_time = 0; } @@ -2750,18 +3578,24 @@ irmp_ISR (void) { if (irmp_pause_time >= FDC_1_PAUSE_LEN_MIN && irmp_pause_time <= FDC_1_PAUSE_LEN_MAX) { +#ifdef ANALYZE 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) { +#ifdef ANALYZE ANALYZE_PRINTF (" 0 (FDC)\n"); +#endif // ANALYZE irmp_store_bit2 (0); } if (! irmp_param.protocol) { +#ifdef ANALYZE 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; @@ -2774,18 +3608,24 @@ irmp_ISR (void) { if (irmp_pause_time >= RCCAR_1_PAUSE_LEN_MIN && irmp_pause_time <= RCCAR_1_PAUSE_LEN_MAX) { +#ifdef ANALYZE 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) { +#ifdef ANALYZE ANALYZE_PRINTF (" 0 (RCCAR)\n"); +#endif // ANALYZE irmp_store_bit2 (0); } if (! irmp_param.protocol) { +#ifdef ANALYZE 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; @@ -2805,7 +3645,9 @@ irmp_ISR (void) { 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) @@ -2820,7 +3662,9 @@ irmp_ISR (void) 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) @@ -2832,7 +3676,9 @@ irmp_ISR (void) irmp_pause_time = 0; } } +#ifdef ANALYZE ANALYZE_NEWLINE (); +#endif // ANALYZE wait_for_space = 0; } else @@ -2844,39 +3690,56 @@ irmp_ISR (void) 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_tmp_id = 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 "); +#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; +#else +#ifdef ANALYZE + 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; - +#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; } - - ANALYZE_PRINTF ("Switching to SAMSUNG32 protocol\n"); } 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; } @@ -2892,8 +3755,10 @@ irmp_ISR (void) #endif // IRMP_SUPPORT_NEC42_PROTOCOL == 1 irmp_bit == 8 && irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX) { +#ifdef ANALYZE ANALYZE_PRINTF ("Switching to NEC16 protocol\n"); - irmp_param.protocol = IRMP_NEC16_PROTOCOL; +#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; @@ -2913,14 +3778,18 @@ irmp_ISR (void) { 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; } @@ -2929,14 +3798,18 @@ irmp_ISR (void) { 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; } @@ -2945,31 +3818,39 @@ irmp_ISR (void) { 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; } @@ -2977,8 +3858,10 @@ irmp_ISR (void) } 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; } @@ -2986,19 +3869,70 @@ irmp_ISR (void) 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 +#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"? +#ifdef ANALYZE 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"? +#ifdef ANALYZE ANALYZE_PUTCHAR ('0'); ANALYZE_NEWLINE (); +#endif // ANALYZE irmp_store_bit (0); wait_for_space = 0; } @@ -3016,14 +3950,18 @@ irmp_ISR (void) 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; @@ -3031,8 +3969,10 @@ irmp_ISR (void) 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; } @@ -3055,7 +3995,7 @@ irmp_ISR (void) 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 && repetition_len < AUTO_FRAME_REPETITION_LEN) + if (last_irmp_command == irmp_tmp_command && key_repetition_len < AUTO_FRAME_REPETITION_LEN) { repetition_frame_number++; } @@ -3068,9 +4008,24 @@ irmp_ISR (void) // 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, repetition_len, AUTO_FRAME_REPETITION_LEN); - repetition_len = 0; + repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN); +#endif // ANALYZE + 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) + { +#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); +#endif // ANALYZE + key_repetition_len = 0; } else #endif @@ -3079,20 +4034,24 @@ irmp_ISR (void) // 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, repetition_len, AUTO_FRAME_REPETITION_LEN); - repetition_len = 0; + repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN); +#endif // ANALYZE + key_repetition_len = 0; } else #endif #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 - // if SAMSUNG32 protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame - if (irmp_param.protocol == IRMP_SAMSUNG32_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)) { - ANALYZE_PRINTF ("code skipped: SAMSUNG32 auto repetition frame #%d, counter = %d, auto repetition len = %d\n", - repetition_frame_number + 1, repetition_len, AUTO_FRAME_REPETITION_LEN); - repetition_len = 0; +#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); +#endif // ANALYZE + key_repetition_len = 0; } else #endif @@ -3101,15 +4060,32 @@ irmp_ISR (void) // 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, repetition_len, AUTO_FRAME_REPETITION_LEN); - repetition_len = 0; + repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN); +#endif // ANALYZE + 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)) + { +#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); +#endif // ANALYZE + key_repetition_len = 0; } else #endif { - ANALYZE_PRINTF ("%8d code detected, length = %d\n", time_counter, irmp_bit); +#ifdef ANALYZE + ANALYZE_PRINTF ("%8.3fms code detected, length = %d\n", (double) (time_counter * 1000) / F_INTERRUPTS, irmp_bit); +#endif // ANALYZE irmp_ir_detected = TRUE; #if IRMP_SUPPORT_DENON_PROTOCOL == 1 @@ -3118,16 +4094,31 @@ irmp_ISR (void) 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 + irmp_command = irmp_tmp_command; // store command } else { - ANALYZE_PRINTF ("waiting for inverted command repetition\n"); - irmp_ir_detected = FALSE; - last_irmp_denon_command = irmp_tmp_command; + 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 @@ -3136,7 +4127,9 @@ irmp_ISR (void) #if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1 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"); +#endif // ANALYZE irmp_ir_detected = FALSE; } else @@ -3145,7 +4138,9 @@ irmp_ISR (void) #if IRMP_SUPPORT_NOKIA_PROTOCOL == 1 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"); +#endif // ANALYZE irmp_ir_detected = FALSE; } else @@ -3154,18 +4149,23 @@ irmp_ISR (void) #if IRMP_SUPPORT_NEC_PROTOCOL == 1 if (irmp_param.protocol == IRMP_NEC_PROTOCOL && irmp_bit == 0) // repetition frame { - if (repetition_len < NEC_FRAME_REPEAT_PAUSE_LEN_MAX) + if (key_repetition_len < NEC_FRAME_REPEAT_PAUSE_LEN_MAX) { - ANALYZE_PRINTF ("Detected NEC repetition frame, repetition_len = %d\n", repetition_len); +#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; - repetition_len = 0; + key_repetition_len = 0; } else { - ANALYZE_PRINTF ("Detected NEC repetition frame, ignoring it: timeout occured, repetition_len = %d > %d\n", - repetition_len, NEC_FRAME_REPEAT_PAUSE_LEN_MAX); +#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; } } @@ -3174,28 +4174,54 @@ irmp_ISR (void) #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 if (irmp_param.protocol == IRMP_KASEIKYO_PROTOCOL) { - uint8_t xor; - // ANALYZE_PRINTF ("0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", - // xor_check[0], xor_check[1], xor_check[2], xor_check[3], xor_check[4], xor_check[5]); + uint8_t xor_value; - xor = (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 != (xor_check[2] & 0x0F)) + if (xor_value != (xor_check[2] & 0x0F)) { - ANALYZE_PRINTF ("error 4: wrong XOR check for customer id: 0x%1x 0x%1x\n", xor, 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); +#endif // ANALYZE irmp_ir_detected = FALSE; } - xor = xor_check[2] ^ xor_check[3] ^ xor_check[4]; + xor_value = xor_check[2] ^ xor_check[3] ^ xor_check[4]; - if (xor != xor_check[5]) + if (xor_value != xor_check[5]) { - ANALYZE_PRINTF ("error 4: wrong XOR check for data bits: 0x%02x 0x%02x\n", xor, 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]); +#endif // ANALYZE irmp_ir_detected = FALSE; } + + 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) + { +#ifdef ANALYZE + ANALYZE_PRINTF ("error 6: parity check failed\n"); +#endif // ANALYZE + irmp_ir_detected = FALSE; + } + + if ((irmp_tmp_address & 0x03) == 0x02) + { +#ifdef ANALYZE + ANALYZE_PRINTF ("code skipped: ORTEK end of transmission frame (key release)\n"); +#endif // ANALYZE + 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? { @@ -3203,8 +4229,9 @@ irmp_ISR (void) } 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) @@ -3224,7 +4251,10 @@ irmp_ISR (void) irmp_address = irmp_tmp_address; // store address #if IRMP_SUPPORT_NEC_PROTOCOL == 1 - 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 @@ -3243,9 +4273,9 @@ irmp_ISR (void) if (irmp_ir_detected) { - if (last_irmp_command == irmp_command && - last_irmp_address == irmp_address && - repetition_len < IRMP_KEY_REPETITION_LEN) + 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; } @@ -3253,11 +4283,13 @@ irmp_ISR (void) last_irmp_address = irmp_tmp_address; // store as last address, too last_irmp_command = irmp_tmp_command; // store as last command, too - repetition_len = 0; + key_repetition_len = 0; } else { +#ifdef ANALYZE ANALYZE_ONLY_NORMAL_PUTCHAR ('\n'); +#endif // ANALYZE } irmp_start_bit_detected = 0; // and wait for next start bit @@ -3274,6 +4306,12 @@ irmp_ISR (void) } } } + +#if defined(STELLARIS_ARM_CORTEX_M4) + // Clear the timer interrupt + TimerIntClear(TIMER1_BASE, TIMER_TIMA_TIMEOUT); +#endif + return (irmp_ir_detected); } @@ -3350,6 +4388,11 @@ print_timings (void) 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); @@ -3364,6 +4407,11 @@ print_timings (void) 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 ("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); @@ -3394,8 +4442,8 @@ print_timings (void) 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, - 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_2); + 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, @@ -3417,6 +4465,19 @@ print_timings (void) 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", + (uint8_t)(F_INTERRUPTS * RCMM32_START_BIT_PULSE_TIME), (uint8_t)(F_INTERRUPTS * RCMM32_START_BIT_PAUSE_TIME), + (uint8_t)(F_INTERRUPTS * RCMM32_PULSE_TIME), + (uint8_t)(F_INTERRUPTS * RCMM32_00_PAUSE_TIME), (uint8_t)(F_INTERRUPTS * RCMM32_01_PAUSE_TIME), + (uint8_t)(F_INTERRUPTS * RCMM32_10_PAUSE_TIME), (uint8_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 @@ -3444,7 +4505,7 @@ print_spectrum (char * text, int * buf, int is_pulse) } } - for (i = 1; i < 100; i++) + for (i = 1; i < 200; i++) { if (buf[i] > 0) { @@ -3638,6 +4699,10 @@ get_fdc_key (uint16_t cmd) static int analyze = FALSE; static int list = FALSE; static IRMP_DATA irmp_data; +static int expected_protocol; +static int expected_address; +static int expected_command; +static int do_check_expected_values; static void next_tick (void) @@ -3654,15 +4719,15 @@ next_tick (void) if (verbose) { - printf ("%8d ", time_counter); + printf ("%8.3fms ", (double) (time_counter * 1000) / F_INTERRUPTS); } 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, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x, key = '%c'\n", - irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key, key); + 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 { @@ -3703,19 +4768,39 @@ next_tick (void) default : p = ""; break; } - printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x, key = %s\n", - irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key, p); + 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 ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x\n", - irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key); + printf (" checked!\n"); } + do_check_expected_values = FALSE; // only check 1st frame in a line! } else { - printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x\n", - irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags); + putchar ('\n'); } } } @@ -3761,6 +4846,10 @@ main (int argc, char ** argv) print_timings (); return (0); } + else if (! strcmp (argv[1], "-r")) + { + radio = TRUE; + } } for (i = 0; i < 256; i++) @@ -3846,6 +4935,7 @@ main (int argc, char ** argv) else if (ch == '\n') { IRMP_PIN = 0xff; + time_counter = 0; if (list && pause > 0) { @@ -3855,7 +4945,7 @@ main (int argc, char ** argv) if (! analyze) { - for (i = 0; i < (int) ((8000.0 * F_INTERRUPTS) / 10000); i++) // newline: long pause of 800 msec + for (i = 0; i < (int) ((10000.0 * F_INTERRUPTS) / 10000); i++) // newline: long pause of 10000 msec { next_tick (); } @@ -3865,6 +4955,8 @@ main (int argc, char ** argv) } else if (ch == '#') { + time_counter = 0; + if (analyze) { while ((ch = getchar()) != '\n' && ch != EOF) @@ -3874,13 +4966,81 @@ main (int argc, char ** argv) } 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); } }