X-Git-Url: http://cloudbase.mooo.com/gitweb/irmp.git/blobdiff_plain/cb8474cca0ec71c9780575aae0ad9979576b8e2e..77f488bb850739cdd6170e7a9d3ae72d67283e9d:/irmp.c diff --git a/irmp.c b/irmp.c index 422082b..9136774 100644 --- a/irmp.c +++ b/irmp.c @@ -3,7 +3,7 @@ * * Copyright (c) 2009-2010 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp.c,v 1.14 2010/03/29 09:33:29 fm Exp $ + * $Id: irmp.c,v 1.45 2010/06/11 14:47:24 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -12,6 +12,7 @@ * 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 @@ -20,7 +21,11 @@ * 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 * *--------------------------------------------------------------------------------------------------------------------------------------------------- * @@ -150,7 +155,7 @@ * * data "0": data "1": * ------________________ ------______________ - * 275us 1050us 275us 1900us + * 275us 775us 275us 1900us * *--------------------------------------------------------------------------------------------------------------------------------------------------- * @@ -190,6 +195,47 @@ * *--------------------------------------------------------------------------------------------------------------------------------------------------- * + * 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 + * + *--------------------------------------------------------------------------------------------------------------------------------------------------- + * * PANASONIC (older protocol, yet not implemented, see also MATSUSHITA, timing very similar) * ----------------------------------------------------------------------------------------- * @@ -270,12 +316,34 @@ typedef unsigned int16 uint16_t; #include "irmp.h" #include "irmpconfig.h" -#define IRMP_TIMEOUT 120 // timeout after 12 ms darkness -#define IRMP_REPETITION_TIME (uint16_t)(F_INTERRUPTS * 100.0e-3 + 0.5) // autodetect key repetition within 100 msec +#if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1 || IRMP_SUPPORT_NOKIA_PROTOCOL == 1 +#define IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL 1 +#else +#define IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL 0 +#endif + +#if IRMP_SUPPORT_RC5_PROTOCOL == 1 || IRMP_SUPPORT_RC6_PROTOCOL == 1 || IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1 || IRMP_SUPPORT_SIEMENS_PROTOCOL == 1 +#define IRMP_SUPPORT_MANCHESTER 1 +#else +#define IRMP_SUPPORT_MANCHESTER 0 +#endif + +#define IRMP_TIMEOUT_TIME 16500.0e-6 // timeout after 16.5 ms darkness +#define IRMP_TIMEOUT_LEN (uint8_t)(F_INTERRUPTS * IRMP_TIMEOUT_TIME + 0.5) +#define IRMP_KEY_REPETITION_LEN (uint16_t)(F_INTERRUPTS * 150.0e-3 + 0.5) // autodetect key repetition within 150 msec + +#define MIN_TOLERANCE_00 1.0 // -0% +#define MAX_TOLERANCE_00 1.0 // +0% + +#define MIN_TOLERANCE_05 0.95 // -5% +#define MAX_TOLERANCE_05 1.05 // +5% #define MIN_TOLERANCE_10 0.9 // -10% #define MAX_TOLERANCE_10 1.1 // +10% +#define MIN_TOLERANCE_15 0.85 // -15% +#define MAX_TOLERANCE_15 1.15 // +15% + #define MIN_TOLERANCE_20 0.8 // -20% #define MAX_TOLERANCE_20 1.2 // +20% @@ -291,152 +359,242 @@ typedef unsigned int16 uint16_t; #define MIN_TOLERANCE_60 0.4 // -60% #define MAX_TOLERANCE_60 1.6 // +60% -#define SIRCS_START_BIT_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) -#define SIRCS_START_BIT_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) -#define SIRCS_START_BIT_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) -#define SIRCS_START_BIT_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) -#define SIRCS_1_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) -#define SIRCS_1_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * SIRCS_1_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) -#define SIRCS_0_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME * MIN_TOLERANCE_50 + 0.5) -#define SIRCS_0_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME * MAX_TOLERANCE_50 + 0.5) -#define SIRCS_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) -#define SIRCS_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * SIRCS_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) - -#define NEC_START_BIT_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) -#define NEC_START_BIT_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * NEC_START_BIT_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) -#define NEC_START_BIT_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) -#define NEC_START_BIT_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * NEC_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) -#define NEC_REPEAT_START_BIT_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) -#define NEC_REPEAT_START_BIT_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * NEC_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) -#define NEC_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) -#define NEC_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * NEC_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) -#define NEC_1_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) -#define NEC_1_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * NEC_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) -#define NEC_0_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) -#define NEC_0_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * NEC_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) - -#define SAMSUNG_START_BIT_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) -#define SAMSUNG_START_BIT_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) -#define SAMSUNG_START_BIT_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) -#define SAMSUNG_START_BIT_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) -#define SAMSUNG_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME * MIN_TOLERANCE_50 + 0.5) -#define SAMSUNG_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME * MAX_TOLERANCE_50 + 0.5) -#define SAMSUNG_1_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) -#define SAMSUNG_1_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) -#define SAMSUNG_0_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) -#define SAMSUNG_0_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) - -#define MATSUSHITA_START_BIT_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) -#define MATSUSHITA_START_BIT_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) -#define MATSUSHITA_START_BIT_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) -#define MATSUSHITA_START_BIT_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) -#define MATSUSHITA_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) -#define MATSUSHITA_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) -#define MATSUSHITA_1_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) -#define MATSUSHITA_1_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) -#define MATSUSHITA_0_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) -#define MATSUSHITA_0_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * MATSUSHITA_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) - -#define KASEIKYO_START_BIT_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) -#define KASEIKYO_START_BIT_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) -#define KASEIKYO_START_BIT_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) -#define KASEIKYO_START_BIT_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * KASEIKYO_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) -#define KASEIKYO_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MIN_TOLERANCE_50 + 0.5) -#define KASEIKYO_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * KASEIKYO_PULSE_TIME * MAX_TOLERANCE_60 + 0.5) -#define KASEIKYO_1_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) -#define KASEIKYO_1_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) -#define KASEIKYO_0_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) -#define KASEIKYO_0_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) - -#define RECS80_START_BIT_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) -#define RECS80_START_BIT_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) -#define RECS80_START_BIT_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) -#define RECS80_START_BIT_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) -#define RECS80_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) -#define RECS80_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * RECS80_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) -#define RECS80_1_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) -#define RECS80_1_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * RECS80_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) -#define RECS80_0_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) -#define RECS80_0_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * RECS80_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) - -#define RC5_START_BIT_LEN_MIN (uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_20 + 0.5) -#define RC5_START_BIT_LEN_MAX (uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_20 + 0.5) -#define RC5_BIT_LEN_MIN (uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MIN_TOLERANCE_20 + 0.5) -#define RC5_BIT_LEN_MAX (uint8_t)(F_INTERRUPTS * RC5_BIT_TIME * MAX_TOLERANCE_20 + 0.5) - -#define DENON_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MIN_TOLERANCE_50 + 0.5) -#define DENON_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * DENON_PULSE_TIME * MAX_TOLERANCE_50 + 0.5) -#define DENON_1_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) -#define DENON_1_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * DENON_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) -#define DENON_0_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) -#define DENON_0_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * DENON_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) - -#define RC6_START_BIT_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) -#define RC6_START_BIT_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * RC6_START_BIT_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) -#define RC6_START_BIT_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) -#define RC6_START_BIT_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) -#define RC6_TOGGLE_BIT_LEN_MIN (uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MIN_TOLERANCE_20 + 0.5) -#define RC6_TOGGLE_BIT_LEN_MAX (uint8_t)(F_INTERRUPTS * RC6_TOGGLE_BIT_TIME * MAX_TOLERANCE_20 + 0.5) -#define RC6_BIT_LEN_MIN (uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_30 + 0.5) -#define RC6_BIT_LEN_MAX (uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_30 + 0.5) - -#define RECS80EXT_START_BIT_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) -#define RECS80EXT_START_BIT_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) -#define RECS80EXT_START_BIT_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) -#define RECS80EXT_START_BIT_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * RECS80EXT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) -#define RECS80EXT_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) -#define RECS80EXT_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * RECS80EXT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) -#define RECS80EXT_1_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) -#define RECS80EXT_1_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * RECS80EXT_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) -#define RECS80EXT_0_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) -#define RECS80EXT_0_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) - -#define NUBERT_START_BIT_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) -#define NUBERT_START_BIT_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) -#define NUBERT_START_BIT_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) -#define NUBERT_START_BIT_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) -#define NUBERT_1_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) -#define NUBERT_1_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) -#define NUBERT_1_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) -#define NUBERT_1_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) -#define NUBERT_0_PULSE_LEN_MIN (uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) -#define NUBERT_0_PULSE_LEN_MAX (uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) -#define NUBERT_0_PAUSE_LEN_MIN (uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) -#define NUBERT_0_PAUSE_LEN_MAX (uint8_t)(F_INTERRUPTS * NUBERT_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) - -#define AUTO_REPETITION_LEN (uint16_t)(F_INTERRUPTS * AUTO_REPETITION_TIME + 0.5) // use uint16_t! +#define SIRCS_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#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) +#define SIRCS_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_START_BIT_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) // only 5% to avoid conflict with RC6 +#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) +#define SIRCS_0_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define SIRCS_0_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIRCS_0_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#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 SAMSUNG_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define SAMSUNG_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define SAMSUNG_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define SAMSUNG_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define SAMSUNG_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define SAMSUNG_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define SAMSUNG_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define SAMSUNG_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define SAMSUNG_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define SAMSUNG_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * SAMSUNG_0_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) + +#define MATSUSHITA_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define MATSUSHITA_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define MATSUSHITA_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define MATSUSHITA_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define MATSUSHITA_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) +#define MATSUSHITA_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) +#define MATSUSHITA_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) +#define MATSUSHITA_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * MATSUSHITA_1_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) +#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_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_60 + 0.5) + 1) +#define KASEIKYO_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MIN_TOLERANCE_50 + 0.5) - 1) +#define KASEIKYO_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * KASEIKYO_1_PAUSE_TIME * MAX_TOLERANCE_50 + 0.5) + 1) +#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_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_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) + +#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_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 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_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) +#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 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) +#define RC6_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define RC6_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#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_LEN_MIN ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define RC6_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * RC6_BIT_TIME * MAX_TOLERANCE_10 + 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 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) +#define RECS80EXT_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * RECS80EXT_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) + +#define NUBERT_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define NUBERT_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define NUBERT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define NUBERT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define NUBERT_1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define NUBERT_1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_1_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define NUBERT_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define NUBERT_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define NUBERT_0_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define NUBERT_0_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * NUBERT_0_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#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 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) +#define BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT2_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT3_PAUSE_TIME * MAX_TOLERANCE_05 + 0.5) + 1) // 10% is too big (uint8_t) +#define BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_START_BIT4_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define BANG_OLUFSEN_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define BANG_OLUFSEN_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define BANG_OLUFSEN_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define BANG_OLUFSEN_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_1_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define BANG_OLUFSEN_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define BANG_OLUFSEN_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_0_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define BANG_OLUFSEN_R_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define BANG_OLUFSEN_R_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_R_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * BANG_OLUFSEN_TRAILER_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#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 GRUNDIG_OR_NOKIA_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_BIT_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define GRUNDIG_OR_NOKIA_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define GRUNDIG_OR_NOKIA_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_BIT_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define GRUNDIG_OR_NOKIA_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_BIT_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_PRE_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) + 1) +#define GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * GRUNDIG_OR_NOKIA_PRE_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) + +#define SIEMENS_START_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIEMENS_BIT_TIME * 1 + 0.5) - 1) +#define SIEMENS_START_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_BIT_TIME * 1 + 0.5) + 1) +#define SIEMENS_BIT_LEN_MIN ((uint8_t)(F_INTERRUPTS * SIEMENS_BIT_TIME * 1 + 0.5) - 1) +#define SIEMENS_BIT_LEN_MAX ((uint8_t)(F_INTERRUPTS * SIEMENS_BIT_TIME * 1 + 0.5) + 1) + +#define FDC1_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC1_START_BIT_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define FDC1_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC1_START_BIT_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define FDC1_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC1_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define FDC1_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC1_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define FDC1_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC1_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define FDC1_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC1_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define FDC1_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC1_PULSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define FDC1_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC1_PULSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define FDC1_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC1_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define FDC1_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC1_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define FDC1_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC1_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define FDC1_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC1_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) + +#define FDC2_START_BIT_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC2_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define FDC2_START_BIT_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC2_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define FDC2_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC2_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define FDC2_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC2_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define FDC2_REPEAT_START_BIT_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC2_REPEAT_START_BIT_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define FDC2_REPEAT_START_BIT_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC2_REPEAT_START_BIT_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define FDC2_PULSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC2_PULSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define FDC2_PULSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC2_PULSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define FDC2_1_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC2_1_PAUSE_TIME * MIN_TOLERANCE_30 + 0.5) - 1) +#define FDC2_1_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC2_1_PAUSE_TIME * MAX_TOLERANCE_30 + 0.5) + 1) +#define FDC2_0_PAUSE_LEN_MIN ((uint8_t)(F_INTERRUPTS * FDC2_0_PAUSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) +#define FDC2_0_PAUSE_LEN_MAX ((uint8_t)(F_INTERRUPTS * FDC2_0_PAUSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) + +#define AUTO_FRAME_REPETITION_LEN (uint16_t)(F_INTERRUPTS * AUTO_FRAME_REPETITION_TIME + 0.5) // use uint16_t! #ifdef DEBUG -#define DEBUG_PUTCHAR(a) { if (! silent) { putchar (a); } } -#define DEBUG_PRINTF(...) { if (! silent) { printf (__VA_ARGS__); } } -static int silent; +#define DEBUG_PUTCHAR(a) { if (! silent) { putchar (a); } } +#define DEBUG_ONLY_NORMAL_PUTCHAR(a) { if (! silent && !verbose) { putchar (a); } } +#define DEBUG_PRINTF(...) { if (verbose) { printf (__VA_ARGS__); } } +#define DEBUG_NEWLINE() { if (verbose) { putchar ('\n'); } } +static int silent; +static int time_counter; +static int verbose; #else #define DEBUG_PUTCHAR(a) +#define DEBUG_ONLY_NORMAL_PUTCHAR(a) #define DEBUG_PRINTF(...) +#define DEBUG_NEWLINE() #endif #if IRMP_LOGGING == 1 -#define irmp_logIsr(x) irmp_logIr((x) ? 1:0) -#define UART_BAUD 9600L - -// calculate real baud rate: -#define UBRR_VAL ((F_CPU+UART_BAUD*8)/(UART_BAUD*16)-1) // round -#define BAUD_REAL (F_CPU/(16*(UBRR_VAL+1))) // real baudrate - -#ifdef CODEVISION -#if ((BAUD_REAL*1000)/UART_BAUD-1000) > 10 -# error Error of baud rate of RS232 UARTx is more than 1%. That is too high! +#define BAUD 9600L +#include + +#ifdef UBRR0H + +#define UART0_UBRRH UBRR0H +#define UART0_UBRRL UBRR0L +#define UART0_UCSRA UCSR0A +#define UART0_UCSRB UCSR0B +#define UART0_UCSRC UCSR0C +#define UART0_UDRE_BIT_VALUE (1< 10) || (-BAUD_ERROR < 10)) -# error Error of baud rate of RS232 UARTx is more than 1%. That is too high! +#define UART0_UBRRH UBRRH +#define UART0_UBRRL UBRRL +#define UART0_UCSRA UCSRA +#define UART0_UCSRB UCSRB +#define UART0_UCSRC UCSRC +#define UART0_UDRE_BIT_VALUE (1<> 8; // store baudrate (upper byte) - UBRR0L = UBRR_VAL & 0xFF; // store baudrate (lower byte) + UART0_UBRRH = UBRRH_VALUE; // set baud rate + UART0_UBRRL = UBRRL_VALUE; + +#if USE_2X + UART0_UCSRA = (1< c_endBits) - { // if stop condition (200 sequenced ones) meets, output on uart + if (cnt > ENDBITS) + { // if stop condition is true, output on uart uint16_t i; - for (i = 0; i < c_startcycles; ++i) + for (i = 0; i < STARTCYCLES; i++) { - irmp_uart_putc ('0'); // the ignored starting zeros + irmp_uart_putc ('0'); // the ignored starting zeros } - for (i = 0;i < (s_dataIdx - c_endBits + 20) / 8; ++i) // transform bitset into uart chars + for (i = 0; i < (buf_idx - ENDBITS + 20) / 8; i++) // transform bitset into uart chars { - uint8_t d = s_data[i]; + uint8_t d = buf[i]; uint8_t j; - for (j = 0;j<8;++j) + for (j = 0; j < 8; j++) { irmp_uart_putc ((d & 1) + '0'); d >>= 1; @@ -532,19 +701,19 @@ irmp_logIr (uint8_t val) } irmp_uart_putc ('\n'); - s_dataIdx = 0; + buf_idx = 0; } } else { - s_ctr = 0; + cnt = 0; } } } } #else -#define irmp_logIsr(x) +#define irmp_log(val) #endif typedef struct @@ -565,28 +734,30 @@ typedef struct uint8_t complete_len; // complete length of frame uint8_t stop_bit; // flag: frame has stop bit uint8_t lsb_first; // flag: LSB first + uint8_t flags; // some flags } IRMP_PARAMETER; #if IRMP_SUPPORT_SIRCS_PROTOCOL == 1 static PROGMEM IRMP_PARAMETER sircs_param = { - IRMP_SIRCS_PROTOCOL, - SIRCS_1_PULSE_LEN_MIN, - SIRCS_1_PULSE_LEN_MAX, - SIRCS_PAUSE_LEN_MIN, - SIRCS_PAUSE_LEN_MAX, - SIRCS_0_PULSE_LEN_MIN, - SIRCS_0_PULSE_LEN_MAX, - SIRCS_PAUSE_LEN_MIN, - SIRCS_PAUSE_LEN_MAX, - SIRCS_ADDRESS_OFFSET, - SIRCS_ADDRESS_OFFSET + SIRCS_ADDRESS_LEN, - SIRCS_COMMAND_OFFSET, - SIRCS_COMMAND_OFFSET + SIRCS_COMMAND_LEN, - SIRCS_COMPLETE_DATA_LEN, - SIRCS_STOP_BIT, - SIRCS_LSB + IRMP_SIRCS_PROTOCOL, // protocol: ir protocol + SIRCS_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + SIRCS_1_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + SIRCS_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + SIRCS_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + SIRCS_0_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + SIRCS_0_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + SIRCS_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + SIRCS_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + SIRCS_ADDRESS_OFFSET, // address_offset: address offset + SIRCS_ADDRESS_OFFSET + SIRCS_ADDRESS_LEN, // address_end: end of address + SIRCS_COMMAND_OFFSET, // command_offset: command offset + SIRCS_COMMAND_OFFSET + SIRCS_COMMAND_LEN, // command_end: end of command + SIRCS_COMPLETE_DATA_LEN, // complete_len: complete length of frame + SIRCS_STOP_BIT, // stop_bit: flag: frame has stop bit + SIRCS_LSB, // lsb_first: flag: LSB first + SIRCS_FLAGS // flags: some flags }; #endif @@ -595,22 +766,44 @@ static PROGMEM IRMP_PARAMETER sircs_param = static PROGMEM IRMP_PARAMETER nec_param = { - IRMP_NEC_PROTOCOL, - NEC_PULSE_LEN_MIN, - NEC_PULSE_LEN_MAX, - NEC_1_PAUSE_LEN_MIN, - NEC_1_PAUSE_LEN_MAX, - NEC_PULSE_LEN_MIN, - NEC_PULSE_LEN_MAX, - NEC_0_PAUSE_LEN_MIN, - NEC_0_PAUSE_LEN_MAX, - NEC_ADDRESS_OFFSET, - NEC_ADDRESS_OFFSET + NEC_ADDRESS_LEN, - NEC_COMMAND_OFFSET, - NEC_COMMAND_OFFSET + NEC_COMMAND_LEN, - NEC_COMPLETE_DATA_LEN, - NEC_STOP_BIT, - NEC_LSB + IRMP_NEC_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 + NEC_ADDRESS_OFFSET, // address_offset: address offset + NEC_ADDRESS_OFFSET + NEC_ADDRESS_LEN, // address_end: end of address + NEC_COMMAND_OFFSET, // command_offset: command offset + NEC_COMMAND_OFFSET + NEC_COMMAND_LEN, // command_end: end of command + NEC_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 +}; + +static 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 + 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 + 0, // address_offset: address offset + 0, // address_end: end of address + 0, // command_offset: command offset + 0, // command_end: end of command + 0, // 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 @@ -619,22 +812,23 @@ static PROGMEM IRMP_PARAMETER nec_param = static PROGMEM IRMP_PARAMETER samsung_param = { - IRMP_SAMSUNG_PROTOCOL, - SAMSUNG_PULSE_LEN_MIN, - SAMSUNG_PULSE_LEN_MAX, - SAMSUNG_1_PAUSE_LEN_MIN, - SAMSUNG_1_PAUSE_LEN_MAX, - SAMSUNG_PULSE_LEN_MIN, - SAMSUNG_PULSE_LEN_MAX, - SAMSUNG_0_PAUSE_LEN_MIN, - SAMSUNG_0_PAUSE_LEN_MAX, - SAMSUNG_ADDRESS_OFFSET, - SAMSUNG_ADDRESS_OFFSET + SAMSUNG_ADDRESS_LEN, - SAMSUNG_COMMAND_OFFSET, - SAMSUNG_COMMAND_OFFSET + SAMSUNG_COMMAND_LEN, - SAMSUNG_COMPLETE_DATA_LEN, - SAMSUNG_STOP_BIT, - SAMSUNG_LSB + IRMP_SAMSUNG_PROTOCOL, // protocol: ir protocol + SAMSUNG_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + SAMSUNG_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + SAMSUNG_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + SAMSUNG_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + SAMSUNG_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + SAMSUNG_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + SAMSUNG_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + SAMSUNG_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + SAMSUNG_ADDRESS_OFFSET, // address_offset: address offset + SAMSUNG_ADDRESS_OFFSET + SAMSUNG_ADDRESS_LEN, // address_end: end of address + SAMSUNG_COMMAND_OFFSET, // command_offset: command offset + SAMSUNG_COMMAND_OFFSET + SAMSUNG_COMMAND_LEN, // command_end: end of command + SAMSUNG_COMPLETE_DATA_LEN, // complete_len: complete length of frame + SAMSUNG_STOP_BIT, // stop_bit: flag: frame has stop bit + SAMSUNG_LSB, // lsb_first: flag: LSB first + SAMSUNG_FLAGS // flags: some flags }; #endif @@ -643,22 +837,23 @@ static PROGMEM IRMP_PARAMETER samsung_param = static PROGMEM IRMP_PARAMETER matsushita_param = { - IRMP_MATSUSHITA_PROTOCOL, - MATSUSHITA_PULSE_LEN_MIN, - MATSUSHITA_PULSE_LEN_MAX, - MATSUSHITA_1_PAUSE_LEN_MIN, - MATSUSHITA_1_PAUSE_LEN_MAX, - MATSUSHITA_PULSE_LEN_MIN, - MATSUSHITA_PULSE_LEN_MAX, - MATSUSHITA_0_PAUSE_LEN_MIN, - MATSUSHITA_0_PAUSE_LEN_MAX, - MATSUSHITA_ADDRESS_OFFSET, - MATSUSHITA_ADDRESS_OFFSET + MATSUSHITA_ADDRESS_LEN, - MATSUSHITA_COMMAND_OFFSET, - MATSUSHITA_COMMAND_OFFSET + MATSUSHITA_COMMAND_LEN, - MATSUSHITA_COMPLETE_DATA_LEN, - MATSUSHITA_STOP_BIT, - MATSUSHITA_LSB + IRMP_MATSUSHITA_PROTOCOL, // protocol: ir protocol + MATSUSHITA_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + MATSUSHITA_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + MATSUSHITA_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + MATSUSHITA_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + MATSUSHITA_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + MATSUSHITA_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + MATSUSHITA_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + MATSUSHITA_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + MATSUSHITA_ADDRESS_OFFSET, // address_offset: address offset + MATSUSHITA_ADDRESS_OFFSET + MATSUSHITA_ADDRESS_LEN, // address_end: end of address + MATSUSHITA_COMMAND_OFFSET, // command_offset: command offset + MATSUSHITA_COMMAND_OFFSET + MATSUSHITA_COMMAND_LEN, // command_end: end of command + MATSUSHITA_COMPLETE_DATA_LEN, // complete_len: complete length of frame + MATSUSHITA_STOP_BIT, // stop_bit: flag: frame has stop bit + MATSUSHITA_LSB, // lsb_first: flag: LSB first + MATSUSHITA_FLAGS // flags: some flags }; #endif @@ -667,22 +862,23 @@ static PROGMEM IRMP_PARAMETER matsushita_param = static PROGMEM IRMP_PARAMETER kaseikyo_param = { - IRMP_KASEIKYO_PROTOCOL, - KASEIKYO_PULSE_LEN_MIN, - KASEIKYO_PULSE_LEN_MAX, - KASEIKYO_1_PAUSE_LEN_MIN, - KASEIKYO_1_PAUSE_LEN_MAX, - KASEIKYO_PULSE_LEN_MIN, - KASEIKYO_PULSE_LEN_MAX, - KASEIKYO_0_PAUSE_LEN_MIN, - KASEIKYO_0_PAUSE_LEN_MAX, - KASEIKYO_ADDRESS_OFFSET, - KASEIKYO_ADDRESS_OFFSET + KASEIKYO_ADDRESS_LEN, - KASEIKYO_COMMAND_OFFSET, - KASEIKYO_COMMAND_OFFSET + KASEIKYO_COMMAND_LEN, - KASEIKYO_COMPLETE_DATA_LEN, - KASEIKYO_STOP_BIT, - KASEIKYO_LSB + IRMP_KASEIKYO_PROTOCOL, // protocol: ir protocol + KASEIKYO_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + KASEIKYO_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + KASEIKYO_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + KASEIKYO_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + KASEIKYO_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + KASEIKYO_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + KASEIKYO_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + KASEIKYO_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + KASEIKYO_ADDRESS_OFFSET, // address_offset: address offset + KASEIKYO_ADDRESS_OFFSET + KASEIKYO_ADDRESS_LEN, // address_end: end of address + KASEIKYO_COMMAND_OFFSET, // command_offset: command offset + KASEIKYO_COMMAND_OFFSET + KASEIKYO_COMMAND_LEN, // command_end: end of command + KASEIKYO_COMPLETE_DATA_LEN, // complete_len: complete length of frame + KASEIKYO_STOP_BIT, // stop_bit: flag: frame has stop bit + KASEIKYO_LSB, // lsb_first: flag: LSB first + KASEIKYO_FLAGS // flags: some flags }; #endif @@ -691,22 +887,23 @@ static PROGMEM IRMP_PARAMETER kaseikyo_param = static PROGMEM IRMP_PARAMETER recs80_param = { - IRMP_RECS80_PROTOCOL, - RECS80_PULSE_LEN_MIN, - RECS80_PULSE_LEN_MAX, - RECS80_1_PAUSE_LEN_MIN, - RECS80_1_PAUSE_LEN_MAX, - RECS80_PULSE_LEN_MIN, - RECS80_PULSE_LEN_MAX, - RECS80_0_PAUSE_LEN_MIN, - RECS80_0_PAUSE_LEN_MAX, - RECS80_ADDRESS_OFFSET, - RECS80_ADDRESS_OFFSET + RECS80_ADDRESS_LEN, - RECS80_COMMAND_OFFSET, - RECS80_COMMAND_OFFSET + RECS80_COMMAND_LEN, - RECS80_COMPLETE_DATA_LEN, - RECS80_STOP_BIT, - RECS80_LSB + IRMP_RECS80_PROTOCOL, // protocol: ir protocol + RECS80_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + RECS80_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + RECS80_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + RECS80_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + RECS80_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + RECS80_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + RECS80_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + RECS80_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + RECS80_ADDRESS_OFFSET, // address_offset: address offset + RECS80_ADDRESS_OFFSET + RECS80_ADDRESS_LEN, // address_end: end of address + RECS80_COMMAND_OFFSET, // command_offset: command offset + RECS80_COMMAND_OFFSET + RECS80_COMMAND_LEN, // command_end: end of command + RECS80_COMPLETE_DATA_LEN, // complete_len: complete length of frame + RECS80_STOP_BIT, // stop_bit: flag: frame has stop bit + RECS80_LSB, // lsb_first: flag: LSB first + RECS80_FLAGS // flags: some flags }; #endif @@ -715,22 +912,23 @@ static PROGMEM IRMP_PARAMETER recs80_param = static PROGMEM IRMP_PARAMETER rc5_param = { - IRMP_RC5_PROTOCOL, - RC5_BIT_LEN_MIN, - RC5_BIT_LEN_MAX, - RC5_BIT_LEN_MIN, - RC5_BIT_LEN_MAX, - 1, // tricky: use this as stop bit length - 1, - 1, - 1, - RC5_ADDRESS_OFFSET, - RC5_ADDRESS_OFFSET + RC5_ADDRESS_LEN, - RC5_COMMAND_OFFSET, - RC5_COMMAND_OFFSET + RC5_COMMAND_LEN, - RC5_COMPLETE_DATA_LEN, - RC5_STOP_BIT, - RC5_LSB + IRMP_RC5_PROTOCOL, // protocol: ir protocol + RC5_BIT_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + RC5_BIT_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + RC5_BIT_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + RC5_BIT_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + 1, // tricky: use this as stop bit length // pulse_0_len_min: minimum length of pulse with bit value 0 + 1, // pulse_0_len_max: maximum length of pulse with bit value 0 + 1, // pause_0_len_min: minimum length of pause with bit value 0 + 1, // pause_0_len_max: maximum length of pause with bit value 0 + 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 + RC5_COMMAND_OFFSET + RC5_COMMAND_LEN, // command_end: end of command + RC5_COMPLETE_DATA_LEN, // complete_len: complete length of frame + RC5_STOP_BIT, // stop_bit: flag: frame has stop bit + RC5_LSB, // lsb_first: flag: LSB first + RC5_FLAGS // flags: some flags }; #endif @@ -739,22 +937,23 @@ static PROGMEM IRMP_PARAMETER rc5_param = static PROGMEM IRMP_PARAMETER denon_param = { - IRMP_DENON_PROTOCOL, - DENON_PULSE_LEN_MIN, - DENON_PULSE_LEN_MAX, - DENON_1_PAUSE_LEN_MIN, - DENON_1_PAUSE_LEN_MAX, - DENON_PULSE_LEN_MIN, - DENON_PULSE_LEN_MAX, - DENON_0_PAUSE_LEN_MIN, - DENON_0_PAUSE_LEN_MAX, - DENON_ADDRESS_OFFSET, - DENON_ADDRESS_OFFSET + DENON_ADDRESS_LEN, - DENON_COMMAND_OFFSET, - DENON_COMMAND_OFFSET + DENON_COMMAND_LEN, - DENON_COMPLETE_DATA_LEN, - DENON_STOP_BIT, - DENON_LSB + IRMP_DENON_PROTOCOL, // protocol: ir protocol + DENON_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + DENON_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + DENON_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + DENON_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + DENON_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + DENON_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + DENON_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + DENON_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + DENON_ADDRESS_OFFSET, // address_offset: address offset + DENON_ADDRESS_OFFSET + DENON_ADDRESS_LEN, // address_end: end of address + DENON_COMMAND_OFFSET, // command_offset: command offset + DENON_COMMAND_OFFSET + DENON_COMMAND_LEN, // command_end: end of command + DENON_COMPLETE_DATA_LEN, // complete_len: complete length of frame + DENON_STOP_BIT, // stop_bit: flag: frame has stop bit + DENON_LSB, // lsb_first: flag: LSB first + DENON_FLAGS // flags: some flags }; #endif @@ -763,22 +962,23 @@ static PROGMEM IRMP_PARAMETER denon_param = static PROGMEM IRMP_PARAMETER rc6_param = { - IRMP_RC6_PROTOCOL, - RC6_BIT_LEN_MIN, - RC6_BIT_LEN_MAX, - RC6_BIT_LEN_MIN, - RC6_BIT_LEN_MAX, - 1, // tricky: use this as stop bit length - 1, - 1, - 1, - RC6_ADDRESS_OFFSET, - RC6_ADDRESS_OFFSET + RC6_ADDRESS_LEN, - RC6_COMMAND_OFFSET, - RC6_COMMAND_OFFSET + RC6_COMMAND_LEN, - RC6_COMPLETE_DATA_LEN_SHORT, - RC6_STOP_BIT, - RC6_LSB + IRMP_RC6_PROTOCOL, // protocol: ir protocol + RC6_BIT_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + RC6_BIT_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + RC6_BIT_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + RC6_BIT_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + 1, // tricky: use this as stop bit length // pulse_0_len_min: minimum length of pulse with bit value 0 + 1, // pulse_0_len_max: maximum length of pulse with bit value 0 + 1, // pause_0_len_min: minimum length of pause with bit value 0 + 1, // pause_0_len_max: maximum length of pause with bit value 0 + 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 + RC6_COMMAND_OFFSET + RC6_COMMAND_LEN, // command_end: end of command + RC6_COMPLETE_DATA_LEN_SHORT, // complete_len: complete length of frame + RC6_STOP_BIT, // stop_bit: flag: frame has stop bit + RC6_LSB, // lsb_first: flag: LSB first + RC6_FLAGS // flags: some flags }; #endif @@ -787,58 +987,185 @@ static PROGMEM IRMP_PARAMETER rc6_param = static PROGMEM IRMP_PARAMETER recs80ext_param = { - IRMP_RECS80EXT_PROTOCOL, - RECS80EXT_PULSE_LEN_MIN, - RECS80EXT_PULSE_LEN_MAX, - RECS80EXT_1_PAUSE_LEN_MIN, - RECS80EXT_1_PAUSE_LEN_MAX, - RECS80EXT_PULSE_LEN_MIN, - RECS80EXT_PULSE_LEN_MAX, - RECS80EXT_0_PAUSE_LEN_MIN, - RECS80EXT_0_PAUSE_LEN_MAX, - RECS80EXT_ADDRESS_OFFSET, - RECS80EXT_ADDRESS_OFFSET + RECS80EXT_ADDRESS_LEN, - RECS80EXT_COMMAND_OFFSET, - RECS80EXT_COMMAND_OFFSET + RECS80EXT_COMMAND_LEN, - RECS80EXT_COMPLETE_DATA_LEN, - RECS80EXT_STOP_BIT, - RECS80EXT_LSB + IRMP_RECS80EXT_PROTOCOL, // protocol: ir protocol + RECS80EXT_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + RECS80EXT_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + RECS80EXT_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + RECS80EXT_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + RECS80EXT_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + RECS80EXT_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + RECS80EXT_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + RECS80EXT_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + RECS80EXT_ADDRESS_OFFSET, // address_offset: address offset + RECS80EXT_ADDRESS_OFFSET + RECS80EXT_ADDRESS_LEN, // address_end: end of address + RECS80EXT_COMMAND_OFFSET, // command_offset: command offset + RECS80EXT_COMMAND_OFFSET + RECS80EXT_COMMAND_LEN, // command_end: end of command + RECS80EXT_COMPLETE_DATA_LEN, // complete_len: complete length of frame + RECS80EXT_STOP_BIT, // stop_bit: flag: frame has stop bit + RECS80EXT_LSB, // lsb_first: flag: LSB first + RECS80EXT_FLAGS // flags: some flags }; #endif -#if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1 +#if IRMP_SUPPORT_NUBERT_PROTOCOL == 1 static PROGMEM IRMP_PARAMETER nubert_param = { - IRMP_NUBERT_PROTOCOL, - NUBERT_1_PULSE_LEN_MIN, - NUBERT_1_PULSE_LEN_MAX, - NUBERT_1_PAUSE_LEN_MIN, - NUBERT_1_PAUSE_LEN_MAX, - NUBERT_0_PULSE_LEN_MIN, - NUBERT_0_PULSE_LEN_MAX, - NUBERT_0_PAUSE_LEN_MIN, - NUBERT_0_PAUSE_LEN_MAX, - NUBERT_ADDRESS_OFFSET, - NUBERT_ADDRESS_OFFSET + NUBERT_ADDRESS_LEN, - NUBERT_COMMAND_OFFSET, - NUBERT_COMMAND_OFFSET + NUBERT_COMMAND_LEN, - NUBERT_COMPLETE_DATA_LEN, - NUBERT_STOP_BIT, - NUBERT_LSB + IRMP_NUBERT_PROTOCOL, // protocol: ir protocol + NUBERT_1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + NUBERT_1_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + NUBERT_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + NUBERT_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + NUBERT_0_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + NUBERT_0_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + NUBERT_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + NUBERT_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + NUBERT_ADDRESS_OFFSET, // address_offset: address offset + NUBERT_ADDRESS_OFFSET + NUBERT_ADDRESS_LEN, // address_end: end of address + NUBERT_COMMAND_OFFSET, // command_offset: command offset + NUBERT_COMMAND_OFFSET + NUBERT_COMMAND_LEN, // command_end: end of command + NUBERT_COMPLETE_DATA_LEN, // complete_len: complete length of frame + NUBERT_STOP_BIT, // stop_bit: flag: frame has stop bit + NUBERT_LSB, // lsb_first: flag: LSB first + NUBERT_FLAGS // flags: some flags +}; + +#endif + +#if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 + +static 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 + BANG_OLUFSEN_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + BANG_OLUFSEN_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + BANG_OLUFSEN_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + BANG_OLUFSEN_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + BANG_OLUFSEN_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + BANG_OLUFSEN_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + BANG_OLUFSEN_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + BANG_OLUFSEN_ADDRESS_OFFSET, // address_offset: address offset + BANG_OLUFSEN_ADDRESS_OFFSET + BANG_OLUFSEN_ADDRESS_LEN, // address_end: end of address + BANG_OLUFSEN_COMMAND_OFFSET, // command_offset: command offset + BANG_OLUFSEN_COMMAND_OFFSET + BANG_OLUFSEN_COMMAND_LEN, // command_end: end of command + BANG_OLUFSEN_COMPLETE_DATA_LEN, // complete_len: complete length of frame + BANG_OLUFSEN_STOP_BIT, // stop_bit: flag: frame has stop bit + BANG_OLUFSEN_LSB, // lsb_first: flag: LSB first + BANG_OLUFSEN_FLAGS // flags: some flags +}; + +#endif + +#if IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1 + +static PROGMEM IRMP_PARAMETER grundig_param = +{ + IRMP_GRUNDIG_PROTOCOL, // protocol: ir protocol + GRUNDIG_OR_NOKIA_BIT_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + GRUNDIG_OR_NOKIA_BIT_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + GRUNDIG_OR_NOKIA_BIT_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + GRUNDIG_OR_NOKIA_BIT_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + 1, // tricky: use this as stop bit length // pulse_0_len_min: minimum length of pulse with bit value 0 + 1, // pulse_0_len_max: maximum length of pulse with bit value 0 + 1, // pause_0_len_min: minimum length of pause with bit value 0 + 1, // pause_0_len_max: maximum length of pause with bit value 0 + 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 + GRUNDIG_COMMAND_OFFSET + GRUNDIG_COMMAND_LEN + 1, // command_end: end of command (USE 1 bit MORE to STORE NOKIA DATA!) + NOKIA_COMPLETE_DATA_LEN, // complete_len: complete length of frame, here: NOKIA instead of GRUNDIG! + GRUNDIG_OR_NOKIA_STOP_BIT, // stop_bit: flag: frame has stop bit + GRUNDIG_OR_NOKIA_LSB, // lsb_first: flag: LSB first + GRUNDIG_OR_NOKIA_FLAGS // flags: some flags +}; + +#endif + +#if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1 + +static PROGMEM IRMP_PARAMETER siemens_param = +{ + IRMP_SIEMENS_PROTOCOL, // protocol: ir protocol + SIEMENS_BIT_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + SIEMENS_BIT_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + SIEMENS_BIT_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + SIEMENS_BIT_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + 1, // tricky: use this as stop bit length // pulse_0_len_min: minimum length of pulse with bit value 0 + 1, // pulse_0_len_max: maximum length of pulse with bit value 0 + 1, // pause_0_len_min: minimum length of pause with bit value 0 + 1, // pause_0_len_max: maximum length of pause with bit value 0 + SIEMENS_ADDRESS_OFFSET, // address_offset: address offset + SIEMENS_ADDRESS_OFFSET + SIEMENS_ADDRESS_LEN, // address_end: end of address + SIEMENS_COMMAND_OFFSET, // command_offset: command offset + SIEMENS_COMMAND_OFFSET + SIEMENS_COMMAND_LEN, // command_end: end of command + SIEMENS_COMPLETE_DATA_LEN, // complete_len: complete length of frame + SIEMENS_STOP_BIT, // stop_bit: flag: frame has stop bit + SIEMENS_LSB, // lsb_first: flag: LSB first + SIEMENS_FLAGS // flags: some flags +}; + +#endif + +#if IRMP_SUPPORT_FDC1_PROTOCOL == 1 + +static PROGMEM IRMP_PARAMETER fdc1_param = +{ + IRMP_FDC1_PROTOCOL, // protocol: ir protocol + FDC1_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + FDC1_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + FDC1_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + FDC1_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + FDC1_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + FDC1_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + FDC1_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + FDC1_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + FDC1_ADDRESS_OFFSET, // address_offset: address offset + FDC1_ADDRESS_OFFSET + FDC1_ADDRESS_LEN, // address_end: end of address + FDC1_COMMAND_OFFSET, // command_offset: command offset + FDC1_COMMAND_OFFSET + FDC1_COMMAND_LEN, // command_end: end of command + FDC1_COMPLETE_DATA_LEN, // complete_len: complete length of frame + FDC1_STOP_BIT, // stop_bit: flag: frame has stop bit + FDC1_LSB, // lsb_first: flag: LSB first + FDC1_FLAGS // flags: some flags }; #endif -static uint8_t irmp_bit; // current bit position +#if IRMP_SUPPORT_FDC2_PROTOCOL == 1 + +static PROGMEM IRMP_PARAMETER fdc2_param = +{ + IRMP_FDC2_PROTOCOL, // protocol: ir protocol + FDC2_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + FDC2_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + FDC2_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + FDC2_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + FDC2_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + FDC2_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + FDC2_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + FDC2_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + FDC2_ADDRESS_OFFSET, // address_offset: address offset + FDC2_ADDRESS_OFFSET + FDC2_ADDRESS_LEN, // address_end: end of address + FDC2_COMMAND_OFFSET, // command_offset: command offset + FDC2_COMMAND_OFFSET + FDC2_COMMAND_LEN, // command_end: end of command + FDC2_COMPLETE_DATA_LEN, // complete_len: complete length of frame + FDC2_STOP_BIT, // stop_bit: flag: frame has stop bit + FDC2_LSB, // lsb_first: flag: LSB first + FDC2_FLAGS // flags: some flags +}; + +#endif + +static uint8_t irmp_bit; // current bit position static IRMP_PARAMETER irmp_param; 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 uint16_t irmp_id; // only used for SAMSUNG protocol static volatile uint8_t irmp_flags; #ifdef DEBUG @@ -855,8 +1182,8 @@ void irmp_init (void) { #ifndef PIC_CCS_COMPILER - IRMP_PORT &= ~(1< IRMP_TIMEOUT) // timeout? + if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout? { // yes... - DEBUG_PRINTF ("error 1: pause after start bit %d too long: %d\n", irmp_pulse_time, irmp_pause_time); + DEBUG_PRINTF ("error 1: pause after start bit pulse %d too long: %d\n", irmp_pulse_time, irmp_pause_time); + DEBUG_ONLY_NORMAL_PUTCHAR ('\n'); irmp_start_bit_detected = 0; // reset flags, let's wait for another start bit irmp_pulse_time = 0; irmp_pause_time = 0; @@ -1057,48 +1398,39 @@ irmp_ISR (void) } else { // receiving first data pulse! + IRMP_PARAMETER * irmp_param_p = (IRMP_PARAMETER *) 0; + DEBUG_PRINTF ("start-bit: pulse = %d, pause = %d\n", irmp_pulse_time, irmp_pause_time); #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 - DEBUG_PRINTF ("protocol = SIRCS, start bit timings: pulse: %2d - %2d, pause: %2d - %2d\n", + { // it's SIRCS + DEBUG_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); - memcpy_P (&irmp_param, &sircs_param, sizeof (IRMP_PARAMETER)); + irmp_param_p = (IRMP_PARAMETER *) (IRMP_PARAMETER *) &sircs_param; } else #endif // IRMP_SUPPORT_SIRCS_PROTOCOL == 1 #if IRMP_SUPPORT_NEC_PROTOCOL == 1 if (irmp_pulse_time >= NEC_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NEC_START_BIT_PULSE_LEN_MAX && - ((irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX) || - (irmp_pause_time >= NEC_REPEAT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_REPEAT_START_BIT_PAUSE_LEN_MAX))) - { // it's NEC - if (irmp_pause_time <= NEC_REPEAT_START_BIT_PAUSE_LEN_MAX) - { - DEBUG_PRINTF ("protocol = NEC (repetition frame), start bit timings: pulse: %2d - %2d, pause: %2d - %2d\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); - } - else - { - DEBUG_PRINTF ("protocol = NEC, start bit timings: pulse: %2d - %2d, pause: %2d - %2d\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); - } - - memcpy_P (&irmp_param, &nec_param, sizeof (IRMP_PARAMETER)); - - if (irmp_pause_time <= NEC_REPEAT_START_BIT_PAUSE_LEN_MAX) - { - irmp_param.address_offset = 0; - irmp_param.address_end = 0; - irmp_param.command_offset = 0; - irmp_param.command_end = 0; - irmp_param.complete_len = 0; - } + irmp_pause_time >= NEC_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NEC_START_BIT_PAUSE_LEN_MAX) + { + DEBUG_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); + irmp_param_p = (IRMP_PARAMETER *) &nec_param; + } + 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 + DEBUG_PRINTF ("protocol = NEC (repetition frame), start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX, + NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX); + + irmp_param_p = (IRMP_PARAMETER *) &nec_rep_param; } else #endif // IRMP_SUPPORT_NEC_PROTOCOL == 1 @@ -1106,11 +1438,11 @@ irmp_ISR (void) #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 if (irmp_pulse_time >= SAMSUNG_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_START_BIT_PULSE_LEN_MAX && irmp_pause_time >= SAMSUNG_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_START_BIT_PAUSE_LEN_MAX) - { // it's SAMSUNG - DEBUG_PRINTF ("protocol = SAMSUNG, start bit timings: pulse: %2d - %2d, pause: %2d - %2d\n", + { // it's SAMSUNG + DEBUG_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); - memcpy_P (&irmp_param, &samsung_param, sizeof (IRMP_PARAMETER)); + irmp_param_p = (IRMP_PARAMETER *) &samsung_param; } else #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 @@ -1118,11 +1450,11 @@ irmp_ISR (void) #if IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1 if (irmp_pulse_time >= MATSUSHITA_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= MATSUSHITA_START_BIT_PULSE_LEN_MAX && irmp_pause_time >= MATSUSHITA_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= MATSUSHITA_START_BIT_PAUSE_LEN_MAX) - { // it's MATSUSHITA - DEBUG_PRINTF ("protocol = MATSUSHITA, start bit timings: pulse: %2d - %2d, pause: %2d - %2d\n", + { // it's MATSUSHITA + DEBUG_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); - memcpy_P (&irmp_param, &matsushita_param, sizeof (IRMP_PARAMETER)); + irmp_param_p = (IRMP_PARAMETER *) &matsushita_param; } else #endif // IRMP_SUPPORT_MATSUSHITA_PROTOCOL == 1 @@ -1130,11 +1462,11 @@ irmp_ISR (void) #if IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 if (irmp_pulse_time >= KASEIKYO_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= KASEIKYO_START_BIT_PULSE_LEN_MAX && irmp_pause_time >= KASEIKYO_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= KASEIKYO_START_BIT_PAUSE_LEN_MAX) - { // it's KASEIKYO - DEBUG_PRINTF ("protocol = KASEIKYO, start bit timings: pulse: %2d - %2d, pause: %2d - %2d\n", + { // it's KASEIKYO + DEBUG_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); - memcpy_P (&irmp_param, &kaseikyo_param, sizeof (IRMP_PARAMETER)); + irmp_param_p = (IRMP_PARAMETER *) &kaseikyo_param; } else #endif // IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1 @@ -1142,11 +1474,11 @@ irmp_ISR (void) #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 - DEBUG_PRINTF ("protocol = RECS80, start bit timings: pulse: %2d - %2d, pause: %2d - %2d\n", + { // it's RECS80 + DEBUG_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); - memcpy_P (&irmp_param, &recs80_param, sizeof (IRMP_PARAMETER)); + irmp_param_p = (IRMP_PARAMETER *) &recs80_param; } else #endif // IRMP_SUPPORT_RECS80_PROTOCOL == 1 @@ -1156,22 +1488,22 @@ irmp_ISR (void) (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 - DEBUG_PRINTF ("protocol = RC5, start bit timings: pulse: %2d - %2d, pause: %2d - %2d\n", + { // it's RC5 + DEBUG_PRINTF ("protocol = 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); - memcpy_P (&irmp_param, &rc5_param, sizeof (IRMP_PARAMETER)); - rc5_last_pause = irmp_pause_time; + irmp_param_p = (IRMP_PARAMETER *) &rc5_param; + last_pause = irmp_pause_time; if ((irmp_pulse_time > RC5_START_BIT_LEN_MAX && irmp_pulse_time <= 2 * RC5_START_BIT_LEN_MAX) || (irmp_pause_time > RC5_START_BIT_LEN_MAX && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX)) { - rc5_last_value = 0; + last_value = 0; rc5_cmd_bit6 = 1<<6; } else { - rc5_last_value = 1; + last_value = 1; } } else @@ -1182,11 +1514,11 @@ 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 - DEBUG_PRINTF ("protocol = DENON, start bit timings: pulse: %2d - %2d, pause: %2d - %2d or %2d - %2d\n", + DEBUG_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); - memcpy_P (&irmp_param, &denon_param, sizeof (IRMP_PARAMETER)); + irmp_param_p = (IRMP_PARAMETER *) &denon_param; } else #endif // IRMP_SUPPORT_DENON_PROTOCOL == 1 @@ -1195,12 +1527,12 @@ irmp_ISR (void) 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 - DEBUG_PRINTF ("protocol = RC6, start bit timings: pulse: %2d - %2d, pause: %2d - %2d\n", + DEBUG_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); - memcpy_P (&irmp_param, &rc6_param, sizeof (IRMP_PARAMETER)); - rc5_last_pause = 0; - rc5_last_value = 0; + irmp_param_p = (IRMP_PARAMETER *) &rc6_param; + last_pause = 0; + last_value = 0; } else #endif // IRMP_SUPPORT_RC6_PROTOCOL == 1 @@ -1208,11 +1540,11 @@ irmp_ISR (void) #if IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1 if (irmp_pulse_time >= RECS80EXT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RECS80EXT_START_BIT_PULSE_LEN_MAX && irmp_pause_time >= RECS80EXT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RECS80EXT_START_BIT_PAUSE_LEN_MAX) - { // it's RECS80EXT - DEBUG_PRINTF ("protocol = RECS80EXT, start bit timings: pulse: %2d - %2d, pause: %2d - %2d\n", + { // it's RECS80EXT + DEBUG_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); - memcpy_P (&irmp_param, &recs80ext_param, sizeof (IRMP_PARAMETER)); + irmp_param_p = (IRMP_PARAMETER *) &recs80ext_param; } else #endif // IRMP_SUPPORT_RECS80EXT_PROTOCOL == 1 @@ -1220,15 +1552,89 @@ irmp_ISR (void) #if IRMP_SUPPORT_NUBERT_PROTOCOL == 1 if (irmp_pulse_time >= NUBERT_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= NUBERT_START_BIT_PULSE_LEN_MAX && irmp_pause_time >= NUBERT_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= NUBERT_START_BIT_PAUSE_LEN_MAX) - { // it's NUBERT - DEBUG_PRINTF ("protocol = NUBERT, start bit timings: pulse: %2d - %2d, pause: %2d - %2d\n", + { // it's NUBERT + DEBUG_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); - memcpy_P (&irmp_param, &nubert_param, sizeof (IRMP_PARAMETER)); + irmp_param_p = (IRMP_PARAMETER *) &nubert_param; } else #endif // IRMP_SUPPORT_NUBERT_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 + DEBUG_PRINTF ("protocol = BANG_OLUFSEN\n"); + DEBUG_PRINTF ("start bit 1 timings: pulse: %3d - %3d, pause: %3d - %3d\n", + BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX, + BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX); + DEBUG_PRINTF ("start bit 2 timings: pulse: %3d - %3d, pause: %3d - %3d\n", + BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX, + BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX); + DEBUG_PRINTF ("start bit 3 timings: pulse: %3d - %3d, pause: %3d - %3d\n", + BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX, + BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX); + DEBUG_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); + irmp_param_p = (IRMP_PARAMETER *) &bang_olufsen_param; + last_value = 0; + } + else +#endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 + +#if IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1 + if (irmp_pulse_time >= GRUNDIG_OR_NOKIA_START_BIT_LEN_MIN && irmp_pulse_time <= GRUNDIG_OR_NOKIA_START_BIT_LEN_MAX && + irmp_pause_time >= GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MIN && irmp_pause_time <= GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MAX) + { // it's GRUNDIG + DEBUG_PRINTF ("protocol = GRUNDIG, pre bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + GRUNDIG_OR_NOKIA_START_BIT_LEN_MIN, GRUNDIG_OR_NOKIA_START_BIT_LEN_MAX, + GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MIN, GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MAX); + irmp_param_p = (IRMP_PARAMETER *) &grundig_param; + last_pause = irmp_pause_time; + last_value = 1; + } + else +#endif // IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1 + +#if IRMP_SUPPORT_SIEMENS_PROTOCOL == 1 + if (((irmp_pulse_time >= SIEMENS_START_BIT_LEN_MIN && irmp_pulse_time <= SIEMENS_START_BIT_LEN_MAX) || + (irmp_pulse_time >= 2 * SIEMENS_START_BIT_LEN_MIN && irmp_pulse_time <= 2 * SIEMENS_START_BIT_LEN_MAX)) && + ((irmp_pause_time >= SIEMENS_START_BIT_LEN_MIN && irmp_pause_time <= SIEMENS_START_BIT_LEN_MAX) || + (irmp_pause_time >= 2 * SIEMENS_START_BIT_LEN_MIN && irmp_pause_time <= 2 * SIEMENS_START_BIT_LEN_MAX))) + { // it's SIEMENS + DEBUG_PRINTF ("protocol = SIEMENS, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + SIEMENS_START_BIT_LEN_MIN, SIEMENS_START_BIT_LEN_MAX, + SIEMENS_START_BIT_LEN_MIN, SIEMENS_START_BIT_LEN_MAX); + irmp_param_p = (IRMP_PARAMETER *) &siemens_param; + last_pause = irmp_pause_time; + last_value = 1; + } + else +#endif // IRMP_SUPPORT_SIEMENS_PROTOCOL == 1 +#if IRMP_SUPPORT_FDC1_PROTOCOL == 1 + if (irmp_pulse_time >= FDC1_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC1_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= FDC1_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC1_START_BIT_PAUSE_LEN_MAX) + { + DEBUG_PRINTF ("protocol = FDC1, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + FDC1_START_BIT_PULSE_LEN_MIN, FDC1_START_BIT_PULSE_LEN_MAX, + FDC1_START_BIT_PAUSE_LEN_MIN, FDC1_START_BIT_PAUSE_LEN_MAX); + irmp_param_p = (IRMP_PARAMETER *) &fdc1_param; + } + else +#endif // IRMP_SUPPORT_FDC1_PROTOCOL == 1 +#if IRMP_SUPPORT_FDC2_PROTOCOL == 1 + if (irmp_pulse_time >= FDC2_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= FDC2_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= FDC2_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= FDC2_START_BIT_PAUSE_LEN_MAX) + { + DEBUG_PRINTF ("protocol = FDC2, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + FDC2_START_BIT_PULSE_LEN_MIN, FDC2_START_BIT_PULSE_LEN_MAX, + FDC2_START_BIT_PAUSE_LEN_MIN, FDC2_START_BIT_PAUSE_LEN_MAX); + irmp_param_p = (IRMP_PARAMETER *) &fdc2_param; + } + else +#endif // IRMP_SUPPORT_FDC2_PROTOCOL == 1 { DEBUG_PRINTF ("protocol = UNKNOWN\n"); irmp_start_bit_detected = 0; // wait for another start bit... @@ -1236,58 +1642,89 @@ irmp_ISR (void) if (irmp_start_bit_detected) { - DEBUG_PRINTF ("pulse_1 = %2d - %2d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max); - DEBUG_PRINTF ("pause_1 = %2d - %2d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max); + memcpy_P (&irmp_param, irmp_param_p, sizeof (IRMP_PARAMETER)); + +#ifdef DEBUG + if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) + { + DEBUG_PRINTF ("pulse_1: %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max); + DEBUG_PRINTF ("pause_1: %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max); + } + else + { + DEBUG_PRINTF ("pulse: %3d - %3d or %3d - %3d\n", irmp_param.pulse_1_len_min, irmp_param.pulse_1_len_max, + 2 * irmp_param.pulse_1_len_min, 2 * irmp_param.pulse_1_len_max); + DEBUG_PRINTF ("pause: %3d - %3d or %3d - %3d\n", irmp_param.pause_1_len_min, irmp_param.pause_1_len_max, + 2 * irmp_param.pause_1_len_min, 2 * irmp_param.pause_1_len_max); + } + +#if IRMP_SUPPORT_RC6_PROTOCOL == 1 if (irmp_param.protocol == IRMP_RC6_PROTOCOL) { - DEBUG_PRINTF ("pulse_toggle = %2d - %2d\n", RC6_TOGGLE_BIT_LEN_MIN, RC6_TOGGLE_BIT_LEN_MAX); + DEBUG_PRINTF ("pulse_toggle: %3d - %3d\n", RC6_TOGGLE_BIT_LEN_MIN, RC6_TOGGLE_BIT_LEN_MAX); } - DEBUG_PRINTF ("pulse_0 = %2d - %2d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max); - DEBUG_PRINTF ("pause_0 = %2d - %2d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max); - DEBUG_PRINTF ("command_offset = %d\n", irmp_param.command_offset); - DEBUG_PRINTF ("command_len = %d\n", irmp_param.command_end - irmp_param.command_offset); - DEBUG_PRINTF ("complete_len = %d\n", irmp_param.complete_len); - DEBUG_PRINTF ("stop_bit = %d\n", irmp_param.stop_bit); +#endif + + if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) + { + DEBUG_PRINTF ("pulse_0: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max); + DEBUG_PRINTF ("pause_0: %3d - %3d\n", irmp_param.pause_0_len_min, irmp_param.pause_0_len_max); + } + +#if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 + if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL) + { + DEBUG_PRINTF ("pulse_r: %3d - %3d\n", irmp_param.pulse_0_len_min, irmp_param.pulse_0_len_max); + DEBUG_PRINTF ("pause_r: %3d - %3d\n", BANG_OLUFSEN_R_PAUSE_LEN_MIN, BANG_OLUFSEN_R_PAUSE_LEN_MAX); + } +#endif + + DEBUG_PRINTF ("command_offset: %2d\n", irmp_param.command_offset); + DEBUG_PRINTF ("command_len: %3d\n", irmp_param.command_end - irmp_param.command_offset); + DEBUG_PRINTF ("complete_len: %3d\n", irmp_param.complete_len); + DEBUG_PRINTF ("stop_bit: %3d\n", irmp_param.stop_bit); +#endif // DEBUG } irmp_bit = 0; -#if IRMP_SUPPORT_RC5_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_RC5_PROTOCOL) +#if IRMP_SUPPORT_MANCHESTER == 1 + if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) && irmp_param.protocol != IRMP_RC6_PROTOCOL) // manchester, but not rc6 { - if (irmp_pause_time > RC5_START_BIT_LEN_MAX && irmp_pause_time <= 2 * RC5_START_BIT_LEN_MAX) + if (irmp_pause_time > irmp_param.pulse_1_len_max && irmp_pause_time <= 2 * irmp_param.pulse_1_len_max) { - DEBUG_PRINTF ("[bit %2d: pulse = %2d, pause = %2d] ", irmp_bit, irmp_pulse_time, irmp_pause_time); - DEBUG_PUTCHAR ('1'); - DEBUG_PUTCHAR ('\n'); - irmp_store_bit (1); + DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time); + DEBUG_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1'); + DEBUG_NEWLINE (); + irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1); } - else if (! rc5_last_value) + else if (! last_value) { - DEBUG_PRINTF ("[bit %2d: pulse = %2d, pause = %2d] ", irmp_bit, irmp_pulse_time, irmp_pause_time); - DEBUG_PUTCHAR ('0'); - DEBUG_PUTCHAR ('\n'); - irmp_store_bit (0); + DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time); + + DEBUG_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0'); + DEBUG_NEWLINE (); + irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0); } } else -#endif // IRMP_SUPPORT_RC5_PROTOCOL == 1 +#endif // IRMP_SUPPORT_MANCHESTER == 1 #if IRMP_SUPPORT_DENON_PROTOCOL == 1 if (irmp_param.protocol == IRMP_DENON_PROTOCOL) { - DEBUG_PRINTF ("[bit %2d: pulse = %2d, pause = %2d] ", irmp_bit, irmp_pulse_time, irmp_pause_time); + DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time); if (irmp_pause_time >= DENON_1_PAUSE_LEN_MIN && irmp_pause_time <= DENON_1_PAUSE_LEN_MAX) { // pause timings correct for "1"? DEBUG_PUTCHAR ('1'); // yes, store 1 - DEBUG_PUTCHAR ('\n'); + DEBUG_NEWLINE (); 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"? DEBUG_PUTCHAR ('0'); // yes, store 0 - DEBUG_PUTCHAR ('\n'); + DEBUG_NEWLINE (); irmp_store_bit (0); } } @@ -1309,7 +1746,7 @@ irmp_ISR (void) if (irmp_pulse_time >= irmp_param.pulse_0_len_min && irmp_pulse_time <= irmp_param.pulse_0_len_max) { #ifdef DEBUG - if (irmp_param.protocol != IRMP_RC5_PROTOCOL) + if (! (irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) { DEBUG_PRINTF ("stop bit detected\n"); } @@ -1334,32 +1771,50 @@ irmp_ISR (void) irmp_pause_time > SIRCS_PAUSE_LEN_MAX && // minimum is 12 irmp_bit >= 12 - 1) // pause too long? { // yes, break and close this frame - irmp_param.complete_len = irmp_bit + 1; // set new complete length + irmp_param.complete_len = irmp_bit + 1; // set new complete length got_light = TRUE; // this is a lie, but helps (generates stop bit) irmp_param.command_end = irmp_param.command_offset + irmp_bit + 1; // correct command length irmp_pause_time = SIRCS_PAUSE_LEN_MAX - 1; // correct pause length } else #endif -#if IRMP_SUPPORT_RC5_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_RC5_PROTOCOL && - irmp_pause_time > 2 * RC5_BIT_LEN_MAX && irmp_bit >= RC5_COMPLETE_DATA_LEN - 2 && !irmp_param.stop_bit) - { // special rc5 decoder - got_light = TRUE; // this is a lie, but generates a stop bit ;-) - irmp_param.stop_bit = TRUE; // set flag +#if IRMP_SUPPORT_GRUNDIG_OR_NOKIA_PROTOCOL == 1 + if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && !irmp_param.stop_bit) + { + if (irmp_pause_time > 2 * irmp_param.pause_1_len_max && irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN - 2) + { // special manchester decoder + irmp_param.complete_len = GRUNDIG_COMPLETE_DATA_LEN; // correct complete len + got_light = TRUE; // this is a lie, but generates a stop bit ;-) + irmp_param.stop_bit = TRUE; // set flag + } + else if (irmp_bit >= GRUNDIG_COMPLETE_DATA_LEN) + { + DEBUG_PRINTF ("Switching to NOKIA protocol\n"); + irmp_param.protocol = IRMP_NOKIA_PROTOCOL; // change protocol + irmp_param.address_offset = NOKIA_ADDRESS_OFFSET; + irmp_param.address_end = NOKIA_ADDRESS_OFFSET + NOKIA_ADDRESS_LEN; + irmp_param.command_offset = NOKIA_COMMAND_OFFSET; + irmp_param.command_end = NOKIA_COMMAND_OFFSET + NOKIA_COMMAND_LEN; + + if (irmp_tmp_command & 0x300) + { + irmp_tmp_address = (irmp_tmp_command >> 8); + irmp_tmp_command &= 0xFF; + } + } } else #endif -#if IRMP_SUPPORT_RC6_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_RC6_PROTOCOL && - irmp_pause_time > 2 * RC6_BIT_LEN_MAX && irmp_bit >= irmp_param.complete_len - 2 && !irmp_param.stop_bit) - { // special rc6 decoder +#if IRMP_SUPPORT_MANCHESTER == 1 + if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER) && + irmp_pause_time > 2 * irmp_param.pause_1_len_max && irmp_bit >= irmp_param.complete_len - 2 && !irmp_param.stop_bit) + { // special manchester decoder got_light = TRUE; // this is a lie, but generates a stop bit ;-) - irmp_param.stop_bit = TRUE; // set flag + irmp_param.stop_bit = TRUE; // set flag } else -#endif - if (irmp_pause_time > IRMP_TIMEOUT) // timeout? +#endif // IRMP_SUPPORT_MANCHESTER == 1 + if (irmp_pause_time > IRMP_TIMEOUT_LEN) // timeout? { // yes... if (irmp_bit == irmp_param.complete_len - 1 && irmp_param.stop_bit == 0) { @@ -1368,6 +1823,7 @@ irmp_ISR (void) else { DEBUG_PRINTF ("error 2: pause %d after data bit %d too long\n", irmp_pause_time, irmp_bit); + DEBUG_ONLY_NORMAL_PUTCHAR ('\n'); irmp_start_bit_detected = 0; // wait for another start bit... irmp_pulse_time = 0; @@ -1383,108 +1839,70 @@ irmp_ISR (void) if (got_light) { - DEBUG_PRINTF ("[bit %2d: pulse = %2d, pause = %2d] ", irmp_bit, irmp_pulse_time, irmp_pause_time); + DEBUG_PRINTF ("%8d [bit %2d: pulse = %3d, pause = %3d] ", time_counter, irmp_bit, irmp_pulse_time, irmp_pause_time); -#if IRMP_SUPPORT_RC5_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_RC5_PROTOCOL) // special rc5 decoder +#if IRMP_SUPPORT_MANCHESTER == 1 + if ((irmp_param.flags & IRMP_PARAM_FLAG_IS_MANCHESTER)) // manchester { - if (irmp_pulse_time > RC5_BIT_LEN_MAX && irmp_pulse_time <= 2 * RC5_BIT_LEN_MAX) +#if IRMP_SUPPORT_RC6_PROTOCOL == 1 + if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit >= 3 && irmp_bit <= 5) // special bits of rc6 { - DEBUG_PUTCHAR ('1'); - irmp_store_bit (1); + if (irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MAX && irmp_pause_time > RC6_TOGGLE_BIT_LEN_MAX) + { + DEBUG_PUTCHAR ('1'); + irmp_store_bit (1); + } + DEBUG_PUTCHAR ('0'); - DEBUG_PUTCHAR ('\n'); irmp_store_bit (0); - rc5_last_value = 0; + last_value = 0; + DEBUG_NEWLINE (); } - - else // if (irmp_pulse_time >= RC5_BIT_LEN_MIN && irmp_pulse_time <= RC5_BIT_LEN_MAX) + else +#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1 + if (irmp_pulse_time > irmp_param.pulse_1_len_max && irmp_pulse_time <= 2 * irmp_param.pulse_1_len_max) + { + DEBUG_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '0' : '1'); + irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 0 : 1 ); + DEBUG_PUTCHAR ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? '1' : '0'); + irmp_store_bit ((irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0 ); + DEBUG_NEWLINE (); + last_value = (irmp_param.flags & IRMP_PARAM_FLAG_1ST_PULSE_IS_1) ? 1 : 0; + } + else // if (irmp_pulse_time >= irmp_param.pulse_1_len_max && irmp_pulse_time <= irmp_param.pulse_1_len_max) { - uint8_t rc5_value; + uint8_t manchester_value; - if (rc5_last_pause > RC5_BIT_LEN_MAX && rc5_last_pause <= 2 * RC5_BIT_LEN_MAX) + if (last_pause > irmp_param.pause_1_len_max && last_pause <= 2 * irmp_param.pause_1_len_max) { - rc5_value = rc5_last_value ? 0 : 1; - rc5_last_value = rc5_value; + manchester_value = last_value ? 0 : 1; + last_value = manchester_value; } else { - rc5_value = rc5_last_value; + manchester_value = last_value; } - DEBUG_PUTCHAR (rc5_value + '0'); - DEBUG_PUTCHAR ('\n'); - irmp_store_bit (rc5_value); - } - - rc5_last_pause = irmp_pause_time; - wait_for_space = 0; - } - else -#endif - +#if 0 #if IRMP_SUPPORT_RC6_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_RC6_PROTOCOL) // special rc6 decoder - { - switch (irmp_bit) - { // handle toggle bit, which is 2 times longer than other bits - case 3: - case 4: - case 5: - if (irmp_pulse_time > RC6_TOGGLE_BIT_LEN_MAX && irmp_pause_time > RC6_TOGGLE_BIT_LEN_MAX) - { - DEBUG_PUTCHAR ('1'); - irmp_store_bit (1); - } - - DEBUG_PUTCHAR ('0'); - irmp_store_bit (0); - rc5_last_value = 0; - DEBUG_PUTCHAR ('\n'); - break; - - default: - if (irmp_pulse_time > RC6_BIT_LEN_MAX && irmp_pulse_time <= 2 * RC6_BIT_LEN_MAX) - { - DEBUG_PUTCHAR ('0'); - irmp_store_bit (0); - DEBUG_PUTCHAR ('1'); - DEBUG_PUTCHAR ('\n'); - irmp_store_bit (1); - rc5_last_value = 1; - } - else // if (irmp_pulse_time >= RC6_BIT_LEN_MIN && irmp_pulse_time <= RC6_BIT_LEN_MAX) - { - uint8_t rc5_value; - - if (rc5_last_pause > RC6_BIT_LEN_MAX && rc5_last_pause <= 2 * RC6_BIT_LEN_MAX) - { - rc5_value = rc5_last_value ? 0 : 1; - rc5_last_value = rc5_value; - } - else - { - rc5_value = rc5_last_value; - } - - if (irmp_bit == 1 && rc5_value == 0) - { - irmp_param.complete_len = RC6_COMPLETE_DATA_LEN_LONG; - } - - DEBUG_PUTCHAR (rc5_value + '0'); - DEBUG_PUTCHAR ('\n'); - irmp_store_bit (rc5_value); - } + if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_bit == 1 && manchester_value == 0) // RC6 mode != 0 ??? + { + irmp_param.complete_len = RC6_COMPLETE_DATA_LEN_LONG; + } +#endif // IRMP_SUPPORT_RC6_PROTOCOL == 1 +#endif // 0 - rc5_last_pause = irmp_pause_time; - break; - } // switch + DEBUG_PUTCHAR (manchester_value + '0'); + DEBUG_NEWLINE (); + irmp_store_bit (manchester_value); + } - wait_for_space = 0; + last_pause = irmp_pause_time; + wait_for_space = 0; } else -#endif +#endif // IRMP_SUPPORT_MANCHESTER == 1 + #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 if (irmp_param.protocol == IRMP_SAMSUNG_PROTOCOL && irmp_bit == 16) // Samsung: 16th bit @@ -1499,45 +1917,128 @@ irmp_ISR (void) } else if (irmp_pulse_time >= SAMSUNG_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_PULSE_LEN_MAX) { + 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; + if (irmp_pause_time >= SAMSUNG_1_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_1_PAUSE_LEN_MAX) { DEBUG_PUTCHAR ('1'); - DEBUG_PUTCHAR ('\n'); + DEBUG_NEWLINE (); irmp_store_bit (1); wait_for_space = 0; } else { DEBUG_PUTCHAR ('0'); - DEBUG_PUTCHAR ('\n'); + DEBUG_NEWLINE (); irmp_store_bit (0); wait_for_space = 0; } DEBUG_PRINTF ("Switching to SAMSUNG32 protocol\n"); - - 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; } else { // timing incorrect! - DEBUG_PRINTF ("error 3: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time); - irmp_start_bit_detected = 0; // reset flags and wait for next start bit + DEBUG_PRINTF ("error 3 Samsung: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time); + DEBUG_ONLY_NORMAL_PUTCHAR ('\n'); + irmp_start_bit_detected = 0; // reset flags and wait for next start bit irmp_pause_time = 0; } - - irmp_pulse_time = 1; // set counter to 1, not 0 } else #endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL +#if IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 + if (irmp_param.protocol == IRMP_BANG_OLUFSEN_PROTOCOL) + { + if (irmp_pulse_time >= BANG_OLUFSEN_PULSE_LEN_MIN && irmp_pulse_time <= BANG_OLUFSEN_PULSE_LEN_MAX) + { + if (irmp_bit == 1) // Bang & Olufsen: 3rd bit + { + if (irmp_pause_time >= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX) + { + DEBUG_PRINTF ("3rd start bit\n"); + wait_for_space = 0; + irmp_tmp_id = 0; + irmp_bit++; + } + else + { // timing incorrect! + DEBUG_PRINTF ("error 3a B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time); + DEBUG_ONLY_NORMAL_PUTCHAR ('\n'); + irmp_start_bit_detected = 0; // reset flags and wait for next start bit + irmp_pause_time = 0; + } + } + else if (irmp_bit == 19) // Bang & Olufsen: trailer bit + { + if (irmp_pause_time >= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_TRAILER_BIT_PAUSE_LEN_MAX) + { + DEBUG_PRINTF ("trailer bit\n"); + wait_for_space = 0; + irmp_tmp_id = 0; + irmp_bit++; + } + else + { // timing incorrect! + DEBUG_PRINTF ("error 3b B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time); + DEBUG_ONLY_NORMAL_PUTCHAR ('\n'); + irmp_start_bit_detected = 0; // reset flags and wait for next start bit + irmp_pause_time = 0; + } + } + else + { + if (irmp_pause_time >= BANG_OLUFSEN_1_PAUSE_LEN_MIN && irmp_pause_time <= BANG_OLUFSEN_1_PAUSE_LEN_MAX) + { // pulse & pause timings correct for "1"? + DEBUG_PUTCHAR ('1'); + DEBUG_NEWLINE (); + 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"? + DEBUG_PUTCHAR ('0'); + DEBUG_NEWLINE (); + 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) + { + DEBUG_PUTCHAR (last_value + '0'); + DEBUG_NEWLINE (); + irmp_store_bit (last_value); + wait_for_space = 0; + } + else + { // timing incorrect! + DEBUG_PRINTF ("error 3c B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time); + DEBUG_ONLY_NORMAL_PUTCHAR ('\n'); + irmp_start_bit_detected = 0; // reset flags and wait for next start bit + irmp_pause_time = 0; + } + } + } + else + { // timing incorrect! + DEBUG_PRINTF ("error 3d B&O: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time); + DEBUG_ONLY_NORMAL_PUTCHAR ('\n'); + irmp_start_bit_detected = 0; // reset flags and wait for next start bit + irmp_pause_time = 0; + } + } + else +#endif // IRMP_SUPPORT_BANG_OLUFSEN_PROTOCOL + if (irmp_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"? DEBUG_PUTCHAR ('1'); - DEBUG_PUTCHAR ('\n'); + DEBUG_NEWLINE (); irmp_store_bit (1); wait_for_space = 0; } @@ -1545,13 +2046,14 @@ irmp_ISR (void) irmp_pause_time >= irmp_param.pause_0_len_min && irmp_pause_time <= irmp_param.pause_0_len_max) { // pulse & pause timings correct for "0"? DEBUG_PUTCHAR ('0'); - DEBUG_PUTCHAR ('\n'); + DEBUG_NEWLINE (); irmp_store_bit (0); wait_for_space = 0; } else { // timing incorrect! DEBUG_PRINTF ("error 3: timing not correct: data bit %d, pulse: %d, pause: %d\n", irmp_bit, irmp_pulse_time, irmp_pause_time); + DEBUG_ONLY_NORMAL_PUTCHAR ('\n'); irmp_start_bit_detected = 0; // reset flags and wait for next start bit irmp_pause_time = 0; } @@ -1561,7 +2063,7 @@ irmp_ISR (void) } else { // counting the pulse length ... - if (!irmp_input) // still light? + if (! irmp_input) // still light? { // yes... irmp_pulse_time++; // increment counter } @@ -1574,17 +2076,48 @@ irmp_ISR (void) if (irmp_bit == irmp_param.complete_len && irmp_param.stop_bit == 0) // enough bits received? { - // if SIRCS/SAMSUNG32 protocol and the code will be repeated within 50 ms, we will ignore it. - if ((irmp_param.protocol == IRMP_SIRCS_PROTOCOL || - irmp_param.protocol == IRMP_SAMSUNG32_PROTOCOL || - irmp_param.protocol == IRMP_NUBERT_PROTOCOL) && - last_irmp_command == irmp_tmp_command && repetition_counter < AUTO_REPETITION_LEN) + if (last_irmp_command == irmp_tmp_command && repetition_counter < AUTO_FRAME_REPETITION_LEN) + { + repetition_frame_number++; + } + else + { + repetition_frame_number = 0; + } + +#if IRMP_SUPPORT_SIRCS_PROTOCOL == 1 + // if SIRCS protocol and the code will be repeated within 50 ms, we will ignore 2nd and 3rd repetition frame + if (irmp_param.protocol == IRMP_SIRCS_PROTOCOL && (repetition_frame_number == 1 || repetition_frame_number == 2)) + { + DEBUG_PRINTF ("code skipped: SIRCS auto repetition frame #%d, counter = %d, auto repetition len = %d\n", + repetition_frame_number + 1, repetition_counter, AUTO_FRAME_REPETITION_LEN); + repetition_counter = 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)) + { + DEBUG_PRINTF ("code skipped: SAMSUNG32 auto repetition frame #%d, counter = %d, auto repetition len = %d\n", + repetition_frame_number + 1, repetition_counter, AUTO_FRAME_REPETITION_LEN); + repetition_counter = 0; + } + else +#endif + +#if IRMP_SUPPORT_NUBERT_PROTOCOL == 1 + // if NUBERT protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame + if (irmp_param.protocol == IRMP_NUBERT_PROTOCOL && (repetition_frame_number & 0x01)) { - DEBUG_PRINTF ("code skipped, recognized SIRCS, SAMSUNG32 or NUBERT repetition, counter = %d, auto repetition len = %d\n", - repetition_counter, AUTO_REPETITION_LEN); + DEBUG_PRINTF ("code skipped: NUBERT auto repetition frame #%d, counter = %d, auto repetition len = %d\n", + repetition_frame_number + 1, repetition_counter, AUTO_FRAME_REPETITION_LEN); repetition_counter = 0; } else +#endif + { DEBUG_PRINTF ("code detected, length = %d\n", irmp_bit); irmp_ir_detected = TRUE; @@ -1609,6 +2142,24 @@ irmp_ISR (void) } else #endif // IRMP_SUPPORT_DENON_PROTOCOL + +#if IRMP_SUPPORT_GRUNDIG_PROTOCOL == 1 + if (irmp_param.protocol == IRMP_GRUNDIG_PROTOCOL && irmp_tmp_command == 0x01ff) + { // Grundig start frame? + DEBUG_PRINTF ("Detected GRUNDIG start frame, ignoring it\n"); + irmp_ir_detected = FALSE; + } + else +#endif // IRMP_SUPPORT_GRUNDIG_PROTOCOL + +#if IRMP_SUPPORT_NOKIA_PROTOCOL == 1 + if (irmp_param.protocol == IRMP_NOKIA_PROTOCOL && irmp_tmp_address == 0x00ff && irmp_tmp_command == 0x00fe) + { // Nokia start frame? + DEBUG_PRINTF ("Detected NOKIA start frame, ignoring it\n"); + irmp_ir_detected = FALSE; + } + else +#endif // IRMP_SUPPORT_NOKIA_PROTOCOL { #if IRMP_SUPPORT_NEC_PROTOCOL == 1 if (irmp_param.protocol == IRMP_NEC_PROTOCOL && irmp_bit == 0) // repetition frame @@ -1639,7 +2190,7 @@ irmp_ISR (void) { if (last_irmp_command == irmp_command && last_irmp_address == irmp_address && - repetition_counter < IRMP_REPETITION_TIME) + repetition_counter < IRMP_KEY_REPETITION_LEN) { irmp_flags |= IRMP_FLAG_REPETITION; } @@ -1649,6 +2200,10 @@ irmp_ISR (void) repetition_counter = 0; } + else + { + DEBUG_ONLY_NORMAL_PUTCHAR ('\n'); + } irmp_start_bit_detected = 0; // and wait for next start bit irmp_tmp_command = 0; @@ -1657,6 +2212,7 @@ irmp_ISR (void) } } } + return (irmp_ir_detected); } #ifdef DEBUG @@ -1666,48 +2222,127 @@ irmp_ISR (void) // Compile it under linux with: // cc irmp.c -o irmp // -// usage: ./irmp [-v|-s|-a] < file +// usage: ./irmp [-v|-s|-a|-l|-p] < file +// options: +// -v verbose +// -s silent +// -a analyze +// -l list pulse/pauses +// -p print timings + +static void +print_timings (void) +{ + printf ("PROTOCOL START BIT NO. START BIT PULSE START BIT PAUSE\n"); + printf ("====================================================================================\n"); + printf ("SIRCS 1 %3d - %3d %3d - %3d\n", + SIRCS_START_BIT_PULSE_LEN_MIN, SIRCS_START_BIT_PULSE_LEN_MAX, SIRCS_START_BIT_PAUSE_LEN_MIN, SIRCS_START_BIT_PAUSE_LEN_MAX); + printf ("NEC 1 %3d - %3d %3d - %3d\n", + NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX, NEC_START_BIT_PAUSE_LEN_MIN, NEC_START_BIT_PAUSE_LEN_MAX); + printf ("NEC (rep) 1 %3d - %3d %3d - %3d\n", + NEC_START_BIT_PULSE_LEN_MIN, NEC_START_BIT_PULSE_LEN_MAX, NEC_REPEAT_START_BIT_PAUSE_LEN_MIN, NEC_REPEAT_START_BIT_PAUSE_LEN_MAX); + printf ("SAMSUNG 1 %3d - %3d %3d - %3d\n", + SAMSUNG_START_BIT_PULSE_LEN_MIN, SAMSUNG_START_BIT_PULSE_LEN_MAX, SAMSUNG_START_BIT_PAUSE_LEN_MIN, SAMSUNG_START_BIT_PAUSE_LEN_MAX); + printf ("MATSUSHITA 1 %3d - %3d %3d - %3d\n", + MATSUSHITA_START_BIT_PULSE_LEN_MIN, MATSUSHITA_START_BIT_PULSE_LEN_MAX, MATSUSHITA_START_BIT_PAUSE_LEN_MIN, MATSUSHITA_START_BIT_PAUSE_LEN_MAX); + printf ("KASEIKYO 1 %3d - %3d %3d - %3d\n", + KASEIKYO_START_BIT_PULSE_LEN_MIN, KASEIKYO_START_BIT_PULSE_LEN_MAX, KASEIKYO_START_BIT_PAUSE_LEN_MIN, KASEIKYO_START_BIT_PAUSE_LEN_MAX); + printf ("RECS80 1 %3d - %3d %3d - %3d\n", + RECS80_START_BIT_PULSE_LEN_MIN, RECS80_START_BIT_PULSE_LEN_MAX, RECS80_START_BIT_PAUSE_LEN_MIN, RECS80_START_BIT_PAUSE_LEN_MAX); + printf ("RC5 1 %3d - %3d %3d - %3d\n", + RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX, RC5_START_BIT_LEN_MIN, RC5_START_BIT_LEN_MAX); + printf ("DENON 1 %3d - %3d %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); + printf ("RC6 1 %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); + printf ("RECS80EXT 1 %3d - %3d %3d - %3d\n", + RECS80EXT_START_BIT_PULSE_LEN_MIN, RECS80EXT_START_BIT_PULSE_LEN_MAX, RECS80EXT_START_BIT_PAUSE_LEN_MIN, RECS80EXT_START_BIT_PAUSE_LEN_MAX); + printf ("NUBERT 1 %3d - %3d %3d - %3d\n", + NUBERT_START_BIT_PULSE_LEN_MIN, NUBERT_START_BIT_PULSE_LEN_MAX, NUBERT_START_BIT_PAUSE_LEN_MIN, NUBERT_START_BIT_PAUSE_LEN_MAX); + printf ("BANG_OLUFSEN 1 %3d - %3d %3d - %3d\n", + BANG_OLUFSEN_START_BIT1_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PULSE_LEN_MAX, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT1_PAUSE_LEN_MAX); + printf ("BANG_OLUFSEN 2 %3d - %3d %3d - %3d\n", + BANG_OLUFSEN_START_BIT2_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PULSE_LEN_MAX, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT2_PAUSE_LEN_MAX); + printf ("BANG_OLUFSEN 3 %3d - %3d %3d - %3d\n", + BANG_OLUFSEN_START_BIT3_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PULSE_LEN_MAX, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT3_PAUSE_LEN_MAX); + printf ("BANG_OLUFSEN 4 %3d - %3d %3d - %3d\n", + BANG_OLUFSEN_START_BIT4_PULSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PULSE_LEN_MAX, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MIN, BANG_OLUFSEN_START_BIT4_PAUSE_LEN_MAX); + printf ("GRUNDIG/NOKIA 1 %3d - %3d %3d - %3d\n", + GRUNDIG_OR_NOKIA_START_BIT_LEN_MIN, GRUNDIG_OR_NOKIA_START_BIT_LEN_MAX, GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MIN, GRUNDIG_OR_NOKIA_PRE_PAUSE_LEN_MAX); + printf ("SIEMENS 1 %3d - %3d %3d - %3d\n", + SIEMENS_START_BIT_LEN_MIN, SIEMENS_START_BIT_LEN_MAX, SIEMENS_START_BIT_LEN_MIN, SIEMENS_START_BIT_LEN_MAX); + printf ("FDC1 1 %3d - %3d %3d - %3d\n", + FDC1_START_BIT_PULSE_LEN_MIN, FDC1_START_BIT_PULSE_LEN_MAX, FDC1_START_BIT_PAUSE_LEN_MIN, FDC1_START_BIT_PAUSE_LEN_MAX); + printf ("FDC2 1 %3d - %3d %3d - %3d\n", + FDC2_START_BIT_PULSE_LEN_MIN, FDC2_START_BIT_PULSE_LEN_MAX, FDC2_START_BIT_PAUSE_LEN_MIN, FDC2_START_BIT_PAUSE_LEN_MAX); +} + +void +print_spectrum (char * text, int * buf) +{ + int i; + int j; + int max = 0; + int value; + int sum = 0; + int counter = 0; + double average = 0; + + puts ("--------------------------------------------------------------------------------------------------------------"); + printf ("%s:\n", text); + + for (i = 0; i < 256; i++) + { + if (buf[i] > max) + { + max = buf[i]; + } + } + + for (i = 0; i < 100; i++) + { + if (buf[i] > 0) + { + printf ("%3d ", i); + value = (buf[i] * 100) / max; + + for (j = 0; j < value; j++) + { + putchar ('o'); + } + printf (" %d\n", buf[i]); + + sum += i * buf[i]; + counter += buf[i]; + } + else + { + if (counter > 0) + { + average = (float) sum / (float) counter; + printf ("average: %0.2f = %0.2f usec\n", average, (1000000. * average) / (float) F_INTERRUPTS); + } + counter = 0; + sum = 0; + } + } +} int main (int argc, char ** argv) { int i; - int verbose = FALSE; int analyze = FALSE; + int list = FALSE; int ch; int last_ch = 0; int pulse = 0; int pause = 0; - int min_pulse_long = 100000; - int max_pulse_long = 0; - int sum_pulses_long = 0; - int n_pulses_long = 0; - - int min_pulse_short = 100000; - int max_pulse_short = 0; - int sum_pulses_short = 0; - int n_pulses_short = 0; - - int min_pause_long = 100000; - int max_pause_long = 0; - int sum_pauses_long = 0; - int n_pauses_long = 0; - - int min_pause_short = 100000; - int max_pause_short = 0; - int sum_pauses_short = 0; - int n_pauses_short = 0; - - int min_start_pulse = 100000; - int max_start_pulse = 0; - int sum_start_pulses = 0; - int n_start_pulses = 0; - - int min_start_pause = 100000; - int max_start_pause = 0; - int sum_start_pauses = 0; - int n_start_pauses = 0; + int start_pulses[256]; + int start_pauses[256]; + int pulses[256]; + int pauses[256]; int first_pulse = TRUE; int first_pause = TRUE; @@ -1720,15 +2355,31 @@ main (int argc, char ** argv) { verbose = TRUE; } + else if (! strcmp (argv[1], "-l")) + { + list = TRUE; + } else if (! strcmp (argv[1], "-a")) { analyze = TRUE; - verbose = TRUE; } else if (! strcmp (argv[1], "-s")) { silent = TRUE; } + else if (! strcmp (argv[1], "-p")) + { + print_timings (); + return (0); + } + } + + for (i = 0; i < 256; i++) + { + start_pulses[i] = 0; + start_pauses[i] = 0; + pulses[i] = 0; + pauses[i] = 0; } IRMP_PIN = 0xFF; @@ -1739,59 +2390,29 @@ main (int argc, char ** argv) { if (last_ch != ch) { - if (verbose && pause > 0) + if (pause > 0) { - printf ("pause: %d\n", pause); - - if (first_pause) + if (list) { - if (min_start_pause > pause) - { - min_start_pause = pause; - } - if (max_start_pause < pause) - { - max_start_pause = pause; - } - n_start_pauses++; - sum_start_pauses += pause; - first_pause = FALSE; + printf ("pause: %d\n", pause); } - else + + if (analyze) { - if (pause >= 10) + if (first_pause) { - if (pause > 100) // perhaps repetition frame follows + if (pause < 256) { - first_pulse = TRUE; - first_pause = TRUE; - } - else - { - if (min_pause_long > pause) - { - min_pause_long = pause; - } - if (max_pause_long < pause) - { - max_pause_long = pause; - } - n_pauses_long++; - sum_pauses_long += pause; + start_pauses[pause]++; } + first_pause = FALSE; } else { - if (min_pause_short > pause) - { - min_pause_short = pause; - } - if (max_pause_short < pause) + if (pause < 256) { - max_pause_short = pause; + pauses[pause]++; } - n_pauses_short++; - sum_pauses_short += pause; } } } @@ -1804,56 +2425,32 @@ main (int argc, char ** argv) { if (last_ch != ch) { - if (verbose) + if (list) { printf ("pulse: %d ", pulse); + } + if (analyze) + { if (first_pulse) { - if (min_start_pulse > pulse) - { - min_start_pulse = pulse; - } - if (max_start_pulse < pulse) + if (pulse < 256) { - max_start_pulse = pulse; + start_pulses[pulse]++; } - n_start_pulses++; - sum_start_pulses += pulse; first_pulse = FALSE; } else { - if (pulse >= 10) + if (pulse < 256) { - if (min_pulse_long > pulse) - { - min_pulse_long = pulse; - } - if (max_pulse_long < pulse) - { - max_pulse_long = pulse; - } - n_pulses_long++; - sum_pulses_long += pulse; - } - else - { - if (min_pulse_short > pulse) - { - min_pulse_short = pulse; - } - if (max_pulse_short < pulse) - { - max_pulse_short = pulse; - } - n_pulses_short++; - sum_pulses_short += pulse; + pulses[pulse]++; } } } pulse = 0; } + pause++; IRMP_PIN = 0xff; } @@ -1861,7 +2458,7 @@ main (int argc, char ** argv) { IRMP_PIN = 0xff; - if (verbose && pause > 0) + if (list && pause > 0) { printf ("pause: %d\n", pause); } @@ -1869,9 +2466,9 @@ main (int argc, char ** argv) if (! analyze) { - for (i = 0; i < 8000; i++) // newline: long pause of 800 msec + for (i = 0; i < (int) ((8000.0 * F_INTERRUPTS) / 10000); i++) // newline: long pause of 800 msec { - irmp_ISR (); + (void) irmp_ISR (); } } first_pulse = TRUE; @@ -1879,85 +2476,52 @@ main (int argc, char ** argv) } else if (ch == '#') { - puts ("-------------------------------------------------------------------"); - putchar (ch); - - while ((ch = getchar()) != '\n' && ch != EOF) + if (analyze) + { + while ((ch = getchar()) != '\n' && ch != EOF) + { + ; + } + } + else { - if (ch != '\r') // ignore CR in DOS/Windows files + puts ("-------------------------------------------------------------------"); + putchar (ch); + + while ((ch = getchar()) != '\n' && ch != EOF) { - putchar (ch); + if (ch != '\r') // ignore CR in DOS/Windows files + { + putchar (ch); + } } + putchar ('\n'); } - putchar ('\n'); + } last_ch = ch; - if (! analyze) + if (! analyze && ! list) { - irmp_ISR (); - } + (void) irmp_ISR (); - if (irmp_get_data (&irmp_data)) - { - printf ("protcol = %d, address = 0x%04x, code = 0x%04x, flags = 0x%02x\n", - irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags); + if (irmp_get_data (&irmp_data)) + { + DEBUG_ONLY_NORMAL_PUTCHAR (' '); + 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); + } } } if (analyze) { - printf ("\nSTATITSTICS:\n"); - printf ("---------------------------------\n"); - printf ("number of start pulses: %d\n", n_start_pulses); - printf ("minimum start pulse length: %d usec\n", (F_INTERRUPTS * min_start_pulse) / 100); - printf ("maximum start pulse length: %d usec\n", (F_INTERRUPTS * max_start_pulse) / 100); - if (n_start_pulses > 0) - { - printf ("average start pulse length: %d usec\n", ((F_INTERRUPTS * sum_start_pulses) / n_start_pulses) / 100); - } - putchar ('\n'); - printf ("number of start pauses: %d\n", n_start_pauses); - if (n_start_pauses > 0) - { - printf ("minimum start pause length: %d usec\n", (F_INTERRUPTS * min_start_pause) / 100); - printf ("maximum start pause length: %d usec\n", (F_INTERRUPTS * max_start_pause) / 100); - printf ("average start pause length: %d usec\n", ((F_INTERRUPTS * sum_start_pauses) / n_start_pauses) / 100); - } - putchar ('\n'); - printf ("number of long pulses: %d\n", n_pulses_long); - if (n_pulses_long > 0) - { - printf ("minimum long pulse length: %d usec\n", (F_INTERRUPTS * min_pulse_long) / 100); - printf ("maximum long pulse length: %d usec\n", (F_INTERRUPTS * max_pulse_long) / 100); - printf ("average long pulse length: %d usec\n", ((F_INTERRUPTS * sum_pulses_long) / n_pulses_long) / 100); - } - putchar ('\n'); - printf ("number of short pulses: %d\n", n_pulses_short); - if (n_pulses_short > 0) - { - printf ("minimum short pulse length: %d usec\n", (F_INTERRUPTS * min_pulse_short) / 100); - printf ("maximum short pulse length: %d usec\n", (F_INTERRUPTS * max_pulse_short) / 100); - printf ("average short pulse length: %d usec\n", ((F_INTERRUPTS * sum_pulses_short) / n_pulses_short) / 100); - - } - putchar ('\n'); - printf ("number of long pauses: %d\n", n_pauses_long); - if (n_pauses_long > 0) - { - printf ("minimum long pause length: %d usec\n", (F_INTERRUPTS * min_pause_long) / 100); - printf ("maximum long pause length: %d usec\n", (F_INTERRUPTS * max_pause_long) / 100); - printf ("average long pause length: %d usec\n", ((F_INTERRUPTS * sum_pauses_long) / n_pauses_long) / 100); - } - putchar ('\n'); - printf ("number of short pauses: %d\n", n_pauses_short); - if (n_pauses_short > 0) - { - printf ("minimum short pause length: %d usec\n", (F_INTERRUPTS * min_pause_short) / 100); - printf ("maximum short pause length: %d usec\n", (F_INTERRUPTS * max_pause_short) / 100); - printf ("average short pause length: %d usec\n", ((F_INTERRUPTS * sum_pauses_short) / n_pauses_short) / 100); - } + print_spectrum ("START PULSES", start_pulses); + print_spectrum ("START PAUSES", start_pauses); + print_spectrum ("PULSES", pulses); + print_spectrum ("PAUSES", pauses); + puts ("--------------------------------------------------------------------------------------------------------------"); } return 0; }