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

Files at this revision

API Documentation at this revision

Comitter:
sigveseb
Date:
Fri Aug 01 13:06:27 2014 +0000
Parent:
13:f016a0bc4a7d
Child:
15:cf6c517f31ad
Commit message:
Change IR bt interface

Changed in this revision

Puck.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Puck.lib	Fri Aug 01 12:37:29 2014 +0000
+++ b/Puck.lib	Fri Aug 01 13:06:27 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/sigveseb/code/Puck/#5432b38585ea
+http://mbed.org/teams/Nordic-Pucks/code/Puck/#e620c41de9c3
--- 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