From 956ea3ea733ead7da9cf5584b9a0dc1c1d98d548 Mon Sep 17 00:00:00 2001 From: ukw Date: Wed, 9 Jul 2014 15:10:15 +0000 Subject: [PATCH] Version 2.6.0: added SAMSUNG48 protocol (yet only in IRMP). git-svn-id: svn://mikrocontroller.net/irmp@139 aeb2e35e-bfc4-4214-b83c-9e8de998ed28 --- README.txt | 2 +- irmp.c | 62 ++++++++++++++++++++++++++++++++++++++++--------- irmp.h | 6 +++++ irmpconfig.h | 15 ++++++------ irmpprotocols.h | 19 +++++++++++---- irsnd.c | 4 ++-- 6 files changed, 82 insertions(+), 26 deletions(-) diff --git a/README.txt b/README.txt index cd004b0..e0e3684 100644 --- a/README.txt +++ b/README.txt @@ -1,7 +1,7 @@ IRMP - Infrared Multi Protocol Decoder -------------------------------------- -Version IRMP: 2.5.8 09.07.2014 +Version IRMP: 2.6.0 09.07.2014 Version IRSND: 2.5.4 23.06.2014 Dokumentation: diff --git a/irmp.c b/irmp.c index 0d71f30..cd12f29 100644 --- a/irmp.c +++ b/irmp.c @@ -3,7 +3,7 @@ * * Copyright (c) 2009-2013 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp.c,v 1.156 2014/07/09 07:12:56 fm Exp $ + * $Id: irmp.c,v 1.158 2014/07/09 15:03:49 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -542,6 +542,7 @@ irmp_protocol_names[IRMP_N_PROTOCOLS + 1] = "RCMM12", "SPEAKER", "LGAIR", + "SAMSG48", "RADIO1" }; @@ -1827,7 +1828,15 @@ irmp_get_data (IRMP_DATA * irmp_data_p) rtc = TRUE; } break; + +#if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1 + case IRMP_SAMSUNG48_PROTOCOL: + irmp_command = (irmp_command & 0x00FF) | ((irmp_id & 0x00FF) << 8); + rtc = TRUE; + break; +#endif #endif + #if IRMP_SUPPORT_NEC_PROTOCOL == 1 case IRMP_NEC_PROTOCOL: if ((irmp_command >> 8) == (~irmp_command & 0x00FF)) @@ -2001,7 +2010,7 @@ irmp_set_callback_ptr (void (*cb)(uint8_t)) static uint16_t irmp_tmp_address; // ir address static uint16_t irmp_tmp_command; // ir command -#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1) || IRMP_SUPPORT_NEC42_PROTOCOL == 1 +#if (IRMP_SUPPORT_RC5_PROTOCOL == 1 && (IRMP_SUPPORT_FDC_PROTOCOL == 1 || IRMP_SUPPORT_RCCAR_PROTOCOL == 1)) || IRMP_SUPPORT_NEC42_PROTOCOL == 1 static uint16_t irmp_tmp_address2; // ir address static uint16_t irmp_tmp_command2; // ir command #endif @@ -2097,7 +2106,16 @@ irmp_store_bit (uint8_t value) { if (irmp_param.lsb_first) { - irmp_tmp_command |= (((uint16_t) (value)) << (irmp_bit - irmp_param.command_offset)); // CV wants cast +#if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1 + if (irmp_param.protocol == IRMP_SAMSUNG48_PROTOCOL && irmp_bit >= 32) + { + irmp_tmp_id |= (((uint16_t) (value)) << (irmp_bit - 32)); // CV wants cast + } + else +#endif + { + irmp_tmp_command |= (((uint16_t) (value)) << (irmp_bit - irmp_param.command_offset)); // CV wants cast + } } else { @@ -3358,6 +3376,20 @@ irmp_ISR (void) } #endif // IRMP_SUPPORT_JVC_PROTOCOL == 1 #endif // IRMP_SUPPORT_NEC42_PROTOCOL == 1 + +#if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1 + else if (irmp_param.protocol == IRMP_SAMSUNG48_PROTOCOL && irmp_bit == 32) // it was a SAMSUNG32 stop bit + { +#ifdef ANALYZE + ANALYZE_PRINTF ("Switching to SAMSUNG32 protocol\n"); +#endif // ANALYZE + irmp_param.protocol = IRMP_SAMSUNG32_PROTOCOL; + irmp_param.command_offset = SAMSUNG32_COMMAND_OFFSET; + irmp_param.command_end = SAMSUNG32_COMMAND_OFFSET + SAMSUNG32_COMMAND_LEN; + irmp_param.complete_len = SAMSUNG32_COMPLETE_DATA_LEN; + } +#endif // IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 + #if IRMP_SUPPORT_RCMM_PROTOCOL == 1 else if (irmp_param.protocol == IRMP_RCMM32_PROTOCOL && (irmp_bit == 12 || irmp_bit == 24)) // it was a RCMM stop bit { @@ -3694,11 +3726,23 @@ irmp_ISR (void) } else if (irmp_pulse_time >= SAMSUNG_PULSE_LEN_MIN && irmp_pulse_time <= SAMSUNG_PULSE_LEN_MAX) { +#if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1 +#ifdef ANALYZE + ANALYZE_PRINTF ("Switching to SAMSUNG48 protocol "); +#endif // ANALYZE + irmp_param.protocol = IRMP_SAMSUNG48_PROTOCOL; + irmp_param.command_offset = SAMSUNG48_COMMAND_OFFSET; + irmp_param.command_end = SAMSUNG48_COMMAND_OFFSET + SAMSUNG48_COMMAND_LEN; + irmp_param.complete_len = SAMSUNG48_COMPLETE_DATA_LEN; +#else +#ifdef ANALYZE + ANALYZE_PRINTF ("Switching to SAMSUNG32 protocol "); +#endif // ANALYZE irmp_param.protocol = IRMP_SAMSUNG32_PROTOCOL; irmp_param.command_offset = SAMSUNG32_COMMAND_OFFSET; irmp_param.command_end = SAMSUNG32_COMMAND_OFFSET + SAMSUNG32_COMMAND_LEN; irmp_param.complete_len = SAMSUNG32_COMPLETE_DATA_LEN; - +#endif if (irmp_pause_time >= SAMSUNG_1_PAUSE_LEN_MIN && irmp_pause_time <= SAMSUNG_1_PAUSE_LEN_MAX) { #ifdef ANALYZE @@ -3717,10 +3761,6 @@ irmp_ISR (void) irmp_store_bit (0); wait_for_space = 0; } - -#ifdef ANALYZE - ANALYZE_PRINTF ("Switching to SAMSUNG32 protocol\n"); -#endif // ANALYZE } else { // timing incorrect! @@ -4032,11 +4072,11 @@ irmp_ISR (void) #endif #if IRMP_SUPPORT_SAMSUNG_PROTOCOL == 1 - // if SAMSUNG32 protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame - if (irmp_param.protocol == IRMP_SAMSUNG32_PROTOCOL && (repetition_frame_number & 0x01)) + // if SAMSUNG32 or SAMSUNG48 protocol and the code will be repeated within 50 ms, we will ignore every 2nd frame + if ((irmp_param.protocol == IRMP_SAMSUNG32_PROTOCOL || irmp_param.protocol == IRMP_SAMSUNG48_PROTOCOL) && (repetition_frame_number & 0x01)) { #ifdef ANALYZE - ANALYZE_PRINTF ("code skipped: SAMSUNG32 auto repetition frame #%d, counter = %d, auto repetition len = %d\n", + ANALYZE_PRINTF ("code skipped: SAMSUNG32/SAMSUNG48 auto repetition frame #%d, counter = %d, auto repetition len = %d\n", repetition_frame_number + 1, key_repetition_len, AUTO_FRAME_REPETITION_LEN); #endif // ANALYZE key_repetition_len = 0; diff --git a/irmp.h b/irmp.h index 2ff7766..f1ee081 100644 --- a/irmp.h +++ b/irmp.h @@ -128,6 +128,12 @@ # define IRMP_SUPPORT_LEGO_PROTOCOL 0 #endif +#if IRMP_SUPPORT_SAMSUNG48_PROTOCOL == 1 && IRMP_SUPPORT_SAMSUNG_PROTOCOL == 0 +# warning SAMSUNG48 protocol needs also SAMSUNG protocol, SAMSUNG protocol enabled +# undef IRMP_SUPPORT_SAMSUNG_PROTOCOL +# define IRMP_SUPPORT_SAMSUNG_PROTOCOL 1 +#endif + #if IRMP_SUPPORT_JVC_PROTOCOL == 1 && IRMP_SUPPORT_NEC_PROTOCOL == 0 # warning JVC protocol needs also NEC protocol, NEC protocol enabled # undef IRMP_SUPPORT_NEC_PROTOCOL diff --git a/irmpconfig.h b/irmpconfig.h index 5754453..aeead17 100644 --- a/irmpconfig.h +++ b/irmpconfig.h @@ -5,7 +5,7 @@ * * Copyright (c) 2009-2013 Frank Meyer - frank(at)fli4l.de * - * $Id: irmpconfig.h,v 1.111 2014/07/01 20:08:20 fm Exp $ + * $Id: irmpconfig.h,v 1.113 2014/07/09 15:03:49 fm Exp $ * * ATMEGA88 @ 8 MHz * @@ -53,17 +53,17 @@ // typical protocols, disable here! Enable Remarks F_INTERRUPTS Program Space #define IRMP_SUPPORT_SIRCS_PROTOCOL 1 // Sony SIRCS >= 10000 ~150 bytes #define IRMP_SUPPORT_NEC_PROTOCOL 1 // NEC + APPLE >= 10000 ~300 bytes -#define IRMP_SUPPORT_SAMSUNG_PROTOCOL 1 // Samsung + Samsung32 >= 10000 ~300 bytes -#define IRMP_SUPPORT_MATSUSHITA_PROTOCOL 1 // Matsushita >= 10000 ~50 bytes +#define IRMP_SUPPORT_SAMSUNG_PROTOCOL 1 // Samsung + Samsg32 >= 10000 ~300 bytes #define IRMP_SUPPORT_KASEIKYO_PROTOCOL 1 // Kaseikyo >= 10000 ~250 bytes // more protocols, enable here! Enable Remarks F_INTERRUPTS Program Space -#define IRMP_SUPPORT_DENON_PROTOCOL 0 // DENON, Sharp >= 10000 ~250 bytes -#define IRMP_SUPPORT_RC5_PROTOCOL 0 // RC5 >= 10000 ~250 bytes -#define IRMP_SUPPORT_RC6_PROTOCOL 0 // RC6 & RC6A >= 10000 ~250 bytes #define IRMP_SUPPORT_JVC_PROTOCOL 0 // JVC >= 10000 ~150 bytes #define IRMP_SUPPORT_NEC16_PROTOCOL 0 // NEC16 >= 10000 ~100 bytes #define IRMP_SUPPORT_NEC42_PROTOCOL 0 // NEC42 >= 10000 ~300 bytes +#define IRMP_SUPPORT_MATSUSHITA_PROTOCOL 0 // Matsushita >= 10000 ~50 bytes +#define IRMP_SUPPORT_DENON_PROTOCOL 0 // DENON, Sharp >= 10000 ~250 bytes +#define IRMP_SUPPORT_RC5_PROTOCOL 0 // RC5 >= 10000 ~250 bytes +#define IRMP_SUPPORT_RC6_PROTOCOL 0 // RC6 & RC6A >= 10000 ~250 bytes #define IRMP_SUPPORT_IR60_PROTOCOL 0 // IR60 (SDA2008) >= 10000 ~300 bytes #define IRMP_SUPPORT_GRUNDIG_PROTOCOL 0 // Grundig >= 10000 ~300 bytes #define IRMP_SUPPORT_SIEMENS_PROTOCOL 0 // Siemens Gigaset >= 15000 ~550 bytes @@ -90,7 +90,8 @@ #define IRMP_SUPPORT_LEGO_PROTOCOL 0 // LEGO Power RC >= 20000 ~150 bytes #define IRMP_SUPPORT_RCMM_PROTOCOL 0 // RCMM 12,24, or 32 >= 20000 ~150 bytes #define IRMP_SUPPORT_LGAIR_PROTOCOL 0 // LG Air Condition >= 10000 ~300 bytes -#define IRMP_SUPPORT_RADIO1_PROTOCOL 0 // RADIO, e.g. TEVION >= 10000 ~250 bytes +#define IRMP_SUPPORT_SAMSUNG48_PROTOCOL 0 // Samsung48 >= 10000 ~100 bytes (SAMSUNG must be enabled!) +#define IRMP_SUPPORT_RADIO1_PROTOCOL 0 // RADIO, e.g. TEVION >= 10000 ~250 bytes (experimental) /*--------------------------------------------------------------------------------------------------------------------------------------------------- * Change hardware pin here for ATMEL AVR diff --git a/irmpprotocols.h b/irmpprotocols.h index ad0abb0..0f66c9c 100644 --- a/irmpprotocols.h +++ b/irmpprotocols.h @@ -5,7 +5,7 @@ * * Copyright (c) 2013 Frank Meyer - frank(at)fli4l.de * - * $Id: irmpprotocols.h,v 1.24 2014/06/06 09:58:32 fm Exp $ + * $Id: irmpprotocols.h,v 1.25 2014/07/09 14:45:56 fm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -65,9 +65,11 @@ #define IRMP_RCMM12_PROTOCOL 38 // Fujitsu-Siemens (Activy keyboard) #define IRMP_SPEAKER_PROTOCOL 39 // Another loudspeaker protocol, similar to Nubert #define IRMP_LGAIR_PROTOCOL 40 // LG air conditioner -#define IRMP_RADIO1_PROTOCOL 41 // Radio protocol (experimental status), do not use it yet! +#define IRMP_SAMSUNG48_PROTOCOL 41 // air conditioner with SAMSUNG protocol (48 bits) -#define IRMP_N_PROTOCOLS 41 // number of supported protocols +#define IRMP_RADIO1_PROTOCOL 42 // Radio protocol (experimental status), do not use it yet! + +#define IRMP_N_PROTOCOLS 42 // number of supported protocols /*--------------------------------------------------------------------------------------------------------------------------------------------------- * timing constants: @@ -161,7 +163,7 @@ typedef uint8_t PAUSE_LEN; #define NEC16_COMPLETE_DATA_LEN 16 // complete length /*--------------------------------------------------------------------------------------------------------------------------------------------------- - * SAMSUNG & SAMSUNG32: + * SAMSUNG & SAMSUNG32 & SAMSUNG48: *--------------------------------------------------------------------------------------------------------------------------------------------------- */ #define SAMSUNG_START_BIT_PULSE_TIME 4500.0e-6 // 4500 usec pulse @@ -185,10 +187,17 @@ typedef uint8_t PAUSE_LEN; #define SAMSUNG32_COMMAND_OFFSET 16 // skip 16 bits #define SAMSUNG32_COMMAND_LEN 16 // read 16 command bits #define SAMSUNG32_COMPLETE_DATA_LEN 32 // complete length -#define SAMSUNG32_FRAMES 1 // SAMSUNG32 sends each frame 1 times +#define SAMSUNG32_FRAMES 2 // SAMSUNG32 sends each frame 2 times // fm: correct? #define SAMSUNG32_AUTO_REPETITION_PAUSE_TIME 47.0e-3 // repetition after 47 ms #define SAMSUNG32_FRAME_REPEAT_PAUSE_TIME 47.0e-3 // frame repeat after 47ms +#define SAMSUNG48_COMMAND_OFFSET 16 // skip 16 bits +#define SAMSUNG48_COMMAND_LEN 32 // read 32 command bits +#define SAMSUNG48_COMPLETE_DATA_LEN 48 // complete length +#define SAMSUNG48_FRAMES 2 // SAMSUNG48 sends each frame 2 times +#define SAMSUNG48_AUTO_REPETITION_PAUSE_TIME 5.0e-3 // repetition after 5 ms +#define SAMSUNG48_FRAME_REPEAT_PAUSE_TIME 47.0e-3 // frame repeat after 47ms + /*--------------------------------------------------------------------------------------------------------------------------------------------------- * MATSUSHITA: *--------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/irsnd.c b/irsnd.c index 554e264..4b276d6 100644 --- a/irsnd.c +++ b/irsnd.c @@ -13,7 +13,7 @@ * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284, ATmega1284P * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P * - * $Id: irsnd.c,v 1.76 2014/06/23 06:56:00 fm Exp $ + * $Id: irsnd.c,v 1.77 2014/07/09 14:45:56 fm Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1489,7 +1489,7 @@ irsnd_ISR (void) pause_0_len = SAMSUNG_0_PAUSE_LEN - 1; has_stop_bit = SAMSUNG_STOP_BIT; complete_data_len = SAMSUNG32_COMPLETE_DATA_LEN; - n_auto_repetitions = SAMSUNG32_FRAMES; // 2 frames + n_auto_repetitions = SAMSUNG32_FRAMES; // 1 frame auto_repetition_pause_len = SAMSUNG32_AUTO_REPETITION_PAUSE_LEN; // 47 ms pause repeat_frame_pause_len = SAMSUNG32_FRAME_REPEAT_PAUSE_LEN; irsnd_set_freq (IRSND_FREQ_38_KHZ); -- 2.39.2