マザー 20151028 XBOX-XBEE

Dependencies:   mbed

Fork of Nucleo_PS3_Jikken_XBOX by 2015 robotic contest arakawa A

Committer:
nodoame
Date:
Fri Oct 30 08:38:18 2015 +0000
Revision:
29:9cfd082de61e
Parent:
28:37147ae0df52
201510030; XBOX??

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nodoame 0:dc587be179e9 1 #include "mbed.h"
nodoame 0:dc587be179e9 2 #include "math.h"
nodoame 0:dc587be179e9 3 #define M_PI 3.1415926535897932384626433832795
nodoame 0:dc587be179e9 4 #define trigL 0
nodoame 0:dc587be179e9 5 #define trigR 1
nodoame 0:dc587be179e9 6 #define btL 2
nodoame 0:dc587be179e9 7 #define btR 3
nodoame 0:dc587be179e9 8 #define btTri 4
nodoame 0:dc587be179e9 9 #define btSph 5
nodoame 0:dc587be179e9 10 #define btCro 6
nodoame 0:dc587be179e9 11 #define btSqa 7
nodoame 20:373fa71ce05b 12 #define btSel 0
nodoame 20:373fa71ce05b 13 #define presUp 4
nodoame 20:373fa71ce05b 14 #define presRight 5
nodoame 20:373fa71ce05b 15 #define presDown 6
nodoame 20:373fa71ce05b 16 #define presLeft 7
nodoame 4:bae4e2d103d4 17 #define devideNum 32
nodoame 4:bae4e2d103d4 18 #define ED 132
nodoame 6:5171a8245b57 19 #define TD 144//208
nodoame 5:428b7ac86810 20 #define EL 134
nodoame 5:428b7ac86810 21 #define TL 200
nodoame 6:5171a8245b57 22 #define TNR 138//204
nodoame 20:373fa71ce05b 23 #define TNL 150
nodoame 27:cc853efb663c 24 #define debugFlag 1
nodoame 11:1ca2498815c9 25 #define stopCount 33
nodoame 24:ee0943b12feb 26 #define shotWait 0.5
nodoame 27:cc853efb663c 27 #define isXBOX true
nodoame 29:9cfd082de61e 28 #define XBOXrate 19200
nodoame 0:dc587be179e9 29
nodoame 0:dc587be179e9 30 Serial pc(SERIAL_TX, SERIAL_RX);
nodoame 1:a3bfd422ea9e 31 //Serial Dev(D8,D2);//コントローラー
nodoame 3:c290afbacd1c 32 Serial Dev(PC_6,PA_12);//コントローラー
nodoame 1:a3bfd422ea9e 33 RawSerial Mechanum(D8,D2);//メカナム
nodoame 0:dc587be179e9 34 I2C i2c(D14,D15);//sda,scl
nodoame 5:428b7ac86810 35 //const int airAddr=0x20;
nodoame 20:373fa71ce05b 36 const int airAddr=0xd0;
nodoame 20:373fa71ce05b 37 const int airReg=10;
nodoame 5:428b7ac86810 38 const int valveAddr=0xC0;
nodoame 1:a3bfd422ea9e 39 BusOut dI2c(PC_0,PC_1,PC_2,PC_3);//i2cデバッグ
nodoame 0:dc587be179e9 40
nodoame 0:dc587be179e9 41 int Bflag = 0;
nodoame 0:dc587be179e9 42 DigitalOut myled(LED1);// ,test1(PB_7) ,test2(PA_15) ,test3(PC_13) ,test4(PC_12);
nodoame 4:bae4e2d103d4 43 PwmOut Blue(D5),Green(D4),Red(D3);
nodoame 4:bae4e2d103d4 44 //PwmOut kRed(A3),kBlue(A1),kGreen(A0);
nodoame 4:bae4e2d103d4 45 PwmOut kRed(A3),kBlue(PA_15),kGreen(PB_7);
nodoame 5:428b7ac86810 46 #define N 7
nodoame 0:dc587be179e9 47 char DATA[N];
nodoame 0:dc587be179e9 48 void rotate(double setAngle);
nodoame 0:dc587be179e9 49 void speed();
nodoame 11:1ca2498815c9 50 int stopCounter=0;
nodoame 23:d5f7e3dab589 51 bool pushF=false;
nodoame 1:a3bfd422ea9e 52
nodoame 5:428b7ac86810 53 void num()//割り込まれたら7回受信
nodoame 0:dc587be179e9 54 {
nodoame 0:dc587be179e9 55 if(Dev.getc()==114){
nodoame 0:dc587be179e9 56 //printf("ReceiveCommand\r\n");
nodoame 0:dc587be179e9 57 for(int i = 0 ;i<N ;i++ )
nodoame 0:dc587be179e9 58 {
nodoame 0:dc587be179e9 59 DATA[i]=Dev.getc();
nodoame 0:dc587be179e9 60 }
nodoame 0:dc587be179e9 61 }
nodoame 11:1ca2498815c9 62 stopCounter=0;
nodoame 0:dc587be179e9 63 }
nodoame 0:dc587be179e9 64
nodoame 0:dc587be179e9 65 bool getBt(int num)
nodoame 0:dc587be179e9 66 {
nodoame 0:dc587be179e9 67 return (DATA[0]>>num)%2;
nodoame 0:dc587be179e9 68 }
nodoame 0:dc587be179e9 69
nodoame 5:428b7ac86810 70 bool getPress(int num)
nodoame 5:428b7ac86810 71 {
nodoame 5:428b7ac86810 72 return (DATA[6]>>num)%2;
nodoame 5:428b7ac86810 73 }
nodoame 5:428b7ac86810 74
nodoame 0:dc587be179e9 75 double pointToDeg(double y,double x,int threshold)//座標から角度を求める関数thresholdはしきい値
nodoame 0:dc587be179e9 76 {
nodoame 0:dc587be179e9 77 if(abs((int)(y-128))<threshold)
nodoame 0:dc587be179e9 78 y=128;
nodoame 0:dc587be179e9 79 if(abs((int)(x-128))<threshold)
nodoame 0:dc587be179e9 80 x=128;
nodoame 0:dc587be179e9 81 return atan2(-(y-128),x-128)/M_PI*180;//y軸反転、/PI*180でRadからDeg変換
nodoame 0:dc587be179e9 82 }
nodoame 0:dc587be179e9 83
nodoame 20:373fa71ce05b 84 int devidePoint(double y,double x,int threshold,float devide)
nodoame 0:dc587be179e9 85 {
nodoame 0:dc587be179e9 86 double tempX,tempY,dev;//仮のX,Yと分けた角度
nodoame 0:dc587be179e9 87 tempX=(x-128);tempY=(y-128);//それぞれ-128
nodoame 0:dc587be179e9 88 if(abs((int)tempY)<threshold)//しきい値以下なら0にする
nodoame 0:dc587be179e9 89 tempY=0;
nodoame 0:dc587be179e9 90 if(abs((int)tempX)<threshold)
nodoame 0:dc587be179e9 91 tempX=0;
nodoame 0:dc587be179e9 92 if(tempX==0&&tempY==0)
nodoame 0:dc587be179e9 93 dev=360;
nodoame 0:dc587be179e9 94 //printf("X:%lfY:%lfDev:%lf\r\n",tempX,tempY,dev);
nodoame 0:dc587be179e9 95 else
nodoame 27:cc853efb663c 96 dev=atan2(tempX,(isXBOX)?(tempY):(-tempY))/M_PI*180;//軸を逆にして代入、Y軸反転
nodoame 0:dc587be179e9 97 return ((dev<0)?(dev+360):(dev))/devide;//分割
nodoame 0:dc587be179e9 98 }
nodoame 0:dc587be179e9 99
nodoame 4:bae4e2d103d4 100 int valueForMechanum(int deg,int devide,bool triL,bool triR,bool btSpd)
nodoame 0:dc587be179e9 101 {
nodoame 0:dc587be179e9 102 bool stpFlag=false,spnFlag=false;//ストップフラグ、スピンフラグ
nodoame 0:dc587be179e9 103 int val=0,i;//値、For用
nodoame 0:dc587be179e9 104 for(i=0;i<6;i++){
nodoame 0:dc587be179e9 105 switch(i){
nodoame 0:dc587be179e9 106 case 0:
nodoame 4:bae4e2d103d4 107 if(deg!=devide||(triL||triR))//スピンかニュートラル以外なら
nodoame 0:dc587be179e9 108 val=1;
nodoame 0:dc587be179e9 109 else
nodoame 0:dc587be179e9 110 stpFlag=true;//ストップ
nodoame 0:dc587be179e9 111 break;
nodoame 0:dc587be179e9 112
nodoame 0:dc587be179e9 113 case 1:
nodoame 0:dc587be179e9 114 if(stpFlag)
nodoame 4:bae4e2d103d4 115 val++;
nodoame 0:dc587be179e9 116 else
nodoame 0:dc587be179e9 117 val+=btSpd;//スピード
nodoame 0:dc587be179e9 118 break;
nodoame 0:dc587be179e9 119
nodoame 0:dc587be179e9 120 case 2:
nodoame 0:dc587be179e9 121 if(triL||triR){//トリガーのどちらかがONなら
nodoame 0:dc587be179e9 122 val++;
nodoame 0:dc587be179e9 123 spnFlag=true;//スピンフラグON
nodoame 0:dc587be179e9 124 }
nodoame 0:dc587be179e9 125 break;
nodoame 0:dc587be179e9 126
nodoame 0:dc587be179e9 127 case 5:
nodoame 4:bae4e2d103d4 128 val=val<<2;//5bit目から7bit目へ
nodoame 0:dc587be179e9 129 if(spnFlag)//トリガーのどちらかの値
nodoame 0:dc587be179e9 130 val+=(triL)?1:0;
nodoame 4:bae4e2d103d4 131 else if(!stpFlag)//ジョイスティックの値
nodoame 0:dc587be179e9 132 val+=deg;
nodoame 0:dc587be179e9 133 break;
nodoame 0:dc587be179e9 134 }
nodoame 0:dc587be179e9 135 if(i<5)
nodoame 0:dc587be179e9 136 val=val<<1;
nodoame 0:dc587be179e9 137 }
nodoame 0:dc587be179e9 138 //printf("val:%ddeg:%dtrigL:%dtrigR:%dbtSp:%d\r\n",val,deg,triL,triR,btSpd);
nodoame 0:dc587be179e9 139 return val;
nodoame 0:dc587be179e9 140 }
nodoame 0:dc587be179e9 141
nodoame 20:373fa71ce05b 142 bool detectPole(int scVector)
nodoame 0:dc587be179e9 143 {
nodoame 15:c941d06092ec 144 int vector=TD,laser=0;
nodoame 20:373fa71ce05b 145 bool btFlag=false,canFlag=false,breakFlag=false,stopFlag=false;
nodoame 4:bae4e2d103d4 146 Blue=0.0f;Green=0.0f,Red=0.8f;
nodoame 0:dc587be179e9 147 while(true)
nodoame 20:373fa71ce05b 148 {
nodoame 20:373fa71ce05b 149 if((getBt(btTri)&&getBt(btSph)&&canFlag)||breakFlag)
nodoame 20:373fa71ce05b 150 return breakFlag;
nodoame 20:373fa71ce05b 151 else if(!(getBt(btTri)&&getBt(btSph)))
nodoame 20:373fa71ce05b 152 canFlag=true;
nodoame 20:373fa71ce05b 153
nodoame 14:aaf2ae25e508 154 //スイッチが押された時
nodoame 20:373fa71ce05b 155 if(((int)DATA[1]&12)==12&&!btFlag){
nodoame 5:428b7ac86810 156 wait(0.001f);
nodoame 5:428b7ac86810 157 Mechanum.putc(64);
nodoame 4:bae4e2d103d4 158 btFlag=true;
nodoame 20:373fa71ce05b 159 Blue=0;Green=0.8;Red=0;
nodoame 15:c941d06092ec 160 vector=scVector;
nodoame 14:aaf2ae25e508 161 }
nodoame 11:1ca2498815c9 162
nodoame 15:c941d06092ec 163 //片方のレーザーが反応したとき
nodoame 20:373fa71ce05b 164 if(btFlag&&!laser){
nodoame 20:373fa71ce05b 165 if(!(((int)DATA[1]&2)==2)){
nodoame 15:c941d06092ec 166 laser=1;
nodoame 20:373fa71ce05b 167 Red=0.8;
nodoame 15:c941d06092ec 168 vector=0;
nodoame 15:c941d06092ec 169 }
nodoame 20:373fa71ce05b 170 else if(!(((int)DATA[1]&1)==1)){
nodoame 15:c941d06092ec 171 laser=2;
nodoame 20:373fa71ce05b 172 Red=0.8;
nodoame 15:c941d06092ec 173 vector=0;
nodoame 9:489a085d1703 174 }
nodoame 9:489a085d1703 175 }
nodoame 15:c941d06092ec 176
nodoame 15:c941d06092ec 177 //もう片方のレーザーが反応した時
nodoame 20:373fa71ce05b 178 else if(!(((int)DATA[1]&laser)==laser)&&laser&&!stopFlag){
nodoame 20:373fa71ce05b 179 Green=0;Red=0.8;Blue=0.8;
nodoame 20:373fa71ce05b 180 vector=64;
nodoame 20:373fa71ce05b 181 stopFlag=true;
nodoame 20:373fa71ce05b 182 wait(0.05);
nodoame 20:373fa71ce05b 183 }
nodoame 20:373fa71ce05b 184 //ストップ後
nodoame 20:373fa71ce05b 185 else if(stopFlag)
nodoame 20:373fa71ce05b 186 {
nodoame 20:373fa71ce05b 187 vector=162;
nodoame 20:373fa71ce05b 188 breakFlag=true;
nodoame 0:dc587be179e9 189 }
nodoame 4:bae4e2d103d4 190
nodoame 15:c941d06092ec 191 //pc.printf("%d\r\n",DATA[1]);
nodoame 20:373fa71ce05b 192 //deg=devidePoint((double)DATA[3],(double)DATA[2],15,360/devideNum);
nodoame 20:373fa71ce05b 193 //pc.printf("%d\r\n",scVector);
nodoame 0:dc587be179e9 194 Mechanum.putc(vector);
nodoame 20:373fa71ce05b 195 wait(0.0126f);
nodoame 0:dc587be179e9 196 }
nodoame 4:bae4e2d103d4 197 btFlag=false;
nodoame 5:428b7ac86810 198 Blue=0;Green=0;Red=0;
nodoame 0:dc587be179e9 199 }
nodoame 0:dc587be179e9 200
nodoame 0:dc587be179e9 201
nodoame 5:428b7ac86810 202 bool shotToDenziben(char reg, char data ,int size,int addr)
nodoame 0:dc587be179e9 203 {
nodoame 5:428b7ac86810 204 char REG[2] = {reg,size};
nodoame 5:428b7ac86810 205 char DATA[2]={data,0};
nodoame 5:428b7ac86810 206 bool A = i2c.write(addr,REG,2);
nodoame 5:428b7ac86810 207 A|= i2c.write(addr,DATA,size);
nodoame 1:a3bfd422ea9e 208 return A;
nodoame 0:dc587be179e9 209 }
nodoame 0:dc587be179e9 210
nodoame 5:428b7ac86810 211 char getshot(char reg)
nodoame 5:428b7ac86810 212 {
nodoame 5:428b7ac86810 213 char input=0;
nodoame 5:428b7ac86810 214 char DATA[2] = {reg,1};
nodoame 5:428b7ac86810 215 i2c.write(airAddr,DATA,2);
nodoame 5:428b7ac86810 216 wait(0.005f);
nodoame 5:428b7ac86810 217 i2c.read(airAddr,&input,1);
nodoame 5:428b7ac86810 218 return input;
nodoame 5:428b7ac86810 219 }
nodoame 5:428b7ac86810 220
nodoame 12:6445a3c3d34c 221 void setFCLED(double RED,double GREEN,double BLUE)
nodoame 12:6445a3c3d34c 222 {
nodoame 12:6445a3c3d34c 223 Red=RED;
nodoame 12:6445a3c3d34c 224 Green=GREEN;
nodoame 12:6445a3c3d34c 225 Blue=BLUE;
nodoame 12:6445a3c3d34c 226 }
nodoame 12:6445a3c3d34c 227
nodoame 4:bae4e2d103d4 228 int main() {
nodoame 0:dc587be179e9 229 pc.baud(230400);
nodoame 25:caa4d20d6c40 230 //Dev.baud(921600);//PS3
nodoame 27:cc853efb663c 231 //Dev.baud(57600);//XBOX
nodoame 29:9cfd082de61e 232 Dev.baud((isXBOX)?(XBOXrate):(921600));
nodoame 0:dc587be179e9 233 Mechanum.baud(230400);
nodoame 5:428b7ac86810 234 DigitalIn bt(USER_BUTTON);
nodoame 0:dc587be179e9 235 Dev.attach(num,Serial::RxIrq);//受信割り込み設定
nodoame 1:a3bfd422ea9e 236 Green=0;Blue=0;Red=0;
nodoame 12:6445a3c3d34c 237 double gValue=0,bValue=0,rValue=0;
nodoame 3:c290afbacd1c 238 DigitalOut l(PB_2);
nodoame 3:c290afbacd1c 239 int sqf=0;
nodoame 20:373fa71ce05b 240 double deg=32;
nodoame 0:dc587be179e9 241 int val;
nodoame 1:a3bfd422ea9e 242 i2c.frequency(400000);
nodoame 12:6445a3c3d34c 243 setFCLED(0,0.8,0.8);
nodoame 23:d5f7e3dab589 244 bool obonFlag=false,pLeftF=false,pRightF=false,btCrF=false,detFinF=false,touchSF=false;
nodoame 0:dc587be179e9 245
nodoame 0:dc587be179e9 246 while(true)
nodoame 12:6445a3c3d34c 247 {
nodoame 23:d5f7e3dab589 248 /* //ポール検出モード
nodoame 0:dc587be179e9 249 if(getBt(btTri)&&getBt(btSph)){
nodoame 20:373fa71ce05b 250 if(deg>devideNum-1);
nodoame 20:373fa71ce05b 251 else if(deg<17){
nodoame 20:373fa71ce05b 252 //pc.printf("R\r\n");
nodoame 20:373fa71ce05b 253 detFinF=detectPole(TNR);
nodoame 20:373fa71ce05b 254 }
nodoame 20:373fa71ce05b 255 else{
nodoame 20:373fa71ce05b 256 //pc.printf("L\r\n");
nodoame 20:373fa71ce05b 257 detFinF=detectPole(TNL);
nodoame 20:373fa71ce05b 258 }
nodoame 23:d5f7e3dab589 259 }*/
nodoame 5:428b7ac86810 260
nodoame 23:d5f7e3dab589 261 do{
nodoame 23:d5f7e3dab589 262 bool l=getBt(btL),r=getBt(btR),t=getBt(btTri);
nodoame 23:d5f7e3dab589 263 if(!l&&!r&&!t)
nodoame 23:d5f7e3dab589 264 pushF=false;
nodoame 23:d5f7e3dab589 265 if(pushF||!obonFlag)
nodoame 23:d5f7e3dab589 266 break;
nodoame 23:d5f7e3dab589 267
nodoame 23:d5f7e3dab589 268 //射出
nodoame 23:d5f7e3dab589 269 if(l){
nodoame 24:ee0943b12feb 270 //pc.printf("L\r\n");
nodoame 23:d5f7e3dab589 271 pushF=true;
nodoame 23:d5f7e3dab589 272 kRed=shotToDenziben(airReg,1,1,airAddr);
nodoame 23:d5f7e3dab589 273 wait(shotWait);
nodoame 23:d5f7e3dab589 274 kRed=shotToDenziben(airReg,0,1,airAddr);
nodoame 23:d5f7e3dab589 275 kRed=0;
nodoame 23:d5f7e3dab589 276 }
nodoame 23:d5f7e3dab589 277
nodoame 23:d5f7e3dab589 278 //射出
nodoame 23:d5f7e3dab589 279 else if(r){
nodoame 24:ee0943b12feb 280 //pc.printf("R\r\n");
nodoame 23:d5f7e3dab589 281 pushF=true;
nodoame 23:d5f7e3dab589 282 kRed=shotToDenziben(airReg,2,1,airAddr);
nodoame 23:d5f7e3dab589 283 wait(shotWait);
nodoame 23:d5f7e3dab589 284 kRed=shotToDenziben(airReg,0,1,airAddr);
nodoame 23:d5f7e3dab589 285 //printf("shot:%d\r\n",i2cS=i2c.write(airAddr,cmd,2));
nodoame 23:d5f7e3dab589 286 //i2c.write(airAddr,cmd,2);
nodoame 23:d5f7e3dab589 287 kRed=0;
nodoame 23:d5f7e3dab589 288 }
nodoame 23:d5f7e3dab589 289
nodoame 23:d5f7e3dab589 290 //射出
nodoame 23:d5f7e3dab589 291 else if(t){
nodoame 24:ee0943b12feb 292 //pc.printf("T\r\n");
nodoame 23:d5f7e3dab589 293 pushF=true;
nodoame 23:d5f7e3dab589 294 kRed=shotToDenziben(airReg,4,1,airAddr);
nodoame 23:d5f7e3dab589 295 wait(shotWait);
nodoame 23:d5f7e3dab589 296 kRed=shotToDenziben(airReg,0,1,airAddr);
nodoame 23:d5f7e3dab589 297 kRed=0;
nodoame 23:d5f7e3dab589 298 }
nodoame 23:d5f7e3dab589 299
nodoame 23:d5f7e3dab589 300 }while(false);
nodoame 3:c290afbacd1c 301
nodoame 5:428b7ac86810 302 //レーザーポインタ
nodoame 3:c290afbacd1c 303 if(getBt(btSqa)&&sqf){
nodoame 3:c290afbacd1c 304 sqf=0;
nodoame 3:c290afbacd1c 305 l=!l;
nodoame 4:bae4e2d103d4 306 kBlue=!kBlue;
nodoame 0:dc587be179e9 307 }
nodoame 3:c290afbacd1c 308 else if(!getBt(btSqa))
nodoame 3:c290afbacd1c 309 sqf=1;
nodoame 3:c290afbacd1c 310
nodoame 22:ab619079fb8d 311 //タッチセンサ
nodoame 23:d5f7e3dab589 312 if(((int)DATA[1]&12)==12&&!touchSF){
nodoame 23:d5f7e3dab589 313 touchSF=true;
nodoame 24:ee0943b12feb 314 gValue=0.5;
nodoame 20:373fa71ce05b 315 }
nodoame 24:ee0943b12feb 316 else if(!(((int)DATA[1]&12)==12)){
nodoame 23:d5f7e3dab589 317 touchSF=false;
nodoame 24:ee0943b12feb 318 gValue=0;
nodoame 23:d5f7e3dab589 319 }
nodoame 20:373fa71ce05b 320 //お盆回し
nodoame 20:373fa71ce05b 321 if(getPress(presUp)){
nodoame 24:ee0943b12feb 322 //pc.printf("L\r\n");
nodoame 20:373fa71ce05b 323 obonFlag=true;
nodoame 22:ab619079fb8d 324 Mechanum.putc(162);
nodoame 24:ee0943b12feb 325 rValue=0.5;
nodoame 20:373fa71ce05b 326 kRed=0;
nodoame 22:ab619079fb8d 327 wait(0.2);
nodoame 20:373fa71ce05b 328 }
nodoame 20:373fa71ce05b 329 else if(getPress(presDown)){
nodoame 22:ab619079fb8d 330 Mechanum.putc(163);
nodoame 23:d5f7e3dab589 331 rValue=0;
nodoame 20:373fa71ce05b 332 obonFlag=false;
nodoame 20:373fa71ce05b 333 kRed=0;
nodoame 22:ab619079fb8d 334 wait(0.2);
nodoame 22:ab619079fb8d 335 }
nodoame 19:cd036cc40a2d 336
nodoame 28:37147ae0df52 337 deg=devidePoint((double)DATA[3],(double)DATA[2],30,360/devideNum);
nodoame 23:d5f7e3dab589 338
nodoame 20:373fa71ce05b 339 if(getPress(btSel)||(detFinF&&deg!=devideNum)){
nodoame 20:373fa71ce05b 340 detFinF=false;
nodoame 20:373fa71ce05b 341 Mechanum.putc(163);
nodoame 20:373fa71ce05b 342 wait(0.1);
nodoame 19:cd036cc40a2d 343 }
nodoame 20:373fa71ce05b 344 else {
nodoame 20:373fa71ce05b 345 val=valueForMechanum(deg,devideNum,getBt(trigL),getBt(trigR),getBt(btSph));
nodoame 27:cc853efb663c 346 pc.printf("deg:%lf\r\n",deg);
nodoame 19:cd036cc40a2d 347 }
nodoame 20:373fa71ce05b 348
nodoame 11:1ca2498815c9 349
nodoame 11:1ca2498815c9 350 //一定時間通信してないと停止
nodoame 11:1ca2498815c9 351 if(stopCounter>stopCount)
nodoame 11:1ca2498815c9 352 val=64;
nodoame 11:1ca2498815c9 353 else
nodoame 11:1ca2498815c9 354 stopCounter++;
nodoame 0:dc587be179e9 355 Mechanum.putc(val);
nodoame 24:ee0943b12feb 356 //bValue=0.8;
nodoame 12:6445a3c3d34c 357 setFCLED(rValue,gValue,bValue);
nodoame 0:dc587be179e9 358 wait(0.03f);
nodoame 11:1ca2498815c9 359 do{
nodoame 11:1ca2498815c9 360 if(!debugFlag)
nodoame 11:1ca2498815c9 361 break;
nodoame 20:373fa71ce05b 362 //pc.printf("%d\r\n",DATA[6]);
nodoame 20:373fa71ce05b 363 //if(getPress(btSel))
nodoame 20:373fa71ce05b 364 // pc.printf("up\r\n");
nodoame 27:cc853efb663c 365 //pc.printf("deg:%d\r\n",deg);
nodoame 11:1ca2498815c9 366 //printf("%lf:%d:%d\r\n",deg,(int)DATA[3],(int)DATA[2]);
nodoame 11:1ca2498815c9 367 //printf("%d\r\n",(int)DATA[0]);
nodoame 11:1ca2498815c9 368 //pc.printf("DATA[1]%d\r\n",(int)(DATA[1]&0x02));
nodoame 11:1ca2498815c9 369 //printf("deg:%lfX1:%d:bt%ddeg:%lfval:%d\r\n",deg,(int)DATA[1],getBt(btSqa),deg,val);
nodoame 20:373fa71ce05b 370 //pc.printf("%lf\r\n",deg);
nodoame 11:1ca2498815c9 371 }while(false);
nodoame 0:dc587be179e9 372 }
nodoame 0:dc587be179e9 373 }