ロボコンマガジン 2013年1月号に掲載されている 「第3回お手軽mbedではじめるロボットプロトタイピング」 で紹介しているうおーるぼっとをマウスで動かすプログラムです。
Dependencies: FatFileSystem TB6612FNG2 mbed
Fork of BlueUSB by
Revision 1:2526b2c89256, committed 2012-12-14
- Comitter:
- jksoft
- Date:
- Fri Dec 14 03:34:00 2012 +0000
- Parent:
- 0:606b230e5b4a
- Commit message:
- Rev1
Changed in this revision
diff -r 606b230e5b4a -r 2526b2c89256 AutoEvents.cpp --- a/AutoEvents.cpp Sat Apr 10 00:30:24 2010 +0000 +++ b/AutoEvents.cpp Fri Dec 14 03:34:00 2012 +0000 @@ -24,6 +24,7 @@ #include "mbed.h" #include "USBHost.h" #include "Utils.h" +#include "TB6612.h" #define AUTOEVT(_class,_subclass,_protocol) (((_class) << 16) | ((_subclass) << 8) | _protocol) #define AUTO_KEYBOARD AUTOEVT(CLASS_HID,1,1) @@ -33,8 +34,12 @@ u8 auto_keyboard[8]; // modifiers,reserved,keycode1..keycode6 u8 auto_joystick[4]; // x,y,buttons,throttle +TB6612 left(p21,p12,p11); +TB6612 right(p22,p14,p13); + void AutoEventCallback(int device, int endpoint, int status, u8* data, int len, void* userData) { + static int speed = 100; int evt = (int)userData; switch (evt) { @@ -47,6 +52,31 @@ default: printf("HUH "); } + + if( (data[0] & 0x01) != 0 ) + { + left = speed; + } + else + { + left = 0; + } + if( (data[0] & 0x02) != 0 ) + { + right = speed; + } + else + { + right = 0; + } + + speed = speed + (signed char)data[3]; + + if( speed > 100 ) speed = 100; + if( speed < -100 ) speed = -100; + + printf("speed = %d ",speed); + printfBytes("data",data,len); USBInterruptTransfer(device,endpoint,data,len,AutoEventCallback,userData); }
diff -r 606b230e5b4a -r 2526b2c89256 FATFileSystem.lib --- a/FATFileSystem.lib Sat Apr 10 00:30:24 2010 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_unsupported/code/fatfilesystem/ \ No newline at end of file
diff -r 606b230e5b4a -r 2526b2c89256 FatFileSystem.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FatFileSystem.lib Fri Dec 14 03:34:00 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/AdamGreen/code/FatFileSystem/#6ceefe1c53e4
diff -r 606b230e5b4a -r 2526b2c89256 TB6612FNG2.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TB6612FNG2.lib Fri Dec 14 03:34:00 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/jksoft/code/TB6612FNG2/#051a7ecff13e