--- /dev/null
+/*\r
+ * IRremote\r
+ * Version 0.1 July, 2009\r
+ * Copyright 2009 Ken Shirriff\r
+ * For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.htm http://arcfn.com\r
+ *\r
+ * Interrupt code based on NECIRrcv by Joe Knapp\r
+ * http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210243556\r
+ * Also influenced by http://zovirl.com/2008/11/12/building-a-universal-remote-with-an-arduino/\r
+ */\r
+\r
+#ifndef IRremote_h\r
+#define IRremote_h\r
+\r
+// The following are compile-time library options.\r
+// If you change them, recompile the library.\r
+// If DEBUG is defined, a lot of debugging output will be printed during decoding.\r
+// TEST must be defined for the IRtest unittests to work. It will make some\r
+// methods virtual, which will be slightly slower, which is why it is optional.\r
+// #define DEBUG\r
+// #define TEST\r
+\r
+// Results returned from the decoder\r
+class decode_results {\r
+public:\r
+ int decode_type; // NEC, SONY, RC5, UNKNOWN\r
+ unsigned long value; // Decoded value\r
+ int bits; // Number of bits in decoded value\r
+ volatile unsigned int *rawbuf; // Raw intervals in .5 us ticks\r
+ int rawlen; // Number of records in rawbuf.\r
+};\r
+\r
+// Values for decode_type\r
+#define NEC 1\r
+#define SONY 2\r
+#define RC5 3\r
+#define RC6 4\r
+#define UNKNOWN -1\r
+\r
+// Decoded value for NEC when a repeat code is received\r
+#define REPEAT 0xffffffff\r
+\r
+// main class for receiving IR\r
+class IRrecv\r
+{\r
+public:\r
+ IRrecv(int recvpin);\r
+ void blink13(int blinkflag);\r
+ int decode(decode_results *results);\r
+ void enableIRIn();\r
+ void resume();\r
+private:\r
+ // These are called by decode\r
+ int getRClevel(decode_results *results, int *offset, int *used, int t1);\r
+ long decodeNEC(decode_results *results);\r
+ long decodeSony(decode_results *results);\r
+ long decodeRC5(decode_results *results);\r
+ long decodeRC6(decode_results *results);\r
+} \r
+;\r
+\r
+// Only used for testing; can remove virtual for shorter code\r
+#ifdef TEST\r
+#define VIRTUAL virtual\r
+#else\r
+#define VIRTUAL\r
+#endif\r
+\r
+class IRsend\r
+{\r
+public:\r
+ IRsend() {}\r
+ void sendNEC(unsigned long data, int nbits);\r
+ void sendSony(unsigned long data, int nbits);\r
+ void sendRaw(unsigned int buf[], int len, int hz);\r
+ void sendRC5(unsigned long data, int nbits);\r
+ void sendRC6(unsigned long data, int nbits);\r
+ // private:\r
+ void enableIROut(int khz);\r
+ VIRTUAL void mark(int usec);\r
+ VIRTUAL void space(int usec);\r
+}\r
+;\r
+\r
+// Some useful constants\r
+\r
+#define USECPERTICK 50 // microseconds per clock interrupt tick\r
+#define RAWBUF 76 // Length of raw duration buffer\r
+\r
+// Marks tend to be 100us too long, and spaces 100us too short\r
+// when received due to sensor lag.\r
+#define MARK_EXCESS 100\r
+\r
+#endif\r