マザー 20151028 XBOX-XBEE

Dependencies:   mbed

Fork of Nucleo_PS3_Jikken_XBOX by 2015 robotic contest arakawa A

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