From cb8474cca0ec71c9780575aae0ad9979576b8e2e Mon Sep 17 00:00:00 2001 From: ukw Date: Mon, 29 Mar 2010 09:48:00 +0000 Subject: [PATCH] bugfix in detection of multiple NEC repetitions, added irmpconfig.h git-svn-id: svn://mikrocontroller.net/irmp@4 aeb2e35e-bfc4-4214-b83c-9e8de998ed28 --- IR-Data/nec-repetition.txt | 4 +++ README.txt | 2 ++ irmp.aps | 2 +- irmp.c | 63 ++++++---------------------------- irmp.h | 32 +++++++++--------- irmpconfig.h | 69 ++++++++++++++++++++++++++++++++++++++ main.c | 4 +++ 7 files changed, 106 insertions(+), 70 deletions(-) create mode 100644 irmpconfig.h diff --git a/IR-Data/nec-repetition.txt b/IR-Data/nec-repetition.txt index f434b92..93fdc90 100644 --- a/IR-Data/nec-repetition.txt +++ b/IR-Data/nec-repetition.txt @@ -2,3 +2,7 @@ 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111110000001111100000001111000000011111111111111110000001111100000001111000000011111000000111110000001111111111111111000000011111111111111110000001111100000001111000000011111111111111110000001111111111111111000000011111111111111110000001111111111111111000000011111000000111110000000111111111111111000000011111111111111110000001111100000001111000000011111000000111110000001111100000001111111111111111000000111110000000111100000001111111111111111000000111111111111111100000001111111111111111000000111111111111111100000001111111111111111000000111111111111111 # rep: 00000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111000000011111111111111 +# rep: +00000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111000000011111111111111 +# rep: +00000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111000000011111111111111 diff --git a/README.txt b/README.txt index 2e2ade7..3e5520c 100644 --- a/README.txt +++ b/README.txt @@ -1,6 +1,8 @@ IRMP - Infrared Multi Protocol Decoder -------------------------------------- +Version: 1.0 + Dokumentation: http://www.mikrocontroller.net/articles/IRMP diff --git a/irmp.aps b/irmp.aps index 683f7a7..9ad8f4b 100644 --- a/irmp.aps +++ b/irmp.aps @@ -1 +1 @@ -irmp07-Jan-2010 20:23:4909-Mar-2010 09:29:34241007-Jan-2010 20:23:4944, 18, 0, 670AVR GCCdefault\irmp.elfC:\avr\irmp\AVR SimulatorATmega88.xmlfalseR00R01R02R03R04R05R06R07R08R09R10R11R12R13R14R15R16R17R18R19R20R21R22R23R24R25R26R27R28R29R30R31Auto000main.cirmp.cirmp.hdefault\irmp.lssdefault\irmp.mapdefaultNOatmega88111irmp.elfdefault\0-Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enumsdefault1C:\Program Files\WinAVR-20090313\bin\avr-gcc.exeC:\Program Files\WinAVR-20090313\utils\bin\make.exe00000main.c100001irmp.c1 +irmp07-Jan-2010 20:23:4929-Mar-2010 11:32:13241007-Jan-2010 20:23:4944, 18, 0, 670AVR GCCdefault\irmp.elfC:\avr\irmp\AVR SimulatorATmega88.xmlfalseR00R01R02R03R04R05R06R07R08R09R10R11R12R13R14R15R16R17R18R19R20R21R22R23R24R25R26R27R28R29R30R31Auto000main.cirmp.cirmp.hirmpconfig.hdefault\irmp.lssdefault\irmp.mapdefaultNOatmega88111irmp.elfdefault\0-Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enumsdefault1C:\Program Files\WinAVR-20090313\bin\avr-gcc.exeC:\Program Files\WinAVR-20090313\utils\bin\make.exe00000main.c100001irmp.c100002irmp.h100003irmpconfig.h1 diff --git a/irmp.c b/irmp.c index d9f1c1b..422082b 100644 --- a/irmp.c +++ b/irmp.c @@ -3,6 +3,8 @@ * * Copyright (c) 2009-2010 Frank Meyer - frank(at)fli4l.de * + * $Id: irmp.c,v 1.14 2010/03/29 09:33:29 fm Exp $ + * * ATMEGA88 @ 8 MHz * * Typical manufacturers: @@ -266,49 +268,7 @@ typedef unsigned int16 uint16_t; #endif // unix #include "irmp.h" - -/*--------------------------------------------------------------------------------------------------------------------------------------------------- - * Change settings from 1 to 0 if you want to disable one or more decoders. - * This saves program space. - * 1 enable decoder - * 0 disable decoder - *--------------------------------------------------------------------------------------------------------------------------------------------------- - */ -#define IRMP_SUPPORT_SIRCS_PROTOCOL 1 // flag: support SIRCS uses ~100 bytes -#define IRMP_SUPPORT_NEC_PROTOCOL 1 // flag: support NEC + APPLE uses ~250 bytes -#define IRMP_SUPPORT_SAMSUNG_PROTOCOL 1 // flag: support Samsung + Samsung32 uses ~250 bytes -#define IRMP_SUPPORT_MATSUSHITA_PROTOCOL 1 // flag: support Matsushita uses ~50 bytes -#define IRMP_SUPPORT_KASEIKYO_PROTOCOL 1 // flag: support Kaseikyo uses ~50 bytes -#define IRMP_SUPPORT_RECS80_PROTOCOL 1 // flag: support RECS80 uses ~50 bytes -#define IRMP_SUPPORT_RC5_PROTOCOL 1 // flag: support RC5 uses ~250 bytes -#define IRMP_SUPPORT_DENON_PROTOCOL 1 // flag: support DENON uses ~250 bytes -#define IRMP_SUPPORT_RC6_PROTOCOL 1 // flag: support RC6 uses ~200 bytes -#define IRMP_SUPPORT_RECS80EXT_PROTOCOL 1 // flag: support RECS80EXT uses ~50 bytes -#define IRMP_SUPPORT_NUBERT_PROTOCOL 1 // flag: support NUBERT uses ~50 bytes - -/*--------------------------------------------------------------------------------------------------------------------------------------------------- - * Change hardware pin here: - *--------------------------------------------------------------------------------------------------------------------------------------------------- - */ -#ifdef PIC_CCS_COMPILER // PIC CCS Compiler: - -#define IRMP_PIN PIN_B4 // use PB4 as IR input on PIC - -#else // AVR: - -#define IRMP_PORT PORTB -#define IRMP_DDR DDRB -#define IRMP_PIN PINB -#define IRMP_BIT 6 // use PB6 as IR input on AVR - -#define input(x) ((x) & (1 << IRMP_BIT)) -#endif - -/*--------------------------------------------------------------------------------------------------------------------------------------------------- - * Set IRMP_LOGGING to 1 if want to log data to UART with 9600Bd - *--------------------------------------------------------------------------------------------------------------------------------------------------- - */ -#define IRMP_LOGGING 0 // 1: log IR signal (scan), 0: do not (default) +#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 @@ -1649,18 +1609,15 @@ irmp_ISR (void) } else #endif // IRMP_SUPPORT_DENON_PROTOCOL - -#if IRMP_SUPPORT_NEC_PROTOCOL == 1 - if (irmp_param.protocol == IRMP_NEC_PROTOCOL && irmp_bit == 0) // repetition frame { - irmp_protocol = irmp_param.protocol; - irmp_address = last_irmp_address; // address is last address - irmp_command = last_irmp_command; // command is last command - irmp_flags |= IRMP_FLAG_REPETITION; - } - else +#if IRMP_SUPPORT_NEC_PROTOCOL == 1 + if (irmp_param.protocol == IRMP_NEC_PROTOCOL && irmp_bit == 0) // repetition frame + { + irmp_tmp_address = last_irmp_address; // address is last address + irmp_tmp_command = last_irmp_command; // command is last command + irmp_flags |= IRMP_FLAG_REPETITION; + } #endif // IRMP_SUPPORT_NEC_PROTOCOL - { irmp_protocol = irmp_param.protocol; irmp_address = irmp_tmp_address; // store address #if IRMP_SUPPORT_NEC_PROTOCOL == 1 diff --git a/irmp.h b/irmp.h index 4a0bfbd..960fdd0 100644 --- a/irmp.h +++ b/irmp.h @@ -3,6 +3,8 @@ * * Copyright (c) 2009-2010 Frank Meyer - frank(at)fli4l.de * + * $Id: irmp.h,v 1.11 2010/03/29 09:33:29 fm Exp $ + * * ATMEGA88 @ 8 MHz * * This program is free software; you can redistribute it and/or modify @@ -21,24 +23,22 @@ extern "C" #endif /*--------------------------------------------------------------------------------------------------------------------------------------------------- - * Change F_INTERRUPTS if you change the number of interrupts per second, F_INTERRUPTS should be in the range from 10000 to 15000 + * IR protocols *--------------------------------------------------------------------------------------------------------------------------------------------------- */ -#define F_INTERRUPTS 10000 // interrupts per second - -#define IRMP_SIRCS_PROTOCOL 1 // Sony -#define IRMP_NEC_PROTOCOL 2 // NEC, Pioneer, JVC, Toshiba, NoName etc. -#define IRMP_SAMSUNG_PROTOCOL 3 // Samsung -#define IRMP_MATSUSHITA_PROTOCOL 4 // Matsushita -#define IRMP_KASEIKYO_PROTOCOL 5 // Kaseikyo (Panasonic etc) -#define IRMP_RECS80_PROTOCOL 6 // Philips, Thomson, Nordmende, Telefunken, Saba -#define IRMP_RC5_PROTOCOL 7 // Philips etc -#define IRMP_DENON_PROTOCOL 8 // Denon -#define IRMP_RC6_PROTOCOL 9 // Philips etc -#define IRMP_SAMSUNG32_PROTOCOL 10 // Samsung32: no sync pulse at bit 16, length 32 instead of 37 -#define IRMP_APPLE_PROTOCOL 11 // Apple, very similar to NEC -#define IRMP_RECS80EXT_PROTOCOL 12 // Philips, Technisat, Thomson, Nordmende, Telefunken, Saba -#define IRMP_NUBERT_PROTOCOL 13 // Nubert +#define IRMP_SIRCS_PROTOCOL 1 // Sony +#define IRMP_NEC_PROTOCOL 2 // NEC, Pioneer, JVC, Toshiba, NoName etc. +#define IRMP_SAMSUNG_PROTOCOL 3 // Samsung +#define IRMP_MATSUSHITA_PROTOCOL 4 // Matsushita +#define IRMP_KASEIKYO_PROTOCOL 5 // Kaseikyo (Panasonic etc) +#define IRMP_RECS80_PROTOCOL 6 // Philips, Thomson, Nordmende, Telefunken, Saba +#define IRMP_RC5_PROTOCOL 7 // Philips etc +#define IRMP_DENON_PROTOCOL 8 // Denon +#define IRMP_RC6_PROTOCOL 9 // Philips etc +#define IRMP_SAMSUNG32_PROTOCOL 10 // Samsung32: no sync pulse at bit 16, length 32 instead of 37 +#define IRMP_APPLE_PROTOCOL 11 // Apple, very similar to NEC +#define IRMP_RECS80EXT_PROTOCOL 12 // Philips, Technisat, Thomson, Nordmende, Telefunken, Saba +#define IRMP_NUBERT_PROTOCOL 13 // Nubert #define SIRCS_START_BIT_PULSE_TIME 2400.0e-6 // 2400 usec pulse #define SIRCS_START_BIT_PAUSE_TIME 600.0e-6 // 600 usec pause diff --git a/irmpconfig.h b/irmpconfig.h new file mode 100644 index 0000000..1b86723 --- /dev/null +++ b/irmpconfig.h @@ -0,0 +1,69 @@ +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * irmpconfig.h + * + * Copyright (c) 2010 Frank Meyer - frank(at)fli4l.de + * + * $Id: irmpconfig.h,v 1.1 2010/03/29 09:35:13 fm Exp $ + * + * ATMEGA88 @ 8 MHz + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ + +#ifndef _IRMPCONFIG_H_ +#define _IRMPCONFIG_H_ + +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * Change F_INTERRUPTS if you change the number of interrupts per second, F_INTERRUPTS should be in the range from 10000 to 15000 + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ +#define F_INTERRUPTS 10000 // interrupts per second + +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * Change settings from 1 to 0 if you want to disable one or more decoders. + * This saves program space. + * 1 enable decoder + * 0 disable decoder + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ +#define IRMP_SUPPORT_SIRCS_PROTOCOL 1 // flag: support SIRCS uses ~100 bytes +#define IRMP_SUPPORT_NEC_PROTOCOL 1 // flag: support NEC + APPLE uses ~250 bytes +#define IRMP_SUPPORT_SAMSUNG_PROTOCOL 1 // flag: support Samsung + Samsung32 uses ~250 bytes +#define IRMP_SUPPORT_MATSUSHITA_PROTOCOL 1 // flag: support Matsushita uses ~50 bytes +#define IRMP_SUPPORT_KASEIKYO_PROTOCOL 1 // flag: support Kaseikyo uses ~50 bytes +#define IRMP_SUPPORT_RECS80_PROTOCOL 1 // flag: support RECS80 uses ~50 bytes +#define IRMP_SUPPORT_RC5_PROTOCOL 1 // flag: support RC5 uses ~250 bytes +#define IRMP_SUPPORT_DENON_PROTOCOL 1 // flag: support DENON uses ~250 bytes +#define IRMP_SUPPORT_RC6_PROTOCOL 1 // flag: support RC6 uses ~200 bytes +#define IRMP_SUPPORT_RECS80EXT_PROTOCOL 1 // flag: support RECS80EXT uses ~50 bytes +#define IRMP_SUPPORT_NUBERT_PROTOCOL 1 // flag: support NUBERT uses ~50 bytes + +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * Change hardware pin here: + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ +#ifdef PIC_CCS_COMPILER // PIC CCS Compiler: + +#define IRMP_PIN PIN_B4 // use PB4 as IR input on PIC + +#else // AVR: + +#define IRMP_PORT PORTB +#define IRMP_DDR DDRB +#define IRMP_PIN PINB +#define IRMP_BIT 6 // use PB6 as IR input on AVR + +#define input(x) ((x) & (1 << IRMP_BIT)) +#endif + +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * Set IRMP_LOGGING to 1 if want to log data to UART with 9600Bd + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ +#define IRMP_LOGGING 0 // 1: log IR signal (scan), 0: do not (default) + +#endif /* _WC_IRMPCONFIG_H_ */ diff --git a/main.c b/main.c index 2e05660..faab8ea 100644 --- a/main.c +++ b/main.c @@ -3,6 +3,8 @@ * * Copyright (c) 2009-2010 Frank Meyer - frank(at)fli4l.de * + * $Id: main.c,v 1.5 2010/03/29 09:33:29 fm Exp $ + * * ATMEGA88 @ 8 MHz * * Fuses: lfuse: 0xE2 hfuse: 0xDC efuse: 0xF9 @@ -45,6 +47,8 @@ #include #include #include "irmp.h" +#include "irmpconfig.h" + #endif // CODEVISION -- 2.39.2