IRremote
ir_Mitsubishi.cpp
Go to the documentation of this file.
1 #include "IRremote.h"
2 
3 //==============================================================================
4 // MMMMM IIIII TTTTT SSSS U U BBBB IIIII SSSS H H IIIII
5 // M M M I T S U U B B I S H H I
6 // M M M I T SSS U U BBBB I SSS HHHHH I
7 // M M I T S U U B B I S H H I
8 // M M IIIII T SSSS UUU BBBBB IIIII SSSS H H IIIII
9 //==============================================================================
10 
11 // Looks like Sony except for timings, 48 chars of data and time/space different
12 
13 #define MITSUBISHI_BITS 16
14 
15 // Mitsubishi RM 75501
16 // 14200 7 41 7 42 7 42 7 17 7 17 7 18 7 41 7 18 7 17 7 17 7 18 7 41 8 17 7 17 7 18 7 17 7
17 // #define MITSUBISHI_HDR_MARK 250 // seen range 3500
18 #define MITSUBISHI_HDR_SPACE 350 // 7*50+100
19 #define MITSUBISHI_ONE_MARK 1950 // 41*50-100
20 #define MITSUBISHI_ZERO_MARK 750 // 17*50-100
21 // #define MITSUBISHI_DOUBLE_SPACE_USECS 800 // usually see 713 - not using ticks as get number wrap around
22 // #define MITSUBISHI_RPT_LENGTH 45000
23 
24 //+=============================================================================
25 #if DECODE_MITSUBISHI
26 bool IRrecv::decodeMitsubishi (decode_results *results)
27 {
28  // Serial.print("?!? decoding Mitsubishi:");Serial.print(irparams.rawlen); Serial.print(" want "); Serial.println( 2 * MITSUBISHI_BITS + 2);
29  long data = 0;
30  if (irparams.rawlen < 2 * MITSUBISHI_BITS + 2) return false ;
31  unsigned int offset = 0; // Skip first space
32  // Initial space
33 
34 #if 0
35  // Put this back in for debugging - note can't use #DEBUG as if Debug on we don't see the repeat cos of the delay
36  Serial.print("IR Gap: ");
37  Serial.println( results->rawbuf[offset]);
38  Serial.println( "test against:");
39  Serial.println(results->rawbuf[offset]);
40 #endif
41 
42 #if 0
43  // Not seeing double keys from Mitsubishi
44  if (results->rawbuf[offset] < MITSUBISHI_DOUBLE_SPACE_USECS) {
45  // Serial.print("IR Gap found: ");
46  results->bits = 0;
47  results->value = REPEAT;
48  results->decode_type = MITSUBISHI;
49  return true;
50  }
51 #endif
52 
53  offset++;
54 
55  // Typical
56  // 14200 7 41 7 42 7 42 7 17 7 17 7 18 7 41 7 18 7 17 7 17 7 18 7 41 8 17 7 17 7 18 7 17 7
57 
58  // Initial Space
59  if (!MATCH_MARK(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) return false ;
60  offset++;
61 
62  while (offset + 1 < irparams.rawlen) {
63  if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ONE_MARK)) data = (data << 1) | 1 ;
64  else if (MATCH_MARK(results->rawbuf[offset], MITSUBISHI_ZERO_MARK)) data <<= 1 ;
65  else return false ;
66  offset++;
67 
68  if (!MATCH_SPACE(results->rawbuf[offset], MITSUBISHI_HDR_SPACE)) break ;
69  offset++;
70  }
71 
72  // Success
73  results->bits = (offset - 1) / 2;
74  if (results->bits < MITSUBISHI_BITS) {
75  results->bits = 0;
76  return false;
77  }
78 
79  results->value = data;
80  results->decode_type = MITSUBISHI;
81  return true;
82 }
83 #endif
84 
MITSUBISHI
@ MITSUBISHI
Definition: IRremote.h:126
decode_results
Results returned from the decoder.
Definition: IRremote.h:174
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
decode_results::decode_type
decode_type_t decode_type
UNKNOWN, NEC, SONY, RC5, ...
Definition: IRremote.h:176
MITSUBISHI_ZERO_MARK
#define MITSUBISHI_ZERO_MARK
Definition: ir_Mitsubishi.cpp:20
MATCH_SPACE
int MATCH_SPACE(int measured_ticks, int desired_us)
Definition: IRremote.cpp:89
irparams
volatile irparams_t irparams
Allow all parts of the code access to the ISR data NB.
MITSUBISHI_BITS
#define MITSUBISHI_BITS
Definition: ir_Mitsubishi.cpp:13
MITSUBISHI_ONE_MARK
#define MITSUBISHI_ONE_MARK
Definition: ir_Mitsubishi.cpp:19
IRremote.h
Public API to the library.
REPEAT
#define REPEAT
Decoded value for NEC when a repeat code is received.
Definition: IRremote.h:188
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
MITSUBISHI_HDR_SPACE
#define MITSUBISHI_HDR_SPACE
Definition: ir_Mitsubishi.cpp:18
irparams_t::rawlen
unsigned int rawlen
counter of entries in rawbuf
Definition: IRremoteInt.h:45