Lib for sending IR signals from mbed.

Dependents:   ir-puck ir-puck2 ir-puck

IRSender.h

Committer:
cristea
Date:
2014-07-28
Revision:
1:402625e9170f
Parent:
0:741de6c95ae9
Child:
2:4576fcd93ffd

File content as of revision 1:402625e9170f:


#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, ...)
    #define APPEND(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__