Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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
Diff: main.cpp
- Revision:
- 15:cf6c517f31ad
- Parent:
- 14:b00d0c5ba8e3
- Parent:
- 12:a7d9b4f303fd
- Child:
- 16:0891823672f4
diff -r b00d0c5ba8e3 -r cf6c517f31ad main.cpp
--- a/main.cpp Fri Aug 01 13:06:27 2014 +0000
+++ b/main.cpp Fri Aug 01 13:46:03 2014 +0000
@@ -1,7 +1,8 @@
#include "mbed.h"
#include "TxIR.hpp"
-#define LOG_LEVEL_VERBOSE
+#define LOG_LEVEL_ERROR
+#include "Log.h"
#include "Puck.h"
Puck* puck = &Puck::getPuck();
@@ -21,13 +22,13 @@
#define COMMAND_BEGIN_CODE_TRANSMISSION 0
#define COMMAND_END_CODE_TRANSMISSION 1
-
void onCommandWrite(uint8_t* value) {
switch(value[0]) {
case COMMAND_BEGIN_CODE_TRANSMISSION:
receiveIndex = 0;
break;
case COMMAND_END_CODE_TRANSMISSION:
+ puck->getBle().disconnect();
LOG_INFO("Going to fire IR code...\n");
txir.txSeq(period, DATA_BUFFER_SIZE, dataBuffer);
LOG_INFO("Fire complete!\n");
@@ -53,8 +54,10 @@
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);
+
while (puck->drive());
}
\ No newline at end of file