McMajan Library Pack  v 2.00
Improve your Arduino !
Ss_McIRDA.h
Go to the documentation of this file.
1 /*
2 McIRDA derived from old verion of IR_Remote by Ken Shirriff
3 This version is by Stefano Smania, www.mcmajan.com
4  */
5 
6 
7 #ifndef _McIRDA_h_
8 #define _McIRDA_h_
9 
10 #include "Ss_McMajan_Config.h"
11 
12 
13 
14 //#if defined(ARDUINO_ARCH_AVR)
15 
16 
17  //#warning INCLUSION McIRDA OK
18 
19 
20 
21  void LongMicroDelay(unsigned int );
22 
23  // Results returned from the decoder
25  {
26  public:
27  int decode_type; // NEC, SONY, RC5, UNKNOWN, etc
28  #ifdef USE_PANASONIC
29  unsigned int panasonicAddress; // This is only used for decoding Panasonic data
30  #endif
31  #ifdef USE_DAIKIN_FTX
32  uint8_t DaikinBuffer[37]; // This is only used for decoding Daikin data
33  #endif
34  unsigned long value; // Decoded value
35  int bits; // Number of bits in decoded value
36  volatile unsigned int *rawbuf; // Raw intervals in .5 us ticks
37  int rawlen; // Number of records in rawbuf.
38  };
39 
40  // Values for decode_type
41  #define NEC 1
42  #define SONY 2
43  #define RC5 3
44  #define RC6 4
45  #define DISH 5
46  #define SHARP 6
47  #define PANASONIC 7
48  #define JVC 8
49  #define SANYO 9
50  #define MITSUBISHI 10
51  #define SAMSUNG 11
52  #define DAIKIN 12
53  #define UNKNOWN -1
54 
55  // Decoded value for NEC when a repeat code is received
56  #define REPEAT 0xffffffff
57 
58  // main class for receiving IR
59  class IRrecv
60  {
61  public:
62  IRrecv(int recvpin);
63  void blink13(int blinkflag);
64  int decode(decode_results *results);
65  void enableIRIn();
66  void resume();
67  private:
68  // These are called by decode
69  int getRClevel(decode_results *results, int *offset, int *used, int t1);
70  #ifdef USE_NEC
71  long decodeNEC(decode_results *results);
72  #endif
73 
74  #ifdef USE_SONY
76  #endif
77 
78  #ifdef USE_SANYO
79  long decodeSanyo(decode_results *results);
80  #endif
81 
82  #ifdef USE_MITSUBISHI
83  long decodeMitsubishi(decode_results *results);
84  #endif
85 
86  #ifdef USE_RC5
87  long decodeRC5(decode_results *results);
88  #endif
89 
90  #ifdef USE_RC6
91  long decodeRC6(decode_results *results);
92  #endif
93 
94  #ifdef USE_PANASONIC
95  long decodePanasonic(decode_results *results);
96  #endif
97 
98  #ifdef USE_JVC
99  long decodeJVC(decode_results *results);
100  #endif
101 
102  #ifdef USE_SAMSUNG
103  long decodeSamsung(decode_results *results);
104  #endif
105 
106  long decodeHash(decode_results *results);
107  #ifdef USE_DAIKIN_FTX
109  #endif
110  int compare(unsigned int oldval, unsigned int newval);
111 
112  };
113 
114 // Only used for testing; can remove virtual for shorter code
115  #ifdef TEST
116  #define VIRTUAL virtual
117  #else
118  #define VIRTUAL
119  #endif
120 
121  class IRsend
122  {
123  public:
124  IRsend() {}
125 
126  void sendNEC(unsigned long data, int nbits);
127  void sendSony(unsigned long data, int nbits);
128 
129  // Neither Sanyo nor Mitsubishi send is implemented yet
130  // void sendSanyo(unsigned long data, int nbits);
131  // void sendMitsubishi(unsigned long data, int nbits);
132  void sendRaw(unsigned int buf[], int len, int hz);
133  void sendRC5(unsigned long data, int nbits);
134  void sendRC6(unsigned long data, int nbits);
135  void sendDISH(unsigned long data, int nbits);
136  void sendSharp(unsigned long data, int nbits);
137  void sendPanasonic(unsigned int address, unsigned long data);
138  void sendSamsung(unsigned long data, int nbits);
139  void sendDaikin();
140  void sendDaikinByte(uint8_t);
141  void sendJVC(unsigned long data, int nbits, int repeat); // *Note instead of sending the REPEAT constant if you want the JVC repeat signal sent, send the original code value and change the repeat argument from 0 to 1. JVC protocol repeats by skipping the header NOT by sending a separate code value like NEC does.
142 
143  // private:
144  void enableIROut(int khz);
145  VIRTUAL void mark(unsigned int usec);
146  VIRTUAL void space(unsigned int usec);
147  };
148 
149 
150 
151 
152  // Some useful constants
153 
154  #define USECPERTICK 50 // microseconds per clock interrupt tick
155  #ifdef USE_DAIKIN_FTX
156  #define RAWBUF 585 // Length of raw duration buffer
157  #else
158  #define RAWBUF 100 // Length of raw duration buffer
159  #endif
160 
161  // Marks tend to be 100us too long, and spaces 100us too short
162  // when received due to sensor lag.
163  #define MARK_EXCESS 100
164 
165 
166 
167 
168 /*
169  #elif defined(ARDUINO_ARCH_SAM)
170  #error Arduino SAM family is not supported by McIRDA (.h)
171  #else
172  #error Yor platform is not supported by McIRDA (.h)
173  #endif */
174 
175 #endif
void sendSharp(unsigned long data, int nbits)
Definition: Ss_McIRDA.cpp:1364
void enableIRIn()
Definition: Ss_McIRDA.cpp:482
unsigned long value
Definition: Ss_McIRDA.h:34
IRrecv(int recvpin)
Definition: Ss_McIRDA.cpp:475
void enableIROut(int khz)
Definition: Ss_McIRDA.cpp:448
void sendDaikinByte(uint8_t)
Definition: Ss_McIRDA.cpp:113
volatile unsigned int * rawbuf
Definition: Ss_McIRDA.h:36
void sendRC5(unsigned long data, int nbits)
Definition: Ss_McIRDA.cpp:282
IRsend()
Definition: Ss_McIRDA.h:124
void sendRaw(unsigned int buf[], int len, int hz)
Definition: Ss_McIRDA.cpp:266
void sendDISH(unsigned long data, int nbits)
Definition: Ss_McIRDA.cpp:1399
void blink13(int blinkflag)
Definition: Ss_McIRDA.cpp:506
void sendDaikin()
Definition: Ss_McIRDA.cpp:125
void sendPanasonic(unsigned int address, unsigned long data)
Definition: Ss_McIRDA.cpp:339
void sendJVC(unsigned long data, int nbits, int repeat)
Definition: Ss_McIRDA.cpp:368
unsigned int panasonicAddress
Definition: Ss_McIRDA.h:29
void sendSony(unsigned long data, int nbits)
Definition: Ss_McIRDA.cpp:247
void sendRC6(unsigned long data, int nbits)
Definition: Ss_McIRDA.cpp:306
VIRTUAL void space(unsigned int usec)
Definition: Ss_McIRDA.cpp:431
void resume()
Definition: Ss_McIRDA.cpp:588
int decode(decode_results *results)
Definition: Ss_McIRDA.cpp:598
VIRTUAL void mark(unsigned int usec)
Definition: Ss_McIRDA.cpp:413
void LongMicroDelay(unsigned int micros)
Definition: Ss_McIRDA.cpp:391
void sendSamsung(unsigned long data, int nbits)
Definition: Ss_McIRDA.cpp:92
#define VIRTUAL
Definition: Ss_McIRDA.h:118
void sendNEC(unsigned long data, int nbits)
Definition: Ss_McIRDA.cpp:70