Daisen Remote library
DAISEN リモコン用ライブラリ
- ダイセン電子工業 製
Sample
リモコンの受信機(受信モジュール)とはシリアル(UART)で接続します。
#include "mbed.h" #include "daisenRemote.h" Serial pc(USBTX, USBRX); DigitalOut myled(LED1); daisenRemote remote(p10, daisenRemote::RF); // rx, type void isrRemote () { pc.printf("Recv: %d\r\n", remote.read()); } int main() { pc.baud(115200); pc.printf("*** REMOTE\r\n"); remote.attach(isrRemote); for (;;) { led1 = ! led1; wait(0.2); } }
daisenRemote.h
- Committer:
- okini3939
- Date:
- 2015-04-21
- Revision:
- 0:9edcf415fe92
File content as of revision 0:9edcf415fe92:
/* * Daisen Remote library * Copyright (c) 2015 Hiroshi Suga * Released under the MIT License: http://mbed.org/license/mit * * 2.4GHz: http://www.daisendenshi.com/category_list.php?master_categories_id=102&categories_id=141&categories_name=2.4GHz%91%D1%96%B3%90%FC%83%8A%83%82%83R%83%93%91%97%90M%8A%ED * Infrared: http://www.daisendenshi.com/category_list.php?master_categories_id=102&categories_id=106&categories_name=%90%D4%8AO%83%8A%83%82%83R%83%93%91%97%90M%8A%ED */ #include "mbed.h" #include "FunctionPointer.h" class daisenRemote { public: enum remoteType { RF, // 2.4GHz IR, // Infrared }; daisenRemote (PinName rx, remoteType type = RF); int read (); void attach(void (*fptr)(void)) { _func.attach(fptr); } template<typename T> void attach(T *tptr, void (T::*mptr)(void)) { _func.attach(tptr, mptr); } private: RawSerial _ir; remoteType _type; int _recv; int _count; char _buf[20]; FunctionPointer _func; void isrRemote (); };