Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of PS3_BlueUSB_user_ver_circlewar by
Revision 21:34b11624c5a0, committed 2016-04-03
- Comitter:
- baba2357
- Date:
- Sun Apr 03 18:21:41 2016 +0000
- Parent:
- 20:18ae99ad72f7
- Commit message:
- ????????
Changed in this revision
| User.cpp | 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 |
--- a/User.cpp Thu Mar 31 00:39:51 2016 +0000
+++ b/User.cpp Sun Apr 03 18:21:41 2016 +0000
@@ -1,18 +1,17 @@
-
#include "Utils.h"
#include "USBHost.h"
#include "hci.h"
#include "ps3.h"
#include "User.h"
#include "mbed.h"
-
-int RSX,RSY,LSX,LSY,BSU,BSL;
+int a=0;
+int RSX,RSY,LSX,LSY,BSU,BSL,H=0,h=0;
+bool circleState=0;
//これより下に関数外に書く要素を記入する
PwmOut led1(LED1);
PwmOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);
-DigitalOut hand(p21);
SPI m(p5, p6, p7);
DigitalOut cs(p8);
void UserLoopSetting()
@@ -45,45 +44,68 @@
}
//ここより下にプログラムを書く
//データ取得例
- int M=0;
- bool H=0;
+ int M=0,move=0,updown=0;
+
m.format(16,3);
m.frequency(1000000);
cs=0;
- if((ButtonState >> BUTTONCIRCLE)&1) {
- //○が押されたとき
- H=!H;
- hand=H;
- }
+
//以下の整数MをSPIで送る
//整数Mを16桁の二進数とする。
- //桁数| 16 | 15 | 14 |13|12|11|10|9|8| 7 |6|5|4|3|2|1|
- //指示|右旋回 |左旋回 |Xの+or-| 出力0~63 |Yの+orー| 出力0~63 |
+ //桁数| 16 | 15 | 14 |13|12|11|10| 9 | 8 | 7 | 6 | 5 |4|3|2|1|
+ //指示|右旋回 |左旋回 |Xの+or-| 出力0~15 |アームonoff|上下onoff| 上下+- |空白|Yの+orー|出力0~15|
if((ButtonState >> BUTTONR1)&1) {
- M=1;
- M=M<<15;
+ M=1<<15;
} else if((ButtonState >> BUTTONL1)&1) {
- M=1;
- M=M<<14;
+ M=1<<14;
} else {
if(LSX-129>0) {
M=1;
- M=M<<6;
- M+=(LSX-128)/2;
- M=M<<7;
+ M=M<<4;
+ M+=(LSX-128)/8;
+ M=M<<9;
} else if(LSX-127<0) {
- if(((LSX-128)/2)==-64) M+=63;
- else M+=(-1)*((LSX-128)/2);
- M=M<<7;
+ if(((LSX-128)/8)==-16) M+=15;
+ else M+=(-1)*((LSX-128)/8);
+ M=M<<9;
}
- if(LSY-129>0) {
- M+=0x40;
- M+=(LSY-128)/2;
- } else if(LSY-127<0) {
- if(((LSY-128)/2)==-64) M+=63;
- else M+=(-1)*((LSY-128)/2);
- } else M=0;
+ if((ButtonState >> BUTTONTRIANGEL)&1) {
+ //○が押されたとき
+ circleState=1;
+ a=0;
+ } else {
+ //a=0;
+ if(circleState == 1) {
+ if(H == 0) {
+ H = 1;
+ } else {
+ H = 0;
+ }
+ circleState = 0;
+ }else circleState = 0;
+ //a++;
+ }
+ h=H<<8;
+ if((ButtonState >> BUTTONUP)&1) {
+ move=1<<7;
+ updown=1<<6;
+ } else if((ButtonState >> BUTTONDOWN)&1) {
+ move=1<<7;
}
+ if(LSY-129>0) {
+ M+=0x10;
+ M+=(LSY-128)/8;
+ } else if(LSY-127<0) {
+ if(((LSY-128)/8)==-16) M+=15;
+ else M+=(-1)*((LSY-128)/8);
+ } else {
+ M=0;
+ }
+ }
+ M+=h;
+ M+=move;
+ M+=updown;
+
// m.write(0xffff);
m.write(M);
// printf("%d,%d\n\r",M&0x40,0x40);
@@ -92,6 +114,7 @@
led2=LSY/256.0f;
led3=ButtonState & 0x0400; //L1の状態
led4=ButtonState & 0x0800; //R1の状態
- //値の取得はps3.hを参照
+//値の取得はps3.hを参照
cs=1;
-}
\ No newline at end of file
+ printf("M:%d\t,h:%d\t,updown:%d\t,move:%d\t,a=%d\t\n",M,H,updown,move,a);
+}
--- a/main.cpp Thu Mar 31 00:39:51 2016 +0000
+++ b/main.cpp Sun Apr 03 18:21:41 2016 +0000
@@ -123,5 +123,4 @@
printf("BlueUSB\nNow get a bunch of usb or bluetooth things and plug them in\r\n");
UserLoopSetting();
TestShell();
-
}
