Infrared remote library for Arduino: send and receive infrared signals with multiple protocols Port from Arduino-IRremote https://github.com/z3t0/Arduino-IRremote
ir_Denon.cpp
00001 #include "IRremote.h" 00002 #include "IRremoteInt.h" 00003 00004 // Reverse Engineered by looking at RAW dumps generated by IRremote 00005 00006 // I have since discovered that Denon publish all their IR codes: 00007 // https://www.google.co.uk/search?q=DENON+MASTER+IR+Hex+Command+Sheet 00008 // -> http://assets.denon.com/documentmaster/us/denon%20master%20ir%20hex.xls 00009 00010 // Having looked at the official Denon Pronto sheet and reverse engineered 00011 // the timing values from it, it is obvious that Denon have a range of 00012 // different timings and protocols ...the values here work for my AVR-3801 Amp! 00013 00014 //============================================================================== 00015 // DDDD EEEEE N N OOO N N 00016 // D D E NN N O O NN N 00017 // D D EEE N N N O O N N N 00018 // D D E N NN O O N NN 00019 // DDDD EEEEE N N OOO N N 00020 //============================================================================== 00021 00022 #define BITS 14 // The number of bits in the command 00023 00024 #define HDR_MARK 300 // The length of the Header:Mark 00025 #define HDR_SPACE 750 // The lenght of the Header:Space 00026 00027 #define BIT_MARK 300 // The length of a Bit:Mark 00028 #define ONE_SPACE 1800 // The length of a Bit:Space for 1's 00029 #define ZERO_SPACE 750 // The length of a Bit:Space for 0's 00030 00031 //+============================================================================= 00032 // 00033 #if SEND_DENON 00034 void IRsend::sendDenon (unsigned long data, int nbits) 00035 { 00036 // Set IR carrier frequency 00037 enableIROut(38); 00038 00039 // Header 00040 mark (HDR_MARK); 00041 space(HDR_SPACE); 00042 00043 // Data 00044 for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) { 00045 if (data & mask) { 00046 mark (BIT_MARK); 00047 space(ONE_SPACE); 00048 } else { 00049 mark (BIT_MARK); 00050 space(ZERO_SPACE); 00051 } 00052 } 00053 00054 // Footer 00055 mark(BIT_MARK); 00056 space(0); // Always end with the LED off 00057 } 00058 #endif 00059 00060 //+============================================================================= 00061 // 00062 #if DECODE_DENON 00063 bool IRrecv::decodeDenon (decode_results *results) 00064 { 00065 unsigned long data = 0; // Somewhere to build our code 00066 int offset = 1; // Skip the Gap reading 00067 00068 // Check we have the right amount of data 00069 if (irparams.rawlen != 1 + 2 + (2 * BITS) + 1) return false ; 00070 00071 // Check initial Mark+Space match 00072 if (!MATCH_MARK (results->rawbuf[offset++], HDR_MARK )) return false ; 00073 if (!MATCH_SPACE(results->rawbuf[offset++], HDR_SPACE)) return false ; 00074 00075 // Read the bits in 00076 for (int i = 0; i < BITS; i++) { 00077 // Each bit looks like: MARK + SPACE_1 -> 1 00078 // or : MARK + SPACE_0 -> 0 00079 if (!MATCH_MARK(results->rawbuf[offset++], BIT_MARK)) return false ; 00080 00081 // IR data is big-endian, so we shuffle it in from the right: 00082 if (MATCH_SPACE(results->rawbuf[offset], ONE_SPACE)) data = (data << 1) | 1 ; 00083 else if (MATCH_SPACE(results->rawbuf[offset], ZERO_SPACE)) data = (data << 1) | 0 ; 00084 else return false ; 00085 offset++; 00086 } 00087 00088 // Success 00089 results->bits = BITS; 00090 results->value = data; 00091 results->decode_type = DENON; 00092 return true; 00093 } 00094 #endif
Generated on Fri Jul 15 2022 02:03:08 by 1.7.2