Lib for sending IR signals from mbed.

Dependents:   ir-puck ir-puck2 ir-puck

Revision:
0:741de6c95ae9
Child:
1:402625e9170f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IRSender.h	Fri Jul 25 07:43:47 2014 +0000
@@ -0,0 +1,32 @@
+
+#ifndef __IRSENDER__H__
+#define __IRSENDER__H__
+
+#define DEBUG 0
+
+#if DEBUG
+    #define LOG(fmt, ...) do {  __IRSENDER__irLogger.printf("[IRSender] "); __IRSENDER__irLogger.printf(fmt, ##__VA_ARGS__); } while(0)
+    #define APPEND(fmt, ...) do { __IRSENDER__irLogger.printf(fmt, ##__VA_ARGS__); } while(0)
+    static Serial __IRSENDER__irLogger(USBTX, USBRX);
+#else
+    #define LOG(fmt, ...)
+#endif
+
+/** Small library to drive the pin of an IR LED.
+ *  Send the frequency of the signal, the length
+ *  of the data and the duration of on and off
+ *  in ms.
+ */
+
+class IRSender {
+    private:
+        bool _inUse;
+        PwmOut senderPin;
+        Timer timer;
+
+    public:
+        IRSender(PinName pin) : _inUse(false), senderPin(pin) {}
+        bool irSeq(unsigned freq, unsigned len, const unsigned *data);
+};
+
+#endif // __IRSENDER__H__