![](/media/cache/profiles/383df222b83e1c6dd536dd72ff48ce09.jpg.50x50_q85.jpg)
ir-puck
Dependencies: Puck IRSender mbed
Fork of ir-puck by
main.cpp@5:3642c0af497e, 2014-07-23 (annotated)
- Committer:
- sigveseb
- Date:
- Wed Jul 23 13:01:27 2014 +0000
- Revision:
- 5:3642c0af497e
- Parent:
- 4:24d9873936e6
- Child:
- 8:260888851644
updated to use newer puck lib
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 | |
sigveseb | 5:3642c0af497e | 4 | #define LOG_LEVEL_VERBOSE |
sigveseb | 5:3642c0af497e | 5 | #include "Puck.h" |
sigveseb | 0:c94311378ec1 | 6 | |
sigveseb | 5:3642c0af497e | 7 | Puck* puck = &Puck::getPuck(); |
sigveseb | 0:c94311378ec1 | 8 | |
sigveseb | 5:3642c0af497e | 9 | const UUID IR_SERVICE_UUID = stringToUUID("bftj ir "); |
sigveseb | 5:3642c0af497e | 10 | const UUID HEADER_UUID = stringToUUID("bftj ir header "); |
sigveseb | 5:3642c0af497e | 11 | const UUID ONE_UUID = stringToUUID("bftj ir one "); |
sigveseb | 5:3642c0af497e | 12 | const UUID ZERO_UUID = stringToUUID("bftj ir zero "); |
sigveseb | 5:3642c0af497e | 13 | const UUID PTRAIL_UUID = stringToUUID("bftj ir ptrail "); |
sigveseb | 5:3642c0af497e | 14 | const UUID PREDATA_UUID = stringToUUID("bftj ir predata "); |
sigveseb | 5:3642c0af497e | 15 | const UUID CODE_UUID = stringToUUID("bftj ir code "); |
sigveseb | 0:c94311378ec1 | 16 | |
stiaje | 4:24d9873936e6 | 17 | |
sigveseb | 5:3642c0af497e | 18 | void onIRCodeWrite(uint8_t* value) { |
sigveseb | 5:3642c0af497e | 19 | LOG_INFO("Going to fire IR code...\n"); |
sigveseb | 5:3642c0af497e | 20 | fireIRCode(puck->getCharacteristicValue(HEADER_UUID), |
sigveseb | 5:3642c0af497e | 21 | puck->getCharacteristicValue(ONE_UUID), |
sigveseb | 5:3642c0af497e | 22 | puck->getCharacteristicValue(ZERO_UUID), |
sigveseb | 5:3642c0af497e | 23 | puck->getCharacteristicValue(PTRAIL_UUID), |
sigveseb | 5:3642c0af497e | 24 | puck->getCharacteristicValue(PREDATA_UUID), |
sigveseb | 5:3642c0af497e | 25 | puck->getCharacteristicValue(CODE_UUID)); |
sigveseb | 5:3642c0af497e | 26 | LOG_INFO("Fire complete!\n"); |
sigveseb | 0:c94311378ec1 | 27 | } |
sigveseb | 0:c94311378ec1 | 28 | |
sigveseb | 0:c94311378ec1 | 29 | |
sigveseb | 5:3642c0af497e | 30 | int main() { |
sigveseb | 5:3642c0af497e | 31 | puck->addCharacteristic(IR_SERVICE_UUID, HEADER_UUID, 4); |
sigveseb | 5:3642c0af497e | 32 | puck->addCharacteristic(IR_SERVICE_UUID, ONE_UUID, 4); |
sigveseb | 5:3642c0af497e | 33 | puck->addCharacteristic(IR_SERVICE_UUID, ZERO_UUID, 4); |
sigveseb | 5:3642c0af497e | 34 | puck->addCharacteristic(IR_SERVICE_UUID, PTRAIL_UUID, 2); |
sigveseb | 5:3642c0af497e | 35 | puck->addCharacteristic(IR_SERVICE_UUID, PREDATA_UUID, 2); |
sigveseb | 5:3642c0af497e | 36 | puck->addCharacteristic(IR_SERVICE_UUID, CODE_UUID, 2); |
sigveseb | 5:3642c0af497e | 37 | puck->init(0xABBA); |
sigveseb | 5:3642c0af497e | 38 | puck->onCharacteristicWrite(CODE_UUID, onIRCodeWrite); |
sigveseb | 5:3642c0af497e | 39 | while (puck->drive()); |
sigveseb | 0:c94311378ec1 | 40 | } |