新部内対抗5班 / Mbed 2 deprecated 2016_Spring_kaida_0611

Dependencies:   mbed

Fork of 2016_Spring_kaida by 新部内対抗5班

Committer:
abcdefgh
Date:
Fri Jun 10 04:49:54 2016 +0000
Revision:
16:ea0808fbbb40
Parent:
15:5e973e6c058c
Child:
17:efe67bbb927e
aaaaaaa;

Who changed what in which revision?

UserRevisionLine numberNew 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 //これより下に関数外に書く要素を記入する
Junbug 12:b2f3c85cba36 10
Junbug 12:b2f3c85cba36 11 //MD1
abcdefgh 13:9b0efec30108 12 PwmOut motorRightOne (p25);
abcdefgh 13:9b0efec30108 13 PwmOut motorRightTwo (p26);
Junbug 12:b2f3c85cba36 14
Junbug 12:b2f3c85cba36 15 //MD2
abcdefgh 14:67ee8d8f4efe 16 PwmOut motorLeftOne (p24);
abcdefgh 14:67ee8d8f4efe 17 PwmOut motorLeftTwo (p23);
Junbug 12:b2f3c85cba36 18
Junbug 12:b2f3c85cba36 19 //MD3 Arm1
abcdefgh 14:67ee8d8f4efe 20 PwmOut armRight(p22);
abcdefgh 15:5e973e6c058c 21 DigitalOut armThree (p29);
abcdefgh 15:5e973e6c058c 22 DigitalOut armFour (p30);
Junbug 12:b2f3c85cba36 23
Junbug 12:b2f3c85cba36 24 //MD4 Arm2
abcdefgh 15:5e973e6c058c 25 PwmOut armLeft(p22);
abcdefgh 15:5e973e6c058c 26 DigitalOut armOne (p19);
abcdefgh 15:5e973e6c058c 27 DigitalOut armTwo (p20);
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 15:5e973e6c058c 96
abcdefgh 16:ea0808fbbb40 97 if( LSY > 140 ) { //forward
Junbug 12:b2f3c85cba36 98 motorRightOne = 0.4;
Junbug 12:b2f3c85cba36 99 motorRightTwo = 0;
Junbug 12:b2f3c85cba36 100 motorLeftOne = 0.4;
Junbug 12:b2f3c85cba36 101 motorLeftTwo = 0;
abcdefgh 15:5e973e6c058c 102
abcdefgh 15:5e973e6c058c 103 } else if( LSY < 110 ) { //back
Junbug 12:b2f3c85cba36 104 motorRightOne = 0;
Junbug 12:b2f3c85cba36 105 motorRightTwo = 0.4;
Junbug 12:b2f3c85cba36 106 motorLeftOne = 0;
Junbug 12:b2f3c85cba36 107 motorLeftTwo = 0.4;
abcdefgh 15:5e973e6c058c 108 } else { //stop
abcdefgh 14:67ee8d8f4efe 109 motorRightOne = 0;
abcdefgh 14:67ee8d8f4efe 110 motorRightTwo = 0;
abcdefgh 14:67ee8d8f4efe 111 motorLeftOne = 0;
abcdefgh 14:67ee8d8f4efe 112 motorLeftTwo = 0;
abcdefgh 14:67ee8d8f4efe 113 }
abcdefgh 14:67ee8d8f4efe 114
abcdefgh 14:67ee8d8f4efe 115 if(( ButtonState >> BUTTONR1)&1 == 1) {
abcdefgh 15:5e973e6c058c 116 motorRightOne = 0;
abcdefgh 15:5e973e6c058c 117 motorRightTwo = 0.4;
abcdefgh 15:5e973e6c058c 118 motorLeftOne = 0.4;
abcdefgh 15:5e973e6c058c 119 motorLeftTwo = 0;
abcdefgh 15:5e973e6c058c 120 }
abcdefgh 15:5e973e6c058c 121 if(( ButtonState >> BUTTONL1)&1 == 1) {
Junbug 12:b2f3c85cba36 122 motorRightOne = 0.4;
Junbug 12:b2f3c85cba36 123 motorRightTwo = 0;
Junbug 12:b2f3c85cba36 124 motorLeftOne = 0;
abcdefgh 16:ea0808fbbb40 125 motorLeftTwo = 0.4;
abcdefgh 14:67ee8d8f4efe 126 }
abcdefgh 14:67ee8d8f4efe 127
abcdefgh 14:67ee8d8f4efe 128 //arm
abcdefgh 14:67ee8d8f4efe 129
abcdefgh 16:ea0808fbbb40 130 if( (ButtonState >> BUTTONUP)&1 == 1 ) {
abcdefgh 15:5e973e6c058c 131 armOne = 0;
abcdefgh 15:5e973e6c058c 132 armTwo = 1;
abcdefgh 15:5e973e6c058c 133 armRight = 0.8;
abcdefgh 16:ea0808fbbb40 134 } else if( (ButtonState >> BUTTONDOWN)&1 == 1 ) {
abcdefgh 14:67ee8d8f4efe 135 armOne = 1;
abcdefgh 14:67ee8d8f4efe 136 armTwo = 0;
abcdefgh 14:67ee8d8f4efe 137 armRight = 0.4;
abcdefgh 14:67ee8d8f4efe 138 } else {
abcdefgh 14:67ee8d8f4efe 139 armOne = 0;
abcdefgh 14:67ee8d8f4efe 140 armTwo = 0;
abcdefgh 14:67ee8d8f4efe 141 armRight = 0;
abcdefgh 15:5e973e6c058c 142
abcdefgh 14:67ee8d8f4efe 143 }
abcdefgh 14:67ee8d8f4efe 144
abcdefgh 15:5e973e6c058c 145 if((ButtonState >> BUTTONTRIANGEL)&1 == 1) {
abcdefgh 14:67ee8d8f4efe 146 armThree = 1;
abcdefgh 14:67ee8d8f4efe 147 armFour = 0;
abcdefgh 14:67ee8d8f4efe 148 armLeft = 0.4;
abcdefgh 15:5e973e6c058c 149 } else if((ButtonState >> BUTTONCROSS)&1 == 1) {
abcdefgh 14:67ee8d8f4efe 150 armThree = 0;
abcdefgh 14:67ee8d8f4efe 151 armFour = 1;
abcdefgh 14:67ee8d8f4efe 152 armLeft = 0.4;
abcdefgh 15:5e973e6c058c 153 } else {
abcdefgh 14:67ee8d8f4efe 154 armThree = 0;
abcdefgh 14:67ee8d8f4efe 155 armFour = 0;
abcdefgh 14:67ee8d8f4efe 156 armLeft = 0;
abcdefgh 14:67ee8d8f4efe 157
abcdefgh 16:ea0808fbbb40 158
Junbug 12:b2f3c85cba36 159 /*
Junbug 12:b2f3c85cba36 160 With oen if, put both arms and legs.
Junbug 12:b2f3c85cba36 161
Junbug 12:b2f3c85cba36 162 Use start and select??
Junbug 12:b2f3c85cba36 163
Junbug 12:b2f3c85cba36 164
Junbug 12:b2f3c85cba36 165 */
Junbug 12:b2f3c85cba36 166
abcdefgh 16:ea0808fbbb40 167
Junbug 12:b2f3c85cba36 168
abcdefgh 16:ea0808fbbb40 169
Junbug 12:b2f3c85cba36 170
Junbug 12:b2f3c85cba36 171 /*
Junbug 12:b2f3c85cba36 172 led3=ButtonState & 0x0400; //L1の状態
Junbug 12:b2f3c85cba36 173 led4=ButtonState & 0x0800; //R1の状態
Junbug 12:b2f3c85cba36 174 */ //値の取得はps3.hを参照
Junbug 12:b2f3c85cba36 175
Junbug 12:b2f3c85cba36 176
Junbug 12:b2f3c85cba36 177
Junbug 12:b2f3c85cba36 178 }