From 7365350cfc3f5406c68411a2eafe97dadaa08444 Mon Sep 17 00:00:00 2001 From: ukw Date: Fri, 9 Sep 2016 08:04:05 +0000 Subject: [PATCH] Version 3.0.2 git-svn-id: svn://mikrocontroller.net/irmp@177 aeb2e35e-bfc4-4214-b83c-9e8de998ed28 --- README.txt | 4 +- irmp-main-avr-uart.c | 4 +- irmp-main-avr.c | 4 +- irmp-main-esp8266.c | 2 + irmp-main-pic-12F1840.c | 4 +- irmp-main-pic-xc8.c | 4 +- irmp-main-stm32.c | 4 +- irmp.c | 147 ++++++++++++++++++++++++++++++++++++---- irmp.h | 11 ++- irmpconfig.h | 5 +- irmpprotocols.h | 61 +++++++++++------ irmpsystem.h | 14 +++- irsnd-main-avr.c | 4 +- irsnd.c | 86 +++++++++++++++++++---- irsnd.h | 4 +- irsndconfig.h | 5 +- 16 files changed, 290 insertions(+), 73 deletions(-) diff --git a/README.txt b/README.txt index bb4647c..ca88fd7 100644 --- a/README.txt +++ b/README.txt @@ -1,8 +1,8 @@ IRMP - Infrared Multi Protocol Decoder -------------------------------------- -Version IRMP: 3.0.0 2016-01-12 -Version IRSND: 3.0.0 2016-01-12 +Version IRMP: 3.0.2 2016-09-09 +Version IRSND: 3.0.2 2016-09-09 Documentation: diff --git a/irmp-main-avr-uart.c b/irmp-main-avr-uart.c index 4b95dfd..7260a72 100644 --- a/irmp-main-avr-uart.c +++ b/irmp-main-avr-uart.c @@ -1,9 +1,9 @@ /*--------------------------------------------------------------------------------------------------------------------------------------------------- - * irmp-main-avr-uart.cpp - demo main module to test IRMP decoder on AVR with UART + * irmp-main-avr-uart.c - demo main module to test IRMP decoder on AVR with UART * * Copyright (c) 2009-2016 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp-main-avr-uart.c,v 1.1 2016/01/12 11:55:05 fm Exp $ + * $Id: irmp-main-avr-uart.c,v 1.2 2016/09/09 08:01:11 fm Exp $ * * This demo module is runnable on AVRs with UART * diff --git a/irmp-main-avr.c b/irmp-main-avr.c index 9cbdbf8..caf6286 100644 --- a/irmp-main-avr.c +++ b/irmp-main-avr.c @@ -1,9 +1,9 @@ /*--------------------------------------------------------------------------------------------------------------------------------------------------- * irmp-main-avr.c - demo main module to test IRMP decoder on AVR * - * Copyright (c) 2009-2017 Frank Meyer - frank(at)fli4l.de + * Copyright (c) 2009-2016 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp-main-avr.c,v 1.1 2016/01/12 11:55:05 fm Exp $ + * $Id: irmp-main-avr.c,v 1.2 2016/01/12 21:15:16 fm Exp $ * * This demo module is runnable on AVRs * diff --git a/irmp-main-esp8266.c b/irmp-main-esp8266.c index 65124cb..caa28e4 100644 --- a/irmp-main-esp8266.c +++ b/irmp-main-esp8266.c @@ -2,6 +2,8 @@ Test program IRMP for ESP8266 2015-11-16 Wolfgang Strobl, Bonn +$Id: irmp-main-esp8266.c,v 1.2 2016/01/12 21:15:16 fm Exp $ + IRMP ported to ESP8266, testet with MOD-WIFI-ESP8266-DEV on ESP8266-EVB evaluation board. https://www.olimex.com/Products/IoT/ESP8266-EVB/ diff --git a/irmp-main-pic-12F1840.c b/irmp-main-pic-12F1840.c index 235105e..821e9e5 100644 --- a/irmp-main-pic-12F1840.c +++ b/irmp-main-pic-12F1840.c @@ -1,10 +1,12 @@ /*--------------------------------------------------------------------------------------------------------------------------------------------------- - * main_pic12f1840.c - example main module for PIC 12f1840 + * irmp-main-pic-12F1840.c - example main module for PIC 12f1840 * * IR decoder using IRMP * * (c) 2014 Wolfgang Strobl (news4 at mystrobl.de) 2014-03-12:2014-07-20 * + * $Id: irmp-main-pic-12F1840.c,v 1.4 2016/09/09 08:01:11 fm Exp $ + * * This demo module is runnable on a Microchip PIC 12F1840 * * To be used with IRMP by Frank Meyer (frank(at)fli4l.de) diff --git a/irmp-main-pic-xc8.c b/irmp-main-pic-xc8.c index 579a4af..2d78327 100644 --- a/irmp-main-pic-xc8.c +++ b/irmp-main-pic-xc8.c @@ -1,9 +1,9 @@ /*--------------------------------------------------------------------------------------------------------------------------------------------------- - * main.c - demo main module to test IRMP decoder on PIC18F4520 with XC8 compiler + * irmp-main-pic-xc8.c - demo main module to test IRMP decoder on PIC18F4520 with XC8 compiler * * Copyright (c) 2009-2016 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp-main-pic-xc8.c,v 1.1 2016/01/12 11:55:05 fm Exp $ + * $Id: irmp-main-pic-xc8.c,v 1.2 2016/09/09 08:01:11 fm Exp $ * * This demo module is runnable on PIC18F4520 with XC8 compiler * diff --git a/irmp-main-stm32.c b/irmp-main-stm32.c index ddc293c..671b117 100644 --- a/irmp-main-stm32.c +++ b/irmp-main-stm32.c @@ -1,9 +1,9 @@ /*--------------------------------------------------------------------------------------------------------------------------------------------------- * irmp-main-stm32.c - demo main module to test IRMP decoder on STM32 * - * Copyright (c) 2009-2015 Frank Meyer - frank(at)fli4l.de + * Copyright (c) 2009-2016 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp-main-stm32.c,v 1.1 2016/01/12 11:55:05 fm Exp $ + * $Id: irmp-main-stm32.c,v 1.2 2016/01/12 21:15:16 fm Exp $ * * This demo module is runnable on STM32 * diff --git a/irmp.c b/irmp.c index 3895bba..3b97afc 100644 --- a/irmp.c +++ b/irmp.c @@ -1,9 +1,9 @@ /*--------------------------------------------------------------------------------------------------------------------------------------------------- * irmp.c - infrared multi-protocol decoder, supports several remote control protocols * - * Copyright (c) 2009-2015 Frank Meyer - frank(at)fli4l.de + * Copyright (c) 2009-2016 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp.c,v 1.184 2016/01/12 11:53:34 fm Exp $ + * $Id: irmp.c,v 1.187 2016/09/09 07:53:29 fm Exp $ * * Supported AVR mikrocontrollers: * @@ -162,6 +162,17 @@ #define KASEIKYO_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) #define KASEIKYO_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * KASEIKYO_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define MITSU_HEAVY_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define MITSU_HEAVY_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define MITSU_HEAVY_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) +#define MITSU_HEAVY_START_BIT_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_START_BIT_PAUSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) +#define MITSU_HEAVY_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_PULSE_TIME * MIN_TOLERANCE_40 + 0.5) - 1) +#define MITSU_HEAVY_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_PULSE_TIME * MAX_TOLERANCE_40 + 0.5) + 1) +#define MITSU_HEAVY_1_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_1_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define MITSU_HEAVY_1_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_1_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) +#define MITSU_HEAVY_0_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_0_PAUSE_TIME * MIN_TOLERANCE_20 + 0.5) - 1) +#define MITSU_HEAVY_0_PAUSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * MITSU_HEAVY_0_PAUSE_TIME * MAX_TOLERANCE_20 + 0.5) + 1) + #define PANASONIC_START_BIT_PULSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PULSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) #define PANASONIC_START_BIT_PULSE_LEN_MAX ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PULSE_TIME * MAX_TOLERANCE_10 + 0.5) + 1) #define PANASONIC_START_BIT_PAUSE_LEN_MIN ((uint_fast8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PAUSE_TIME * MIN_TOLERANCE_10 + 0.5) - 1) @@ -623,6 +634,7 @@ static const char proto_s100[] PROGMEM = "S100"; static const char proto_acp24[] PROGMEM = "ACP24"; static const char proto_technics[] PROGMEM = "TECHNICS"; static const char proto_panasonic[] PROGMEM = "PANASONIC"; +static const char proto_mitsu_heavy[] PROGMEM = "MITSU_HEAVY"; static const char proto_radio1[] PROGMEM = "RADIO1"; @@ -678,6 +690,7 @@ irmp_protocol_names[IRMP_N_PROTOCOLS + 1] PROGMEM = proto_acp24, proto_technics, proto_panasonic, + proto_mitsu_heavy, proto_radio1 }; @@ -1298,6 +1311,31 @@ static const PROGMEM IRMP_PARAMETER panasonic_param = #endif +#if IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL == 1 + +static const PROGMEM IRMP_PARAMETER mitsu_heavy_param = +{ + IRMP_MITSU_HEAVY_PROTOCOL, // protocol: ir protocol + MITSU_HEAVY_PULSE_LEN_MIN, // pulse_1_len_min: minimum length of pulse with bit value 1 + MITSU_HEAVY_PULSE_LEN_MAX, // pulse_1_len_max: maximum length of pulse with bit value 1 + MITSU_HEAVY_1_PAUSE_LEN_MIN, // pause_1_len_min: minimum length of pause with bit value 1 + MITSU_HEAVY_1_PAUSE_LEN_MAX, // pause_1_len_max: maximum length of pause with bit value 1 + MITSU_HEAVY_PULSE_LEN_MIN, // pulse_0_len_min: minimum length of pulse with bit value 0 + MITSU_HEAVY_PULSE_LEN_MAX, // pulse_0_len_max: maximum length of pulse with bit value 0 + MITSU_HEAVY_0_PAUSE_LEN_MIN, // pause_0_len_min: minimum length of pause with bit value 0 + MITSU_HEAVY_0_PAUSE_LEN_MAX, // pause_0_len_max: maximum length of pause with bit value 0 + MITSU_HEAVY_ADDRESS_OFFSET, // address_offset: address offset + MITSU_HEAVY_ADDRESS_OFFSET + MITSU_HEAVY_ADDRESS_LEN, // address_end: end of address + MITSU_HEAVY_COMMAND_OFFSET, // command_offset: command offset + MITSU_HEAVY_COMMAND_OFFSET + MITSU_HEAVY_COMMAND_LEN, // command_end: end of command + MITSU_HEAVY_COMPLETE_DATA_LEN, // complete_len: complete length of frame + MITSU_HEAVY_STOP_BIT, // stop_bit: flag: frame has stop bit + MITSU_HEAVY_LSB, // lsb_first: flag: LSB first + MITSU_HEAVY_FLAGS // flags: some flags +}; + +#endif + #if IRMP_SUPPORT_RECS80_PROTOCOL == 1 static const PROGMEM IRMP_PARAMETER recs80_param = @@ -2338,6 +2376,11 @@ static uint_fast8_t genre2; // s static uint_fast8_t parity; // number of '1' of the first 14 bits, check if even. #endif +#if IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL == 1 +static uint_fast8_t check; // number of '1' of the first 14 bits, check if even. +static uint_fast8_t mitsu_parity; // number of '1' of the first 14 bits, check if even. +#endif + /*--------------------------------------------------------------------------------------------------------------------------------------------------- * store bit * @details store bit in temp address or temp command @@ -2511,11 +2554,11 @@ irmp_store_bit (uint_fast8_t value) { if (irmp_bit >= 20 && irmp_bit < 24) { - irmp_tmp_command |= (((uint_fast16_t) (value)) << (irmp_bit - 8)); // store 4 system bits (genre 1) in upper nibble with LSB first + irmp_tmp_command |= (((uint_fast16_t) (value)) << (irmp_bit - 8)); // store 4 system bits (genre 1) in upper nibble with LSB first } else if (irmp_bit >= 24 && irmp_bit < 28) { - genre2 |= (((uint_fast8_t) (value)) << (irmp_bit - 20)); // store 4 system bits (genre 2) in upper nibble with LSB first + genre2 |= (((uint_fast8_t) (value)) << (irmp_bit - 20)); // store 4 system bits (genre 2) in upper nibble with LSB first } if (irmp_bit < KASEIKYO_COMPLETE_DATA_LEN) @@ -2532,6 +2575,47 @@ irmp_store_bit (uint_fast8_t value) } else #endif + +#if IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL == 1 + if (irmp_param.protocol == IRMP_MITSU_HEAVY_PROTOCOL) // squeeze 64 bits into 16 bits: + { + if (irmp_bit == 72 ) + { // irmp_tmp_address, irmp_tmp_command received: check parity & compress + mitsu_parity = PARITY_CHECK_OK; + + check = irmp_tmp_address >> 8; // inverted upper byte == lower byte? + check = ~ check; + + if (check == (irmp_tmp_address & 0xFF)) + { // ok: + irmp_tmp_address <<= 8; // throw away upper byte + } + else + { + mitsu_parity = PARITY_CHECK_FAILED; + } + + check = irmp_tmp_command >> 8; // inverted upper byte == lower byte? + check = ~ check; + if (check == (irmp_tmp_command & 0xFF)) + { // ok: pack together + irmp_tmp_address |= irmp_tmp_command & 0xFF; // byte 1, byte2 in irmp_tmp_address, irmp_tmp_command can be used for byte 3 + } + else + { + mitsu_parity = PARITY_CHECK_FAILED; + } + irmp_tmp_command = 0; + } + + if (irmp_bit >= 72 ) + { // receive 3. word in irmp_tmp_command + irmp_tmp_command <<= 1; + irmp_tmp_command |= value; + } + } + else +#endif // IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL { ; } @@ -2968,6 +3052,20 @@ irmp_ISR (void) else #endif // IRMP_SUPPORT_PANASONIC_PROTOCOL == 1 +#if IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL == 1 + if (irmp_pulse_time >= MITSU_HEAVY_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= MITSU_HEAVY_START_BIT_PULSE_LEN_MAX && + irmp_pause_time >= MITSU_HEAVY_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= MITSU_HEAVY_START_BIT_PAUSE_LEN_MAX) + { // it's MITSU_HEAVY +#ifdef ANALYZE + ANALYZE_PRINTF ("protocol = MITSU_HEAVY, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n", + MITSU_HEAVY_START_BIT_PULSE_LEN_MIN, MITSU_HEAVY_START_BIT_PULSE_LEN_MAX, + MITSU_HEAVY_START_BIT_PAUSE_LEN_MIN, MITSU_HEAVY_START_BIT_PAUSE_LEN_MAX); +#endif // ANALYZE + irmp_param_p = (IRMP_PARAMETER *) &mitsu_heavy_param; + } + else +#endif // IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL == 1 + #if IRMP_SUPPORT_RADIO1_PROTOCOL == 1 if (irmp_pulse_time >= RADIO1_START_BIT_PULSE_LEN_MIN && irmp_pulse_time <= RADIO1_START_BIT_PULSE_LEN_MAX && irmp_pause_time >= RADIO1_START_BIT_PAUSE_LEN_MIN && irmp_pause_time <= RADIO1_START_BIT_PAUSE_LEN_MAX) @@ -4774,6 +4872,25 @@ irmp_ISR (void) } #endif // IRMP_SUPPORT_ORTEK_PROTOCOL == 1 +#if IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL == 1 + if (irmp_param.protocol == IRMP_MITSU_HEAVY_PROTOCOL) + { + check = irmp_tmp_command >> 8; // inverted upper byte == lower byte? + check = ~ check; + if (check == (irmp_tmp_command & 0xFF)) { //ok: + irmp_tmp_command &= 0xFF; + } + else mitsu_parity = PARITY_CHECK_FAILED; + if (mitsu_parity == PARITY_CHECK_FAILED) + { +#ifdef ANALYZE + ANALYZE_PRINTF ("error 7: parity check failed\n"); +#endif // ANALYZE + irmp_ir_detected = FALSE; + } + } +#endif // IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL + #if IRMP_SUPPORT_RC6_PROTOCOL == 1 if (irmp_param.protocol == IRMP_RC6_PROTOCOL && irmp_param.complete_len == RC6_COMPLETE_DATA_LEN_LONG) // RC6 mode = 6? { @@ -5013,16 +5130,16 @@ get_fdc_key (uint_fast16_t cmd) { static uint8_t key_table[128] = { - // 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, '^', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 0xDF, '´', 0, '\b', - '\t', 'q', 'w', 'e', 'r', 't', 'z', 'u', 'i', 'o', 'p', 0xFC, '+', 0, 0, 'a', - 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 0xF6, 0xE4, '#', '\r', 0, '<', 'y', 'x', - 'c', 'v', 'b', 'n', 'm', ',', '.', '-', 0, 0, 0, 0, 0, ' ', 0, 0, - - 0, '°', '!', '"', '§', '$', '%', '&', '/', '(', ')', '=', '?', '`', 0, '\b', - '\t', 'Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I', 'O', 'P', 0xDC, '*', 0, 0, 'A', - 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 0xD6, 0xC4, '\'', '\r', 0, '>', 'Y', 'X', - 'C', 'V', 'B', 'N', 'M', ';', ':', '_', 0, 0, 0, 0, 0, ' ', 0, 0 + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + 0, '^', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 0xDF, '´', 0, '\b', + '\t', 'q', 'w', 'e', 'r', 't', 'z', 'u', 'i', 'o', 'p', 0xFC, '+', 0, 0, 'a', + 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 0xF6, 0xE4, '#', '\r', 0, '<', 'y', 'x', + 'c', 'v', 'b', 'n', 'm', ',', '.', '-', 0, 0, 0, 0, 0, ' ', 0, 0, + + 0, '°', '!', '"', '§', '$', '%', '&', '/', '(', ')', '=', '?', '`', 0, '\b', + '\t', 'Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I', 'O', 'P', 0xDC, '*', 0, 0, 'A', + 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 0xD6, 0xC4, '\'', '\r', 0, '>', 'Y', 'X', + 'C', 'V', 'B', 'N', 'M', ';', ':', '_', 0, 0, 0, 0, 0, ' ', 0, 0 }; static uint_fast8_t state; @@ -5069,7 +5186,7 @@ get_fdc_key (uint_fast16_t cmd) { switch (cmd) { - case 0x0003: key = '²'; break; + case 0x0003: key = 0xB2; break; // upper 2 case 0x0008: key = '{'; break; case 0x0009: key = '['; break; case 0x000A: key = ']'; break; diff --git a/irmp.h b/irmp.h index c305fab..ded7e80 100644 --- a/irmp.h +++ b/irmp.h @@ -1,9 +1,9 @@ /*--------------------------------------------------------------------------------------------------------------------------------------------------- * irmp.h * - * Copyright (c) 2009-2015 Frank Meyer - frank(at)fli4l.de + * Copyright (c) 2009-2016 Frank Meyer - frank(at)fli4l.de * - * $Id: irmp.h,v 1.101 2015/11/18 08:27:50 fm Exp $ + * $Id: irmp.h,v 1.103 2016/09/09 07:53:29 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 @@ -121,6 +121,13 @@ # define IRMP_SUPPORT_ROOMBA_PROTOCOL 0 #endif +#if IRMP_SUPPORT_PANASONIC_PROTOCOL == 1 && IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL == 1 +# warning PANASONIC protocol conflicts wih MITSU_HEAVY, please enable only one of both protocols +# warning MITSU_HEAVY protocol disabled +# undef IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL +# define IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL 0 +#endif + #if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_ORTEK_PROTOCOL == 1 # warning RC5 protocol conflicts wih ORTEK, please enable only one of both protocols # warning ORTEK protocol disabled diff --git a/irmpconfig.h b/irmpconfig.h index 35caa8c..61c14a9 100644 --- a/irmpconfig.h +++ b/irmpconfig.h @@ -3,10 +3,10 @@ * * DO NOT INCLUDE THIS FILE, WILL BE INCLUDED BY IRMP.H! * - * Copyright (c) 2009-2015 Frank Meyer - frank(at)fli4l.de + * Copyright (c) 2009-2016 Frank Meyer - frank(at)fli4l.de * Extensions for PIC 12F1820 W.Strobl 2014-07-20 * - * $Id: irmpconfig.h,v 1.146 2016/01/12 11:53:34 fm Exp $ + * $Id: irmpconfig.h,v 1.148 2016/09/09 07:53:29 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 @@ -97,6 +97,7 @@ #define IRMP_SUPPORT_ACP24_PROTOCOL 0 // ACP24 >= 10000 ~250 bytes #define IRMP_SUPPORT_TECHNICS_PROTOCOL 0 // TECHNICS >= 10000 ~250 bytes #define IRMP_SUPPORT_PANASONIC_PROTOCOL 0 // PANASONIC Beamer >= 10000 ~250 bytes +#define IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL 0 // Mitsubishi Aircond >= 10000 ~250 bytes #define IRMP_SUPPORT_RADIO1_PROTOCOL 0 // RADIO, e.g. TEVION >= 10000 ~250 bytes (experimental) /*--------------------------------------------------------------------------------------------------------------------------------------------------- diff --git a/irmpprotocols.h b/irmpprotocols.h index 0e6a020..a742d6d 100644 --- a/irmpprotocols.h +++ b/irmpprotocols.h @@ -3,9 +3,9 @@ * * DO NOT INCLUDE THIS FILE, WILL BE INCLUDED BY IRMP.H or IRSND.H! * - * Copyright (c) 2013-2015 Frank Meyer - frank(at)fli4l.de + * Copyright (c) 2013-2016 Frank Meyer - frank(at)fli4l.de * - * $Id: irmpprotocols.h,v 1.44 2015/11/30 09:31:54 fm Exp $ + * $Id: irmpprotocols.h,v 1.46 2016/09/09 07:53:29 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 @@ -73,10 +73,11 @@ #define IRMP_ACP24_PROTOCOL 46 // Stiebel Eltron ACP24 air conditioner #define IRMP_TECHNICS_PROTOCOL 47 // Technics, similar to Matsushita, but 22 instead of 24 bits #define IRMP_PANASONIC_PROTOCOL 48 // Panasonic (Beamer), start bits similar to KASEIKYO +#define IRMP_MITSU_HEAVY_PROTOCOL 49 // Mitsubishi-Heavy Aircondition, similar timing as Panasonic beamer -#define IRMP_RADIO1_PROTOCOL 49 // Radio protocol (experimental status), do not use it yet! +#define IRMP_RADIO1_PROTOCOL 50 // Radio protocol (experimental status), do not use it yet! -#define IRMP_N_PROTOCOLS 50 // number of supported protocols +#define IRMP_N_PROTOCOLS 51 // number of supported protocols /*--------------------------------------------------------------------------------------------------------------------------------------------------- * timing constants: @@ -257,22 +258,42 @@ typedef uint8_t PAUSE_LEN; * PANASONIC (Beamer), start bit timings similar to KASEIKYO *--------------------------------------------------------------------------------------------------------------------------------------------------- */ -#define PANASONIC_START_BIT_PULSE_TIME 3600.0e-6 // 3600 usec pulse -#define PANASONIC_START_BIT_PAUSE_TIME 1600.0e-6 // 1690 usec pause -#define PANASONIC_PULSE_TIME 565.0e-6 // 565 usec pulse -#define PANASONIC_1_PAUSE_TIME 1140.0e-6 // 1140 usec pause -#define PANASONIC_0_PAUSE_TIME 316.0e-6 // 316 usec pause -#define PANASONIC_AUTO_REPETITION_PAUSE_TIME 40.0e-3 // repetition after 40 ms? -#define PANASONIC_FRAME_REPEAT_PAUSE_TIME 40.0e-3 // frame repeat after 40 ms -#define PANASONIC_ADDRESS_OFFSET 24 // skip 24 bits: 010000000000010000000001 -#define PANASONIC_ADDRESS_LEN 16 // read 16 address bits -#define PANASONIC_COMMAND_OFFSET 40 // skip 40 bits -#define PANASONIC_COMMAND_LEN 16 // read 16 command bits -#define PANASONIC_COMPLETE_DATA_LEN 56 // complete length -#define PANASONIC_STOP_BIT 1 // has stop bit -#define PANASONIC_LSB 1 // LSB...MSB? -#define PANASONIC_FRAMES 1 // PANASONIC sends 1 frame -#define PANASONIC_FLAGS 0 // flags +#define PANASONIC_START_BIT_PULSE_TIME 3600.0e-6 // 3600 usec pulse +#define PANASONIC_START_BIT_PAUSE_TIME 1600.0e-6 // 1690 usec pause +#define PANASONIC_PULSE_TIME 565.0e-6 // 565 usec pulse +#define PANASONIC_1_PAUSE_TIME 1140.0e-6 // 1140 usec pause +#define PANASONIC_0_PAUSE_TIME 316.0e-6 // 316 usec pause +#define PANASONIC_AUTO_REPETITION_PAUSE_TIME 40.0e-3 // repetition after 40 ms? +#define PANASONIC_FRAME_REPEAT_PAUSE_TIME 40.0e-3 // frame repeat after 40 ms +#define PANASONIC_ADDRESS_OFFSET 24 // skip 24 bits: 010000000000010000000001 +#define PANASONIC_ADDRESS_LEN 16 // read 16 address bits +#define PANASONIC_COMMAND_OFFSET 40 // skip 40 bits +#define PANASONIC_COMMAND_LEN 16 // read 16 command bits +#define PANASONIC_COMPLETE_DATA_LEN 56 // complete length +#define PANASONIC_STOP_BIT 1 // has stop bit +#define PANASONIC_LSB 1 // LSB...MSB? +#define PANASONIC_FRAMES 1 // PANASONIC sends 1 frame +#define PANASONIC_FLAGS 0 // flags + +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * MITSUBISHI-Heavy Aircondition, timings similar to PANASONIC beamer + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ +#define MITSU_HEAVY_START_BIT_PULSE_TIME 3200.0e-6 // 3600 usec pulse +#define MITSU_HEAVY_START_BIT_PAUSE_TIME 1560.0e-6 // 1690 usec pause +#define MITSU_HEAVY_PULSE_TIME 400.0e-6 // 565 usec pulse +#define MITSU_HEAVY_1_PAUSE_TIME 1200.0e-6 // 1140 usec pause +#define MITSU_HEAVY_0_PAUSE_TIME 430.0e-6 // 316 usec pause +#define MITSU_HEAVY_FRAME_REPEAT_PAUSE_TIME 40.0e-3 // frame repeat after 40 ms +#define MITSU_HEAVY_ADDRESS_OFFSET 40 // skip 24 bits: 010000000000010000000001 +#define MITSU_HEAVY_ADDRESS_LEN 16 // read 16 address bits +#define MITSU_HEAVY_COMMAND_OFFSET 56 // skip 40 bits +#define MITSU_HEAVY_COMMAND_LEN 16 // read 16 command bits +#define MITSU_HEAVY_COMPLETE_DATA_LEN 88 // complete length +#define MITSU_HEAVY_STOP_BIT 1 // has stop bit +#define MITSU_HEAVY_LSB 0 // LSB...MSB? +#define MITSU_HEAVY_FRAMES 1 // PANASONIC sends 1 frame +#define MITSU_HEAVY_FLAGS 0 // flags /*--------------------------------------------------------------------------------------------------------------------------------------------------- * RECS80: diff --git a/irmpsystem.h b/irmpsystem.h index cef563b..4cafdd5 100644 --- a/irmpsystem.h +++ b/irmpsystem.h @@ -1,9 +1,9 @@ /*--------------------------------------------------------------------------------------------------------------------------------------------------- * irmpsystem.h - system specific includes and defines * - * Copyright (c) 2009-2015 Frank Meyer - frank(at)fli4l.de + * Copyright (c) 2009-2016 Frank Meyer - frank(at)fli4l.de * - * $Id: irmpsystem.h,v 1.22 2016/01/12 11:53:34 fm Exp $ + * $Id: irmpsystem.h,v 1.24 2016/09/09 07:53:29 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 @@ -158,6 +158,8 @@ typedef unsigned short uint16_t; #if defined(PIC_CCS) || defined(PIC_C18) || defined(ARM_STM32) || defined(STELLARIS_ARM_CORTEX_M4) typedef unsigned char uint8_t; typedef unsigned short uint16_t; +typedef unsigned char uint_fast8_t; +typedef unsigned short uint_fast16_t; #endif #if defined (PIC_C18) // PIC C18 or XC8 compiler @@ -175,7 +177,13 @@ typedef unsigned short uint16_t; # define FALSE 0 #endif -typedef struct __attribute__ ((__packed__)) +#if defined(PIC_C18) +#define IRMP_PACKED_STRUCT +#else +#define IRMP_PACKED_STRUCT __attribute__ ((__packed__)) +#endif + +typedef struct IRMP_PACKED_STRUCT { uint8_t protocol; // protocol, e.g. NEC_PROTOCOL uint16_t address; // address diff --git a/irsnd-main-avr.c b/irsnd-main-avr.c index 7ce5302..ba14086 100644 --- a/irsnd-main-avr.c +++ b/irsnd-main-avr.c @@ -1,8 +1,10 @@ /*--------------------------------------------------------------------------------------------------------------------------------------------------- - * irsndmain.c - demo main module to test IRSND encoder on AVRs + * irsnd-main-avr.c - demo main module to test IRSND encoder on AVRs * * Copyright (c) 2010-2016 Frank Meyer - frank(at)fli4l.de * + * $Id: irsnd-main-avr.c,v 1.3 2016/09/09 08:01:11 fm Exp $ + * * ATMEGA88 @ 8 MHz internal RC Osc with BODLEVEL 4.3V: lfuse: 0xE2 hfuse: 0xDC efuse: 0xF9 * ATMEGA88 @ 8 MHz external Crystal Osc with BODLEVEL 4.3V: lfuse: 0xFF hfuse: 0xDC efuse: 0xF9 * diff --git a/irsnd.c b/irsnd.c index 8e1fd51..15692c1 100644 --- a/irsnd.c +++ b/irsnd.c @@ -1,7 +1,7 @@ /*--------------------------------------------------------------------------------------------------------------------------------------------------- * @file irsnd.c * - * Copyright (c) 2010-2015 Frank Meyer - frank(at)fli4l.de + * Copyright (c) 2010-2016 Frank Meyer - frank(at)fli4l.de * * Supported AVR mikrocontrollers: * @@ -14,7 +14,7 @@ * ATmega164, ATmega324, ATmega644, ATmega644P, ATmega1284, ATmega1284P * ATmega88, ATmega88P, ATmega168, ATmega168P, ATmega328P * - * $Id: irsnd.c,v 1.99 2015/12/16 14:12:17 fm Exp $ + * $Id: irsnd.c,v 1.101 2016/09/09 07:53:29 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 @@ -181,10 +181,15 @@ //Nothing here to do here -> See irsndconfig.h #elif defined (ARM_STM32) //STM32 //Nothing here to do here -> See irsndconfig.h -#elif defined (TEENSY_ARM_CORTEX_M4) // Teensy3 -# if !digitalPinHasPWM(IRSND_PIN) -# error need pin with PWM output. -# endif +/*--------------------------------------------------------------------------------------------------------------------------------------------------- + * Macro digitalPinHasPWM bothers PIC_C18 compiler, but why? + * + * #elif defined (TEENSY_ARM_CORTEX_M4) // Teensy3 + * # if !digitalPinHasPWM(IRSND_PIN) + * # error need pin with PWM output. + * # endif + *--------------------------------------------------------------------------------------------------------------------------------------------------- + */ #else # if !defined (unix) && !defined (WIN32) # error mikrocontroller not defined, please fill in definitions here. @@ -260,13 +265,20 @@ #define KASEIKYO_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * KASEIKYO_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! #define KASEIKYO_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * KASEIKYO_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! -#define PANASONIC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PULSE_TIME + 0.5) -#define PANASONIC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PAUSE_TIME + 0.5) -#define PANASONIC_PULSE_LEN (uint8_t)(F_INTERRUPTS * PANASONIC_PULSE_TIME + 0.5) -#define PANASONIC_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * PANASONIC_1_PAUSE_TIME + 0.5) -#define PANASONIC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * PANASONIC_0_PAUSE_TIME + 0.5) -#define PANASONIC_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * PANASONIC_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! -#define PANASONIC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * PANASONIC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! +#define PANASONIC_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PULSE_TIME + 0.5) +#define PANASONIC_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * PANASONIC_START_BIT_PAUSE_TIME + 0.5) +#define PANASONIC_PULSE_LEN (uint8_t)(F_INTERRUPTS * PANASONIC_PULSE_TIME + 0.5) +#define PANASONIC_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * PANASONIC_1_PAUSE_TIME + 0.5) +#define PANASONIC_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * PANASONIC_0_PAUSE_TIME + 0.5) +#define PANASONIC_AUTO_REPETITION_PAUSE_LEN (uint16_t)(F_INTERRUPTS * PANASONIC_AUTO_REPETITION_PAUSE_TIME + 0.5) // use uint16_t! +#define PANASONIC_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * PANASONIC_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! + +#define MITSU_HEAVY_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * MITSU_HEAVY_START_BIT_PULSE_TIME + 0.5) +#define MITSU_HEAVY_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MITSU_HEAVY_START_BIT_PAUSE_TIME + 0.5) +#define MITSU_HEAVY_PULSE_LEN (uint8_t)(F_INTERRUPTS * MITSU_HEAVY_PULSE_TIME + 0.5) +#define MITSU_HEAVY_1_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MITSU_HEAVY_1_PAUSE_TIME + 0.5) +#define MITSU_HEAVY_0_PAUSE_LEN (uint8_t)(F_INTERRUPTS * MITSU_HEAVY_0_PAUSE_TIME + 0.5) +#define MITSU_HEAVY_FRAME_REPEAT_PAUSE_LEN (uint16_t)(F_INTERRUPTS * MITSU_HEAVY_FRAME_REPEAT_PAUSE_TIME + 0.5) // use uint16_t! #define RECS80_START_BIT_PULSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PULSE_TIME + 0.5) #define RECS80_START_BIT_PAUSE_LEN (uint8_t)(F_INTERRUPTS * RECS80_START_BIT_PAUSE_TIME + 0.5) @@ -493,7 +505,7 @@ static volatile uint8_t irsnd_busy = 0; static volatile uint8_t irsnd_protocol = 0; -static volatile uint8_t irsnd_buffer[9] = {0}; +static volatile uint8_t irsnd_buffer[11] = {0}; static volatile uint8_t irsnd_repeat = 0; static volatile uint8_t irsnd_is_on = FALSE; @@ -1171,6 +1183,28 @@ irsnd_send_data (IRMP_DATA * irmp_data_p, uint8_t do_wait) break; } #endif +#if IRSND_SUPPORT_MITSU_HEAVY_PROTOCOL == 1 + case IRMP_MITSU_HEAVY_PROTOCOL: + { + address = irmp_data_p->address; + command = irmp_data_p->command; + + irsnd_buffer[0] = 0x4A; + irsnd_buffer[1] = 0x75; + irsnd_buffer[2] = 0xC3; + irsnd_buffer[3] = 0x64; + irsnd_buffer[4] = 0x9B; + irsnd_buffer[5] = ~(address & 0xFF00) >> 8; + irsnd_buffer[6] = (address & 0xFF00) >> 8; + irsnd_buffer[7] = ~(address & 0x00FF); + irsnd_buffer[8] = (address & 0x00FF); + irsnd_buffer[9] = ~(command & 0x00FF); + irsnd_buffer[10] = (command & 0x00FF); + + irsnd_busy = TRUE; + break; + } +#endif #if IRSND_SUPPORT_RECS80_PROTOCOL == 1 case IRMP_RECS80_PROTOCOL: { @@ -1905,6 +1939,24 @@ irsnd_ISR (void) break; } #endif +#if IRSND_SUPPORT_MITSU_HEAVY_PROTOCOL == 1 + case IRMP_MITSU_HEAVY_PROTOCOL: + { + startbit_pulse_len = MITSU_HEAVY_START_BIT_PULSE_LEN; + startbit_pause_len = MITSU_HEAVY_START_BIT_PAUSE_LEN - 1; + pulse_1_len = MITSU_HEAVY_PULSE_LEN; + pause_1_len = MITSU_HEAVY_1_PAUSE_LEN - 1; + pulse_0_len = MITSU_HEAVY_PULSE_LEN; + pause_0_len = MITSU_HEAVY_0_PAUSE_LEN - 1; + has_stop_bit = MITSU_HEAVY_STOP_BIT; + complete_data_len = MITSU_HEAVY_COMPLETE_DATA_LEN; + n_auto_repetitions = MITSU_HEAVY_FRAMES; // 1 frame + auto_repetition_pause_len = 0;; + repeat_frame_pause_len = MITSU_HEAVY_FRAME_REPEAT_PAUSE_LEN; + irsnd_set_freq (IRSND_FREQ_40_KHZ); + break; + } +#endif #if IRSND_SUPPORT_RECS80_PROTOCOL == 1 case IRMP_RECS80_PROTOCOL: { @@ -2428,6 +2480,9 @@ irsnd_ISR (void) #if IRSND_SUPPORT_PANASONIC_PROTOCOL == 1 case IRMP_PANASONIC_PROTOCOL: #endif +#if IRSND_SUPPORT_MITSU_HEAVY_PROTOCOL == 1 + case IRMP_MITSU_HEAVY_PROTOCOL: +#endif #if IRSND_SUPPORT_RECS80_PROTOCOL == 1 case IRMP_RECS80_PROTOCOL: #endif @@ -2489,7 +2544,8 @@ irsnd_ISR (void) IRSND_SUPPORT_NUBERT_PROTOCOL == 1 || IRSND_SUPPORT_FAN_PROTOCOL == 1 || IRSND_SUPPORT_SPEAKER_PROTOCOL == 1 || IRSND_SUPPORT_BANG_OLUFSEN_PROTOCOL == 1 || \ IRSND_SUPPORT_FDC_PROTOCOL == 1 || IRSND_SUPPORT_RCCAR_PROTOCOL == 1 || IRSND_SUPPORT_JVC_PROTOCOL == 1 || IRSND_SUPPORT_NIKON_PROTOCOL == 1 || \ IRSND_SUPPORT_LEGO_PROTOCOL == 1 || IRSND_SUPPORT_THOMSON_PROTOCOL == 1 || IRSND_SUPPORT_ROOMBA_PROTOCOL == 1 || IRSND_SUPPORT_TELEFUNKEN_PROTOCOL == 1 || \ - IRSND_SUPPORT_PENTAX_PROTOCOL == 1 || IRSND_SUPPORT_ACP24_PROTOCOL == 1 || IRSND_SUPPORT_PANASONIC_PROTOCOL == 1 || IRSND_SUPPORT_BOSE_PROTOCOL == 1 + IRSND_SUPPORT_PENTAX_PROTOCOL == 1 || IRSND_SUPPORT_ACP24_PROTOCOL == 1 || IRSND_SUPPORT_PANASONIC_PROTOCOL == 1 || IRSND_SUPPORT_BOSE_PROTOCOL == 1 || \ + IRSND_SUPPORT_MITSU_HEAVY_PROTOCOL == 1 { if (pulse_counter == 0) { diff --git a/irsnd.h b/irsnd.h index 9fb8bb8..1e797d5 100644 --- a/irsnd.h +++ b/irsnd.h @@ -1,9 +1,9 @@ /*--------------------------------------------------------------------------------------------------------------------------------------------------- * irsnd.h * - * Copyright (c) 2010-2015 Frank Meyer - frank(at)fli4l.de + * Copyright (c) 2010-2016 Frank Meyer - frank(at)fli4l.de * - * $Id: irsnd.h,v 1.23 2015/11/18 08:27:50 fm Exp $ + * $Id: irsnd.h,v 1.24 2016/01/12 21:15:16 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 diff --git a/irsndconfig.h b/irsndconfig.h index 93b8a40..bded8ed 100644 --- a/irsndconfig.h +++ b/irsndconfig.h @@ -3,9 +3,9 @@ * * DO NOT INCLUDE THIS FILE, WILL BE INCLUDED BY IRSND.H! * - * Copyright (c) 2010-2015 Frank Meyer - frank(at)fli4l.de + * Copyright (c) 2010-2016 Frank Meyer - frank(at)fli4l.de * - * $Id: irsndconfig.h,v 1.86 2015/11/18 08:27:50 fm Exp $ + * $Id: irsndconfig.h,v 1.88 2016/09/09 07:53:29 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 @@ -87,6 +87,7 @@ #define IRSND_SUPPORT_ACP24_PROTOCOL 0 // ACP24 >= 10000 ~150 bytes #define IRSND_SUPPORT_TECHNICS_PROTOCOL 0 // TECHNICS >= 10000 DON'T CHANGE, NOT SUPPORTED YET! #define IRSND_SUPPORT_PANASONIC_PROTOCOL 0 // PANASONIC Beamer >= 10000 ~150 bytes +#define IRSND_SUPPORT_MITSU_HEAVY_PROTOCOL 0 // Mitsubishi-Heavy Aircondition, similar Timing to Panasonic beamer /*--------------------------------------------------------------------------------------------------------------------------------------------------- -- 2.39.2