AppleRemote receive library.
Diff: main.cpp
- Revision:
- 0:a5f26ed3f510
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Aug 08 11:19:56 2010 +0000 @@ -0,0 +1,38 @@ +#include "mbed.h" +#include "AppleRemote.h" + +Serial pc(USBTX, USBRX); +AppleRemote remote(p5); + +int main() { + + pc.baud(115200); + remote.start(); + //remote.repeat(1); + + while(1) { + if(remote.readable()){ + int code; + code = remote.getc() & 0x0ff; + pc.printf("code = %02X ",code); + switch(code){ + /* --- */ + case AppleRemote::MENU_1ST: pc.printf("Menu (1st generation)\n"); break; + case AppleRemote::PLAY_1ST: pc.printf("Play (1st generation)\n"); break; + case AppleRemote::RIGHT_1ST: pc.printf("Right (1st generation)\n"); break; + case AppleRemote::LEFT_1ST: pc.printf("Left (1st generation)\n"); break; + case AppleRemote::UP_1ST: pc.printf("Up (1st generation)\n"); break; + case AppleRemote::DOWN_1ST: pc.printf("DOWN (1st generation)\n"); break; + /* --- */ + case AppleRemote::CENTER_2ND: pc.printf("Center (2nd generation)\n"); break; + case AppleRemote::MENU_2ND: pc.printf("Menu (2nd generation)\n"); break; + case AppleRemote::PLAY_2ND: pc.printf("Play (2nd generation)\n"); break; + case AppleRemote::RIGHT_2ND: pc.printf("Right (2nd generation)\n"); break; + case AppleRemote::LEFT_2ND: pc.printf("Left (2nd generation)\n"); break; + case AppleRemote::UP_2ND: pc.printf("Up (2nd generation)\n"); break; + case AppleRemote::DOWN_2ND: pc.printf("DOWN (2nd generation)\n"); break; + default: pc.printf("*** UNKNOWN ***\n"); break; + } + } + } +}