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
User.cpp
00001 #include "Utils.h" 00002 #include "USBHost.h" 00003 #include "hci.h" 00004 #include "ps3.h" 00005 #include "User.h" 00006 #include "mbed.h" 00007 #include "math.h" 00008 00009 int RSX,RSY,LSX,LSY,BSU,BSL; 00010 PwmOut servo(p21); //check survo pin 00011 SPI spi(p5,p6,p7); 00012 DigitalOut cs(p8); 00013 int Speed_Mode = 2 ; 00014 int send; 00015 00016 00017 void UserLoopSetting() 00018 { 00019 spi.format(8,3); 00020 spi.frequency(1000000); 00021 servo.pulsewidth_us(1450); 00022 } 00023 void UserLoop(char n,const u8* data) 00024 { 00025 u16 ButtonState; 00026 if(n==0) { //有線Ps3USB.cpp 00027 RSX = ((ps3report*)data)->RightStickX; 00028 RSY = ((ps3report*)data)->RightStickY; 00029 LSX = ((ps3report*)data)->LeftStickX; 00030 LSY = ((ps3report*)data)->LeftStickY; 00031 BSU = (u8)(((ps3report*)data)->ButtonState & 0x00ff); 00032 BSL = (u8)(((ps3report*)data)->ButtonState >> 8); 00033 //ボタンの処理 00034 ButtonState = ((ps3report*)data)->ButtonState; 00035 } else {//無線TestShell.cpp 00036 RSX = ((ps3report*)(data + 1))->RightStickX; 00037 RSY = ((ps3report*)(data + 1))->RightStickY; 00038 LSX = ((ps3report*)(data + 1))->LeftStickX; 00039 LSY = ((ps3report*)(data + 1))->LeftStickY; 00040 BSU = (u8)(((ps3report*)(data + 1))->ButtonState & 0x00ff); 00041 BSL = (u8)(((ps3report*)(data + 1))->ButtonState >> 8); 00042 //ボタンの処理 00043 ButtonState = ((ps3report*)(data + 1))->ButtonState; 00044 } 00045 //ここより下にプログラムを書く 00046 //spi通信用プログラム 00047 send = 0; 00048 if((ButtonState >> BUTTONUP)&1 == 1&&(ButtonState >> BUTTONL1)&1 == 1)//UPL1 00049 { 00050 send = 84; 00051 }else if ((ButtonState >> BUTTONDOWN)&1 == 1&&(ButtonState >> BUTTONR1)&1 == 1)//DownR1 00052 { 00053 send = 168; 00054 }else if ((ButtonState >> BUTTONUP)&1 == 1&&(ButtonState >> BUTTONR1)&1 == 1)//UPR1 00055 { 00056 send = 148; 00057 }else if ((ButtonState >> BUTTONDOWN)&1 == 1&&(ButtonState >> BUTTONL1)&1 == 1)//DownL1 00058 { 00059 send = 104; 00060 }else if((ButtonState >> BUTTONUP)&1 == 1) 00061 {//対応するボタンを書く(今回上ボタン 00062 send = 20; 00063 }else if((ButtonState >> BUTTONDOWN)&1 == 1) 00064 {//対応するボタンを書く(今回下ボタン 00065 send = 40; 00066 }else if((ButtonState >> BUTTONL1)&1 == 1) 00067 {//対応するボタンを書く(今回L1ボタン 00068 send = 100; 00069 }else if((ButtonState >> BUTTONR1)&1 == 1) 00070 {//対応するボタンを書く(今回R1ボタン 00071 send = 152; 00072 }else{ 00073 send = 0; 00074 } 00075 if((ButtonState >> BUTTONL2)&1 == 1&&Speed_Mode>1) {//対応するボタンを書く(今回L2ボタン 00076 Speed_Mode-=1; 00077 wait(0.1); 00078 }else if((ButtonState >> BUTTONR2)&1 == 1&&Speed_Mode<3) {//対応するボタンを書く(今回R2ボタン 00079 Speed_Mode+=1; 00080 wait(0.1); 00081 } 00082 if((ButtonState >> BUTTONTRIANGEL)&1 == 1) {//対応するボタンを書く(今回△ボタン 00083 servo.pulsewidth_us(1450); 00084 } else if((ButtonState >> BUTTONCROSS)&1 == 1) {//対応するボタンを書く(今回×ボタン 00085 servo.pulsewidth_us(2400); 00086 } 00087 send += Speed_Mode; 00088 spi. write(send); 00089 }
Generated on Thu Jul 14 2022 17:06:26 by
1.7.2