にいむら にいむら
/
mainboardnrp2018
unkounko
Diff: System/Process/Process.cpp
- Revision:
- 11:88f17bc0724f
- Parent:
- 10:a765515594bd
diff -r a765515594bd -r 88f17bc0724f System/Process/Process.cpp --- a/System/Process/Process.cpp Thu Feb 21 01:04:40 2019 +0000 +++ b/System/Process/Process.cpp Mon Feb 25 05:48:20 2019 +0000 @@ -2,7 +2,6 @@ //2018/02/24のやつ #include "Process.h" - #include "mbed.h" #include "../../Communication/XBee/XBee.h" #include "../../Input/Switch/Switch.h" @@ -26,8 +25,32 @@ #define a 0 #define b 1 #define c 2 +#define d 3 +#define e 4 +#define ARMlim 0 +#define lim 1 +int Air0=0; +int Air1=1; +int homes=0; + + + +//////////////////関数、タイマーの宣言/////////////// +DigitalOut Air[]= { + DigitalOut(A5), + DigitalOut(A4), +}; +Timer Airtime; +Timer home; +void AirOut(int pin,int mode) +{ + Air[pin]=mode; +} +//////////// +float s=Airtime.read();//エアータイム + int a_array[15][15] = { {-80, -70, -60, -50, -40, -20, -10, 0, 10, 20, 40, 50, 60, 70, 80}, {-79, -69, -55, -47, -35, -20, -10, 0, 10, 20, 35, 47, 55, 69, 79}, @@ -42,7 +65,8 @@ {-75, -67, -49, -40, 40 , -20, -10, 0, 10, 20, 25, 40, 49, 67, 75}, {-77, -68, -50, -45, 60 , -20, -10, 0, 10, 20, 30, 45, 50, 68, 77}, {-79, -69, -55, -47, 70 , -20, -10, 0, 10, 20, 35, 47, 55, 69, 79}, -{-80, -70, -60, -50, -40, -20, -10, 0, 10, 20, 40, 50, 60, 70, 80}}; +{-80, -70, -60, -50, -40, -20, -10, 0, 10, 20, 40, 50, 60, 70, 80}, +{-80, -70, -60, -50, -40, -20,s-10, 0, 10, 20, 40, 50, 60, 70, 80}}; int b_array[15][15] = { {80, 80, 80 , 77 , 75 , 72 , 71 , 70, 60, 50, 40, 30, 20, 10, 0}, @@ -58,6 +82,7 @@ {17, 13, 10 , 0 , -10, -20, -25,-30, -35, -40 ,-45 ,-50 ,-57 ,-60 , -60}, {13, 10, 0 , -10, -20, -30, -35,-40, -45, -50 ,-55 ,-60 , -70, -71, -80}, {10, 0 , -10, -20, -30, -40, -45,-50, -55, -60 ,-65 ,-70 ,-75 ,-80 , -80}, +{0 , -10, -20, -30, -40, -50, -60,-70, -71, -72 ,-75 ,-77 ,-80 ,-80 , -80}, {0 , -10, -20, -30, -40, -50, -60,-70, -71, -72 ,-75 ,-77 ,-80 ,-80 , -80}}; int c_array[15][15] = { @@ -74,6 +99,7 @@ {-60, -60, -57, -50, -45, -40, -35,-30, -25, -20 ,-10 ,0 ,10 ,13 ,17}, {-80, -71, -70, -60, -55, -50, -45,-40, -35, -30 ,-20 ,-10 ,0 ,10 ,13}, {-80, -80, -75, -70, -65, -60, -55,-50, -45, -40 ,-30 ,-20 ,-10 ,0 ,10}, +{-80, -80, -80, -77, -75, -72, -71,-70, -60, -50 ,-40 ,-30 ,-20 ,-10 ,0}, {-80, -80, -80, -77, -75, -72, -71,-70, -60, -50 ,-40 ,-30 ,-20 ,-10 ,0}}; @@ -81,8 +107,6 @@ -int pwm_array[15] = { 30 , 25 , 20 , 15 , 10 , 5 , 0 , 0 , 0 , -5 , -10 , -15 , -20 , -25 , -30 }; - #define usiro 0 #define mae 0 uint8_t motorData[5]; @@ -92,10 +116,8 @@ int conly; int conrx; int conry; -int conba; -int conbb; -int conbx; -int conby; + +int mode=0; //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ //_____________________ @@ -171,21 +193,12 @@ //conby = controller->Button.Y; //conbx = controller->Button.X; - if(((conlx >6) && (conly <8)) ||((conrx >6)&&(conry <8))){ - motor[a].dir = BRAKE; - motor[b].dir = BRAKE; - motor[c].dir = BRAKE; - motor[a].pwm = 100.0; - motor[b].pwm = 100.0; - motor[c].pwm = 100.0; - } - if(a_array[conly][conlx]<0){ - motor[a].pwm = (-1*a_array[conly][conlx]*100)/90; + motor[a].pwm = (-1*a_array[conly][conlx]*100)/80; motor[a].dir = FOR; }else if(a_array[conly][conlx] > 0){ - motor[a].pwm = a_array[conly][conlx]; - motor[a].dir = FOR;// + motor[a].pwm = (a_array[conly][conlx]*100)/80; + motor[a].dir = BACK; }else if(a_array[conly][conlx] == 0){ if(conry < 6){ motor[a].dir = BACK; @@ -200,7 +213,7 @@ motor[c].dir = FOR; motor[a].pwm = 100.0; motor[b].pwm = 100.0; - motor[c].pwm = 100.0; + motor[c].pwm = 100.0; }else{ motor[a].dir = BRAKE; motor[b].dir = BRAKE; @@ -212,27 +225,27 @@ } if(b_array[conly][conlx] <0 ){ - motor[b].pwm = (-1*b_array[conly][conlx]*100)/90; + motor[b].pwm = (-1*b_array[conly][conlx]*100)/80; motor[b].dir = FOR; }else if(b_array[conly][conlx] > 0){ - motor[b].pwm = b_array[conly][conlx]; - motor[b].dir = FOR;// + motor[b].pwm = (b_array[conly][conlx]*100)/80; + motor[b].dir = BACK; }else if(a_array[conly][conlx] == 0 ){ if(conrx < 6 ) { - motor[a].dir = BACK; - motor[b].dir = BACK; - motor[c].dir = BACK; - motor[a].pwm = 100.0; - motor[b].pwm = 100.0; - motor[c].pwm = 100.0; - }else if(conrx > 8){ - motor[a].dir = FOR; - motor[b].dir = FOR; - motor[c].dir = FOR; - motor[a].pwm = 100.0; - motor[b].pwm = 100.0; - motor[c].pwm = 100.0; - }else{ + motor[a].dir = BACK; + motor[b].dir = BACK; + motor[c].dir = BACK; + motor[a].pwm = 100.0; + motor[b].pwm = 100.0; + motor[c].pwm = 100.0; + }else if(conrx > 8){ + motor[a].dir = FOR; + motor[b].dir = FOR; + motor[c].dir = FOR; + motor[a].pwm = 100.0; + motor[b].pwm = 100.0; + motor[c].pwm = 100.0; + }else{ motor[a].dir = BRAKE; motor[b].dir = BRAKE; motor[c].dir = BRAKE; @@ -240,14 +253,13 @@ motor[b].pwm = 100.0; motor[c].pwm = 100.0; } - } - + } if(c_array[conly][conlx] <0 ){ - motor[c].pwm =(-1*c_array[conly][conlx]*100)/90; - motor[c].dir = FOR;// + motor[c].pwm =(-1*c_array[conly][conlx]*100)/80; + motor[c].dir = BACK; }else if(c_array[conly][conlx] > 0){ - motor[c].pwm = c_array[conly][conlx]; + motor[c].pwm =(c_array[conly][conlx]*100)/80; motor[c].dir = FOR; }else if(a_array[conly][conlx] == 0 ){ if(conrx < 6 ) { @@ -272,41 +284,66 @@ motor[b].pwm = 100.0; motor[c].pwm = 100.0; } - - // -//if (a_array[conlx>6][conly<8]){ -// motor[a].dir = BRAKE; -// motor[a].pwm = 100.0; -// } -//if (b_array[conlx>6][conly<8]){ -// motor[b].dir = BRAKE; -// motor[b].pwm = 100.0; -// } -//if (c_array[conlx>6][conly<8]){ -// motor[c].dir = BRAKE; -// motor[c].pwm = 100.0; -// } -// + } + +////////////課題1//////////// + if(controller->Button.X){ + if(Switch::checkPushed(ARMlim)){ + motor[d].dir = BRAKE; + motor[d].pwm = 100; + }else{ + motor[d].dir = FOR; + motor[d].pwm = 100; + } + }else if(controller->Button.Y){ + motor[d].dir = BACK; + motor[d].pwm = 100; + }else{ + motor[d].dir = BRAKE; + motor[d].pwm = 100; + } + if(controller->Button.A) { + AirOut(Air0,1); + } else if(controller->Button.B) { + AirOut(Air0,0); + } +//////////////課題2///////////////////// +// if((controller->Button.ZL)&&(mode==0)) { +// Airtime.start(); +// AirOut(Air1,0); +// } +// if((s>1)&&(s<3)) { +// AirOut(Air1,1); +// }else if(s>=3){ +// Airtime.stop(); +// Airtime.reset(); +// mode=1; +// } +// if((mode==2)||((controller->Button.ZR)&&(mode==1))) { +// motor[4].dir=FOR; +// motor[4].pwm=10; +// } +// if(!(Switch::checkPushed(lim))&&(mode==1)){ +// mode=2; +// } +// if((Switch::checkPushed(lim))&&(mode==2)){ +// motor[4].dir=BRAKE; +// motor[4].pwm=100; +// mode=0; +// } // - //(conba) - //{aira=0;} - // if(conbb) -// {airb=0;} - - - - - +// if (controller->Button.ZL) +// AiOut(Air1,0); + + if(controller->Button.ZL){ + AirOut(Air1,1) + AirOut(Air1.0) + motor[4].dir = FOR; + motor[4].pwm = 100.0; + if(Switch::checkPushed(lim)){ + motor. + } - - - - } - - - - -// //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ //___________________________