naoki nishii
/
Roomba_Hack
ルンバハック用.
Revision 0:ac1e1657002a, committed 2016-06-24
- Comitter:
- naoki_westwell
- Date:
- Fri Jun 24 07:33:46 2016 +0000
- Commit message:
- Roomba Hack
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Song_Hack.cpp Fri Jun 24 07:33:46 2016 +0000 @@ -0,0 +1,47 @@ +#include "mbed.h" +#include <System_Select.h> + +#ifdef SONG_HACK + +Serial Roomba(p9, p10); + +void send_cmd(char command); + +int main(){ + Roomba.baud(115200); + + send_cmd(START); + send_cmd(SAFE); + wait(5); + + send_cmd(SONG); + send_cmd(0); + send_cmd(8); + send_cmd(0x18); + send_cmd(32); + send_cmd(0x1A); + send_cmd(32); + send_cmd(0x1C); + send_cmd(32); + send_cmd(0x1D); + send_cmd(32); + send_cmd(0x1F); + send_cmd(32); + send_cmd(0x21); + send_cmd(32); + send_cmd(0x23); + send_cmd(32); + send_cmd(0x24); + send_cmd(32); + + wait(1); + + send_cmd(PLAY); + send_cmd(0); + +} + +void send_cmd(char command){ + Roomba.putc(command); +} +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/System_Select.h Fri Jun 24 07:33:46 2016 +0000 @@ -0,0 +1,32 @@ +////////////////////////////////////// +/* 名目規則:[Device]_[Interface] */ +/* [Device] */ +/* 有線: Wired */ +/* Bluetooth: BT */ +/* Xbee: Xbee */ +/* [Interface] */ +/* PC: Pc */ +/* Smartphone: SM */ +/* Hand-made switch:HMS */ +/* ※define は大文字にする. */ +/////////////////////////////////////// + +/* システム選択 */ +#define CMD_RECEIVER +//#define CMD_TRANSMITTER +//#define SONG_HACK + +#define START 0x80 +#define BAUD 0x81 +#define SAFE 0x83 +#define FULL 0x84 +#define CLEAN 0x87 +#define MAX 0x88 +#define SPOT 0x86 +#define SEEK_DOCK 0x8F +#define SCHEDULE 0xA7 +#define SET_DAY_TIME 0xA8 +#define POWER 0x85 +#define BUTTONS 0xA5 +#define SONG 0x8C +#define PLAY 0x8D \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cmd_Receiver.cpp Fri Jun 24 07:33:46 2016 +0000 @@ -0,0 +1,21 @@ +#include "mbed.h" +#include <System_Select.h> + +#ifdef CMD_RECEIVER + +Serial Device(p13, p14); +Serial Roomba(p9, p10); +//Serial pc(USBTX, USBRX); // tx, rx + +int main() { + Device.baud(115200); + Roomba.baud(115200); + + while(1) { + if(Device.readable()){ + Roomba.putc(Device.getc()); + } + } +} + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cmd_Transmitter.cpp Fri Jun 24 07:33:46 2016 +0000 @@ -0,0 +1,38 @@ +#include "mbed.h" +#include <System_Select.h> + +#ifdef CMD_TRANSMITTER + +Serial Device(p9, p10); +DigitalIn SW(p17); +//Serial pc(USBTX, USBRX); // tx, rx + +void send_cmd(char commnad); + +int main() { + Device.baud(115200); + int cnt1 = 0, cnt2 = 0; + + while(1){ + if(cnt1==1){ + send_cmd(START); // OI ON and start cleaning + //send_cmd(SAFE); + send_cmd(CLEAN); + cnt2 = 0; + } + if(cnt2==1){ + send_cmd(BUTTONS); // + send_cmd(0x01); // + cnt1 = 0; + } + + if(SW) cnt1++; + else cnt2++; + } +} + +void send_cmd(char command){ + Device.putc(command); +} + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jun 24 07:33:46 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34 \ No newline at end of file