Lib for sending IR signals from mbed.
Dependents: ir-puck ir-puck2 ir-puck
IRSender.h@1:402625e9170f, 2014-07-28 (annotated)
- Committer:
- cristea
- Date:
- Mon Jul 28 09:15:02 2014 +0000
- Revision:
- 1:402625e9170f
- Parent:
- 0:741de6c95ae9
- Child:
- 2:4576fcd93ffd
Add append to non-debug statements also
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cristea | 0:741de6c95ae9 | 1 | |
cristea | 0:741de6c95ae9 | 2 | #ifndef __IRSENDER__H__ |
cristea | 0:741de6c95ae9 | 3 | #define __IRSENDER__H__ |
cristea | 0:741de6c95ae9 | 4 | |
cristea | 0:741de6c95ae9 | 5 | #define DEBUG 0 |
cristea | 0:741de6c95ae9 | 6 | |
cristea | 0:741de6c95ae9 | 7 | #if DEBUG |
cristea | 0:741de6c95ae9 | 8 | #define LOG(fmt, ...) do { __IRSENDER__irLogger.printf("[IRSender] "); __IRSENDER__irLogger.printf(fmt, ##__VA_ARGS__); } while(0) |
cristea | 0:741de6c95ae9 | 9 | #define APPEND(fmt, ...) do { __IRSENDER__irLogger.printf(fmt, ##__VA_ARGS__); } while(0) |
cristea | 0:741de6c95ae9 | 10 | static Serial __IRSENDER__irLogger(USBTX, USBRX); |
cristea | 0:741de6c95ae9 | 11 | #else |
cristea | 0:741de6c95ae9 | 12 | #define LOG(fmt, ...) |
cristea | 1:402625e9170f | 13 | #define APPEND(fmt, ...) |
cristea | 0:741de6c95ae9 | 14 | #endif |
cristea | 0:741de6c95ae9 | 15 | |
cristea | 0:741de6c95ae9 | 16 | /** Small library to drive the pin of an IR LED. |
cristea | 0:741de6c95ae9 | 17 | * Send the frequency of the signal, the length |
cristea | 0:741de6c95ae9 | 18 | * of the data and the duration of on and off |
cristea | 0:741de6c95ae9 | 19 | * in ms. |
cristea | 0:741de6c95ae9 | 20 | */ |
cristea | 0:741de6c95ae9 | 21 | |
cristea | 0:741de6c95ae9 | 22 | class IRSender { |
cristea | 0:741de6c95ae9 | 23 | private: |
cristea | 0:741de6c95ae9 | 24 | bool _inUse; |
cristea | 0:741de6c95ae9 | 25 | PwmOut senderPin; |
cristea | 0:741de6c95ae9 | 26 | Timer timer; |
cristea | 0:741de6c95ae9 | 27 | |
cristea | 0:741de6c95ae9 | 28 | public: |
cristea | 0:741de6c95ae9 | 29 | IRSender(PinName pin) : _inUse(false), senderPin(pin) {} |
cristea | 0:741de6c95ae9 | 30 | bool irSeq(unsigned freq, unsigned len, const unsigned *data); |
cristea | 0:741de6c95ae9 | 31 | }; |
cristea | 0:741de6c95ae9 | 32 | |
cristea | 0:741de6c95ae9 | 33 | #endif // __IRSENDER__H__ |