IRremote
ir_Denon.cpp
Go to the documentation of this file.
1 #include "IRremote.h"
2 
3 // Reverse Engineered by looking at RAW dumps generated by IRremote
4 
5 // I have since discovered that Denon publish all their IR codes:
6 // https://www.google.co.uk/search?q=DENON+MASTER+IR+Hex+Command+Sheet
7 // -> http://assets.denon.com/documentmaster/us/denon%20master%20ir%20hex.xls
8 
9 // Having looked at the official Denon Pronto sheet and reverse engineered
10 // the timing values from it, it is obvious that Denon have a range of
11 // different timings and protocols ...the values here work for my AVR-3801 Amp!
12 
13 //==============================================================================
14 // DDDD EEEEE N N OOO N N
15 // D D E NN N O O NN N
16 // D D EEE N N N O O N N N
17 // D D E N NN O O N NN
18 // DDDD EEEEE N N OOO N N
19 //==============================================================================
20 
21 #define BITS 14 // The number of bits in the command
22 
23 #define HDR_MARK 300 // The length of the Header:Mark
24 #define HDR_SPACE 750 // The lenght of the Header:Space
25 
26 #define BIT_MARK 300 // The length of a Bit:Mark
27 #define ONE_SPACE 1800 // The length of a Bit:Space for 1's
28 #define ZERO_SPACE 750 // The length of a Bit:Space for 0's
29 
30 //+=============================================================================
31 //
32 #if SEND_DENON
33 void IRsend::sendDenon(unsigned long data, int nbits) {
34  // Set IR carrier frequency
35  enableIROut(38);
36 
37  // Header
38  mark(HDR_MARK);
40 
41  // Data
42  for (unsigned long mask = 1UL << (nbits - 1); mask; mask >>= 1) {
43  if (data & mask) {
44  mark(BIT_MARK);
46  } else {
47  mark(BIT_MARK);
49  }
50  }
51 
52  // Footer
53  mark(BIT_MARK);
54  space(0); // Always end with the LED off
55 }
56 #endif
57 
58 //+=============================================================================
59 //
60 #if DECODE_DENON
61 bool IRrecv::decodeDenon(decode_results *results) {
62  unsigned long data = 0; // Somewhere to build our code
63  int offset = 1; // Skip the Gap reading
64 
65  // Check we have the right amount of data
66  if (irparams.rawlen != 1 + 2 + (2 * BITS) + 1) {
67  return false;
68  }
69 
70  // Check initial Mark+Space match
71  if (!MATCH_MARK(results->rawbuf[offset], HDR_MARK)) {
72  return false;
73  }
74  offset++;
75 
76  if (!MATCH_SPACE(results->rawbuf[offset], HDR_SPACE)) {
77  return false;
78  }
79  offset++;
80 
81  // Read the bits in
82  for (int i = 0; i < BITS; i++) {
83  // Each bit looks like: MARK + SPACE_1 -> 1
84  // or : MARK + SPACE_0 -> 0
85  if (!MATCH_MARK(results->rawbuf[offset], BIT_MARK)) {
86  return false;
87  }
88  offset++;
89 
90  // IR data is big-endian, so we shuffle it in from the right:
91  if (MATCH_SPACE(results->rawbuf[offset], ONE_SPACE)) {
92  data = (data << 1) | 1;
93  } else if (MATCH_SPACE(results->rawbuf[offset], ZERO_SPACE)) {
94  data = (data << 1) | 0;
95  } else {
96  return false;
97  }
98  offset++;
99  }
100 
101  // Success
102  results->bits = BITS;
103  results->value = data;
104  results->decode_type = DENON;
105  return true;
106 }
107 #endif
decode_results
Results returned from the decoder.
Definition: IRremote.h:174
DENON
@ DENON
Definition: IRremote.h:130
decode_results::bits
int bits
Number of bits in decoded value.
Definition: IRremote.h:179
decode_results::rawbuf
volatile unsigned int * rawbuf
Raw intervals in 50uS ticks.
Definition: IRremote.h:180
IRsend::mark
void mark(unsigned int usec)
Definition: irSend.cpp:69
IRsend::enableIROut
void enableIROut(int khz)
Definition: irSend.cpp:127
IRsend::sendDenon
void sendDenon(unsigned long data, int nbits)
Definition: ir_Denon.cpp:33
HDR_SPACE
#define HDR_SPACE
Definition: ir_Denon.cpp:24
BITS
#define BITS
Definition: ir_Denon.cpp:21
decode_results::decode_type
decode_type_t decode_type
UNKNOWN, NEC, SONY, RC5, ...
Definition: IRremote.h:176
MATCH_SPACE
int MATCH_SPACE(int measured_ticks, int desired_us)
Definition: IRremote.cpp:89
BIT_MARK
#define BIT_MARK
Definition: ir_Denon.cpp:26
irparams
volatile irparams_t irparams
Allow all parts of the code access to the ISR data NB.
IRremote.h
Public API to the library.
IRsend::space
void space(unsigned int usec)
Definition: irSend.cpp:103
decode_results::value
unsigned long value
Decoded value [max 32-bits].
Definition: IRremote.h:178
MATCH_MARK
int MATCH_MARK(int measured_ticks, int desired_us)
Definition: IRremote.cpp:63
ZERO_SPACE
#define ZERO_SPACE
Definition: ir_Denon.cpp:28
HDR_MARK
#define HDR_MARK
Definition: ir_Denon.cpp:23
ONE_SPACE
#define ONE_SPACE
Definition: ir_Denon.cpp:27
irparams_t::rawlen
unsigned int rawlen
counter of entries in rawbuf
Definition: IRremoteInt.h:45