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 clubvs2017_momoi by
KaidaKari.cpp@17:efe67bbb927e, 2016-06-10 (annotated)
- Committer:
- abcdefgh
- Date:
- Fri Jun 10 06:05:29 2016 +0000
- Revision:
- 17:efe67bbb927e
- Parent:
- 16:ea0808fbbb40
- Child:
- 18:cab2885dc8fe
momoi
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Junbug | 12:b2f3c85cba36 | 1 | #include "Utils.h" |
Junbug | 12:b2f3c85cba36 | 2 | #include "USBHost.h" |
Junbug | 12:b2f3c85cba36 | 3 | #include "hci.h" |
Junbug | 12:b2f3c85cba36 | 4 | #include "ps3.h" |
Junbug | 12:b2f3c85cba36 | 5 | #include "User.h" |
Junbug | 12:b2f3c85cba36 | 6 | #include "mbed.h" |
Junbug | 12:b2f3c85cba36 | 7 | |
Junbug | 12:b2f3c85cba36 | 8 | int RSX,RSY,LSX,LSY,BSU,BSL; |
Junbug | 12:b2f3c85cba36 | 9 | //これより下に関数外に書く要素を記入する |
abcdefgh | 17:efe67bbb927e | 10 | double flag; |
Junbug | 12:b2f3c85cba36 | 11 | //MD1 |
abcdefgh | 17:efe67bbb927e | 12 | PwmOut motorRightOne (p23); |
abcdefgh | 17:efe67bbb927e | 13 | PwmOut motorRightTwo (p24); |
Junbug | 12:b2f3c85cba36 | 14 | |
Junbug | 12:b2f3c85cba36 | 15 | //MD2 |
abcdefgh | 17:efe67bbb927e | 16 | PwmOut motorLeftOne (p21); |
abcdefgh | 17:efe67bbb927e | 17 | PwmOut motorLeftTwo (p22); |
Junbug | 12:b2f3c85cba36 | 18 | |
Junbug | 12:b2f3c85cba36 | 19 | //MD3 Arm1 |
abcdefgh | 17:efe67bbb927e | 20 | PwmOut armRight(p26); |
abcdefgh | 17:efe67bbb927e | 21 | DigitalOut armThree (p30); |
abcdefgh | 17:efe67bbb927e | 22 | DigitalOut armFour (p29); |
Junbug | 12:b2f3c85cba36 | 23 | |
Junbug | 12:b2f3c85cba36 | 24 | //MD4 Arm2 |
abcdefgh | 17:efe67bbb927e | 25 | PwmOut armLeft(p25); |
abcdefgh | 17:efe67bbb927e | 26 | DigitalOut armOne (p6); |
abcdefgh | 17:efe67bbb927e | 27 | DigitalOut armTwo (p5); |
Junbug | 12:b2f3c85cba36 | 28 | |
Junbug | 12:b2f3c85cba36 | 29 | |
Junbug | 12:b2f3c85cba36 | 30 | /* |
Junbug | 12:b2f3c85cba36 | 31 | |
Junbug | 12:b2f3c85cba36 | 32 | PWM->0.xxx |
Junbug | 12:b2f3c85cba36 | 33 | Digitals->0 and 0.xxx |
Junbug | 12:b2f3c85cba36 | 34 | for arms(I guess...) |
Junbug | 12:b2f3c85cba36 | 35 | |
Junbug | 12:b2f3c85cba36 | 36 | For lergs, turn right or left, and just going go and back.->Probably using sticks. |
Junbug | 12:b2f3c85cba36 | 37 | How to cha ge speed? Two different tyes of speed. |
Junbug | 12:b2f3c85cba36 | 38 | |
Junbug | 12:b2f3c85cba36 | 39 | Wow, Taka-chan will do one of the machine. He wants to do with the angles. Plus I don't understand what they are talking about!! |
Junbug | 12:b2f3c85cba36 | 40 | Left stick, speed and right/left |
Junbug | 12:b2f3c85cba36 | 41 | Push button and max incline -> the max speed |
Junbug | 12:b2f3c85cba36 | 42 | Just max incline -> usual speed |
Junbug | 12:b2f3c85cba36 | 43 | Little incline -> slow speed |
Junbug | 12:b2f3c85cba36 | 44 | |
Junbug | 12:b2f3c85cba36 | 45 | L1/R2 -> turning? |
Junbug | 12:b2f3c85cba36 | 46 | |
Junbug | 12:b2f3c85cba36 | 47 | Lifting -> |
Junbug | 12:b2f3c85cba36 | 48 | |
Junbug | 12:b2f3c85cba36 | 49 | */ |
Junbug | 12:b2f3c85cba36 | 50 | |
Junbug | 12:b2f3c85cba36 | 51 | |
Junbug | 12:b2f3c85cba36 | 52 | |
Junbug | 12:b2f3c85cba36 | 53 | void UserLoopSetting() |
Junbug | 12:b2f3c85cba36 | 54 | { |
Junbug | 12:b2f3c85cba36 | 55 | //一度だけ行いたい初期設定をここに書く |
Junbug | 12:b2f3c85cba36 | 56 | /* |
Junbug | 12:b2f3c85cba36 | 57 | I need to ask what to do with this! |
Junbug | 12:b2f3c85cba36 | 58 | Actually, do we have any LEDs? |
Junbug | 12:b2f3c85cba36 | 59 | */ |
abcdefgh | 15:5e973e6c058c | 60 | |
Junbug | 12:b2f3c85cba36 | 61 | } |
Junbug | 12:b2f3c85cba36 | 62 | |
Junbug | 12:b2f3c85cba36 | 63 | void UserLoop(char n,const u8* data) |
Junbug | 12:b2f3c85cba36 | 64 | { |
Junbug | 12:b2f3c85cba36 | 65 | u16 ButtonState; |
Junbug | 12:b2f3c85cba36 | 66 | if(n==0) { //有線Ps3USB.cpp |
Junbug | 12:b2f3c85cba36 | 67 | RSX = ((ps3report*)data)->RightStickX; |
Junbug | 12:b2f3c85cba36 | 68 | RSY = ((ps3report*)data)->RightStickY; |
Junbug | 12:b2f3c85cba36 | 69 | LSX = ((ps3report*)data)->LeftStickX; |
Junbug | 12:b2f3c85cba36 | 70 | LSY = ((ps3report*)data)->LeftStickY; |
Junbug | 12:b2f3c85cba36 | 71 | BSU = (u8)(((ps3report*)data)->ButtonState & 0x00ff); |
Junbug | 12:b2f3c85cba36 | 72 | BSL = (u8)(((ps3report*)data)->ButtonState >> 8); |
Junbug | 12:b2f3c85cba36 | 73 | //ボタンの処理 |
Junbug | 12:b2f3c85cba36 | 74 | ButtonState = ((ps3report*)data)->ButtonState; |
Junbug | 12:b2f3c85cba36 | 75 | } else {//無線TestShell.cpp |
Junbug | 12:b2f3c85cba36 | 76 | RSX = ((ps3report*)(data + 1))->RightStickX; |
Junbug | 12:b2f3c85cba36 | 77 | RSY = ((ps3report*)(data + 1))->RightStickY; |
Junbug | 12:b2f3c85cba36 | 78 | LSX = ((ps3report*)(data + 1))->LeftStickX; |
Junbug | 12:b2f3c85cba36 | 79 | LSY = ((ps3report*)(data + 1))->LeftStickY; |
Junbug | 12:b2f3c85cba36 | 80 | BSU = (u8)(((ps3report*)(data + 1))->ButtonState & 0x00ff); |
Junbug | 12:b2f3c85cba36 | 81 | BSL = (u8)(((ps3report*)(data + 1))->ButtonState >> 8); |
Junbug | 12:b2f3c85cba36 | 82 | //ボタンの処理 |
Junbug | 12:b2f3c85cba36 | 83 | ButtonState = ((ps3report*)(data + 1))->ButtonState; |
Junbug | 12:b2f3c85cba36 | 84 | } |
Junbug | 12:b2f3c85cba36 | 85 | //ここより下にプログラムを書く |
Junbug | 12:b2f3c85cba36 | 86 | |
Junbug | 12:b2f3c85cba36 | 87 | /* |
Junbug | 12:b2f3c85cba36 | 88 | double thesOne = 64; |
Junbug | 12:b2f3c85cba36 | 89 | double thesTwo = 127; |
Junbug | 12:b2f3c85cba36 | 90 | double thesThree = 191; |
Junbug | 12:b2f3c85cba36 | 91 | double fastSpeed = 1; |
Junbug | 12:b2f3c85cba36 | 92 | double slowSpeed = 0.5; |
Junbug | 12:b2f3c85cba36 | 93 | */ |
abcdefgh | 15:5e973e6c058c | 94 | |
abcdefgh | 14:67ee8d8f4efe | 95 | //motor |
abcdefgh | 17:efe67bbb927e | 96 | if((ButtonState >> BUTTONPS)&1 == 1){ |
abcdefgh | 17:efe67bbb927e | 97 | flag = 0; |
abcdefgh | 17:efe67bbb927e | 98 | }else if((ButtonState >> BUTTONSTART)&1 == 1) { |
abcdefgh | 17:efe67bbb927e | 99 | flag += 0.05; |
abcdefgh | 17:efe67bbb927e | 100 | } else if((ButtonState >> BUTTONSELECT)&1 == 1) { |
abcdefgh | 17:efe67bbb927e | 101 | flag -= 0.05; |
abcdefgh | 17:efe67bbb927e | 102 | } |
abcdefgh | 17:efe67bbb927e | 103 | |
abcdefgh | 17:efe67bbb927e | 104 | if(LSY>140 && ((ButtonState >> BUTTONLANALOG)&1) == 1) { |
abcdefgh | 17:efe67bbb927e | 105 | motorRightOne = 0.8; |
Junbug | 12:b2f3c85cba36 | 106 | motorRightTwo = 0; |
abcdefgh | 17:efe67bbb927e | 107 | motorLeftOne = 0.8; |
abcdefgh | 17:efe67bbb927e | 108 | motorLeftTwo = 0; |
abcdefgh | 17:efe67bbb927e | 109 | }else if(LSY<110 && ((ButtonState >> BUTTONLANALOG)&1) == 1) { |
abcdefgh | 17:efe67bbb927e | 110 | motorRightOne = 0; |
abcdefgh | 17:efe67bbb927e | 111 | motorRightTwo = 0.8; |
abcdefgh | 17:efe67bbb927e | 112 | motorLeftOne = 0; |
abcdefgh | 17:efe67bbb927e | 113 | motorLeftTwo = 0.8; |
abcdefgh | 17:efe67bbb927e | 114 | }else if( LSY > 140 ) { //forward |
abcdefgh | 17:efe67bbb927e | 115 | motorRightOne = 0.4 + flag; |
abcdefgh | 17:efe67bbb927e | 116 | motorRightTwo = 0; |
abcdefgh | 17:efe67bbb927e | 117 | motorLeftOne = 0.4 + flag; |
Junbug | 12:b2f3c85cba36 | 118 | motorLeftTwo = 0; |
abcdefgh | 15:5e973e6c058c | 119 | |
abcdefgh | 15:5e973e6c058c | 120 | } else if( LSY < 110 ) { //back |
Junbug | 12:b2f3c85cba36 | 121 | motorRightOne = 0; |
abcdefgh | 17:efe67bbb927e | 122 | motorRightTwo = 0.4 + flag; |
Junbug | 12:b2f3c85cba36 | 123 | motorLeftOne = 0; |
abcdefgh | 17:efe67bbb927e | 124 | motorLeftTwo = 0.4 + flag; |
abcdefgh | 15:5e973e6c058c | 125 | } else { //stop |
abcdefgh | 14:67ee8d8f4efe | 126 | motorRightOne = 0; |
abcdefgh | 14:67ee8d8f4efe | 127 | motorRightTwo = 0; |
abcdefgh | 14:67ee8d8f4efe | 128 | motorLeftOne = 0; |
abcdefgh | 14:67ee8d8f4efe | 129 | motorLeftTwo = 0; |
abcdefgh | 14:67ee8d8f4efe | 130 | } |
abcdefgh | 14:67ee8d8f4efe | 131 | |
abcdefgh | 14:67ee8d8f4efe | 132 | if(( ButtonState >> BUTTONR1)&1 == 1) { |
abcdefgh | 15:5e973e6c058c | 133 | motorRightOne = 0; |
abcdefgh | 17:efe67bbb927e | 134 | motorRightTwo = 0.4 + flag; |
abcdefgh | 17:efe67bbb927e | 135 | motorLeftOne = 0.4 + flag; |
abcdefgh | 15:5e973e6c058c | 136 | motorLeftTwo = 0; |
abcdefgh | 15:5e973e6c058c | 137 | } |
abcdefgh | 15:5e973e6c058c | 138 | if(( ButtonState >> BUTTONL1)&1 == 1) { |
abcdefgh | 17:efe67bbb927e | 139 | motorRightOne = 0.4 + flag; |
Junbug | 12:b2f3c85cba36 | 140 | motorRightTwo = 0; |
Junbug | 12:b2f3c85cba36 | 141 | motorLeftOne = 0; |
abcdefgh | 17:efe67bbb927e | 142 | motorLeftTwo = 0.4 + flag; |
abcdefgh | 14:67ee8d8f4efe | 143 | } |
abcdefgh | 14:67ee8d8f4efe | 144 | |
abcdefgh | 14:67ee8d8f4efe | 145 | //arm |
abcdefgh | 14:67ee8d8f4efe | 146 | |
abcdefgh | 16:ea0808fbbb40 | 147 | if( (ButtonState >> BUTTONUP)&1 == 1 ) { |
abcdefgh | 17:efe67bbb927e | 148 | armThree = 0; |
abcdefgh | 17:efe67bbb927e | 149 | armFour = 1; |
abcdefgh | 17:efe67bbb927e | 150 | armLeft = 0.4; |
abcdefgh | 17:efe67bbb927e | 151 | } else if( (ButtonState >> BUTTONDOWN)&1 == 1 ) { |
abcdefgh | 17:efe67bbb927e | 152 | armThree = 1; |
abcdefgh | 17:efe67bbb927e | 153 | armFour = 0; |
abcdefgh | 17:efe67bbb927e | 154 | armLeft = 0.4; |
abcdefgh | 17:efe67bbb927e | 155 | } else { |
abcdefgh | 17:efe67bbb927e | 156 | armThree = 0; |
abcdefgh | 17:efe67bbb927e | 157 | armFour = 0; |
abcdefgh | 17:efe67bbb927e | 158 | armLeft = 0; |
abcdefgh | 17:efe67bbb927e | 159 | |
abcdefgh | 17:efe67bbb927e | 160 | } |
abcdefgh | 17:efe67bbb927e | 161 | |
abcdefgh | 17:efe67bbb927e | 162 | if((ButtonState >> BUTTONSQUARE)&1 == 1) { |
abcdefgh | 17:efe67bbb927e | 163 | armOne = 1; |
abcdefgh | 17:efe67bbb927e | 164 | armTwo = 0; |
abcdefgh | 17:efe67bbb927e | 165 | armRight = 0.4; |
abcdefgh | 17:efe67bbb927e | 166 | } else if((ButtonState >> BUTTONCIRCLE)&1 == 1) { |
abcdefgh | 15:5e973e6c058c | 167 | armOne = 0; |
abcdefgh | 15:5e973e6c058c | 168 | armTwo = 1; |
abcdefgh | 14:67ee8d8f4efe | 169 | armRight = 0.4; |
abcdefgh | 14:67ee8d8f4efe | 170 | } else { |
abcdefgh | 14:67ee8d8f4efe | 171 | armOne = 0; |
abcdefgh | 14:67ee8d8f4efe | 172 | armTwo = 0; |
abcdefgh | 14:67ee8d8f4efe | 173 | armRight = 0; |
abcdefgh | 15:5e973e6c058c | 174 | |
abcdefgh | 17:efe67bbb927e | 175 | printf("%f ",flag); |
abcdefgh | 14:67ee8d8f4efe | 176 | |
abcdefgh | 17:efe67bbb927e | 177 | /* |
abcdefgh | 17:efe67bbb927e | 178 | With oen if, put both arms and legs. |
abcdefgh | 14:67ee8d8f4efe | 179 | |
abcdefgh | 17:efe67bbb927e | 180 | Use start and select?? |
Junbug | 12:b2f3c85cba36 | 181 | |
Junbug | 12:b2f3c85cba36 | 182 | |
abcdefgh | 17:efe67bbb927e | 183 | */ |
Junbug | 12:b2f3c85cba36 | 184 | |
abcdefgh | 16:ea0808fbbb40 | 185 | |
Junbug | 12:b2f3c85cba36 | 186 | |
abcdefgh | 16:ea0808fbbb40 | 187 | |
Junbug | 12:b2f3c85cba36 | 188 | |
abcdefgh | 17:efe67bbb927e | 189 | /* |
abcdefgh | 17:efe67bbb927e | 190 | led3=ButtonState & 0x0400; //L1の状態 |
abcdefgh | 17:efe67bbb927e | 191 | led4=ButtonState & 0x0800; //R1の状態 |
abcdefgh | 17:efe67bbb927e | 192 | */ //値の取得はps3.hを参照 |
Junbug | 12:b2f3c85cba36 | 193 | |
abcdefgh | 17:efe67bbb927e | 194 | } |
Junbug | 12:b2f3c85cba36 | 195 | |
Junbug | 12:b2f3c85cba36 | 196 | } |