The IR Puck can mimic arbitrary infrared remote controls. Built on the Puck IOT platform.
Dependencies: Puck IRSender mbed
The IR Puck is a puck that can mimic arbitrary infrared remote controls. This is useful for controlling things like TVs, radios, airconditioners, window blinds, and just about anything and everything that can be otherwise be controlled by a regular remote control.
A tutorial for the IR Puck is available on GitHub.
Tutorials and in-depth documentation for the Puck platform is available at the project's GitHub page
main.cpp@10:35d78d589580, 2014-07-24 (annotated)
- Committer:
- cristea
- Date:
- Thu Jul 24 09:30:43 2014 +0000
- Revision:
- 10:35d78d589580
- Parent:
- 8:260888851644
- Child:
- 12:a7d9b4f303fd
Update logging to new logging system
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sigveseb | 0:c94311378ec1 | 1 | #include "mbed.h" |
sigveseb | 0:c94311378ec1 | 2 | #include "IR.h" |
sigveseb | 0:c94311378ec1 | 3 | |
cristea | 10:35d78d589580 | 4 | #define LOG_LEVEL_ERROR |
cristea | 10:35d78d589580 | 5 | #include "Log.h" |
sigveseb | 5:3642c0af497e | 6 | #include "Puck.h" |
sigveseb | 0:c94311378ec1 | 7 | |
sigveseb | 5:3642c0af497e | 8 | Puck* puck = &Puck::getPuck(); |
sigveseb | 0:c94311378ec1 | 9 | |
sigveseb | 5:3642c0af497e | 10 | const UUID IR_SERVICE_UUID = stringToUUID("bftj ir "); |
sigveseb | 5:3642c0af497e | 11 | const UUID HEADER_UUID = stringToUUID("bftj ir header "); |
sigveseb | 5:3642c0af497e | 12 | const UUID ONE_UUID = stringToUUID("bftj ir one "); |
sigveseb | 5:3642c0af497e | 13 | const UUID ZERO_UUID = stringToUUID("bftj ir zero "); |
sigveseb | 5:3642c0af497e | 14 | const UUID PTRAIL_UUID = stringToUUID("bftj ir ptrail "); |
sigveseb | 5:3642c0af497e | 15 | const UUID PREDATA_UUID = stringToUUID("bftj ir predata "); |
sigveseb | 5:3642c0af497e | 16 | const UUID CODE_UUID = stringToUUID("bftj ir code "); |
sigveseb | 0:c94311378ec1 | 17 | |
stiaje | 4:24d9873936e6 | 18 | |
sigveseb | 5:3642c0af497e | 19 | void onIRCodeWrite(uint8_t* value) { |
stiaje | 8:260888851644 | 20 | puck->getBle().disconnect(); |
sigveseb | 5:3642c0af497e | 21 | LOG_INFO("Going to fire IR code...\n"); |
sigveseb | 5:3642c0af497e | 22 | fireIRCode(puck->getCharacteristicValue(HEADER_UUID), |
sigveseb | 5:3642c0af497e | 23 | puck->getCharacteristicValue(ONE_UUID), |
sigveseb | 5:3642c0af497e | 24 | puck->getCharacteristicValue(ZERO_UUID), |
sigveseb | 5:3642c0af497e | 25 | puck->getCharacteristicValue(PTRAIL_UUID), |
sigveseb | 5:3642c0af497e | 26 | puck->getCharacteristicValue(PREDATA_UUID), |
sigveseb | 5:3642c0af497e | 27 | puck->getCharacteristicValue(CODE_UUID)); |
sigveseb | 5:3642c0af497e | 28 | LOG_INFO("Fire complete!\n"); |
sigveseb | 0:c94311378ec1 | 29 | } |
sigveseb | 0:c94311378ec1 | 30 | |
sigveseb | 0:c94311378ec1 | 31 | |
sigveseb | 5:3642c0af497e | 32 | int main() { |
sigveseb | 5:3642c0af497e | 33 | puck->addCharacteristic(IR_SERVICE_UUID, HEADER_UUID, 4); |
sigveseb | 5:3642c0af497e | 34 | puck->addCharacteristic(IR_SERVICE_UUID, ONE_UUID, 4); |
sigveseb | 5:3642c0af497e | 35 | puck->addCharacteristic(IR_SERVICE_UUID, ZERO_UUID, 4); |
sigveseb | 5:3642c0af497e | 36 | puck->addCharacteristic(IR_SERVICE_UUID, PTRAIL_UUID, 2); |
sigveseb | 5:3642c0af497e | 37 | puck->addCharacteristic(IR_SERVICE_UUID, PREDATA_UUID, 2); |
sigveseb | 5:3642c0af497e | 38 | puck->addCharacteristic(IR_SERVICE_UUID, CODE_UUID, 2); |
sigveseb | 5:3642c0af497e | 39 | puck->init(0xABBA); |
sigveseb | 5:3642c0af497e | 40 | puck->onCharacteristicWrite(CODE_UUID, onIRCodeWrite); |
sigveseb | 5:3642c0af497e | 41 | while (puck->drive()); |
sigveseb | 0:c94311378ec1 | 42 | } |