Nordic Pucks / Mbed 2 deprecated ir-puck Featured

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

Revision:
14:b00d0c5ba8e3
Parent:
13:f016a0bc4a7d
Child:
15:cf6c517f31ad
diff -r f016a0bc4a7d -r b00d0c5ba8e3 main.cpp
--- a/main.cpp	Fri Aug 01 12:37:29 2014 +0000
+++ b/main.cpp	Fri Aug 01 13:06:27 2014 +0000
@@ -13,7 +13,8 @@
 const UUID DATA_UUID       = stringToUUID("bftj ir data    ");
 const UUID PERIOD_UUID     = stringToUUID("bftj ir period  ");
 
-unsigned int dataBuffer[100];
+#define DATA_BUFFER_SIZE 100
+unsigned int dataBuffer[DATA_BUFFER_SIZE];
 uint8_t period = 26;
 int receiveIndex;
 
@@ -22,14 +23,13 @@
 
 
 void onCommandWrite(uint8_t* value) {
-    LOG_VERBOSE("Got command: %i\n", value[0]);
     switch(value[0]) {
         case COMMAND_BEGIN_CODE_TRANSMISSION:
             receiveIndex = 0;
             break;
         case COMMAND_END_CODE_TRANSMISSION:
             LOG_INFO("Going to fire IR code...\n");
-            txir.txSeq(period, 200, dataBuffer);
+            txir.txSeq(period, DATA_BUFFER_SIZE, dataBuffer);
             LOG_INFO("Fire complete!\n");
             break;
     }
@@ -37,8 +37,7 @@
 
 
 void onDataWrite(uint8_t* value) {
-    LOG_VERBOSE("Got data, index: %i\n", receiveIndex);
-    for(int i = 0; i < 20 && receiveIndex < 100; i += 2) {
+    for(int i = 0; i < 20 && receiveIndex < DATA_BUFFER_SIZE; i += 2) {
         dataBuffer[receiveIndex++] = (value[i] << 8) | value[i + 1];
     }
 }
@@ -46,7 +45,6 @@
 
 void onPeriodWrite(uint8_t* value) {
     period = value[0];    
-    LOG_VERBOSE("Period is now: %i\n", period);
 }
 
 
@@ -55,8 +53,8 @@
     puck->addCharacteristic(IR_SERVICE_UUID, DATA_UUID, 20);
     puck->addCharacteristic(IR_SERVICE_UUID, PERIOD_UUID, 1);
     puck->init(0xABBA);
-    puck->onCharacteristicWrite(COMMAND_UUID, onCommandWrite);
-    puck->onCharacteristicWrite(DATA_UUID, onDataWrite);
-    puck->onCharacteristicWrite(PERIOD_UUID, onPeriodWrite);
+    puck->onCharacteristicWrite(&COMMAND_UUID, onCommandWrite);
+    puck->onCharacteristicWrite(&DATA_UUID, onDataWrite);
+    puck->onCharacteristicWrite(&PERIOD_UUID, onPeriodWrite);
     while (puck->drive());
 }
\ No newline at end of file