Arch + Grove - Infrared Receiver + Infrared Remote Control = Wireless Keyboard

Dependencies:   DigitDisplay RemoteIR USBDevice mbed

Files at this revision

API Documentation at this revision

Comitter:
yihui
Date:
Tue Aug 26 14:22:26 2014 +0000
Commit message:
initial

Changed in this revision

DigitDisplay.lib Show annotated file Show diff for this revision Revisions of this file
RemoteIR.lib Show annotated file Show diff for this revision Revisions of this file
USBDevice.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 9d5cfc5edee0 DigitDisplay.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DigitDisplay.lib	Tue Aug 26 14:22:26 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/seeed/code/DigitDisplay/#d3173c8bfd48
diff -r 000000000000 -r 9d5cfc5edee0 RemoteIR.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RemoteIR.lib	Tue Aug 26 14:22:26 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/shintamainjp/code/RemoteIR/#268cc2ab63bd
diff -r 000000000000 -r 9d5cfc5edee0 USBDevice.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Tue Aug 26 14:22:26 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/USBDevice/#ecbbaf64bc3d
diff -r 000000000000 -r 9d5cfc5edee0 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Aug 26 14:22:26 2014 +0000
@@ -0,0 +1,82 @@
+
+#include <string.h>
+#include "mbed.h"
+#include "ReceiverIR.h"
+#include "DigitDisplay.h"
+#include "USBKeyboard.h"
+
+ 
+ReceiverIR ir_rx(P0_4);
+DigitDisplay display(P1_14, P1_13);
+USBKeyboard keyboard;
+BusOut led(LED1);
+Ticker ledTicker;
+
+const uint8_t INFRARED_CODE[][4] = {
+{0x00, 0xFF, 0x45, 0xBA},   // Power
+{0x00, 0xFF, 0x46, 0xB9},   // Mode
+{0x00, 0xFF, 0x47, 0xB8},   // Mute
+{0x00, 0xFF, 0x44, 0xBB},   // Play
+{0x00, 0xFF, 0x40, 0xBF},   // Prev
+{0x00, 0xFF, 0x43, 0xBC},   // Next
+{0x00, 0xFF, 0x07, 0xF8},   // EQ
+{0x00, 0xFF, 0x15, 0xEA},   // -
+{0x00, 0xFF, 0x09, 0xF6},   // +
+{0x00, 0xFF, 0x16, 0xE9},   // 0
+{0x00, 0xFF, 0x19, 0xE6},   // 
+{0x00, 0xFF, 0x0D, 0xF2},   // U/SD
+{0x00, 0xFF, 0x0C, 0xF3},   // 1
+{0x00, 0xFF, 0x18, 0xE7},   // 2
+{0x00, 0xFF, 0x5E, 0xA1},   // 3
+{0x00, 0xFF, 0x08, 0xF7},   // 4
+{0x00, 0xFF, 0x1C, 0xE3},   // 5
+{0x00, 0xFF, 0x5A, 0xA5},   // 6
+{0x00, 0xFF, 0x42, 0xBD},   // 7
+{0x00, 0xFF, 0x52, 0xAD},   // 8
+{0x00, 0xFF, 0x4A, 0xB5}    // 9
+};
+
+ 
+void blink(void) {
+    led = !led;
+}
+
+int main(void) {
+    ledTicker.attach(&blink, 0.5);
+    
+    while (1) {
+        uint8_t rbuffer[32] = {0, };
+        int bitlength;
+        RemoteIR::Format format;
+ 
+        memset(rbuffer, 0x00, sizeof(rbuffer));
+        
+        while (ir_rx.getState() != ReceiverIR::Received) {
+        }
+        bitlength = ir_rx.getData(&format, rbuffer, sizeof(rbuffer) * 8);
+        if ((RemoteIR::NEC == format) && (32 == bitlength)) {
+            for (int i = 0; i < (sizeof(INFRARED_CODE) / sizeof(INFRARED_CODE[0])); i++) {
+                if (0 == memcmp(rbuffer, INFRARED_CODE[i], 4)) {
+                    // No i infrared code is matched
+                    display.write(i);
+                    if (2 == i) {
+                        keyboard.mediaControl(KEY_MUTE);
+                    } else if (3 == i) {
+                        keyboard.mediaControl(KEY_PLAY_PAUSE);
+                    } else if (4 == i) {
+                        keyboard.mediaControl(KEY_PREVIOUS_TRACK);
+                    } else if (5 == i) {
+                        keyboard.mediaControl(KEY_NEXT_TRACK);
+                    } else if (7 == i) {
+                        keyboard.mediaControl(KEY_VOLUME_DOWN);
+                    } else if (8 == i) {
+                        keyboard.mediaControl(KEY_VOLUME_UP);
+                    } else if (12 <= i) {
+                        keyboard.putc('1' + i - 12);
+                    }
+                    break;
+                }
+            }
+        }
+    }
+}
diff -r 000000000000 -r 9d5cfc5edee0 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Aug 26 14:22:26 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8e73be2a2ac1
\ No newline at end of file