aa

Dependencies:   mbed TrapezoidControl QEI

Committer:
yabahiro
Date:
Sun Sep 29 07:28:05 2019 +0000
Revision:
41:e1dd6d97f17d
Parent:
40:7f93984e8ba1
Child:
42:4f9689c0a349
aa;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kishibekairohan 13:b6e02d6261d7 1
t_yamamoto 0:669ef71cba68 2 #include "mbed.h"
t_yamamoto 0:669ef71cba68 3 #include "Process.h"
7ka884 4:ba9df71868df 4 #include "QEI.h"
t_yamamoto 0:669ef71cba68 5
7ka884 4:ba9df71868df 6 #include "../../CommonLibraries/PID/PID.h"
t_yamamoto 0:669ef71cba68 7 #include "../../Communication/RS485/ActuatorHub/ActuatorHub.h"
yabahiro 21:1f1e9c585da8 8 #include "../../Communication/RS485/LineHub/LineHub.h"
t_yamamoto 0:669ef71cba68 9 #include "../../Communication/Controller/Controller.h"
t_yamamoto 0:669ef71cba68 10 #include "../../Input/ExternalInt/ExternalInt.h"
t_yamamoto 0:669ef71cba68 11 #include "../../Input/Switch/Switch.h"
t_yamamoto 0:669ef71cba68 12 #include "../../Input/Potentiometer/Potentiometer.h"
kishibekairohan 16:3f2c2d89372b 13 #include "../../Input/Encoder/Encoder.h"
t_yamamoto 0:669ef71cba68 14 #include "../../LED/LED.h"
t_yamamoto 0:669ef71cba68 15 #include "../../Safty/Safty.h"
t_yamamoto 0:669ef71cba68 16 #include "../Using.h"
t_yamamoto 0:669ef71cba68 17
t_yamamoto 0:669ef71cba68 18 using namespace SWITCH;
7ka884 4:ba9df71868df 19 using namespace PID_SPACE;
kishibekairohan 16:3f2c2d89372b 20 using namespace ENCODER;
yabahiro 21:1f1e9c585da8 21 using namespace LINEHUB;
t_yamamoto 0:669ef71cba68 22
t_yamamoto 0:669ef71cba68 23 static CONTROLLER::ControllerData *controller;
t_yamamoto 0:669ef71cba68 24 ACTUATORHUB::MOTOR::MotorStatus motor[MOUNTING_MOTOR_NUM];
t_yamamoto 0:669ef71cba68 25 ACTUATORHUB::SOLENOID::SolenoidStatus solenoid;
t_yamamoto 0:669ef71cba68 26
t_yamamoto 0:669ef71cba68 27 static bool lock;
t_yamamoto 0:669ef71cba68 28 static bool processChangeComp;
t_yamamoto 0:669ef71cba68 29 static int current;
t_yamamoto 0:669ef71cba68 30
t_yamamoto 0:669ef71cba68 31 static void AllActuatorReset();
t_yamamoto 0:669ef71cba68 32
t_yamamoto 0:669ef71cba68 33 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 34 static void (*Process[USE_PROCESS_NUM])(void);
t_yamamoto 0:669ef71cba68 35 #endif
t_yamamoto 0:669ef71cba68 36
t_yamamoto 0:669ef71cba68 37 #pragma region USER-DEFINED_VARIABLES_AND_PROTOTYPE
t_yamamoto 0:669ef71cba68 38
t_yamamoto 0:669ef71cba68 39 /*Replace here with the definition code of your variables.*/
t_yamamoto 0:669ef71cba68 40
kishibekairohan 2:c015739085d3 41 Serial pc(USBTX, USBRX);
kishibekairohan 2:c015739085d3 42
kishibekairohan 16:3f2c2d89372b 43 //**************Encoder***************
kishibekairohan 16:3f2c2d89372b 44 const int PerRev = 256;
kishibekairohan 16:3f2c2d89372b 45 QEI ECD_0(ECD_A_0,ECD_B_0,NC,PerRev,QEI::X4_ENCODING);
kishibekairohan 16:3f2c2d89372b 46 QEI ECD_1(ECD_A_1,ECD_B_1,NC,PerRev,QEI::X4_ENCODING);
kishibekairohan 16:3f2c2d89372b 47 QEI ECD_2(ECD_A_2,ECD_B_2,NC,PerRev,QEI::X4_ENCODING);
kishibekairohan 16:3f2c2d89372b 48 QEI ECD_3(ECD_A_3,ECD_B_3,NC,PerRev,QEI::X4_ENCODING);
kishibekairohan 16:3f2c2d89372b 49 //**************Encoder***************
kishibekairohan 7:e88c5d47a3be 50
kishibekairohan 16:3f2c2d89372b 51 //**************Buzzer****************
kishibekairohan 11:028a150943b5 52 //DigitalOut buzzer(BUZZER_PIN);
kishibekairohan 9:f93fc79a49ea 53 void BuzzerTimer_func();
kishibekairohan 9:f93fc79a49ea 54 Ticker BuzzerTimer;
kishibekairohan 16:3f2c2d89372b 55 bool EMGflag = false;
yabahiro 21:1f1e9c585da8 56 //PWMOut buzzer(BUZZER_PIN);
kishibekairohan 16:3f2c2d89372b 57 //**************Buzzer****************
kishibekairohan 11:028a150943b5 58
kishibekairohan 11:028a150943b5 59 //************TapeLed*****************
kishibekairohan 11:028a150943b5 60 void TapeLedEms_func();
kishibekairohan 11:028a150943b5 61 TapeLedData tapeLED;
kishibekairohan 11:028a150943b5 62 TapeLedData sendLedData;
kishibekairohan 11:028a150943b5 63 TapeLED_Mode ledMode = Normal;
kishibekairohan 11:028a150943b5 64 Ticker tapeLedTimer;
kishibekairohan 11:028a150943b5 65 //************TapaLed*****************
kishibekairohan 16:3f2c2d89372b 66
M_souta 18:c694bae76e51 67 float tireProRPM[4];
M_souta 18:c694bae76e51 68 float tireTarRPM[4];
yabahiro 21:1f1e9c585da8 69 float tirepwm[4];
yabahiro 21:1f1e9c585da8 70
yabahiro 21:1f1e9c585da8 71 const int omni[15][15] = {
yabahiro 21:1f1e9c585da8 72 { 0, 5, 21, 47, 83, 130, 187, 255, 255, 255, 255, 255, 255, 255, 255 },
yabahiro 21:1f1e9c585da8 73 { -5, 0, 5, 21, 47, 83, 130, 187, 193, 208, 234, 255, 255, 255, 255 },
yabahiro 21:1f1e9c585da8 74 { -21, -5, 0, 5, 21, 47, 83, 130, 135, 151, 177, 213, 255, 255, 255 },
yabahiro 21:1f1e9c585da8 75 { -47, -21, 5, 0, 5, 21, 47, 83, 88, 104, 130, 167, 213, 255, 255 },
yabahiro 21:1f1e9c585da8 76 { -83, -47, -21, 5, 0, 5, 21, 47, 52, 68, 94, 130, 177, 234, 255 },
yabahiro 21:1f1e9c585da8 77 { -130, -83, -47, -21, 5, 0, 5, 21, 26, 42, 68, 104, 151, 208, 255 },
yabahiro 21:1f1e9c585da8 78 { -187, -130, -83, -47, -21, -5, 0, 5, 10, 26, 52, 88, 135, 193, 255 },
yabahiro 21:1f1e9c585da8 79 { -255, -187, -130, -83, -47, -21, -5, 0, 5, 21, 47, 83, 130, 187, 255 },
yabahiro 21:1f1e9c585da8 80 { -255, -193, -135, -88, -52, -26, -10, -5, 0, 5, 21, 47, 83, 130, 187 },
yabahiro 21:1f1e9c585da8 81 { -255, -208, -151, -104, -68, -42, -26, -21, -5, 0, 5, 21, 47, 83, 130 },
yabahiro 21:1f1e9c585da8 82 { -255, -234, -177, -130, -94, -68, -52, -47, -21, -7, 0, 7, 21, 47, 83 },
yabahiro 21:1f1e9c585da8 83 { -255, -255, -213, -167, -130, -104, -88, -83, -47, -21, -5, 0, 5, 21, 47 },
yabahiro 21:1f1e9c585da8 84 { -255, -255, -255, -213, -177, -151, -135, -130, -83, -47, -21, -5, 0, 5, 21 },
yabahiro 21:1f1e9c585da8 85 { -255, -255, -255, -255, -234, -208, -193, -187, -130, -83, -47, -21, -5, 0, 5 },
yabahiro 21:1f1e9c585da8 86 { -255, -255, -255, -255, -255, -255, -255, -255, -187, -130, -83, -47, -21, -5, 0 }
yabahiro 21:1f1e9c585da8 87 };
yabahiro 21:1f1e9c585da8 88
yabahiro 21:1f1e9c585da8 89 const int curve[15] = { -152, -98, -54, -18, 0, 0, 0, 0, 0, 0, 0, 18, 54, 98, 152 };
yabahiro 21:1f1e9c585da8 90 //{-200,-146,-102,-66,-36,-16,0,0,0,16,36,66,102,146,200}
yabahiro 21:1f1e9c585da8 91
yabahiro 21:1f1e9c585da8 92 uint8_t SetStatus(int);
yabahiro 21:1f1e9c585da8 93 uint8_t SetStatus(int pwmVal)
yabahiro 21:1f1e9c585da8 94 {
yabahiro 21:1f1e9c585da8 95 if (pwmVal < 0) return BACK;
yabahiro 21:1f1e9c585da8 96 else if (pwmVal > 0) return FOR;
yabahiro 21:1f1e9c585da8 97 else if (pwmVal == 0) return BRAKE;
yabahiro 21:1f1e9c585da8 98 else return BRAKE;
yabahiro 21:1f1e9c585da8 99 }
yabahiro 21:1f1e9c585da8 100 uint8_t Setpwm(int);
yabahiro 21:1f1e9c585da8 101 uint8_t Setpwm(int pwmVal)
yabahiro 21:1f1e9c585da8 102 {
yabahiro 21:1f1e9c585da8 103 if (pwmVal == 0 || pwmVal > 255 || pwmVal < -255) return 255;
yabahiro 21:1f1e9c585da8 104 else return abs(pwmVal);
yabahiro 21:1f1e9c585da8 105 }
M_souta 18:c694bae76e51 106
yabahiro 35:94f026ab4d30 107 void LedMode(int led)
yabahiro 35:94f026ab4d30 108 {
yabahiro 39:f89166d7411c 109 /*
yabahiro 36:788274604650 110 switch(led) {
yabahiro 36:788274604650 111 case 1:
yabahiro 36:788274604650 112 POTENTIOMETER::dio[0]= 1;
yabahiro 36:788274604650 113 POTENTIOMETER::dio[1]= 0;
yabahiro 36:788274604650 114 POTENTIOMETER::dio[2]= 0;
yabahiro 36:788274604650 115 POTENTIOMETER::dio[3]= 0;
yabahiro 36:788274604650 116 break;
yabahiro 36:788274604650 117 case 2:
yabahiro 36:788274604650 118 POTENTIOMETER::dio[0]= 0;
yabahiro 36:788274604650 119 POTENTIOMETER::dio[1]= 1;
yabahiro 36:788274604650 120 POTENTIOMETER::dio[2]= 0;
yabahiro 36:788274604650 121 POTENTIOMETER::dio[3]= 0;
yabahiro 36:788274604650 122 break;
yabahiro 36:788274604650 123 case 3:
yabahiro 36:788274604650 124 POTENTIOMETER::dio[0]= 1;
yabahiro 36:788274604650 125 POTENTIOMETER::dio[1]= 1;
yabahiro 36:788274604650 126 POTENTIOMETER::dio[2]= 0;
yabahiro 36:788274604650 127 POTENTIOMETER::dio[3]= 0;
yabahiro 36:788274604650 128 break;
yabahiro 36:788274604650 129 case 4:
yabahiro 36:788274604650 130 POTENTIOMETER::dio[0]= 0;
yabahiro 36:788274604650 131 POTENTIOMETER::dio[1]= 0;
yabahiro 36:788274604650 132 POTENTIOMETER::dio[2]= 1;
yabahiro 36:788274604650 133 POTENTIOMETER::dio[3]= 0;
yabahiro 36:788274604650 134 break;
yabahiro 36:788274604650 135 }
yabahiro 39:f89166d7411c 136 */
yabahiro 35:94f026ab4d30 137 if(led/8>=1) {
yabahiro 36:788274604650 138 POTENTIOMETER::dio[3]= 1;
yabahiro 35:94f026ab4d30 139 led=led%8;
yabahiro 35:94f026ab4d30 140 } else {
yabahiro 36:788274604650 141 POTENTIOMETER::dio[3]= 0;
yabahiro 35:94f026ab4d30 142 }
yabahiro 35:94f026ab4d30 143
yabahiro 35:94f026ab4d30 144 if(led/4>=1) {
yabahiro 36:788274604650 145 POTENTIOMETER::dio[2]= 1;
yabahiro 36:788274604650 146 led=led%4;
yabahiro 36:788274604650 147 } else {
yabahiro 36:788274604650 148 POTENTIOMETER::dio[2]= 0;
yabahiro 36:788274604650 149 }
yabahiro 36:788274604650 150
yabahiro 36:788274604650 151 if(led/2>=1) {
yabahiro 35:94f026ab4d30 152 POTENTIOMETER::dio[1]= 1;
yabahiro 36:788274604650 153 led=led%2;
yabahiro 35:94f026ab4d30 154 } else {
yabahiro 35:94f026ab4d30 155 POTENTIOMETER::dio[1]= 0;
yabahiro 35:94f026ab4d30 156 }
yabahiro 35:94f026ab4d30 157
yabahiro 36:788274604650 158 if(led/1>=1) {
yabahiro 36:788274604650 159 POTENTIOMETER::dio[0]= 1;
yabahiro 36:788274604650 160 led=0;
yabahiro 35:94f026ab4d30 161 } else {
yabahiro 36:788274604650 162 POTENTIOMETER::dio[0]= 0;
yabahiro 35:94f026ab4d30 163 }
yabahiro 35:94f026ab4d30 164 }
yabahiro 31:45f97698857b 165 int Twsh;
yabahiro 31:45f97698857b 166 bool UP_flag = false;
yabahiro 35:94f026ab4d30 167 bool SW_flag = false;
yabahiro 31:45f97698857b 168 bool Air_flag = false;
yabahiro 35:94f026ab4d30 169 bool zyouge;
yabahiro 39:f89166d7411c 170 bool zyougedo;
yabahiro 31:45f97698857b 171 bool dz1=true;
yabahiro 31:45f97698857b 172 bool dz1i=false;
yabahiro 31:45f97698857b 173 bool dz2=true;
yabahiro 31:45f97698857b 174 bool dz2i=false;
yabahiro 31:45f97698857b 175 bool dz3=true;
yabahiro 31:45f97698857b 176 bool dz3i=false;
yabahiro 31:45f97698857b 177 bool dz4=true;
yabahiro 31:45f97698857b 178 bool dz4i=false;
yabahiro 31:45f97698857b 179 bool zone;
yabahiro 31:45f97698857b 180 bool through=false;
yabahiro 35:94f026ab4d30 181 bool counts=false;
yabahiro 36:788274604650 182 bool mtc=false;
yabahiro 36:788274604650 183 bool mtc2 = false;
yabahiro 31:45f97698857b 184
yabahiro 41:e1dd6d97f17d 185 bool start_flag = true;
yabahiro 41:e1dd6d97f17d 186
yabahiro 31:45f97698857b 187 int mode =1;
yabahiro 31:45f97698857b 188 int cross=0;//十字数える用
yabahiro 35:94f026ab4d30 189 int cros=0;
yabahiro 31:45f97698857b 190 int count=100000;//wait代替え
kishibekairohan 33:656aa14904a5 191
kishibekairohan 33:656aa14904a5 192 ///*********PWM調整用*********///
yabahiro 40:7f93984e8ba1 193 int fast =60;
yabahiro 40:7f93984e8ba1 194 int normal = 40;
yabahiro 40:7f93984e8ba1 195 int slow = 20;
yabahiro 31:45f97698857b 196
t_yamamoto 0:669ef71cba68 197 #pragma endregion USER-DEFINED_VARIABLES_AND_PROTOTYPE
t_yamamoto 0:669ef71cba68 198
t_yamamoto 0:669ef71cba68 199 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 200 #if USE_PROCESS_NUM>0
t_yamamoto 0:669ef71cba68 201 static void Process0(void);
t_yamamoto 0:669ef71cba68 202 #endif
t_yamamoto 0:669ef71cba68 203 #if USE_PROCESS_NUM>1
t_yamamoto 0:669ef71cba68 204 static void Process1(void);
t_yamamoto 0:669ef71cba68 205 #endif
t_yamamoto 0:669ef71cba68 206 #if USE_PROCESS_NUM>2
t_yamamoto 0:669ef71cba68 207 static void Process2(void);
t_yamamoto 0:669ef71cba68 208 #endif
t_yamamoto 0:669ef71cba68 209 #if USE_PROCESS_NUM>3
t_yamamoto 0:669ef71cba68 210 static void Process3(void);
t_yamamoto 0:669ef71cba68 211 #endif
t_yamamoto 0:669ef71cba68 212 #if USE_PROCESS_NUM>4
t_yamamoto 0:669ef71cba68 213 static void Process4(void);
t_yamamoto 0:669ef71cba68 214 #endif
t_yamamoto 0:669ef71cba68 215 #if USE_PROCESS_NUM>5
t_yamamoto 0:669ef71cba68 216 static void Process5(void);
t_yamamoto 0:669ef71cba68 217 #endif
t_yamamoto 0:669ef71cba68 218 #if USE_PROCESS_NUM>6
t_yamamoto 0:669ef71cba68 219 static void Process6(void);
t_yamamoto 0:669ef71cba68 220 #endif
t_yamamoto 0:669ef71cba68 221 #if USE_PROCESS_NUM>7
t_yamamoto 0:669ef71cba68 222 static void Process7(void);
t_yamamoto 0:669ef71cba68 223 #endif
t_yamamoto 0:669ef71cba68 224 #if USE_PROCESS_NUM>8
t_yamamoto 0:669ef71cba68 225 static void Process8(void);
t_yamamoto 0:669ef71cba68 226 #endif
t_yamamoto 0:669ef71cba68 227 #if USE_PROCESS_NUM>9
t_yamamoto 0:669ef71cba68 228 static void Process9(void);
t_yamamoto 0:669ef71cba68 229 #endif
t_yamamoto 0:669ef71cba68 230 #endif
t_yamamoto 0:669ef71cba68 231
t_yamamoto 0:669ef71cba68 232 void SystemProcessInitialize()
t_yamamoto 0:669ef71cba68 233 {
yabahiro 21:1f1e9c585da8 234 #pragma region USER-DEFINED_VARIABLE_INIT
yabahiro 21:1f1e9c585da8 235 /*Replace here with the initialization code of your variables.*/
yabahiro 21:1f1e9c585da8 236 #pragma endregion USER-DEFINED_VARIABLE_INIT
t_yamamoto 0:669ef71cba68 237
yabahiro 21:1f1e9c585da8 238 lock = true;
yabahiro 21:1f1e9c585da8 239 processChangeComp = true;
yabahiro 21:1f1e9c585da8 240 current = DEFAULT_PROCESS;
t_yamamoto 0:669ef71cba68 241
yabahiro 21:1f1e9c585da8 242 #ifdef USE_SUBPROCESS
yabahiro 21:1f1e9c585da8 243 #if USE_PROCESS_NUM>0
yabahiro 21:1f1e9c585da8 244 Process[0] = Process0;
yabahiro 21:1f1e9c585da8 245 #endif
yabahiro 21:1f1e9c585da8 246 #if USE_PROCESS_NUM>1
yabahiro 21:1f1e9c585da8 247 Process[1] = Process1;
yabahiro 21:1f1e9c585da8 248 #endif
yabahiro 21:1f1e9c585da8 249 #if USE_PROCESS_NUM>2
yabahiro 21:1f1e9c585da8 250 Process[2] = Process2;
yabahiro 21:1f1e9c585da8 251 #endif
yabahiro 21:1f1e9c585da8 252 #if USE_PROCESS_NUM>3
yabahiro 21:1f1e9c585da8 253 Process[3] = Process3;
yabahiro 21:1f1e9c585da8 254 #endif
yabahiro 21:1f1e9c585da8 255 #if USE_PROCESS_NUM>4
yabahiro 21:1f1e9c585da8 256 Process[4] = Process4;
yabahiro 21:1f1e9c585da8 257 #endif
yabahiro 21:1f1e9c585da8 258 #if USE_PROCESS_NUM>5
yabahiro 21:1f1e9c585da8 259 Process[5] = Process5;
yabahiro 21:1f1e9c585da8 260 #endif
yabahiro 21:1f1e9c585da8 261 #if USE_PROCESS_NUM>6
yabahiro 21:1f1e9c585da8 262 Process[6] = Process6;
yabahiro 21:1f1e9c585da8 263 #endif
yabahiro 21:1f1e9c585da8 264 #if USE_PROCESS_NUM>7
yabahiro 21:1f1e9c585da8 265 Process[7] = Process7;
yabahiro 21:1f1e9c585da8 266 #endif
yabahiro 21:1f1e9c585da8 267 #if USE_PROCESS_NUM>8
yabahiro 21:1f1e9c585da8 268 Process[8] = Process8;
yabahiro 21:1f1e9c585da8 269 #endif
yabahiro 21:1f1e9c585da8 270 #if USE_PROCESS_NUM>9
yabahiro 21:1f1e9c585da8 271 Process[9] = Process9;
yabahiro 21:1f1e9c585da8 272 #endif
yabahiro 21:1f1e9c585da8 273 #endif
t_yamamoto 0:669ef71cba68 274 }
t_yamamoto 0:669ef71cba68 275
t_yamamoto 0:669ef71cba68 276 static void SystemProcessUpdate()
t_yamamoto 0:669ef71cba68 277 {
yabahiro 21:1f1e9c585da8 278 #ifdef USE_SUBPROCESS
yabahiro 21:1f1e9c585da8 279 if(controller->Button.HOME) lock = false;
yabahiro 21:1f1e9c585da8 280
yabahiro 21:1f1e9c585da8 281 if(controller->Button.START && processChangeComp) {
yabahiro 21:1f1e9c585da8 282 current++;
yabahiro 21:1f1e9c585da8 283 if (USE_PROCESS_NUM < current) current = USE_PROCESS_NUM;
yabahiro 21:1f1e9c585da8 284 processChangeComp = false;
yabahiro 21:1f1e9c585da8 285 } else if(controller->Button.SELECT && processChangeComp) {
yabahiro 21:1f1e9c585da8 286 current--;
yabahiro 21:1f1e9c585da8 287 if (current < 0) current = 0;
yabahiro 21:1f1e9c585da8 288 processChangeComp = false;
yabahiro 21:1f1e9c585da8 289 } else if(!controller->Button.SELECT && !controller->Button.START) processChangeComp = true;
yabahiro 21:1f1e9c585da8 290 #endif
yabahiro 21:1f1e9c585da8 291
yabahiro 21:1f1e9c585da8 292 #ifdef USE_MOTOR
yabahiro 21:1f1e9c585da8 293 ACTUATORHUB::MOTOR::Motor::Update(motor);
yabahiro 21:1f1e9c585da8 294 #endif
yabahiro 21:1f1e9c585da8 295
yabahiro 21:1f1e9c585da8 296 #ifdef USE_SOLENOID
yabahiro 21:1f1e9c585da8 297 ACTUATORHUB::SOLENOID::Solenoid::Update(solenoid);
yabahiro 21:1f1e9c585da8 298 #endif
yabahiro 21:1f1e9c585da8 299
yabahiro 21:1f1e9c585da8 300 #ifdef USE_RS485
yabahiro 21:1f1e9c585da8 301 ACTUATORHUB::ActuatorHub::Update();
yabahiro 21:1f1e9c585da8 302 #endif
yabahiro 21:1f1e9c585da8 303
yabahiro 21:1f1e9c585da8 304 }
yabahiro 21:1f1e9c585da8 305
yabahiro 21:1f1e9c585da8 306 int g[8];
yabahiro 21:1f1e9c585da8 307
yabahiro 21:1f1e9c585da8 308 void SystemProcess()
yabahiro 21:1f1e9c585da8 309 {
yabahiro 21:1f1e9c585da8 310 SystemProcessInitialize();
yabahiro 21:1f1e9c585da8 311
yabahiro 21:1f1e9c585da8 312 while(1) {
yabahiro 21:1f1e9c585da8 313 for(int i = 0; i < 8; i++) {
yabahiro 21:1f1e9c585da8 314 g[i] = LineHub::GetPara(i);
yabahiro 21:1f1e9c585da8 315 }
yabahiro 41:e1dd6d97f17d 316 if(ThSW) {
yabahiro 41:e1dd6d97f17d 317 Twsh=1;
yabahiro 41:e1dd6d97f17d 318 } else {
yabahiro 41:e1dd6d97f17d 319 Twsh=2;
yabahiro 41:e1dd6d97f17d 320 }
yabahiro 41:e1dd6d97f17d 321 if(StertSW && start_flag) {
yabahiro 41:e1dd6d97f17d 322 start_flag = false;
yabahiro 41:e1dd6d97f17d 323 lock = false;
yabahiro 41:e1dd6d97f17d 324 LedMode(1);
yabahiro 41:e1dd6d97f17d 325 if(ZoneSW) {
yabahiro 41:e1dd6d97f17d 326 mode=1;
yabahiro 41:e1dd6d97f17d 327 current = 2;
yabahiro 41:e1dd6d97f17d 328 } else {
yabahiro 41:e1dd6d97f17d 329 mode=1;
yabahiro 41:e1dd6d97f17d 330 current = 5;
yabahiro 41:e1dd6d97f17d 331 }
yabahiro 41:e1dd6d97f17d 332 }
yabahiro 41:e1dd6d97f17d 333 if(DWSW||DOSW) {
yabahiro 41:e1dd6d97f17d 334 if(DWSW) {
yabahiro 41:e1dd6d97f17d 335 zyouge=true;
yabahiro 41:e1dd6d97f17d 336 }
yabahiro 41:e1dd6d97f17d 337 if(DOSW) {
yabahiro 41:e1dd6d97f17d 338 if(DOLS) {
yabahiro 41:e1dd6d97f17d 339 motor[MOTOR_0].pwm = 100;
yabahiro 41:e1dd6d97f17d 340 motor[MOTOR_0].dir = BRAKE;
yabahiro 41:e1dd6d97f17d 341 } else {
yabahiro 41:e1dd6d97f17d 342 motor[MOTOR_0].pwm = 50;
yabahiro 41:e1dd6d97f17d 343 motor[MOTOR_0].dir = BACK;
yabahiro 41:e1dd6d97f17d 344 }
yabahiro 41:e1dd6d97f17d 345 }
yabahiro 41:e1dd6d97f17d 346 } else if(zyouge==false){
yabahiro 41:e1dd6d97f17d 347 motor[MOTOR_0].pwm = 100;
yabahiro 41:e1dd6d97f17d 348 motor[MOTOR_0].dir = BRAKE;
yabahiro 41:e1dd6d97f17d 349 }
yabahiro 41:e1dd6d97f17d 350 if(zyouge) {
yabahiro 41:e1dd6d97f17d 351 if(Twsh==1) {
yabahiro 41:e1dd6d97f17d 352 motor[MOTOR_0].pwm = 220;
yabahiro 41:e1dd6d97f17d 353 motor[MOTOR_0].dir = FOR;
yabahiro 41:e1dd6d97f17d 354 if(UPLS) {
yabahiro 41:e1dd6d97f17d 355 motor[MOTOR_0].pwm = 100;
yabahiro 41:e1dd6d97f17d 356 motor[MOTOR_0].dir = BRAKE;
yabahiro 41:e1dd6d97f17d 357 zyouge=false;
yabahiro 41:e1dd6d97f17d 358 }
yabahiro 41:e1dd6d97f17d 359 }
yabahiro 41:e1dd6d97f17d 360 if(Twsh==2) {
yabahiro 41:e1dd6d97f17d 361 motor[MOTOR_0].pwm = 230;
yabahiro 41:e1dd6d97f17d 362 motor[MOTOR_0].dir = FOR;
yabahiro 41:e1dd6d97f17d 363 if(UPLS2) {
yabahiro 41:e1dd6d97f17d 364 motor[MOTOR_0].pwm = 100;
yabahiro 41:e1dd6d97f17d 365 motor[MOTOR_0].dir = BRAKE;
yabahiro 41:e1dd6d97f17d 366 zyouge=false;
yabahiro 41:e1dd6d97f17d 367 }
yabahiro 41:e1dd6d97f17d 368 }
yabahiro 41:e1dd6d97f17d 369 }
yabahiro 41:e1dd6d97f17d 370 if(AIRSW) {
yabahiro 41:e1dd6d97f17d 371 if(SW_flag==false) {
yabahiro 41:e1dd6d97f17d 372 if(Air_flag==false) {
yabahiro 41:e1dd6d97f17d 373 solenoid.solenoid3 = SOLENOID_ON;
yabahiro 41:e1dd6d97f17d 374 Air_flag=true;
yabahiro 41:e1dd6d97f17d 375 SW_flag=true;
yabahiro 41:e1dd6d97f17d 376 } else {
yabahiro 41:e1dd6d97f17d 377 solenoid.solenoid3 = SOLENOID_OFF;
yabahiro 41:e1dd6d97f17d 378 Air_flag=false;
yabahiro 41:e1dd6d97f17d 379 SW_flag=true;
yabahiro 41:e1dd6d97f17d 380 }
yabahiro 41:e1dd6d97f17d 381 }
yabahiro 41:e1dd6d97f17d 382 } else {
yabahiro 41:e1dd6d97f17d 383 SW_flag=false;
yabahiro 41:e1dd6d97f17d 384 }
yabahiro 35:94f026ab4d30 385
yabahiro 36:788274604650 386 //printf("0:%d 1:%d 2:%d 3:%d 4:%d 5:%d 6:%d 9:%d\n\r",g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7]);
yabahiro 35:94f026ab4d30 387
yabahiro 21:1f1e9c585da8 388 #ifdef USE_MU
yabahiro 21:1f1e9c585da8 389 controller = CONTROLLER::Controller::GetData();
yabahiro 21:1f1e9c585da8 390 #endif
yabahiro 21:1f1e9c585da8 391
yabahiro 21:1f1e9c585da8 392 #ifdef USE_ERRORCHECK
yabahiro 41:e1dd6d97f17d 393 if(SAFTY::ErrorCheck::Check() & SAFTY::Error::ControllerLost & start_flag) { //& start_flag
yabahiro 21:1f1e9c585da8 394 CONTROLLER::Controller::DataReset();
yabahiro 21:1f1e9c585da8 395 AllActuatorReset();
yabahiro 21:1f1e9c585da8 396 lock = true;
yabahiro 21:1f1e9c585da8 397 } else
yabahiro 21:1f1e9c585da8 398 #endif
yabahiro 21:1f1e9c585da8 399 {
yabahiro 21:1f1e9c585da8 400
yabahiro 21:1f1e9c585da8 401 #ifdef USE_SUBPROCESS
yabahiro 21:1f1e9c585da8 402 if(!lock) {
yabahiro 21:1f1e9c585da8 403 Process[current]();
yabahiro 21:1f1e9c585da8 404 } else
yabahiro 21:1f1e9c585da8 405 #endif
yabahiro 21:1f1e9c585da8 406 {
yabahiro 21:1f1e9c585da8 407 //ロック時の処理
yabahiro 21:1f1e9c585da8 408 }
yabahiro 21:1f1e9c585da8 409 }
yabahiro 21:1f1e9c585da8 410 /*
yabahiro 21:1f1e9c585da8 411 //Emergency!
yabahiro 21:1f1e9c585da8 412 if(!EMG_0 && !EMG_1 && !EMGflag) {
yabahiro 21:1f1e9c585da8 413 buzzer = 0;
yabahiro 21:1f1e9c585da8 414 BuzzerTimer.attach(BuzzerTimer_func, 1);
yabahiro 21:1f1e9c585da8 415 EMGflag = true;
yabahiro 21:1f1e9c585da8 416 LED_DEBUG0 = 1;
yabahiro 21:1f1e9c585da8 417 }
yabahiro 21:1f1e9c585da8 418 if(EMG_0 && EMG_1 && EMGflag) {
yabahiro 21:1f1e9c585da8 419 buzzer = 1;
yabahiro 21:1f1e9c585da8 420 BuzzerTimer.detach();
yabahiro 21:1f1e9c585da8 421 EMGflag = false;
yabahiro 21:1f1e9c585da8 422 }
yabahiro 21:1f1e9c585da8 423 */
yabahiro 21:1f1e9c585da8 424 SystemProcessUpdate();
yabahiro 21:1f1e9c585da8 425 }
t_yamamoto 0:669ef71cba68 426 }
t_yamamoto 0:669ef71cba68 427
t_yamamoto 0:669ef71cba68 428 #pragma region PROCESS
t_yamamoto 0:669ef71cba68 429 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 430 #if USE_PROCESS_NUM>0
yabahiro 21:1f1e9c585da8 431 static void Process0()
yabahiro 21:1f1e9c585da8 432 {
yabahiro 41:e1dd6d97f17d 433 ///*
yabahiro 36:788274604650 434 mode=1;
yabahiro 36:788274604650 435 LedMode(1);
yabahiro 35:94f026ab4d30 436 if(ThSW) {
yabahiro 35:94f026ab4d30 437 Twsh=1;
yabahiro 35:94f026ab4d30 438 } else {
yabahiro 35:94f026ab4d30 439 Twsh=2;
yabahiro 31:45f97698857b 440 }
yabahiro 36:788274604650 441
yabahiro 25:38d4964e8aad 442 if(StertSW) {
yabahiro 41:e1dd6d97f17d 443 //start_flag == false;
yabahiro 41:e1dd6d97f17d 444 //lock = false;
yabahiro 36:788274604650 445 if(ZoneSW) {
yabahiro 31:45f97698857b 446 mode=1;
yabahiro 31:45f97698857b 447 current = 2;
yabahiro 31:45f97698857b 448 } else {
yabahiro 31:45f97698857b 449 mode=1;
yabahiro 40:7f93984e8ba1 450 current = 5;
yabahiro 31:45f97698857b 451 }
yabahiro 25:38d4964e8aad 452 }
yabahiro 35:94f026ab4d30 453 if(DWSW) {
yabahiro 35:94f026ab4d30 454 zyouge=true;
yabahiro 35:94f026ab4d30 455 }
yabahiro 39:f89166d7411c 456 if(DOSW) {
yabahiro 39:f89166d7411c 457 zyougedo=true;
yabahiro 39:f89166d7411c 458 }
yabahiro 35:94f026ab4d30 459 if(AIRSW) {
yabahiro 35:94f026ab4d30 460 if(SW_flag==false) {
yabahiro 35:94f026ab4d30 461 if(Air_flag==false) {
yabahiro 35:94f026ab4d30 462 solenoid.solenoid3 = SOLENOID_ON;
yabahiro 35:94f026ab4d30 463 Air_flag=true;
yabahiro 35:94f026ab4d30 464 SW_flag=true;
yabahiro 35:94f026ab4d30 465 } else {
yabahiro 35:94f026ab4d30 466 solenoid.solenoid3 = SOLENOID_OFF;
yabahiro 35:94f026ab4d30 467 Air_flag=false;
yabahiro 35:94f026ab4d30 468 SW_flag=true;
yabahiro 35:94f026ab4d30 469 }
yabahiro 35:94f026ab4d30 470 }
yabahiro 35:94f026ab4d30 471 } else {
yabahiro 35:94f026ab4d30 472 SW_flag=false;
yabahiro 31:45f97698857b 473 }
yabahiro 31:45f97698857b 474
yabahiro 35:94f026ab4d30 475 if(zyouge) {
yabahiro 35:94f026ab4d30 476 if(Twsh==1) {
yabahiro 35:94f026ab4d30 477 motor[MOTOR_0].pwm = 220;
yabahiro 35:94f026ab4d30 478 motor[MOTOR_0].dir = FOR;
yabahiro 35:94f026ab4d30 479 if(UPLS) {
yabahiro 35:94f026ab4d30 480 motor[MOTOR_0].pwm = 100;
yabahiro 35:94f026ab4d30 481 motor[MOTOR_0].dir = BRAKE;
yabahiro 35:94f026ab4d30 482 zyouge=false;
yabahiro 35:94f026ab4d30 483 }
yabahiro 35:94f026ab4d30 484 }
yabahiro 35:94f026ab4d30 485 if(Twsh==2) {
yabahiro 37:7cfa39c41245 486 motor[MOTOR_0].pwm = 230;
yabahiro 35:94f026ab4d30 487 motor[MOTOR_0].dir = FOR;
yabahiro 35:94f026ab4d30 488 if(UPLS2) {
yabahiro 35:94f026ab4d30 489 motor[MOTOR_0].pwm = 100;
yabahiro 35:94f026ab4d30 490 motor[MOTOR_0].dir = BRAKE;
yabahiro 35:94f026ab4d30 491 zyouge=false;
yabahiro 35:94f026ab4d30 492 }
yabahiro 31:45f97698857b 493 }
yabahiro 39:f89166d7411c 494 }
yabahiro 39:f89166d7411c 495 if(zyougedo) {
yabahiro 39:f89166d7411c 496 motor[MOTOR_0].pwm = 50;
yabahiro 39:f89166d7411c 497 motor[MOTOR_0].dir = BACK;
yabahiro 39:f89166d7411c 498 if(DOLS) {
yabahiro 39:f89166d7411c 499 motor[MOTOR_0].pwm = 100;
yabahiro 39:f89166d7411c 500 motor[MOTOR_0].dir = BRAKE;
yabahiro 39:f89166d7411c 501 zyougedo=false;
yabahiro 39:f89166d7411c 502 }
yabahiro 31:45f97698857b 503 }
yabahiro 41:e1dd6d97f17d 504 //*/
yabahiro 35:94f026ab4d30 505 }
yabahiro 31:45f97698857b 506
t_yamamoto 0:669ef71cba68 507 #endif
t_yamamoto 0:669ef71cba68 508
t_yamamoto 0:669ef71cba68 509 #if USE_PROCESS_NUM>1
kishibekairohan 16:3f2c2d89372b 510 static void Process1()
t_yamamoto 0:669ef71cba68 511 {
yabahiro 41:e1dd6d97f17d 512 start_flag = true;
yabahiro 41:e1dd6d97f17d 513
yabahiro 36:788274604650 514 mtc=false;
yabahiro 36:788274604650 515 mtc2 = false;
yabahiro 36:788274604650 516 LedMode(2);
yabahiro 31:45f97698857b 517 mode=1;
yabahiro 27:545148741493 518 cross=0;
yabahiro 35:94f026ab4d30 519 Twsh=1;
yabahiro 21:1f1e9c585da8 520 motor[TIRE_FR].dir = SetStatus(-omni[controller->AnalogL.Y][14-controller->AnalogL.X] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 521 motor[TIRE_FL].dir = SetStatus(omni[controller->AnalogL.Y][controller->AnalogL.X] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 522 motor[TIRE_BR].dir = SetStatus(-omni[14-controller->AnalogL.X][14-controller->AnalogL.Y] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 523 motor[TIRE_BL].dir = SetStatus(omni[controller->AnalogL.X][14-controller->AnalogL.Y] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 524
yabahiro 21:1f1e9c585da8 525 motor[TIRE_FR].pwm = Setpwm(omni[controller->AnalogL.Y][14-controller->AnalogL.X]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 526 motor[TIRE_FL].pwm = Setpwm(omni[controller->AnalogL.Y][controller->AnalogL.X]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 527 motor[TIRE_BR].pwm = Setpwm(omni[14-controller->AnalogL.X][14-controller->AnalogL.Y]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 528 motor[TIRE_BL].pwm = Setpwm(omni[controller->AnalogL.X][14-controller->AnalogL.Y]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 529
yabahiro 21:1f1e9c585da8 530 if(controller->Button.UP||controller->Button.DOWN) {
yabahiro 21:1f1e9c585da8 531
yabahiro 21:1f1e9c585da8 532 if(controller->Button.UP) {
yabahiro 35:94f026ab4d30 533 motor[MOTOR_0].pwm =200;
yabahiro 21:1f1e9c585da8 534 motor[MOTOR_0].dir = FOR;
yabahiro 35:94f026ab4d30 535 if(UPLS) {
yabahiro 35:94f026ab4d30 536 motor[MOTOR_0].pwm = 0;
yabahiro 35:94f026ab4d30 537 motor[MOTOR_0].dir = BRAKE;
yabahiro 35:94f026ab4d30 538 }
yabahiro 21:1f1e9c585da8 539 }
yabahiro 21:1f1e9c585da8 540 if(controller->Button.DOWN) {
yabahiro 21:1f1e9c585da8 541 motor[MOTOR_0].pwm = 50;
yabahiro 21:1f1e9c585da8 542 motor[MOTOR_0].dir = BACK;
yabahiro 21:1f1e9c585da8 543 }
yabahiro 21:1f1e9c585da8 544 } else {
yabahiro 21:1f1e9c585da8 545 motor[MOTOR_0].pwm = 0;
yabahiro 21:1f1e9c585da8 546 motor[MOTOR_0].dir = BRAKE;
yabahiro 21:1f1e9c585da8 547 }
yabahiro 21:1f1e9c585da8 548
yabahiro 21:1f1e9c585da8 549 if(controller->Button.Y) {
yabahiro 21:1f1e9c585da8 550 if(dz2==true) {
yabahiro 21:1f1e9c585da8 551 if(dz2i==false) {
yabahiro 21:1f1e9c585da8 552 solenoid.solenoid2 = SOLENOID_ON;
yabahiro 21:1f1e9c585da8 553 dz2i=true;
yabahiro 21:1f1e9c585da8 554 } else {
yabahiro 21:1f1e9c585da8 555 solenoid.solenoid2 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 556 dz2i=false;
yabahiro 21:1f1e9c585da8 557 }
yabahiro 21:1f1e9c585da8 558 dz2=false;
yabahiro 21:1f1e9c585da8 559 }
yabahiro 21:1f1e9c585da8 560 } else {
yabahiro 21:1f1e9c585da8 561 dz2=true;
yabahiro 21:1f1e9c585da8 562 }
yabahiro 21:1f1e9c585da8 563
yabahiro 21:1f1e9c585da8 564 if(controller->Button.A) {
yabahiro 21:1f1e9c585da8 565 if(dz3==true) {
yabahiro 21:1f1e9c585da8 566 if(dz3i==false) {
yabahiro 30:9450dc1d53cc 567
yabahiro 21:1f1e9c585da8 568 dz3i=true;
yabahiro 21:1f1e9c585da8 569 } else {
yabahiro 21:1f1e9c585da8 570 solenoid.solenoid3 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 571 dz3i=false;
yabahiro 21:1f1e9c585da8 572 }
yabahiro 21:1f1e9c585da8 573 dz3=false;
yabahiro 21:1f1e9c585da8 574 }
yabahiro 21:1f1e9c585da8 575 } else {
yabahiro 21:1f1e9c585da8 576 dz3=true;
yabahiro 21:1f1e9c585da8 577 }
yabahiro 21:1f1e9c585da8 578
yabahiro 21:1f1e9c585da8 579 if(controller->Button.B) {
yabahiro 21:1f1e9c585da8 580 if(dz4==true) {
yabahiro 21:1f1e9c585da8 581 if(dz4i==false) {
yabahiro 21:1f1e9c585da8 582 solenoid.solenoid4 = SOLENOID_ON;
yabahiro 21:1f1e9c585da8 583 dz4i=true;
yabahiro 21:1f1e9c585da8 584 } else {
yabahiro 21:1f1e9c585da8 585 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 586 dz4i=false;
yabahiro 21:1f1e9c585da8 587 }
yabahiro 21:1f1e9c585da8 588 dz4=false;
yabahiro 21:1f1e9c585da8 589 }
yabahiro 21:1f1e9c585da8 590 } else {
yabahiro 21:1f1e9c585da8 591 dz4=true;
yabahiro 21:1f1e9c585da8 592 }
yabahiro 21:1f1e9c585da8 593 /*
yabahiro 21:1f1e9c585da8 594 if(controller->Button.RIGHT){
yabahiro 21:1f1e9c585da8 595 motor[MOTOR_1].dir = FOR;
yabahiro 21:1f1e9c585da8 596 motor[MOTOR_1].pwm = 60;
yabahiro 21:1f1e9c585da8 597 if (ARM_1){
yabahiro 21:1f1e9c585da8 598 motor[MOTOR_1].dir = BRAKE;
yabahiro 21:1f1e9c585da8 599 }
yabahiro 21:1f1e9c585da8 600 }
yabahiro 21:1f1e9c585da8 601 else if(controller->Button.LEFT){
yabahiro 21:1f1e9c585da8 602 motor[MOTOR_1].dir = BACK;
yabahiro 21:1f1e9c585da8 603 motor[MOTOR_1].pwm = 60;
yabahiro 21:1f1e9c585da8 604 if (ARM_0){
yabahiro 21:1f1e9c585da8 605 motor[MOTOR_1].dir = BRAKE;
yabahiro 21:1f1e9c585da8 606 }
yabahiro 21:1f1e9c585da8 607 }
yabahiro 21:1f1e9c585da8 608 */
t_yamamoto 0:669ef71cba68 609 }
t_yamamoto 0:669ef71cba68 610 #endif
t_yamamoto 0:669ef71cba68 611
t_yamamoto 0:669ef71cba68 612 #if USE_PROCESS_NUM>2
kishibekairohan 16:3f2c2d89372b 613 static void Process2()
yabahiro 21:1f1e9c585da8 614 {
yabahiro 36:788274604650 615 LedMode(3);
yabahiro 31:45f97698857b 616 // printf("1:%d 2:%d 3:%d 4:%d 5:%d 6:%d 7:%d 8:%d\n\r",g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7]);
yabahiro 31:45f97698857b 617 count++;
yabahiro 31:45f97698857b 618 if(mode==1) {//スタートゾーンから白線検知
kishibekairohan 33:656aa14904a5 619 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 620 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 621 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 622 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 623 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 624 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 625 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 626 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 627 if(g[2]==0) {
yabahiro 31:45f97698857b 628 count=100000;
yabahiro 31:45f97698857b 629 cross=0;
yabahiro 31:45f97698857b 630 mode=3;
yabahiro 31:45f97698857b 631 }
yabahiro 31:45f97698857b 632 } else if(mode==3) { //横ライントレースから縦ライントレースへ
yabahiro 31:45f97698857b 633 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 634 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 635 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 636 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 637 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 638 motor[TIRE_BR].dir = BACK;
yabahiro 31:45f97698857b 639 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 640 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 641 if(g[0]==0) {
yabahiro 35:94f026ab4d30 642 mode=10;
yabahiro 35:94f026ab4d30 643 count=100000;
yabahiro 31:45f97698857b 644 }
yabahiro 35:94f026ab4d30 645 } else if(mode==10) { //縦ライントレース
yabahiro 35:94f026ab4d30 646
yabahiro 35:94f026ab4d30 647 if(counts==false&&g[2]==0) {
yabahiro 35:94f026ab4d30 648 cros++;
yabahiro 35:94f026ab4d30 649 counts=true;
yabahiro 31:45f97698857b 650 }
yabahiro 35:94f026ab4d30 651 if(counts==true&&g[2]==99) {
yabahiro 35:94f026ab4d30 652 counts=false;
yabahiro 35:94f026ab4d30 653 }
yabahiro 35:94f026ab4d30 654
yabahiro 35:94f026ab4d30 655 if(cros==Twsh) {
yabahiro 35:94f026ab4d30 656 mode=11;
yabahiro 31:45f97698857b 657 count=0;
yabahiro 35:94f026ab4d30 658 cros=0;
yabahiro 35:94f026ab4d30 659 }//ゆっくりモードに入れなかった時の保険
yabahiro 31:45f97698857b 660 switch(g[0]) {
yabahiro 31:45f97698857b 661 case 98:
kishibekairohan 33:656aa14904a5 662 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 663 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 664 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 665 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 666 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 667 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 668 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 669 motor[TIRE_BL].dir = FOR;
yabahiro 35:94f026ab4d30 670 mtc=true;
yabahiro 35:94f026ab4d30 671 if(count>80000) {
yabahiro 31:45f97698857b 672 cross++;
yabahiro 31:45f97698857b 673 count=0;
yabahiro 31:45f97698857b 674 }
yabahiro 31:45f97698857b 675 if(cross==Twsh) {
yabahiro 31:45f97698857b 676 mode=11;
yabahiro 31:45f97698857b 677 count=0;
yabahiro 35:94f026ab4d30 678 cross=0;
yabahiro 31:45f97698857b 679 }
yabahiro 31:45f97698857b 680 break;
yabahiro 31:45f97698857b 681 case 0:
kishibekairohan 33:656aa14904a5 682 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 683 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 684 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 685 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 686 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 687 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 688 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 689 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 690 mtc=true;
yabahiro 31:45f97698857b 691 break;
yabahiro 31:45f97698857b 692 case 255:
kishibekairohan 33:656aa14904a5 693 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 694 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 695 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 696 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 697 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 698 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 699 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 700 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 701 mtc=true;
yabahiro 31:45f97698857b 702 break;
yabahiro 31:45f97698857b 703 case 253:
kishibekairohan 33:656aa14904a5 704 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 705 motor[TIRE_FR].dir = BACK;
yabahiro 31:45f97698857b 706 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 707 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 708 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 709 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 710 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 711 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 712 mtc=true;
yabahiro 31:45f97698857b 713 break;
yabahiro 31:45f97698857b 714 case 254:
kishibekairohan 33:656aa14904a5 715 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 716 motor[TIRE_FR].dir = BACK;
yabahiro 31:45f97698857b 717 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 718 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 719 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 720 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 721 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 722 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 723 mtc=true;
yabahiro 31:45f97698857b 724 break;
yabahiro 31:45f97698857b 725 case 1:
kishibekairohan 33:656aa14904a5 726 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 727 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 728 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 729 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 730 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 731 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 732 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 733 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 734 mtc=true;
yabahiro 31:45f97698857b 735 break;
yabahiro 31:45f97698857b 736 case 3:
yabahiro 31:45f97698857b 737 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 738 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 739 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 740 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 741 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 742 motor[TIRE_BR].dir = BACK;
yabahiro 31:45f97698857b 743 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 744 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 745 mtc=true;
yabahiro 31:45f97698857b 746 break;
yabahiro 31:45f97698857b 747 case 2:
yabahiro 31:45f97698857b 748 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 749 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 750 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 751 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 752 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 753 motor[TIRE_BR].dir = BACK;
yabahiro 31:45f97698857b 754 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 755 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 756 mtc=true;
yabahiro 31:45f97698857b 757 break;
yabahiro 31:45f97698857b 758 }
yabahiro 31:45f97698857b 759 if(g[0]!=98&&mtc==true) {
yabahiro 31:45f97698857b 760 switch(g[1]) {
yabahiro 31:45f97698857b 761 case 0:
yabahiro 31:45f97698857b 762 mtc=false;
yabahiro 31:45f97698857b 763 break;
yabahiro 31:45f97698857b 764 case 255:
yabahiro 31:45f97698857b 765 motor[TIRE_BR].pwm += 5;
yabahiro 31:45f97698857b 766 mtc=false;
yabahiro 31:45f97698857b 767 break;
yabahiro 31:45f97698857b 768 case 253:
yabahiro 31:45f97698857b 769 motor[TIRE_BR].pwm += 10;
yabahiro 31:45f97698857b 770 mtc=false;
yabahiro 31:45f97698857b 771 break;
yabahiro 31:45f97698857b 772 case 254:
yabahiro 31:45f97698857b 773 motor[TIRE_BR].pwm += 20;
yabahiro 31:45f97698857b 774 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 775 mtc=false;
yabahiro 31:45f97698857b 776 break;
yabahiro 31:45f97698857b 777 case 1:
yabahiro 31:45f97698857b 778 motor[TIRE_BL].pwm += 5;
yabahiro 31:45f97698857b 779 mtc=false;
yabahiro 31:45f97698857b 780 break;
yabahiro 31:45f97698857b 781 case 3:
yabahiro 31:45f97698857b 782 motor[TIRE_BL].pwm += 10;
yabahiro 31:45f97698857b 783 mtc=false;
yabahiro 31:45f97698857b 784 break;
yabahiro 31:45f97698857b 785 case 2:
yabahiro 31:45f97698857b 786 motor[TIRE_BL].pwm += 20;
yabahiro 31:45f97698857b 787 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 788 mtc=false;
yabahiro 31:45f97698857b 789 break;
yabahiro 21:1f1e9c585da8 790 }
yabahiro 31:45f97698857b 791 }
yabahiro 31:45f97698857b 792 } else if(mode==11) {
yabahiro 31:45f97698857b 793 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 794 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 795 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 796 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 797 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 798 motor[TIRE_BR].dir = BACK;
yabahiro 31:45f97698857b 799 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 800 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 801 if(g[2]==0) {
yabahiro 31:45f97698857b 802 count=0;
yabahiro 31:45f97698857b 803 cross=0;
yabahiro 31:45f97698857b 804 mode=20;
yabahiro 31:45f97698857b 805 }
yabahiro 31:45f97698857b 806 } else if(mode==20) {
yabahiro 35:94f026ab4d30 807
yabahiro 38:391a0c8e4c16 808 if(Twsh==2) {
yabahiro 38:391a0c8e4c16 809 solenoid.solenoid2 = SOLENOID_ON;
yabahiro 38:391a0c8e4c16 810 }
yabahiro 35:94f026ab4d30 811 if(counts==false&&g[0]==0) {
yabahiro 35:94f026ab4d30 812 cros++;
yabahiro 35:94f026ab4d30 813 counts=true;
yabahiro 35:94f026ab4d30 814 }
yabahiro 35:94f026ab4d30 815 if(counts==true&&g[0]==99) {
yabahiro 35:94f026ab4d30 816 counts=false;
yabahiro 35:94f026ab4d30 817 }
yabahiro 35:94f026ab4d30 818
yabahiro 35:94f026ab4d30 819 if(cros==2) {
yabahiro 37:7cfa39c41245 820
yabahiro 37:7cfa39c41245 821 // mode=21;
yabahiro 37:7cfa39c41245 822 // count=0;
yabahiro 37:7cfa39c41245 823 // cros=0;
yabahiro 35:94f026ab4d30 824 }//ゆっくりモードに入れなかった時の保険
yabahiro 35:94f026ab4d30 825
yabahiro 31:45f97698857b 826 switch(g[2]) {
yabahiro 31:45f97698857b 827 case 98:
kishibekairohan 33:656aa14904a5 828 motor[TIRE_FR].pwm = normal;
kishibekairohan 22:c47f29caded6 829 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 830 motor[TIRE_FL].pwm = normal;
kishibekairohan 22:c47f29caded6 831 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 832 motor[TIRE_BR].pwm = normal;
kishibekairohan 22:c47f29caded6 833 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 834 motor[TIRE_BL].pwm = normal;
kishibekairohan 22:c47f29caded6 835 motor[TIRE_BL].dir = BACK;
yabahiro 35:94f026ab4d30 836 if(count>80000) {
yabahiro 31:45f97698857b 837 cross++;
yabahiro 31:45f97698857b 838 count=0;
yabahiro 31:45f97698857b 839 }
yabahiro 31:45f97698857b 840 mtc2=true;
yabahiro 35:94f026ab4d30 841 if(cross==2) {
yabahiro 31:45f97698857b 842 mode=21;
yabahiro 31:45f97698857b 843 count=0;
yabahiro 31:45f97698857b 844 cross=0;
yabahiro 31:45f97698857b 845 }
yabahiro 31:45f97698857b 846 break;
yabahiro 31:45f97698857b 847 case 0:
kishibekairohan 33:656aa14904a5 848 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 849 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 850 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 851 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 852 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 853 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 854 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 855 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 856 mtc2=true;
yabahiro 31:45f97698857b 857 break;
yabahiro 31:45f97698857b 858 case 255:
kishibekairohan 33:656aa14904a5 859 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 860 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 861 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 862 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 863 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 864 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 865 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 866 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 867 mtc2=true;
yabahiro 31:45f97698857b 868 break;
yabahiro 31:45f97698857b 869 case 253:
yabahiro 31:45f97698857b 870 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 871 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 872 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 873 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 874 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 875 motor[TIRE_BR].dir = BACK;
yabahiro 31:45f97698857b 876 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 877 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 878 mtc2=true;
yabahiro 31:45f97698857b 879 break;
yabahiro 31:45f97698857b 880 case 254:
yabahiro 31:45f97698857b 881 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 882 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 883 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 884 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 885 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 886 motor[TIRE_BR].dir = BACK;
yabahiro 31:45f97698857b 887 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 888 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 889 mtc2=true;
yabahiro 31:45f97698857b 890 break;
yabahiro 31:45f97698857b 891 case 1:
kishibekairohan 33:656aa14904a5 892 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 893 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 894 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 895 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 896 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 897 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 898 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 899 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 900 mtc2=true;
yabahiro 31:45f97698857b 901 break;
yabahiro 31:45f97698857b 902 case 3:
kishibekairohan 33:656aa14904a5 903 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 904 motor[TIRE_FR].dir = FOR;
yabahiro 31:45f97698857b 905 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 906 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 907 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 908 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 909 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 910 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 911 mtc2=true;
yabahiro 31:45f97698857b 912 break;
yabahiro 31:45f97698857b 913 case 2:
kishibekairohan 33:656aa14904a5 914 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 915 motor[TIRE_FR].dir = FOR;
yabahiro 31:45f97698857b 916 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 917 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 918 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 919 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 920 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 921 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 922 mtc2=true;
yabahiro 31:45f97698857b 923 break;
yabahiro 31:45f97698857b 924 }
yabahiro 31:45f97698857b 925 if(g[2]!=98&&mtc2==true) {
yabahiro 31:45f97698857b 926 switch(g[3]) {
yabahiro 29:c78a46f51209 927 case 0:
yabahiro 31:45f97698857b 928 mtc2=false;
yabahiro 29:c78a46f51209 929 break;
yabahiro 29:c78a46f51209 930 case 255:
yabahiro 31:45f97698857b 931 motor[TIRE_BL].pwm += 5;
yabahiro 31:45f97698857b 932 mtc2=false;
yabahiro 29:c78a46f51209 933 break;
yabahiro 29:c78a46f51209 934 case 253:
yabahiro 31:45f97698857b 935 motor[TIRE_BL].pwm += 10;
yabahiro 31:45f97698857b 936 mtc2=false;
yabahiro 29:c78a46f51209 937 break;
yabahiro 29:c78a46f51209 938 case 254:
yabahiro 31:45f97698857b 939 motor[TIRE_BL].pwm += 20;
yabahiro 29:c78a46f51209 940 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 941 mtc2=false;
yabahiro 29:c78a46f51209 942 break;
yabahiro 29:c78a46f51209 943 case 1:
yabahiro 31:45f97698857b 944 motor[TIRE_FL].pwm += 5;
yabahiro 31:45f97698857b 945 mtc2=false;
yabahiro 29:c78a46f51209 946 break;
yabahiro 29:c78a46f51209 947 case 3:
yabahiro 31:45f97698857b 948 motor[TIRE_FL].pwm += 10;
yabahiro 31:45f97698857b 949 mtc2=false;
yabahiro 29:c78a46f51209 950 break;
yabahiro 29:c78a46f51209 951 case 2:
yabahiro 31:45f97698857b 952 motor[TIRE_FL].pwm += 20;
yabahiro 31:45f97698857b 953 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 954 mtc2=false;
yabahiro 29:c78a46f51209 955 break;
yabahiro 29:c78a46f51209 956 }
yabahiro 31:45f97698857b 957 }
yabahiro 31:45f97698857b 958 } else if(mode==21) {
yabahiro 31:45f97698857b 959 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 960 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 961 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 962 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 963 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 964 motor[TIRE_BR].dir = BACK;
yabahiro 31:45f97698857b 965 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 966 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 967 if(g[0]==0) {
yabahiro 31:45f97698857b 968 mode=30;
yabahiro 35:94f026ab4d30 969 cros=0;
yabahiro 35:94f026ab4d30 970 zyouge=true;
yabahiro 31:45f97698857b 971 }
yabahiro 31:45f97698857b 972 } else if(mode==30) {
yabahiro 38:391a0c8e4c16 973 motor[TIRE_FR].pwm = 62;
yabahiro 38:391a0c8e4c16 974 motor[TIRE_FR].dir = BACK;
yabahiro 38:391a0c8e4c16 975 motor[TIRE_FL].pwm = 60;
yabahiro 38:391a0c8e4c16 976 motor[TIRE_FL].dir = FOR;
yabahiro 38:391a0c8e4c16 977 motor[TIRE_BR].pwm = 60;
yabahiro 38:391a0c8e4c16 978 motor[TIRE_BR].dir = BACK;
yabahiro 38:391a0c8e4c16 979 motor[TIRE_BL].pwm = 62;
yabahiro 38:391a0c8e4c16 980 motor[TIRE_BL].dir = FOR;
yabahiro 38:391a0c8e4c16 981 if(g[0]==98) {
yabahiro 35:94f026ab4d30 982 mode=31;
yabahiro 38:391a0c8e4c16 983 }
yabahiro 38:391a0c8e4c16 984 if(g[3]==0) {
yabahiro 38:391a0c8e4c16 985 mode=32;
yabahiro 35:94f026ab4d30 986 count=0;
yabahiro 35:94f026ab4d30 987 cros=0;
yabahiro 35:94f026ab4d30 988 }//ゆっくりモードに入れなかった時の保険
yabahiro 38:391a0c8e4c16 989 /*
yabahiro 38:391a0c8e4c16 990 if(g[0]==98) {
yabahiro 38:391a0c8e4c16 991 if(Twsh==2) {
yabahiro 38:391a0c8e4c16 992 solenoid.solenoid2 = SOLENOID_OFF;
yabahiro 38:391a0c8e4c16 993 }
yabahiro 38:391a0c8e4c16 994 mode=31;
yabahiro 38:391a0c8e4c16 995 count=0;
yabahiro 38:391a0c8e4c16 996 }
yabahiro 31:45f97698857b 997 switch(g[0]) {
yabahiro 31:45f97698857b 998 case 98:
yabahiro 35:94f026ab4d30 999 motor[TIRE_FR].pwm = 30;
yabahiro 31:45f97698857b 1000 motor[TIRE_FR].dir = BACK;
yabahiro 35:94f026ab4d30 1001 motor[TIRE_FL].pwm = 30;
yabahiro 31:45f97698857b 1002 motor[TIRE_FL].dir = FOR;
yabahiro 35:94f026ab4d30 1003 motor[TIRE_BR].pwm = 30;
yabahiro 31:45f97698857b 1004 motor[TIRE_BR].dir = BACK;
yabahiro 35:94f026ab4d30 1005 motor[TIRE_BL].pwm = 30;
yabahiro 31:45f97698857b 1006 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 1007 if(count>100000) {
yabahiro 31:45f97698857b 1008 cross++;
yabahiro 31:45f97698857b 1009 count=0;
yabahiro 31:45f97698857b 1010 }
yabahiro 31:45f97698857b 1011 mtc=true;
yabahiro 31:45f97698857b 1012 if(cross==1) {
yabahiro 35:94f026ab4d30 1013 if(Twsh==2) {
yabahiro 35:94f026ab4d30 1014 solenoid.solenoid2 = SOLENOID_OFF;
yabahiro 35:94f026ab4d30 1015 }
yabahiro 31:45f97698857b 1016 mode=31;
yabahiro 31:45f97698857b 1017 count=0;
yabahiro 29:c78a46f51209 1018 }
yabahiro 31:45f97698857b 1019 break;
yabahiro 31:45f97698857b 1020 case 0:
yabahiro 38:391a0c8e4c16 1021 motor[TIRE_FR].pwm = 80;
yabahiro 31:45f97698857b 1022 motor[TIRE_FR].dir = BACK;
yabahiro 38:391a0c8e4c16 1023 motor[TIRE_FL].pwm = 80;
yabahiro 31:45f97698857b 1024 motor[TIRE_FL].dir = FOR;
yabahiro 38:391a0c8e4c16 1025 motor[TIRE_BR].pwm = 80;
yabahiro 31:45f97698857b 1026 motor[TIRE_BR].dir = BACK;
yabahiro 38:391a0c8e4c16 1027 motor[TIRE_BL].pwm = 80;
yabahiro 31:45f97698857b 1028 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 1029 mtc=true;
yabahiro 31:45f97698857b 1030 break;
yabahiro 31:45f97698857b 1031 case 255:
yabahiro 38:391a0c8e4c16 1032 motor[TIRE_FR].pwm = 80;
yabahiro 31:45f97698857b 1033 motor[TIRE_FR].dir = BACK;
yabahiro 38:391a0c8e4c16 1034 motor[TIRE_FL].pwm = 40;
yabahiro 31:45f97698857b 1035 motor[TIRE_FL].dir = FOR;
yabahiro 38:391a0c8e4c16 1036 motor[TIRE_BR].pwm = 40;
yabahiro 31:45f97698857b 1037 motor[TIRE_BR].dir = BACK;
yabahiro 38:391a0c8e4c16 1038 motor[TIRE_BL].pwm = 80;
yabahiro 31:45f97698857b 1039 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 1040 mtc=true;
yabahiro 31:45f97698857b 1041 break;
yabahiro 31:45f97698857b 1042 case 253:
yabahiro 38:391a0c8e4c16 1043 motor[TIRE_FR].pwm = 80;
yabahiro 31:45f97698857b 1044 motor[TIRE_FR].dir = BACK;
yabahiro 31:45f97698857b 1045 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1046 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 1047 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1048 motor[TIRE_BR].dir = FREE;
yabahiro 38:391a0c8e4c16 1049 motor[TIRE_BL].pwm = 40;
yabahiro 31:45f97698857b 1050 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 1051 mtc=true;
yabahiro 31:45f97698857b 1052 break;
yabahiro 31:45f97698857b 1053 case 254:
yabahiro 38:391a0c8e4c16 1054 motor[TIRE_FR].pwm = 50;
yabahiro 31:45f97698857b 1055 motor[TIRE_FR].dir = BACK;
yabahiro 31:45f97698857b 1056 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1057 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 1058 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1059 motor[TIRE_BR].dir = FREE;
yabahiro 38:391a0c8e4c16 1060 motor[TIRE_BL].pwm = 50;
yabahiro 31:45f97698857b 1061 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 1062 mtc=true;
yabahiro 31:45f97698857b 1063 break;
yabahiro 31:45f97698857b 1064 case 1:
yabahiro 38:391a0c8e4c16 1065 motor[TIRE_FR].pwm = 40;
yabahiro 31:45f97698857b 1066 motor[TIRE_FR].dir = BACK;
yabahiro 38:391a0c8e4c16 1067 motor[TIRE_FL].pwm = 80;
yabahiro 31:45f97698857b 1068 motor[TIRE_FL].dir = FOR;
yabahiro 38:391a0c8e4c16 1069 motor[TIRE_BR].pwm = 80;
yabahiro 31:45f97698857b 1070 motor[TIRE_BR].dir = BACK;
yabahiro 38:391a0c8e4c16 1071 motor[TIRE_BL].pwm = 40;
yabahiro 31:45f97698857b 1072 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 1073 mtc=true;
yabahiro 31:45f97698857b 1074 break;
yabahiro 31:45f97698857b 1075 case 3:
yabahiro 31:45f97698857b 1076 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1077 motor[TIRE_FR].dir = FREE;
yabahiro 38:391a0c8e4c16 1078 motor[TIRE_FL].pwm = 40;
yabahiro 31:45f97698857b 1079 motor[TIRE_FL].dir = FOR;
yabahiro 38:391a0c8e4c16 1080 motor[TIRE_BR].pwm = 40;
yabahiro 31:45f97698857b 1081 motor[TIRE_BR].dir = BACK;
yabahiro 31:45f97698857b 1082 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1083 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 1084 mtc=true;
yabahiro 31:45f97698857b 1085 break;
yabahiro 31:45f97698857b 1086 case 2:
yabahiro 31:45f97698857b 1087 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1088 motor[TIRE_FR].dir = FREE;
yabahiro 38:391a0c8e4c16 1089 motor[TIRE_FL].pwm = 50;
yabahiro 31:45f97698857b 1090 motor[TIRE_FL].dir = FOR;
yabahiro 38:391a0c8e4c16 1091 motor[TIRE_BR].pwm = 50;
yabahiro 31:45f97698857b 1092 motor[TIRE_BR].dir = BACK;
yabahiro 31:45f97698857b 1093 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1094 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 1095 mtc=true;
yabahiro 31:45f97698857b 1096 break;
yabahiro 31:45f97698857b 1097 }
yabahiro 31:45f97698857b 1098 if(g[0]!=98&&mtc==true) {
yabahiro 31:45f97698857b 1099 switch(g[1]) {
yabahiro 29:c78a46f51209 1100 case 0:
yabahiro 31:45f97698857b 1101 mtc=false;
yabahiro 29:c78a46f51209 1102 break;
yabahiro 29:c78a46f51209 1103 case 255:
yabahiro 31:45f97698857b 1104 motor[TIRE_BR].pwm += 5;
yabahiro 31:45f97698857b 1105 mtc=false;
yabahiro 29:c78a46f51209 1106 break;
yabahiro 29:c78a46f51209 1107 case 253:
yabahiro 31:45f97698857b 1108 motor[TIRE_BR].pwm += 10;
yabahiro 31:45f97698857b 1109 mtc=false;
yabahiro 29:c78a46f51209 1110 break;
yabahiro 29:c78a46f51209 1111 case 254:
yabahiro 31:45f97698857b 1112 motor[TIRE_BR].pwm += 20;
yabahiro 31:45f97698857b 1113 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1114 mtc=false;
yabahiro 29:c78a46f51209 1115 break;
yabahiro 29:c78a46f51209 1116 case 1:
yabahiro 31:45f97698857b 1117 motor[TIRE_BL].pwm += 5;
yabahiro 31:45f97698857b 1118 mtc=false;
yabahiro 29:c78a46f51209 1119 break;
yabahiro 29:c78a46f51209 1120 case 3:
yabahiro 31:45f97698857b 1121 motor[TIRE_BL].pwm += 10;
yabahiro 31:45f97698857b 1122 mtc=false;
yabahiro 29:c78a46f51209 1123 break;
yabahiro 29:c78a46f51209 1124 case 2:
yabahiro 31:45f97698857b 1125 motor[TIRE_BL].pwm += 20;
yabahiro 31:45f97698857b 1126 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1127 mtc=false;
yabahiro 29:c78a46f51209 1128 break;
yabahiro 29:c78a46f51209 1129 }
yabahiro 38:391a0c8e4c16 1130
yabahiro 31:45f97698857b 1131 }
yabahiro 38:391a0c8e4c16 1132 } else if(mode==31) {
yabahiro 38:391a0c8e4c16 1133 motor[TIRE_FR].pwm = 15;
yabahiro 31:45f97698857b 1134 motor[TIRE_FR].dir = BACK;
yabahiro 38:391a0c8e4c16 1135 motor[TIRE_FL].pwm = 10;
yabahiro 38:391a0c8e4c16 1136 motor[TIRE_FL].dir = BACK;
yabahiro 38:391a0c8e4c16 1137 motor[TIRE_BR].pwm = 10;
yabahiro 38:391a0c8e4c16 1138 motor[TIRE_BR].dir = FOR;
yabahiro 38:391a0c8e4c16 1139 motor[TIRE_BL].pwm = 15;
yabahiro 31:45f97698857b 1140 motor[TIRE_BL].dir = FOR;
yabahiro 35:94f026ab4d30 1141 if(g[3]==0) {
yabahiro 31:45f97698857b 1142 count=0;
yabahiro 31:45f97698857b 1143 mode=40;
yabahiro 31:45f97698857b 1144 }
yabahiro 38:391a0c8e4c16 1145 */
yabahiro 38:391a0c8e4c16 1146
yabahiro 38:391a0c8e4c16 1147 } else if(mode==31) {
yabahiro 38:391a0c8e4c16 1148 motor[TIRE_FR].pwm = 15;
yabahiro 38:391a0c8e4c16 1149 motor[TIRE_FR].dir = BACK;
yabahiro 38:391a0c8e4c16 1150 motor[TIRE_FL].pwm = 15;
yabahiro 38:391a0c8e4c16 1151 motor[TIRE_FL].dir = FOR;
yabahiro 38:391a0c8e4c16 1152 motor[TIRE_BR].pwm = 15;
yabahiro 38:391a0c8e4c16 1153 motor[TIRE_BR].dir = BACK;
yabahiro 38:391a0c8e4c16 1154 motor[TIRE_BL].pwm = 15;
yabahiro 38:391a0c8e4c16 1155 motor[TIRE_BL].dir = FOR;
yabahiro 38:391a0c8e4c16 1156 if(g[3]==0) {
yabahiro 38:391a0c8e4c16 1157 count=0;
yabahiro 38:391a0c8e4c16 1158 mode=32;
yabahiro 38:391a0c8e4c16 1159 }
yabahiro 38:391a0c8e4c16 1160 } else if(mode==32) {
yabahiro 38:391a0c8e4c16 1161 motor[TIRE_FR].pwm = 30;
yabahiro 38:391a0c8e4c16 1162 motor[TIRE_FR].dir = FOR;
yabahiro 38:391a0c8e4c16 1163 motor[TIRE_FL].pwm = 30;
yabahiro 38:391a0c8e4c16 1164 motor[TIRE_FL].dir = BACK;
yabahiro 38:391a0c8e4c16 1165 motor[TIRE_BR].pwm = 30;
yabahiro 38:391a0c8e4c16 1166 motor[TIRE_BR].dir = FOR;
yabahiro 38:391a0c8e4c16 1167 motor[TIRE_BL].pwm = 30;
yabahiro 38:391a0c8e4c16 1168 motor[TIRE_BL].dir = BACK;
yabahiro 38:391a0c8e4c16 1169 if(g[3]==0) {
yabahiro 38:391a0c8e4c16 1170 count=0;
yabahiro 39:f89166d7411c 1171 if(Twsh==2) {
yabahiro 39:f89166d7411c 1172 solenoid.solenoid2 = SOLENOID_OFF;
yabahiro 39:f89166d7411c 1173 }
yabahiro 38:391a0c8e4c16 1174 mode=40;
yabahiro 38:391a0c8e4c16 1175 }
yabahiro 31:45f97698857b 1176 } else if(mode==40) {
yabahiro 38:391a0c8e4c16 1177 if(LIB) {
yabahiro 38:391a0c8e4c16 1178 mode=42;
yabahiro 38:391a0c8e4c16 1179 }
yabahiro 35:94f026ab4d30 1180 if(counts==false&&g[0]==0) {
yabahiro 35:94f026ab4d30 1181 cros++;
yabahiro 35:94f026ab4d30 1182 counts=true;
yabahiro 35:94f026ab4d30 1183 }
yabahiro 35:94f026ab4d30 1184 if(counts==true&&g[0]==99) {
yabahiro 35:94f026ab4d30 1185 counts=false;
yabahiro 35:94f026ab4d30 1186 }
yabahiro 35:94f026ab4d30 1187
yabahiro 38:391a0c8e4c16 1188 if(cros==1) {
yabahiro 36:788274604650 1189 // mode=41;
yabahiro 35:94f026ab4d30 1190 //count=0;
yabahiro 35:94f026ab4d30 1191 //cros=0;
yabahiro 35:94f026ab4d30 1192 }//ゆっくりモードに入れなかった時の保険
yabahiro 35:94f026ab4d30 1193
yabahiro 31:45f97698857b 1194 switch(g[3]) {
yabahiro 31:45f97698857b 1195 case 98:
kishibekairohan 33:656aa14904a5 1196 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 1197 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 1198 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 1199 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1200 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 1201 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 1202 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 1203 motor[TIRE_BL].dir = FOR;
yabahiro 35:94f026ab4d30 1204 if(count>20000) {
yabahiro 31:45f97698857b 1205 cross++;
yabahiro 31:45f97698857b 1206 count=0;
yabahiro 31:45f97698857b 1207 }
yabahiro 31:45f97698857b 1208 mtc2=true;
yabahiro 38:391a0c8e4c16 1209 if(cross==2) {
yabahiro 31:45f97698857b 1210 mode=41;
yabahiro 31:45f97698857b 1211 count=0;
yabahiro 31:45f97698857b 1212 cross=0;
kishibekairohan 22:c47f29caded6 1213 }
yabahiro 31:45f97698857b 1214 break;
yabahiro 31:45f97698857b 1215 case 0:
kishibekairohan 33:656aa14904a5 1216 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 1217 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 1218 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 1219 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1220 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 1221 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 1222 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 1223 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 1224 mtc2=true;
yabahiro 31:45f97698857b 1225 break;
yabahiro 31:45f97698857b 1226 case 255:
kishibekairohan 33:656aa14904a5 1227 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 1228 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 1229 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 1230 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1231 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 1232 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 1233 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 1234 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 1235 mtc2=true;
yabahiro 31:45f97698857b 1236 break;
yabahiro 31:45f97698857b 1237 case 253:
yabahiro 31:45f97698857b 1238 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1239 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 1240 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 1241 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1242 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 1243 motor[TIRE_BR].dir = FOR;
yabahiro 31:45f97698857b 1244 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1245 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 1246 mtc2=true;
yabahiro 31:45f97698857b 1247 break;
yabahiro 31:45f97698857b 1248 case 254:
yabahiro 31:45f97698857b 1249 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1250 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 1251 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 1252 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1253 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 1254 motor[TIRE_BR].dir = FOR;
yabahiro 31:45f97698857b 1255 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1256 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 1257 mtc2=true;
yabahiro 31:45f97698857b 1258 break;
yabahiro 31:45f97698857b 1259 case 1:
kishibekairohan 33:656aa14904a5 1260 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 1261 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 1262 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 1263 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1264 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 1265 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 1266 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 1267 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 1268 mtc2=true;
yabahiro 31:45f97698857b 1269 break;
yabahiro 31:45f97698857b 1270 case 3:
kishibekairohan 33:656aa14904a5 1271 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 1272 motor[TIRE_FR].dir = BACK;
yabahiro 31:45f97698857b 1273 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1274 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 1275 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1276 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 1277 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 1278 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 1279 mtc2=true;
yabahiro 31:45f97698857b 1280 break;
yabahiro 31:45f97698857b 1281 case 2:
kishibekairohan 33:656aa14904a5 1282 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 1283 motor[TIRE_FR].dir = BACK;
yabahiro 31:45f97698857b 1284 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1285 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 1286 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1287 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 1288 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 1289 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 1290 mtc2=true;
yabahiro 31:45f97698857b 1291 break;
yabahiro 31:45f97698857b 1292 }
yabahiro 31:45f97698857b 1293 if(g[2]!=98&&mtc2==true) {
yabahiro 31:45f97698857b 1294 switch(g[2]) {
yabahiro 29:c78a46f51209 1295 case 0:
yabahiro 31:45f97698857b 1296 mtc2=false;
yabahiro 29:c78a46f51209 1297 break;
yabahiro 29:c78a46f51209 1298 case 255:
yabahiro 31:45f97698857b 1299 motor[TIRE_FL].pwm += 5;
yabahiro 31:45f97698857b 1300 mtc2=false;
yabahiro 29:c78a46f51209 1301 break;
yabahiro 29:c78a46f51209 1302 case 253:
yabahiro 31:45f97698857b 1303 motor[TIRE_FL].pwm += 10;
yabahiro 31:45f97698857b 1304 mtc2=false;
yabahiro 29:c78a46f51209 1305 break;
yabahiro 29:c78a46f51209 1306 case 254:
yabahiro 31:45f97698857b 1307 motor[TIRE_FL].pwm += 20;
yabahiro 29:c78a46f51209 1308 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1309 mtc2=false;
yabahiro 29:c78a46f51209 1310 break;
yabahiro 29:c78a46f51209 1311 case 1:
yabahiro 31:45f97698857b 1312 motor[TIRE_BL].pwm += 5;
yabahiro 31:45f97698857b 1313 mtc2=false;
yabahiro 29:c78a46f51209 1314 break;
yabahiro 29:c78a46f51209 1315 case 3:
yabahiro 31:45f97698857b 1316 motor[TIRE_BL].pwm += 10;
yabahiro 31:45f97698857b 1317 mtc2=false;
yabahiro 29:c78a46f51209 1318 break;
yabahiro 29:c78a46f51209 1319 case 2:
yabahiro 31:45f97698857b 1320 motor[TIRE_BL].pwm += 20;
yabahiro 29:c78a46f51209 1321 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1322 mtc2=false;
yabahiro 29:c78a46f51209 1323 break;
yabahiro 29:c78a46f51209 1324 }
yabahiro 31:45f97698857b 1325 }
yabahiro 31:45f97698857b 1326 } else if(mode==41) {
yabahiro 31:45f97698857b 1327 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1328 motor[TIRE_FR].dir = FREE;
yabahiro 35:94f026ab4d30 1329 motor[TIRE_FL].pwm = 30;
yabahiro 31:45f97698857b 1330 motor[TIRE_FL].dir = BACK;
yabahiro 35:94f026ab4d30 1331 motor[TIRE_BR].pwm = 30;
yabahiro 31:45f97698857b 1332 motor[TIRE_BR].dir = FOR;
yabahiro 31:45f97698857b 1333 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1334 motor[TIRE_BL].dir = FREE;
yabahiro 35:94f026ab4d30 1335 if(g[1]==0) {
yabahiro 31:45f97698857b 1336 count=0;
yabahiro 31:45f97698857b 1337 mode=70;
yabahiro 31:45f97698857b 1338 }
yabahiro 38:391a0c8e4c16 1339 } else if(mode==42) {
yabahiro 38:391a0c8e4c16 1340 motor[TIRE_FR].pwm = 20;
yabahiro 38:391a0c8e4c16 1341 motor[TIRE_FR].dir = FOR;
yabahiro 38:391a0c8e4c16 1342 motor[TIRE_FL].pwm = 0;
yabahiro 38:391a0c8e4c16 1343 motor[TIRE_FL].dir = FREE;
yabahiro 38:391a0c8e4c16 1344 motor[TIRE_BR].pwm = 0;
yabahiro 38:391a0c8e4c16 1345 motor[TIRE_BR].dir = FREE;
yabahiro 38:391a0c8e4c16 1346 motor[TIRE_BL].pwm = 20;
yabahiro 38:391a0c8e4c16 1347 motor[TIRE_BL].dir = BACK;
yabahiro 38:391a0c8e4c16 1348 if(g[1]==0) {
yabahiro 38:391a0c8e4c16 1349 count=0;
yabahiro 38:391a0c8e4c16 1350 mode=70;
yabahiro 38:391a0c8e4c16 1351 }
yabahiro 31:45f97698857b 1352 } else if(mode==70) {
yabahiro 31:45f97698857b 1353 switch(g[1]) {
yabahiro 31:45f97698857b 1354 case 99:
yabahiro 31:45f97698857b 1355 if(count>=100000) {
yabahiro 31:45f97698857b 1356 mode=100;
yabahiro 29:c78a46f51209 1357 }
yabahiro 31:45f97698857b 1358 break;
yabahiro 31:45f97698857b 1359 case 98:
kishibekairohan 33:656aa14904a5 1360 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 1361 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 1362 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 1363 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1364 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 1365 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 1366 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 1367 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1368 break;
yabahiro 31:45f97698857b 1369 case 0:
yabahiro 38:391a0c8e4c16 1370 motor[TIRE_FR].pwm = 80;
yabahiro 31:45f97698857b 1371 motor[TIRE_FR].dir = FOR;
yabahiro 38:391a0c8e4c16 1372 motor[TIRE_FL].pwm = 80;
yabahiro 31:45f97698857b 1373 motor[TIRE_FL].dir = BACK;
yabahiro 38:391a0c8e4c16 1374 motor[TIRE_BR].pwm = 80;
yabahiro 31:45f97698857b 1375 motor[TIRE_BR].dir = FOR;
yabahiro 38:391a0c8e4c16 1376 motor[TIRE_BL].pwm = 80;
yabahiro 31:45f97698857b 1377 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1378 mtc=true;
yabahiro 31:45f97698857b 1379 break;
yabahiro 31:45f97698857b 1380 case 255:
kishibekairohan 33:656aa14904a5 1381 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 1382 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 1383 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 1384 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1385 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 1386 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 1387 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 1388 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1389 mtc=true;
yabahiro 31:45f97698857b 1390 break;
yabahiro 31:45f97698857b 1391 case 253:
kishibekairohan 33:656aa14904a5 1392 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 1393 motor[TIRE_FR].dir = FOR;
yabahiro 31:45f97698857b 1394 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1395 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 1396 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1397 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 1398 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 1399 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1400 mtc=true;
yabahiro 31:45f97698857b 1401 break;
yabahiro 31:45f97698857b 1402 case 254:
kishibekairohan 33:656aa14904a5 1403 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 1404 motor[TIRE_FR].dir = FOR;
yabahiro 31:45f97698857b 1405 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1406 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 1407 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1408 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 1409 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 1410 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1411 mtc=true;
yabahiro 31:45f97698857b 1412 break;
yabahiro 31:45f97698857b 1413 case 1:
kishibekairohan 33:656aa14904a5 1414 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 1415 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 1416 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 1417 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1418 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 1419 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 1420 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 1421 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1422 mtc=true;
yabahiro 31:45f97698857b 1423 break;
yabahiro 31:45f97698857b 1424 case 3:
yabahiro 31:45f97698857b 1425 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1426 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 1427 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 1428 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1429 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 1430 motor[TIRE_BR].dir = FOR;
yabahiro 31:45f97698857b 1431 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1432 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 1433 mtc=true;
yabahiro 31:45f97698857b 1434 break;
yabahiro 31:45f97698857b 1435 case 2:
yabahiro 31:45f97698857b 1436 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1437 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 1438 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 1439 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1440 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 1441 motor[TIRE_BR].dir = FOR;
yabahiro 31:45f97698857b 1442 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1443 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 1444 mtc=true;
yabahiro 31:45f97698857b 1445 break;
yabahiro 31:45f97698857b 1446 }
yabahiro 31:45f97698857b 1447 if(g[1]!=98&&mtc==true) {
yabahiro 31:45f97698857b 1448 switch(g[0]) {
yabahiro 29:c78a46f51209 1449 case 0:
yabahiro 31:45f97698857b 1450 mtc=false;
yabahiro 29:c78a46f51209 1451 break;
yabahiro 29:c78a46f51209 1452 case 255:
yabahiro 31:45f97698857b 1453 motor[TIRE_FL].pwm += 5;
yabahiro 31:45f97698857b 1454 mtc=false;
yabahiro 29:c78a46f51209 1455 break;
yabahiro 29:c78a46f51209 1456 case 253:
yabahiro 31:45f97698857b 1457 motor[TIRE_FL].pwm += 10;
yabahiro 31:45f97698857b 1458 mtc=false;
yabahiro 29:c78a46f51209 1459 break;
yabahiro 29:c78a46f51209 1460 case 254:
yabahiro 31:45f97698857b 1461 motor[TIRE_FL].pwm += 20;
yabahiro 31:45f97698857b 1462 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1463 mtc=false;
yabahiro 29:c78a46f51209 1464 break;
yabahiro 29:c78a46f51209 1465 case 1:
yabahiro 31:45f97698857b 1466 motor[TIRE_FR].pwm += 5;
yabahiro 31:45f97698857b 1467 mtc=false;
yabahiro 29:c78a46f51209 1468 break;
yabahiro 29:c78a46f51209 1469 case 3:
yabahiro 31:45f97698857b 1470 motor[TIRE_FR].pwm += 10;
yabahiro 31:45f97698857b 1471 mtc=false;
yabahiro 29:c78a46f51209 1472 break;
yabahiro 29:c78a46f51209 1473 case 2:
yabahiro 31:45f97698857b 1474 motor[TIRE_FR].pwm += 20;
yabahiro 31:45f97698857b 1475 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1476 mtc=false;
yabahiro 29:c78a46f51209 1477 break;
yabahiro 29:c78a46f51209 1478 }
yabahiro 31:45f97698857b 1479 }
yabahiro 31:45f97698857b 1480 } else if(mode==100) {
yabahiro 35:94f026ab4d30 1481 motor[TIRE_FR].pwm = 20;
yabahiro 31:45f97698857b 1482 motor[TIRE_FR].dir = FOR;
yabahiro 35:94f026ab4d30 1483 motor[TIRE_FL].pwm = 20;
yabahiro 31:45f97698857b 1484 motor[TIRE_FL].dir = BACK;
yabahiro 31:45f97698857b 1485 motor[TIRE_BR].pwm = 23;
yabahiro 31:45f97698857b 1486 motor[TIRE_BR].dir = FOR;
yabahiro 35:94f026ab4d30 1487 motor[TIRE_BL].pwm = 20;
yabahiro 31:45f97698857b 1488 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1489 } else {
yabahiro 31:45f97698857b 1490 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1491 motor[TIRE_FR].dir = BRAKE;
yabahiro 31:45f97698857b 1492 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1493 motor[TIRE_FL].dir = BRAKE;
yabahiro 31:45f97698857b 1494 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1495 motor[TIRE_BR].dir = BRAKE;
yabahiro 31:45f97698857b 1496 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1497 motor[TIRE_BL].dir = BRAKE;
yabahiro 31:45f97698857b 1498 }
yabahiro 31:45f97698857b 1499 }
yabahiro 31:45f97698857b 1500 #endif
yabahiro 31:45f97698857b 1501
yabahiro 31:45f97698857b 1502 #if USE_PROCESS_NUM>3
yabahiro 31:45f97698857b 1503 static void Process3()
yabahiro 31:45f97698857b 1504 {
yabahiro 39:f89166d7411c 1505
yabahiro 36:788274604650 1506 }
yabahiro 36:788274604650 1507 #endif
yabahiro 36:788274604650 1508
yabahiro 36:788274604650 1509 #if USE_PROCESS_NUM>4
yabahiro 36:788274604650 1510 static void Process4()
yabahiro 36:788274604650 1511 {
yabahiro 36:788274604650 1512 LedMode(4);
yabahiro 36:788274604650 1513 count++;
yabahiro 31:45f97698857b 1514 if(mode==1) {//スタートゾーンから白線検知
yabahiro 39:f89166d7411c 1515 motor[TIRE_FR].pwm = 40;
yabahiro 31:45f97698857b 1516 motor[TIRE_FR].dir = FOR;
yabahiro 39:f89166d7411c 1517 motor[TIRE_FL].pwm = 40;
yabahiro 31:45f97698857b 1518 motor[TIRE_FL].dir = BACK;
yabahiro 39:f89166d7411c 1519 motor[TIRE_BR].pwm = 40;
yabahiro 31:45f97698857b 1520 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 1521 motor[TIRE_BL].pwm = 45;
yabahiro 31:45f97698857b 1522 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1523 if(g[2]==0) {
yabahiro 31:45f97698857b 1524 count=100000;
yabahiro 31:45f97698857b 1525 cross=0;
yabahiro 36:788274604650 1526 mode=3;
yabahiro 31:45f97698857b 1527 }
yabahiro 36:788274604650 1528 } else if(mode==3) { //横ライントレースから縦ライントレースへ
yabahiro 39:f89166d7411c 1529 motor[TIRE_FR].pwm = 40;
kishibekairohan 32:90f018b10ad6 1530 motor[TIRE_FR].dir = FOR;
yabahiro 36:788274604650 1531 motor[TIRE_FL].pwm = 0;
kishibekairohan 32:90f018b10ad6 1532 motor[TIRE_FL].dir = FREE;
yabahiro 36:788274604650 1533 motor[TIRE_BR].pwm = 0;
kishibekairohan 32:90f018b10ad6 1534 motor[TIRE_BR].dir = FREE;
yabahiro 39:f89166d7411c 1535 motor[TIRE_BL].pwm = 40;
kishibekairohan 32:90f018b10ad6 1536 motor[TIRE_BL].dir = BACK;
yabahiro 35:94f026ab4d30 1537 if(g[0]==0) {
yabahiro 36:788274604650 1538 mode=10;
yabahiro 36:788274604650 1539 count=100000;
yabahiro 36:788274604650 1540 }
yabahiro 36:788274604650 1541 } else if(mode==10) { //縦ライントレース
yabahiro 36:788274604650 1542
yabahiro 36:788274604650 1543 if(counts==false&&g[2]==0) {
yabahiro 36:788274604650 1544 cros++;
yabahiro 36:788274604650 1545 counts=true;
yabahiro 36:788274604650 1546 }
yabahiro 36:788274604650 1547 if(counts==true&&g[2]==99) {
yabahiro 36:788274604650 1548 counts=false;
yabahiro 36:788274604650 1549 }
yabahiro 36:788274604650 1550
yabahiro 36:788274604650 1551 if(cros==Twsh) {
yabahiro 36:788274604650 1552 mode=11;
yabahiro 31:45f97698857b 1553 count=0;
yabahiro 36:788274604650 1554 cros=0;
yabahiro 36:788274604650 1555 }//ゆっくりモードに入れなかった時の保険
kishibekairohan 32:90f018b10ad6 1556 switch(g[1]) {
yabahiro 31:45f97698857b 1557 case 98:
kishibekairohan 33:656aa14904a5 1558 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 1559 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 1560 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 1561 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1562 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 1563 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 1564 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 1565 motor[TIRE_BL].dir = BACK;
yabahiro 36:788274604650 1566 mtc=true;
yabahiro 36:788274604650 1567 if(count>80000) {
yabahiro 31:45f97698857b 1568 cross++;
yabahiro 31:45f97698857b 1569 count=0;
yabahiro 31:45f97698857b 1570 }
yabahiro 31:45f97698857b 1571 if(cross==Twsh) {
yabahiro 31:45f97698857b 1572 mode=11;
yabahiro 31:45f97698857b 1573 count=0;
yabahiro 36:788274604650 1574 cross=0;
yabahiro 31:45f97698857b 1575 }
yabahiro 31:45f97698857b 1576 break;
yabahiro 31:45f97698857b 1577 case 0:
kishibekairohan 33:656aa14904a5 1578 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 1579 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 1580 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 1581 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1582 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 1583 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 1584 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 1585 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1586 mtc=true;
yabahiro 31:45f97698857b 1587 break;
yabahiro 31:45f97698857b 1588 case 255:
kishibekairohan 33:656aa14904a5 1589 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 1590 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 1591 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 1592 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1593 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 1594 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 1595 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 1596 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1597 mtc=true;
yabahiro 31:45f97698857b 1598 break;
yabahiro 31:45f97698857b 1599 case 253:
kishibekairohan 33:656aa14904a5 1600 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 1601 motor[TIRE_FR].dir = FOR;
yabahiro 31:45f97698857b 1602 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1603 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 1604 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1605 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 1606 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 1607 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1608 mtc=true;
yabahiro 31:45f97698857b 1609 break;
yabahiro 31:45f97698857b 1610 case 254:
kishibekairohan 33:656aa14904a5 1611 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 1612 motor[TIRE_FR].dir = FOR;
yabahiro 31:45f97698857b 1613 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1614 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 1615 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1616 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 1617 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 1618 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1619 mtc=true;
yabahiro 31:45f97698857b 1620 break;
yabahiro 31:45f97698857b 1621 case 1:
kishibekairohan 33:656aa14904a5 1622 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 1623 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 1624 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 1625 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1626 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 1627 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 1628 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 1629 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1630 mtc=true;
yabahiro 31:45f97698857b 1631 break;
yabahiro 31:45f97698857b 1632 case 3:
yabahiro 31:45f97698857b 1633 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1634 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 1635 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 1636 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1637 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 1638 motor[TIRE_BR].dir = FOR;
yabahiro 31:45f97698857b 1639 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1640 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 1641 mtc=true;
yabahiro 31:45f97698857b 1642 break;
yabahiro 31:45f97698857b 1643 case 2:
yabahiro 31:45f97698857b 1644 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1645 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 1646 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 1647 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 1648 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 1649 motor[TIRE_BR].dir = FOR;
yabahiro 31:45f97698857b 1650 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1651 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 1652 mtc=true;
yabahiro 31:45f97698857b 1653 break;
yabahiro 31:45f97698857b 1654 }
yabahiro 36:788274604650 1655 if(g[0]!=98&&mtc==true) {
yabahiro 39:f89166d7411c 1656 switch(g[0]) {
yabahiro 31:45f97698857b 1657 case 0:
yabahiro 31:45f97698857b 1658 mtc=false;
yabahiro 31:45f97698857b 1659 break;
yabahiro 31:45f97698857b 1660 case 255:
kishibekairohan 32:90f018b10ad6 1661 motor[TIRE_FL].pwm += 5;
yabahiro 31:45f97698857b 1662 mtc=false;
yabahiro 31:45f97698857b 1663 break;
yabahiro 31:45f97698857b 1664 case 253:
kishibekairohan 32:90f018b10ad6 1665 motor[TIRE_FL].pwm += 10;
yabahiro 31:45f97698857b 1666 mtc=false;
yabahiro 31:45f97698857b 1667 break;
yabahiro 31:45f97698857b 1668 case 254:
kishibekairohan 32:90f018b10ad6 1669 motor[TIRE_FL].pwm += 20;
kishibekairohan 32:90f018b10ad6 1670 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1671 mtc=false;
yabahiro 31:45f97698857b 1672 break;
yabahiro 31:45f97698857b 1673 case 1:
kishibekairohan 32:90f018b10ad6 1674 motor[TIRE_FR].pwm += 5;
yabahiro 31:45f97698857b 1675 mtc=false;
yabahiro 31:45f97698857b 1676 break;
yabahiro 31:45f97698857b 1677 case 3:
kishibekairohan 32:90f018b10ad6 1678 motor[TIRE_FR].pwm += 10;
yabahiro 31:45f97698857b 1679 mtc=false;
yabahiro 31:45f97698857b 1680 break;
yabahiro 31:45f97698857b 1681 case 2:
kishibekairohan 32:90f018b10ad6 1682 motor[TIRE_FR].pwm += 20;
kishibekairohan 32:90f018b10ad6 1683 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1684 mtc=false;
yabahiro 31:45f97698857b 1685 break;
yabahiro 29:c78a46f51209 1686 }
yabahiro 31:45f97698857b 1687 }
yabahiro 31:45f97698857b 1688 } else if(mode==11) {
yabahiro 36:788274604650 1689 motor[TIRE_FR].pwm = normal;
kishibekairohan 32:90f018b10ad6 1690 motor[TIRE_FR].dir = FOR;
yabahiro 36:788274604650 1691 motor[TIRE_FL].pwm = 0;
kishibekairohan 32:90f018b10ad6 1692 motor[TIRE_FL].dir = FREE;
yabahiro 36:788274604650 1693 motor[TIRE_BR].pwm = 0;
kishibekairohan 32:90f018b10ad6 1694 motor[TIRE_BR].dir = FREE;
yabahiro 36:788274604650 1695 motor[TIRE_BL].pwm = normal;
kishibekairohan 32:90f018b10ad6 1696 motor[TIRE_BL].dir = BACK;
yabahiro 35:94f026ab4d30 1697 if(g[2]==0) {
yabahiro 31:45f97698857b 1698 count=0;
yabahiro 36:788274604650 1699 cross=0;
yabahiro 31:45f97698857b 1700 mode=20;
yabahiro 39:f89166d7411c 1701 fast=40;
yabahiro 39:f89166d7411c 1702 normal=30;
yabahiro 39:f89166d7411c 1703 slow=20;
yabahiro 31:45f97698857b 1704 }
yabahiro 31:45f97698857b 1705 } else if(mode==20) {
yabahiro 36:788274604650 1706
yabahiro 38:391a0c8e4c16 1707 if(Twsh==2) {
yabahiro 38:391a0c8e4c16 1708 solenoid.solenoid2 = SOLENOID_ON;
yabahiro 38:391a0c8e4c16 1709 }
yabahiro 38:391a0c8e4c16 1710
yabahiro 36:788274604650 1711 if(counts==false&&g[1]==0) {
yabahiro 36:788274604650 1712 cros++;
yabahiro 36:788274604650 1713 counts=true;
yabahiro 36:788274604650 1714 }
yabahiro 36:788274604650 1715 if(counts==true&&g[1]==99) {
yabahiro 36:788274604650 1716 counts=false;
yabahiro 36:788274604650 1717 }
yabahiro 36:788274604650 1718
yabahiro 36:788274604650 1719 if(cros==2) {
yabahiro 38:391a0c8e4c16 1720 //mode=21;
yabahiro 38:391a0c8e4c16 1721 //count=0;
yabahiro 38:391a0c8e4c16 1722 //cros=0;
yabahiro 36:788274604650 1723 }//ゆっくりモードに入れなかった時の保険
yabahiro 36:788274604650 1724
yabahiro 31:45f97698857b 1725 switch(g[2]) {
yabahiro 31:45f97698857b 1726 case 98:
kishibekairohan 33:656aa14904a5 1727 motor[TIRE_FR].pwm = normal;
kishibekairohan 22:c47f29caded6 1728 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 1729 motor[TIRE_FL].pwm = normal;
yabahiro 23:694ecfa97839 1730 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 1731 motor[TIRE_BR].pwm = normal;
yabahiro 23:694ecfa97839 1732 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 1733 motor[TIRE_BL].pwm = normal;
yabahiro 29:c78a46f51209 1734 motor[TIRE_BL].dir = BACK;
yabahiro 36:788274604650 1735 if(count>80000) {
yabahiro 31:45f97698857b 1736 cross++;
yabahiro 31:45f97698857b 1737 count=0;
yabahiro 31:45f97698857b 1738 }
yabahiro 31:45f97698857b 1739 mtc2=true;
yabahiro 36:788274604650 1740 if(cross==2) {
yabahiro 31:45f97698857b 1741 mode=21;
yabahiro 31:45f97698857b 1742 count=0;
yabahiro 31:45f97698857b 1743 cross=0;
yabahiro 31:45f97698857b 1744 }
yabahiro 31:45f97698857b 1745 break;
yabahiro 31:45f97698857b 1746 case 0:
kishibekairohan 33:656aa14904a5 1747 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 1748 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 1749 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 1750 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 1751 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 1752 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 1753 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 1754 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1755 mtc2=true;
yabahiro 31:45f97698857b 1756 break;
yabahiro 31:45f97698857b 1757 case 255:
yabahiro 36:788274604650 1758 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 1759 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 1760 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 1761 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 1762 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 1763 motor[TIRE_BR].dir = BACK;
yabahiro 36:788274604650 1764 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 1765 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1766 mtc2=true;
yabahiro 31:45f97698857b 1767 break;
yabahiro 31:45f97698857b 1768 case 253:
yabahiro 31:45f97698857b 1769 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1770 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 1771 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 1772 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 1773 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 1774 motor[TIRE_BR].dir = BACK;
yabahiro 31:45f97698857b 1775 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1776 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 1777 mtc2=true;
yabahiro 31:45f97698857b 1778 break;
yabahiro 31:45f97698857b 1779 case 254:
yabahiro 31:45f97698857b 1780 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1781 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 1782 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 1783 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 1784 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 1785 motor[TIRE_BR].dir = BACK;
yabahiro 31:45f97698857b 1786 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1787 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 1788 mtc2=true;
yabahiro 31:45f97698857b 1789 break;
yabahiro 31:45f97698857b 1790 case 1:
kishibekairohan 33:656aa14904a5 1791 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 1792 motor[TIRE_FR].dir = FOR;
kishibekairohan 33:656aa14904a5 1793 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 1794 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 1795 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 1796 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 1797 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 1798 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1799 mtc2=true;
yabahiro 31:45f97698857b 1800 break;
yabahiro 31:45f97698857b 1801 case 3:
kishibekairohan 33:656aa14904a5 1802 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 1803 motor[TIRE_FR].dir = FOR;
yabahiro 31:45f97698857b 1804 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1805 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 1806 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1807 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 1808 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 1809 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1810 mtc2=true;
yabahiro 31:45f97698857b 1811 break;
yabahiro 31:45f97698857b 1812 case 2:
kishibekairohan 33:656aa14904a5 1813 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 1814 motor[TIRE_FR].dir = FOR;
yabahiro 31:45f97698857b 1815 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1816 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 1817 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1818 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 1819 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 1820 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1821 mtc2=true;
yabahiro 31:45f97698857b 1822 break;
yabahiro 31:45f97698857b 1823 }
yabahiro 31:45f97698857b 1824 if(g[2]!=98&&mtc2==true) {
yabahiro 31:45f97698857b 1825 switch(g[3]) {
yabahiro 23:694ecfa97839 1826 case 0:
yabahiro 31:45f97698857b 1827 mtc2=false;
yabahiro 23:694ecfa97839 1828 break;
yabahiro 23:694ecfa97839 1829 case 255:
yabahiro 31:45f97698857b 1830 motor[TIRE_BL].pwm += 5;
yabahiro 31:45f97698857b 1831 mtc2=false;
yabahiro 23:694ecfa97839 1832 break;
yabahiro 23:694ecfa97839 1833 case 253:
yabahiro 31:45f97698857b 1834 motor[TIRE_BL].pwm += 10;
yabahiro 31:45f97698857b 1835 mtc2=false;
yabahiro 23:694ecfa97839 1836 break;
yabahiro 23:694ecfa97839 1837 case 254:
yabahiro 31:45f97698857b 1838 motor[TIRE_BL].pwm += 20;
yabahiro 29:c78a46f51209 1839 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1840 mtc2=false;
yabahiro 23:694ecfa97839 1841 break;
yabahiro 23:694ecfa97839 1842 case 1:
yabahiro 31:45f97698857b 1843 motor[TIRE_FL].pwm += 5;
yabahiro 31:45f97698857b 1844 mtc2=false;
yabahiro 23:694ecfa97839 1845 break;
yabahiro 23:694ecfa97839 1846 case 3:
yabahiro 31:45f97698857b 1847 motor[TIRE_FL].pwm += 10;
yabahiro 31:45f97698857b 1848 mtc2=false;
yabahiro 23:694ecfa97839 1849 break;
yabahiro 23:694ecfa97839 1850 case 2:
yabahiro 31:45f97698857b 1851 motor[TIRE_FL].pwm += 20;
yabahiro 31:45f97698857b 1852 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1853 mtc2=false;
yabahiro 29:c78a46f51209 1854 break;
yabahiro 29:c78a46f51209 1855 }
yabahiro 31:45f97698857b 1856 }
yabahiro 31:45f97698857b 1857 } else if(mode==21) {
yabahiro 36:788274604650 1858 motor[TIRE_FR].pwm = normal;
kishibekairohan 32:90f018b10ad6 1859 motor[TIRE_FR].dir = FOR;
yabahiro 36:788274604650 1860 motor[TIRE_FL].pwm = 0;
kishibekairohan 32:90f018b10ad6 1861 motor[TIRE_FL].dir = FREE;
yabahiro 36:788274604650 1862 motor[TIRE_BR].pwm = 0;
kishibekairohan 32:90f018b10ad6 1863 motor[TIRE_BR].dir = FREE;
yabahiro 36:788274604650 1864 motor[TIRE_BL].pwm = normal;
kishibekairohan 32:90f018b10ad6 1865 motor[TIRE_BL].dir = BACK;
yabahiro 35:94f026ab4d30 1866 if(g[1]==0) {
yabahiro 31:45f97698857b 1867 mode=30;
yabahiro 36:788274604650 1868 cros=0;
yabahiro 36:788274604650 1869 zyouge=true;
yabahiro 39:f89166d7411c 1870 fast=80;
yabahiro 39:f89166d7411c 1871 normal=60;
yabahiro 39:f89166d7411c 1872 slow=40;
yabahiro 31:45f97698857b 1873 }
yabahiro 31:45f97698857b 1874 } else if(mode==30) {
yabahiro 38:391a0c8e4c16 1875 motor[TIRE_FR].pwm = 60;
yabahiro 38:391a0c8e4c16 1876 motor[TIRE_FR].dir = FOR;
yabahiro 38:391a0c8e4c16 1877 motor[TIRE_FL].pwm = 60;
yabahiro 38:391a0c8e4c16 1878 motor[TIRE_FL].dir = BACK;
yabahiro 38:391a0c8e4c16 1879 motor[TIRE_BR].pwm = 60;
yabahiro 38:391a0c8e4c16 1880 motor[TIRE_BR].dir = FOR;
yabahiro 39:f89166d7411c 1881 motor[TIRE_BL].pwm = 50;
yabahiro 38:391a0c8e4c16 1882 motor[TIRE_BL].dir = BACK;
yabahiro 38:391a0c8e4c16 1883 if(g[1]==98) {
yabahiro 38:391a0c8e4c16 1884 mode=31;
yabahiro 38:391a0c8e4c16 1885 }
yabahiro 39:f89166d7411c 1886 if(g[3]==0) {
yabahiro 39:f89166d7411c 1887 mode=32;
yabahiro 36:788274604650 1888 count=0;
yabahiro 36:788274604650 1889 cros=0;
yabahiro 36:788274604650 1890 }//ゆっくりモードに入れなかった時の保険
yabahiro 38:391a0c8e4c16 1891 /*
kishibekairohan 32:90f018b10ad6 1892 switch(g[1]) {
yabahiro 31:45f97698857b 1893 case 98:
yabahiro 36:788274604650 1894 motor[TIRE_FR].pwm = 30;
yabahiro 31:45f97698857b 1895 motor[TIRE_FR].dir = FOR;
yabahiro 36:788274604650 1896 motor[TIRE_FL].pwm = 30;
yabahiro 31:45f97698857b 1897 motor[TIRE_FL].dir = BACK;
yabahiro 36:788274604650 1898 motor[TIRE_BR].pwm = 30;
yabahiro 31:45f97698857b 1899 motor[TIRE_BR].dir = FOR;
yabahiro 36:788274604650 1900 motor[TIRE_BL].pwm = 30;
yabahiro 31:45f97698857b 1901 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1902 if(count>100000) {
yabahiro 31:45f97698857b 1903 cross++;
yabahiro 31:45f97698857b 1904 count=0;
yabahiro 31:45f97698857b 1905 }
yabahiro 31:45f97698857b 1906 mtc=true;
yabahiro 31:45f97698857b 1907 if(cross==1) {
yabahiro 36:788274604650 1908 if(Twsh==2) {
yabahiro 36:788274604650 1909 solenoid.solenoid2 = SOLENOID_OFF;
yabahiro 36:788274604650 1910 }
yabahiro 31:45f97698857b 1911 mode=31;
yabahiro 31:45f97698857b 1912 count=0;
yabahiro 29:c78a46f51209 1913 }
yabahiro 31:45f97698857b 1914 break;
yabahiro 31:45f97698857b 1915 case 0:
yabahiro 36:788274604650 1916 motor[TIRE_FR].pwm = 60;
yabahiro 31:45f97698857b 1917 motor[TIRE_FR].dir = FOR;
yabahiro 36:788274604650 1918 motor[TIRE_FL].pwm = 60;
yabahiro 31:45f97698857b 1919 motor[TIRE_FL].dir = BACK;
yabahiro 36:788274604650 1920 motor[TIRE_BR].pwm = 60;
yabahiro 31:45f97698857b 1921 motor[TIRE_BR].dir = FOR;
yabahiro 36:788274604650 1922 motor[TIRE_BL].pwm = 60;
yabahiro 31:45f97698857b 1923 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1924 mtc=true;
yabahiro 31:45f97698857b 1925 break;
yabahiro 31:45f97698857b 1926 case 255:
yabahiro 36:788274604650 1927 motor[TIRE_FR].pwm = 60;
yabahiro 31:45f97698857b 1928 motor[TIRE_FR].dir = FOR;
yabahiro 36:788274604650 1929 motor[TIRE_FL].pwm = 20;
yabahiro 31:45f97698857b 1930 motor[TIRE_FL].dir = BACK;
yabahiro 36:788274604650 1931 motor[TIRE_BR].pwm = 20;
yabahiro 31:45f97698857b 1932 motor[TIRE_BR].dir = FOR;
yabahiro 36:788274604650 1933 motor[TIRE_BL].pwm = 60;
yabahiro 31:45f97698857b 1934 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1935 mtc=true;
yabahiro 31:45f97698857b 1936 break;
yabahiro 31:45f97698857b 1937 case 253:
yabahiro 36:788274604650 1938 motor[TIRE_FR].pwm = 20;
yabahiro 31:45f97698857b 1939 motor[TIRE_FR].dir = FOR;
yabahiro 31:45f97698857b 1940 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1941 motor[TIRE_FL].dir = BACK;
yabahiro 31:45f97698857b 1942 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1943 motor[TIRE_BR].dir = FOR;
yabahiro 36:788274604650 1944 motor[TIRE_BL].pwm = 20;
yabahiro 31:45f97698857b 1945 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1946 mtc=true;
yabahiro 31:45f97698857b 1947 break;
yabahiro 31:45f97698857b 1948 case 254:
yabahiro 36:788274604650 1949 motor[TIRE_FR].pwm = 30;
yabahiro 31:45f97698857b 1950 motor[TIRE_FR].dir = FOR;
yabahiro 31:45f97698857b 1951 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 1952 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 1953 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 1954 motor[TIRE_BR].dir = FREE;
yabahiro 36:788274604650 1955 motor[TIRE_BL].pwm = 30;
yabahiro 31:45f97698857b 1956 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1957 mtc=true;
yabahiro 31:45f97698857b 1958 break;
yabahiro 31:45f97698857b 1959 case 1:
yabahiro 36:788274604650 1960 motor[TIRE_FR].pwm = 20;
yabahiro 31:45f97698857b 1961 motor[TIRE_FR].dir = FOR;
yabahiro 36:788274604650 1962 motor[TIRE_FL].pwm = 60;
yabahiro 31:45f97698857b 1963 motor[TIRE_FL].dir = BACK;
yabahiro 36:788274604650 1964 motor[TIRE_BR].pwm = 60;
yabahiro 31:45f97698857b 1965 motor[TIRE_BR].dir = FOR;
yabahiro 36:788274604650 1966 motor[TIRE_BL].pwm = 20;
yabahiro 31:45f97698857b 1967 motor[TIRE_BL].dir = BACK;
yabahiro 31:45f97698857b 1968 mtc=true;
yabahiro 31:45f97698857b 1969 break;
yabahiro 31:45f97698857b 1970 case 3:
yabahiro 31:45f97698857b 1971 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1972 motor[TIRE_FR].dir = FREE;
yabahiro 36:788274604650 1973 motor[TIRE_FL].pwm = 20;
yabahiro 31:45f97698857b 1974 motor[TIRE_FL].dir = BACK;
yabahiro 36:788274604650 1975 motor[TIRE_BR].pwm = 20;
yabahiro 31:45f97698857b 1976 motor[TIRE_BR].dir = FOR;
yabahiro 31:45f97698857b 1977 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1978 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 1979 mtc=true;
yabahiro 31:45f97698857b 1980 break;
yabahiro 31:45f97698857b 1981 case 2:
yabahiro 31:45f97698857b 1982 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 1983 motor[TIRE_FR].dir = FREE;
yabahiro 36:788274604650 1984 motor[TIRE_FL].pwm = 30;
yabahiro 31:45f97698857b 1985 motor[TIRE_FL].dir = BACK;
yabahiro 36:788274604650 1986 motor[TIRE_BR].pwm = 30;
yabahiro 31:45f97698857b 1987 motor[TIRE_BR].dir = FOR;
yabahiro 31:45f97698857b 1988 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 1989 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 1990 mtc=true;
yabahiro 31:45f97698857b 1991 break;
yabahiro 31:45f97698857b 1992 }
kishibekairohan 32:90f018b10ad6 1993 if(g[1]!=98&&mtc==true) {
kishibekairohan 32:90f018b10ad6 1994 switch(g[0]) {
yabahiro 29:c78a46f51209 1995 case 0:
yabahiro 31:45f97698857b 1996 mtc=false;
yabahiro 29:c78a46f51209 1997 break;
yabahiro 29:c78a46f51209 1998 case 255:
kishibekairohan 34:cef6c124a52d 1999 motor[TIRE_FL].pwm += 5;
yabahiro 31:45f97698857b 2000 mtc=false;
yabahiro 29:c78a46f51209 2001 break;
yabahiro 29:c78a46f51209 2002 case 253:
kishibekairohan 34:cef6c124a52d 2003 motor[TIRE_FL].pwm += 10;
yabahiro 31:45f97698857b 2004 mtc=false;
yabahiro 29:c78a46f51209 2005 break;
yabahiro 29:c78a46f51209 2006 case 254:
kishibekairohan 34:cef6c124a52d 2007 motor[TIRE_FL].pwm += 20;
kishibekairohan 34:cef6c124a52d 2008 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 2009 mtc=false;
yabahiro 29:c78a46f51209 2010 break;
yabahiro 29:c78a46f51209 2011 case 1:
kishibekairohan 34:cef6c124a52d 2012 motor[TIRE_FR].pwm += 5;
yabahiro 31:45f97698857b 2013 mtc=false;
yabahiro 29:c78a46f51209 2014 break;
yabahiro 29:c78a46f51209 2015 case 3:
kishibekairohan 34:cef6c124a52d 2016 motor[TIRE_FR].pwm += 10;
yabahiro 31:45f97698857b 2017 mtc=false;
yabahiro 29:c78a46f51209 2018 break;
yabahiro 29:c78a46f51209 2019 case 2:
kishibekairohan 34:cef6c124a52d 2020 motor[TIRE_FR].pwm += 20;
kishibekairohan 34:cef6c124a52d 2021 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 2022 mtc=false;
yabahiro 23:694ecfa97839 2023 break;
yabahiro 23:694ecfa97839 2024 }
yabahiro 31:45f97698857b 2025 }
yabahiro 38:391a0c8e4c16 2026 */
yabahiro 31:45f97698857b 2027 } else if(mode==31) {
yabahiro 39:f89166d7411c 2028 motor[TIRE_FR].pwm = 15;
yabahiro 39:f89166d7411c 2029 motor[TIRE_FR].dir = FOR;
yabahiro 39:f89166d7411c 2030 motor[TIRE_FL].pwm = 15;
kishibekairohan 32:90f018b10ad6 2031 motor[TIRE_FL].dir = BACK;
yabahiro 39:f89166d7411c 2032 motor[TIRE_BR].pwm = 15;
kishibekairohan 32:90f018b10ad6 2033 motor[TIRE_BR].dir = FOR;
yabahiro 39:f89166d7411c 2034 motor[TIRE_BL].pwm = 15;
yabahiro 39:f89166d7411c 2035 motor[TIRE_BL].dir = BACK;
yabahiro 35:94f026ab4d30 2036 if(g[3]==0) {
yabahiro 31:45f97698857b 2037 count=0;
yabahiro 39:f89166d7411c 2038 mode=32;
yabahiro 39:f89166d7411c 2039 }
yabahiro 39:f89166d7411c 2040 } else if(mode==32) {
yabahiro 39:f89166d7411c 2041 motor[TIRE_FR].pwm = 30;
yabahiro 39:f89166d7411c 2042 motor[TIRE_FR].dir = BACK;
yabahiro 39:f89166d7411c 2043 motor[TIRE_FL].pwm = 30;
yabahiro 39:f89166d7411c 2044 motor[TIRE_FL].dir = FOR;
yabahiro 39:f89166d7411c 2045 motor[TIRE_BR].pwm = 30;
yabahiro 39:f89166d7411c 2046 motor[TIRE_BR].dir = BACK;
yabahiro 39:f89166d7411c 2047 motor[TIRE_BL].pwm = 30;
yabahiro 39:f89166d7411c 2048 motor[TIRE_BL].dir = FOR;
yabahiro 39:f89166d7411c 2049 if(g[3]==0) {
yabahiro 39:f89166d7411c 2050 count=0;
yabahiro 39:f89166d7411c 2051 if(Twsh==2) {
yabahiro 39:f89166d7411c 2052 solenoid.solenoid2 = SOLENOID_OFF;
yabahiro 39:f89166d7411c 2053 }
yabahiro 31:45f97698857b 2054 mode=40;
yabahiro 31:45f97698857b 2055 }
yabahiro 31:45f97698857b 2056 } else if(mode==40) {
yabahiro 36:788274604650 2057
yabahiro 39:f89166d7411c 2058 if(LIF) {
yabahiro 38:391a0c8e4c16 2059 mode=42;
yabahiro 38:391a0c8e4c16 2060 }
yabahiro 38:391a0c8e4c16 2061
yabahiro 36:788274604650 2062 if(counts==false&&g[0]==0) {
yabahiro 36:788274604650 2063 cros++;
yabahiro 36:788274604650 2064 counts=true;
yabahiro 36:788274604650 2065 }
yabahiro 36:788274604650 2066 if(counts==true&&g[0]==99) {
yabahiro 36:788274604650 2067 counts=false;
yabahiro 36:788274604650 2068 }
yabahiro 36:788274604650 2069
yabahiro 40:7f93984e8ba1 2070 if(cros==1) {
yabahiro 36:788274604650 2071 // mode=41;
yabahiro 36:788274604650 2072 //count=0;
yabahiro 36:788274604650 2073 //cros=0;
yabahiro 36:788274604650 2074 }//ゆっくりモードに入れなかった時の保険
yabahiro 36:788274604650 2075
yabahiro 31:45f97698857b 2076 switch(g[3]) {
yabahiro 31:45f97698857b 2077 case 98:
kishibekairohan 33:656aa14904a5 2078 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 2079 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 2080 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 2081 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 2082 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 2083 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 2084 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 2085 motor[TIRE_BL].dir = FOR;
yabahiro 36:788274604650 2086 if(count>20000) {
yabahiro 31:45f97698857b 2087 cross++;
yabahiro 31:45f97698857b 2088 count=0;
yabahiro 31:45f97698857b 2089 }
yabahiro 31:45f97698857b 2090 mtc2=true;
yabahiro 39:f89166d7411c 2091 if(cross==2) {
yabahiro 31:45f97698857b 2092 mode=41;
yabahiro 31:45f97698857b 2093 count=0;
yabahiro 31:45f97698857b 2094 cross=0;
yabahiro 24:41c23c9a5058 2095 }
yabahiro 31:45f97698857b 2096 break;
yabahiro 31:45f97698857b 2097 case 0:
kishibekairohan 33:656aa14904a5 2098 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 2099 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 2100 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 2101 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 2102 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 2103 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 2104 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 2105 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 2106 mtc2=true;
yabahiro 31:45f97698857b 2107 break;
yabahiro 31:45f97698857b 2108 case 255:
kishibekairohan 33:656aa14904a5 2109 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 2110 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 2111 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 2112 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 2113 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 2114 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 2115 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 2116 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 2117 mtc2=true;
yabahiro 31:45f97698857b 2118 break;
yabahiro 31:45f97698857b 2119 case 253:
yabahiro 31:45f97698857b 2120 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 2121 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 2122 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 2123 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 2124 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 2125 motor[TIRE_BR].dir = FOR;
yabahiro 31:45f97698857b 2126 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 2127 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 2128 mtc2=true;
yabahiro 31:45f97698857b 2129 break;
yabahiro 31:45f97698857b 2130 case 254:
yabahiro 31:45f97698857b 2131 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 2132 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 2133 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 2134 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 2135 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 2136 motor[TIRE_BR].dir = FOR;
yabahiro 31:45f97698857b 2137 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 2138 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 2139 mtc2=true;
yabahiro 31:45f97698857b 2140 break;
yabahiro 31:45f97698857b 2141 case 1:
kishibekairohan 33:656aa14904a5 2142 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 2143 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 2144 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 2145 motor[TIRE_FL].dir = BACK;
kishibekairohan 33:656aa14904a5 2146 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 2147 motor[TIRE_BR].dir = FOR;
kishibekairohan 33:656aa14904a5 2148 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 2149 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 2150 mtc2=true;
yabahiro 31:45f97698857b 2151 break;
yabahiro 31:45f97698857b 2152 case 3:
kishibekairohan 33:656aa14904a5 2153 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 2154 motor[TIRE_FR].dir = BACK;
yabahiro 31:45f97698857b 2155 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 2156 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 2157 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 2158 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 2159 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 2160 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 2161 mtc2=true;
yabahiro 31:45f97698857b 2162 break;
yabahiro 31:45f97698857b 2163 case 2:
kishibekairohan 33:656aa14904a5 2164 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 2165 motor[TIRE_FR].dir = BACK;
yabahiro 31:45f97698857b 2166 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 2167 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 2168 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 2169 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 2170 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 2171 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 2172 mtc2=true;
yabahiro 31:45f97698857b 2173 break;
yabahiro 31:45f97698857b 2174 }
yabahiro 31:45f97698857b 2175 if(g[2]!=98&&mtc2==true) {
yabahiro 31:45f97698857b 2176 switch(g[2]) {
yabahiro 23:694ecfa97839 2177 case 0:
yabahiro 31:45f97698857b 2178 mtc2=false;
yabahiro 23:694ecfa97839 2179 break;
yabahiro 23:694ecfa97839 2180 case 255:
yabahiro 39:f89166d7411c 2181 motor[TIRE_FR].pwm += 5;
yabahiro 31:45f97698857b 2182 mtc2=false;
yabahiro 23:694ecfa97839 2183 break;
yabahiro 23:694ecfa97839 2184 case 253:
yabahiro 39:f89166d7411c 2185 motor[TIRE_FR].pwm += 10;
yabahiro 31:45f97698857b 2186 mtc2=false;
yabahiro 23:694ecfa97839 2187 break;
yabahiro 23:694ecfa97839 2188 case 254:
yabahiro 39:f89166d7411c 2189 motor[TIRE_FR].pwm += 20;
yabahiro 39:f89166d7411c 2190 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 2191 mtc2=false;
yabahiro 23:694ecfa97839 2192 break;
yabahiro 23:694ecfa97839 2193 case 1:
yabahiro 39:f89166d7411c 2194 motor[TIRE_BR].pwm += 5;
yabahiro 31:45f97698857b 2195 mtc2=false;
yabahiro 23:694ecfa97839 2196 break;
yabahiro 23:694ecfa97839 2197 case 3:
yabahiro 39:f89166d7411c 2198 motor[TIRE_BR].pwm += 10;
yabahiro 31:45f97698857b 2199 mtc2=false;
yabahiro 23:694ecfa97839 2200 break;
yabahiro 23:694ecfa97839 2201 case 2:
yabahiro 39:f89166d7411c 2202 motor[TIRE_BR].pwm += 20;
yabahiro 39:f89166d7411c 2203 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 2204 mtc2=false;
yabahiro 29:c78a46f51209 2205 break;
yabahiro 29:c78a46f51209 2206 }
yabahiro 31:45f97698857b 2207 }
yabahiro 31:45f97698857b 2208 } else if(mode==41) {
yabahiro 39:f89166d7411c 2209 motor[TIRE_FR].pwm = 30;
kishibekairohan 32:90f018b10ad6 2210 motor[TIRE_FR].dir = BACK;
yabahiro 36:788274604650 2211 motor[TIRE_FL].pwm = 0;
kishibekairohan 32:90f018b10ad6 2212 motor[TIRE_FL].dir = FREE;
yabahiro 36:788274604650 2213 motor[TIRE_BR].pwm = 0;
kishibekairohan 32:90f018b10ad6 2214 motor[TIRE_BR].dir = FREE;
yabahiro 39:f89166d7411c 2215 motor[TIRE_BL].pwm = 30;
kishibekairohan 32:90f018b10ad6 2216 motor[TIRE_BL].dir = FOR;
yabahiro 36:788274604650 2217 if(g[1]==0) {
yabahiro 31:45f97698857b 2218 count=0;
yabahiro 31:45f97698857b 2219 mode=70;
yabahiro 39:f89166d7411c 2220 normal=60;
yabahiro 39:f89166d7411c 2221 fast=80;
yabahiro 39:f89166d7411c 2222 slow=40;
yabahiro 31:45f97698857b 2223 }
yabahiro 36:788274604650 2224 } else if(mode==70)
kishibekairohan 32:90f018b10ad6 2225 switch(g[0]) {
yabahiro 31:45f97698857b 2226 case 99:
yabahiro 31:45f97698857b 2227 if(count>=100000) {
yabahiro 39:f89166d7411c 2228 cross++;
yabahiro 39:f89166d7411c 2229 mode=100;
yabahiro 39:f89166d7411c 2230 count=0;
yabahiro 39:f89166d7411c 2231 }
yabahiro 39:f89166d7411c 2232 if(cross==3) {
yabahiro 39:f89166d7411c 2233 cross=0;
yabahiro 31:45f97698857b 2234 mode=100;
yabahiro 28:9cd36721cf83 2235 }
yabahiro 31:45f97698857b 2236 break;
yabahiro 31:45f97698857b 2237 case 98:
kishibekairohan 33:656aa14904a5 2238 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 2239 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 2240 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 2241 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 2242 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 2243 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 2244 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 2245 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 2246 break;
yabahiro 31:45f97698857b 2247 case 0:
kishibekairohan 33:656aa14904a5 2248 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 2249 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 2250 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 2251 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 2252 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 2253 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 2254 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 2255 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 2256 mtc=true;
yabahiro 31:45f97698857b 2257 break;
yabahiro 31:45f97698857b 2258 case 255:
kishibekairohan 33:656aa14904a5 2259 motor[TIRE_FR].pwm = fast;
yabahiro 31:45f97698857b 2260 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 2261 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 2262 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 2263 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 2264 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 2265 motor[TIRE_BL].pwm = fast;
yabahiro 31:45f97698857b 2266 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 2267 mtc=true;
yabahiro 31:45f97698857b 2268 break;
yabahiro 31:45f97698857b 2269 case 253:
kishibekairohan 33:656aa14904a5 2270 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 2271 motor[TIRE_FR].dir = BACK;
yabahiro 31:45f97698857b 2272 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 2273 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 2274 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 2275 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 2276 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 2277 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 2278 mtc=true;
yabahiro 31:45f97698857b 2279 break;
yabahiro 31:45f97698857b 2280 case 254:
kishibekairohan 33:656aa14904a5 2281 motor[TIRE_FR].pwm = normal;
yabahiro 31:45f97698857b 2282 motor[TIRE_FR].dir = BACK;
yabahiro 31:45f97698857b 2283 motor[TIRE_FL].pwm = 0;
yabahiro 31:45f97698857b 2284 motor[TIRE_FL].dir = FREE;
yabahiro 31:45f97698857b 2285 motor[TIRE_BR].pwm = 0;
yabahiro 31:45f97698857b 2286 motor[TIRE_BR].dir = FREE;
kishibekairohan 33:656aa14904a5 2287 motor[TIRE_BL].pwm = normal;
yabahiro 31:45f97698857b 2288 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 2289 mtc=true;
yabahiro 31:45f97698857b 2290 break;
yabahiro 31:45f97698857b 2291 case 1:
kishibekairohan 33:656aa14904a5 2292 motor[TIRE_FR].pwm = slow;
yabahiro 31:45f97698857b 2293 motor[TIRE_FR].dir = BACK;
kishibekairohan 33:656aa14904a5 2294 motor[TIRE_FL].pwm = fast;
yabahiro 31:45f97698857b 2295 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 2296 motor[TIRE_BR].pwm = fast;
yabahiro 31:45f97698857b 2297 motor[TIRE_BR].dir = BACK;
kishibekairohan 33:656aa14904a5 2298 motor[TIRE_BL].pwm = slow;
yabahiro 31:45f97698857b 2299 motor[TIRE_BL].dir = FOR;
yabahiro 31:45f97698857b 2300 mtc=true;
yabahiro 31:45f97698857b 2301 break;
yabahiro 31:45f97698857b 2302 case 3:
yabahiro 31:45f97698857b 2303 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 2304 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 2305 motor[TIRE_FL].pwm = slow;
yabahiro 31:45f97698857b 2306 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 2307 motor[TIRE_BR].pwm = slow;
yabahiro 31:45f97698857b 2308 motor[TIRE_BR].dir = BACK;
yabahiro 31:45f97698857b 2309 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 2310 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 2311 mtc=true;
yabahiro 31:45f97698857b 2312 break;
yabahiro 31:45f97698857b 2313 case 2:
yabahiro 31:45f97698857b 2314 motor[TIRE_FR].pwm = 0;
yabahiro 31:45f97698857b 2315 motor[TIRE_FR].dir = FREE;
kishibekairohan 33:656aa14904a5 2316 motor[TIRE_FL].pwm = normal;
yabahiro 31:45f97698857b 2317 motor[TIRE_FL].dir = FOR;
kishibekairohan 33:656aa14904a5 2318 motor[TIRE_BR].pwm = normal;
yabahiro 31:45f97698857b 2319 motor[TIRE_BR].dir = BACK;
yabahiro 31:45f97698857b 2320 motor[TIRE_BL].pwm = 0;
yabahiro 31:45f97698857b 2321 motor[TIRE_BL].dir = FREE;
yabahiro 31:45f97698857b 2322 mtc=true;
yabahiro 31:45f97698857b 2323 break;
yabahiro 31:45f97698857b 2324 }
yabahiro 36:788274604650 2325 if(g[1]!=98&&mtc==true) {
yabahiro 39:f89166d7411c 2326 switch(g[1]) {
yabahiro 36:788274604650 2327 case 0:
yabahiro 36:788274604650 2328 mtc=false;
yabahiro 36:788274604650 2329 break;
yabahiro 36:788274604650 2330 case 255:
yabahiro 36:788274604650 2331 motor[TIRE_BR].pwm += 5;
yabahiro 36:788274604650 2332 mtc=false;
yabahiro 36:788274604650 2333 break;
yabahiro 36:788274604650 2334 case 253:
yabahiro 36:788274604650 2335 motor[TIRE_BR].pwm += 10;
yabahiro 36:788274604650 2336 mtc=false;
yabahiro 36:788274604650 2337 break;
yabahiro 36:788274604650 2338 case 254:
yabahiro 36:788274604650 2339 motor[TIRE_BR].pwm += 20;
yabahiro 36:788274604650 2340 motor[TIRE_BL].pwm = 0;
yabahiro 36:788274604650 2341 mtc=false;
yabahiro 36:788274604650 2342 break;
yabahiro 36:788274604650 2343 case 1:
yabahiro 36:788274604650 2344 motor[TIRE_BL].pwm += 5;
yabahiro 36:788274604650 2345 mtc=false;
yabahiro 36:788274604650 2346 break;
yabahiro 36:788274604650 2347 case 3:
yabahiro 36:788274604650 2348 motor[TIRE_BL].pwm += 10;
yabahiro 36:788274604650 2349 mtc=false;
yabahiro 36:788274604650 2350 break;
yabahiro 36:788274604650 2351 case 2:
yabahiro 36:788274604650 2352 motor[TIRE_BL].pwm += 20;
yabahiro 36:788274604650 2353 motor[TIRE_BR].pwm = 0;
yabahiro 36:788274604650 2354 mtc=false;
yabahiro 36:788274604650 2355 break;
yabahiro 24:41c23c9a5058 2356 }
yabahiro 31:45f97698857b 2357 } else if(mode==100) {
yabahiro 36:788274604650 2358 motor[TIRE_FR].pwm = 20;
kishibekairohan 32:90f018b10ad6 2359 motor[TIRE_FR].dir = BACK;
yabahiro 36:788274604650 2360 motor[TIRE_FL].pwm = 20;
kishibekairohan 32:90f018b10ad6 2361 motor[TIRE_FL].dir = FOR;
yabahiro 31:45f97698857b 2362 motor[TIRE_BR].pwm = 23;
kishibekairohan 32:90f018b10ad6 2363 motor[TIRE_BR].dir = BACK;
yabahiro 36:788274604650 2364 motor[TIRE_BL].pwm = 20;
kishibekairohan 32:90f018b10ad6 2365 motor[TIRE_BL].dir = FOR;
yabahiro 39:f89166d7411c 2366 if(StertSW) {
yabahiro 39:f89166d7411c 2367 SW_flag = true;
yabahiro 39:f89166d7411c 2368 }
yabahiro 40:7f93984e8ba1 2369 if(SW_flag ==true) {
yabahiro 39:f89166d7411c 2370 motor[TIRE_FR].pwm = 100;
yabahiro 40:7f93984e8ba1 2371 motor[TIRE_FR].dir = BRAKE;
yabahiro 40:7f93984e8ba1 2372 motor[TIRE_FL].pwm = 100;
yabahiro 40:7f93984e8ba1 2373 motor[TIRE_FL].dir = BRAKE;
yabahiro 40:7f93984e8ba1 2374 motor[TIRE_BR].pwm = 100;
yabahiro 40:7f93984e8ba1 2375 motor[TIRE_BR].dir = BRAKE;
yabahiro 40:7f93984e8ba1 2376 motor[TIRE_BL].pwm = 100;
yabahiro 40:7f93984e8ba1 2377 motor[TIRE_BL].dir = BRAKE;
yabahiro 40:7f93984e8ba1 2378 fast=60;
yabahiro 40:7f93984e8ba1 2379 normal=40;
yabahiro 40:7f93984e8ba1 2380 slow=20;
yabahiro 40:7f93984e8ba1 2381 mode =1;
yabahiro 40:7f93984e8ba1 2382 cross=0;//十字数える用
yabahiro 40:7f93984e8ba1 2383 cros=0;
yabahiro 40:7f93984e8ba1 2384 count=100000;//wait代替え
yabahiro 40:7f93984e8ba1 2385 UP_flag = false;
yabahiro 39:f89166d7411c 2386 SW_flag = false;
yabahiro 40:7f93984e8ba1 2387 Air_flag = false;
yabahiro 40:7f93984e8ba1 2388 zyouge=false;
yabahiro 40:7f93984e8ba1 2389 zyougedo=false;
yabahiro 40:7f93984e8ba1 2390 dz1=true;
yabahiro 40:7f93984e8ba1 2391 dz1i=false;
yabahiro 40:7f93984e8ba1 2392 dz2=true;
yabahiro 40:7f93984e8ba1 2393 dz2i=false;
yabahiro 40:7f93984e8ba1 2394 dz3=true;
yabahiro 40:7f93984e8ba1 2395 dz3i=false;
yabahiro 40:7f93984e8ba1 2396 dz4=true;
yabahiro 40:7f93984e8ba1 2397 dz4i=false;
yabahiro 40:7f93984e8ba1 2398 through=false;
yabahiro 40:7f93984e8ba1 2399 counts=false;
yabahiro 40:7f93984e8ba1 2400 mtc=false;
yabahiro 40:7f93984e8ba1 2401 mtc2 = false;
yabahiro 40:7f93984e8ba1 2402 current = 0;
yabahiro 40:7f93984e8ba1 2403 if(StertSW==false) {
yabahiro 40:7f93984e8ba1 2404 SW_flag = false;
yabahiro 40:7f93984e8ba1 2405 }
yabahiro 39:f89166d7411c 2406 }
yabahiro 21:1f1e9c585da8 2407 }
yabahiro 40:7f93984e8ba1 2408
yabahiro 40:7f93984e8ba1 2409
kishibekairohan 13:b6e02d6261d7 2410 }
kishibekairohan 13:b6e02d6261d7 2411 #endif
kishibekairohan 13:b6e02d6261d7 2412
kishibekairohan 13:b6e02d6261d7 2413 #if USE_PROCESS_NUM>5
yabahiro 21:1f1e9c585da8 2414 static void Process5()
yabahiro 21:1f1e9c585da8 2415 {
yabahiro 40:7f93984e8ba1 2416 LedMode(5);
yabahiro 40:7f93984e8ba1 2417 count++;
yabahiro 40:7f93984e8ba1 2418 if(mode==1) {//スタートゾーンから白線検知
yabahiro 41:e1dd6d97f17d 2419 fast=50;
yabahiro 40:7f93984e8ba1 2420 normal=30;
yabahiro 40:7f93984e8ba1 2421 slow=20;
yabahiro 41:e1dd6d97f17d 2422 motor[TIRE_FR].pwm = 35;
yabahiro 40:7f93984e8ba1 2423 motor[TIRE_FR].dir = FOR;
yabahiro 41:e1dd6d97f17d 2424 motor[TIRE_FL].pwm = 35;
yabahiro 40:7f93984e8ba1 2425 motor[TIRE_FL].dir = BACK;
yabahiro 41:e1dd6d97f17d 2426 motor[TIRE_BR].pwm = 35;
yabahiro 40:7f93984e8ba1 2427 motor[TIRE_BR].dir = FOR;
yabahiro 41:e1dd6d97f17d 2428 motor[TIRE_BL].pwm = 32;
yabahiro 40:7f93984e8ba1 2429 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 2430 if(g[2]==0) {
yabahiro 40:7f93984e8ba1 2431 count=100000;
yabahiro 40:7f93984e8ba1 2432 cross=0;
yabahiro 40:7f93984e8ba1 2433 mode=3;
yabahiro 40:7f93984e8ba1 2434 }
yabahiro 40:7f93984e8ba1 2435 } else if(mode==3) { //横ライントレースから縦ライントレースへ
yabahiro 41:e1dd6d97f17d 2436 motor[TIRE_FR].pwm = 27;
yabahiro 40:7f93984e8ba1 2437 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 2438 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 2439 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 2440 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 2441 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 2442 motor[TIRE_BL].pwm = 25;
yabahiro 40:7f93984e8ba1 2443 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 2444 if(g[0]==0) {
yabahiro 40:7f93984e8ba1 2445 mode=10;
yabahiro 40:7f93984e8ba1 2446 count=100000;
yabahiro 40:7f93984e8ba1 2447 }
yabahiro 40:7f93984e8ba1 2448 } else if(mode==10) { //縦ライントレース
yabahiro 40:7f93984e8ba1 2449
yabahiro 40:7f93984e8ba1 2450 if(counts==false&&g[2]==0) {
yabahiro 40:7f93984e8ba1 2451 cros++;
yabahiro 40:7f93984e8ba1 2452 counts=true;
yabahiro 40:7f93984e8ba1 2453 }
yabahiro 40:7f93984e8ba1 2454 if(counts==true&&g[2]==99) {
yabahiro 40:7f93984e8ba1 2455 counts=false;
yabahiro 40:7f93984e8ba1 2456 }
yabahiro 40:7f93984e8ba1 2457
yabahiro 40:7f93984e8ba1 2458 if(cros==Twsh) {
yabahiro 40:7f93984e8ba1 2459 mode=11;
yabahiro 40:7f93984e8ba1 2460 count=0;
yabahiro 40:7f93984e8ba1 2461 cros=0;
yabahiro 40:7f93984e8ba1 2462 }//ゆっくりモードに入れなかった時の保険
yabahiro 40:7f93984e8ba1 2463 switch(g[1]) {
yabahiro 40:7f93984e8ba1 2464 case 98:
yabahiro 40:7f93984e8ba1 2465 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 2466 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 2467 motor[TIRE_FL].pwm = normal;
yabahiro 40:7f93984e8ba1 2468 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 2469 motor[TIRE_BR].pwm = normal;
yabahiro 40:7f93984e8ba1 2470 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 2471 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 2472 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 2473 mtc=true;
yabahiro 40:7f93984e8ba1 2474 if(count>80000) {
yabahiro 40:7f93984e8ba1 2475 cross++;
yabahiro 40:7f93984e8ba1 2476 count=0;
yabahiro 40:7f93984e8ba1 2477 }
yabahiro 40:7f93984e8ba1 2478 if(cross==Twsh) {
yabahiro 40:7f93984e8ba1 2479 mode=11;
yabahiro 40:7f93984e8ba1 2480 count=0;
yabahiro 40:7f93984e8ba1 2481 cross=0;
yabahiro 40:7f93984e8ba1 2482 }
yabahiro 40:7f93984e8ba1 2483 break;
yabahiro 40:7f93984e8ba1 2484 case 0:
yabahiro 40:7f93984e8ba1 2485 motor[TIRE_FR].pwm = fast;
yabahiro 40:7f93984e8ba1 2486 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 2487 motor[TIRE_FL].pwm = fast;
yabahiro 40:7f93984e8ba1 2488 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 2489 motor[TIRE_BR].pwm = fast;
yabahiro 40:7f93984e8ba1 2490 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 2491 motor[TIRE_BL].pwm = fast;
yabahiro 40:7f93984e8ba1 2492 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 2493 mtc=true;
yabahiro 40:7f93984e8ba1 2494 break;
yabahiro 40:7f93984e8ba1 2495 case 255:
yabahiro 40:7f93984e8ba1 2496 motor[TIRE_FR].pwm = fast;
yabahiro 40:7f93984e8ba1 2497 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 2498 motor[TIRE_FL].pwm = slow;
yabahiro 40:7f93984e8ba1 2499 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 2500 motor[TIRE_BR].pwm = slow;
yabahiro 40:7f93984e8ba1 2501 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 2502 motor[TIRE_BL].pwm = fast;
yabahiro 40:7f93984e8ba1 2503 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 2504 mtc=true;
yabahiro 40:7f93984e8ba1 2505 break;
yabahiro 40:7f93984e8ba1 2506 case 253:
yabahiro 40:7f93984e8ba1 2507 motor[TIRE_FR].pwm = slow;
yabahiro 40:7f93984e8ba1 2508 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 2509 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 2510 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 2511 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 2512 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 2513 motor[TIRE_BL].pwm = slow;
yabahiro 40:7f93984e8ba1 2514 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 2515 mtc=true;
yabahiro 40:7f93984e8ba1 2516 break;
yabahiro 40:7f93984e8ba1 2517 case 254:
yabahiro 40:7f93984e8ba1 2518 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 2519 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 2520 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 2521 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 2522 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 2523 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 2524 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 2525 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 2526 mtc=true;
yabahiro 40:7f93984e8ba1 2527 break;
yabahiro 40:7f93984e8ba1 2528 case 1:
yabahiro 40:7f93984e8ba1 2529 motor[TIRE_FR].pwm = slow;
yabahiro 40:7f93984e8ba1 2530 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 2531 motor[TIRE_FL].pwm = fast;
yabahiro 40:7f93984e8ba1 2532 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 2533 motor[TIRE_BR].pwm = fast;
yabahiro 40:7f93984e8ba1 2534 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 2535 motor[TIRE_BL].pwm = slow;
yabahiro 40:7f93984e8ba1 2536 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 2537 mtc=true;
yabahiro 40:7f93984e8ba1 2538 break;
yabahiro 40:7f93984e8ba1 2539 case 3:
yabahiro 40:7f93984e8ba1 2540 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 2541 motor[TIRE_FR].dir = FREE;
yabahiro 40:7f93984e8ba1 2542 motor[TIRE_FL].pwm = slow;
yabahiro 40:7f93984e8ba1 2543 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 2544 motor[TIRE_BR].pwm = slow;
yabahiro 40:7f93984e8ba1 2545 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 2546 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 2547 motor[TIRE_BL].dir = FREE;
yabahiro 40:7f93984e8ba1 2548 mtc=true;
yabahiro 40:7f93984e8ba1 2549 break;
yabahiro 40:7f93984e8ba1 2550 case 2:
yabahiro 40:7f93984e8ba1 2551 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 2552 motor[TIRE_FR].dir = FREE;
yabahiro 40:7f93984e8ba1 2553 motor[TIRE_FL].pwm = normal;
yabahiro 40:7f93984e8ba1 2554 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 2555 motor[TIRE_BR].pwm = normal;
yabahiro 40:7f93984e8ba1 2556 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 2557 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 2558 motor[TIRE_BL].dir = FREE;
yabahiro 40:7f93984e8ba1 2559 mtc=true;
yabahiro 40:7f93984e8ba1 2560 break;
yabahiro 40:7f93984e8ba1 2561 }
yabahiro 40:7f93984e8ba1 2562 if(g[0]!=98&&mtc==true) {
yabahiro 40:7f93984e8ba1 2563 switch(g[0]) {
yabahiro 40:7f93984e8ba1 2564 case 0:
yabahiro 40:7f93984e8ba1 2565 mtc=false;
yabahiro 40:7f93984e8ba1 2566 break;
yabahiro 40:7f93984e8ba1 2567 case 255:
yabahiro 40:7f93984e8ba1 2568 motor[TIRE_FL].pwm += 5;
yabahiro 40:7f93984e8ba1 2569 mtc=false;
yabahiro 40:7f93984e8ba1 2570 break;
yabahiro 40:7f93984e8ba1 2571 case 253:
yabahiro 40:7f93984e8ba1 2572 motor[TIRE_FL].pwm += 10;
yabahiro 40:7f93984e8ba1 2573 mtc=false;
yabahiro 40:7f93984e8ba1 2574 break;
yabahiro 40:7f93984e8ba1 2575 case 254:
yabahiro 40:7f93984e8ba1 2576 motor[TIRE_FL].pwm += 20;
yabahiro 40:7f93984e8ba1 2577 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 2578 mtc=false;
yabahiro 40:7f93984e8ba1 2579 break;
yabahiro 40:7f93984e8ba1 2580 case 1:
yabahiro 40:7f93984e8ba1 2581 motor[TIRE_FR].pwm += 5;
yabahiro 40:7f93984e8ba1 2582 mtc=false;
yabahiro 40:7f93984e8ba1 2583 break;
yabahiro 40:7f93984e8ba1 2584 case 3:
yabahiro 40:7f93984e8ba1 2585 motor[TIRE_FR].pwm += 10;
yabahiro 40:7f93984e8ba1 2586 mtc=false;
yabahiro 40:7f93984e8ba1 2587 break;
yabahiro 40:7f93984e8ba1 2588 case 2:
yabahiro 40:7f93984e8ba1 2589 motor[TIRE_FR].pwm += 20;
yabahiro 40:7f93984e8ba1 2590 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 2591 mtc=false;
yabahiro 40:7f93984e8ba1 2592 break;
yabahiro 40:7f93984e8ba1 2593 }
yabahiro 40:7f93984e8ba1 2594 }
yabahiro 40:7f93984e8ba1 2595 } else if(mode==11) {
yabahiro 40:7f93984e8ba1 2596 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 2597 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 2598 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 2599 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 2600 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 2601 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 2602 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 2603 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 2604 if(g[2]==0) {
yabahiro 40:7f93984e8ba1 2605 count=0;
yabahiro 40:7f93984e8ba1 2606 cross=0;
yabahiro 40:7f93984e8ba1 2607 mode=20;
yabahiro 40:7f93984e8ba1 2608 }
yabahiro 40:7f93984e8ba1 2609 } else if(mode==20) {
yabahiro 40:7f93984e8ba1 2610
yabahiro 40:7f93984e8ba1 2611 if(Twsh==2) {
yabahiro 40:7f93984e8ba1 2612 solenoid.solenoid2 = SOLENOID_ON;
yabahiro 40:7f93984e8ba1 2613 }
yabahiro 40:7f93984e8ba1 2614
yabahiro 40:7f93984e8ba1 2615 if(counts==false&&g[1]==0) {
yabahiro 40:7f93984e8ba1 2616 cros++;
yabahiro 40:7f93984e8ba1 2617 counts=true;
yabahiro 40:7f93984e8ba1 2618 }
yabahiro 40:7f93984e8ba1 2619 if(counts==true&&g[1]==99) {
yabahiro 40:7f93984e8ba1 2620 counts=false;
yabahiro 40:7f93984e8ba1 2621 }
yabahiro 40:7f93984e8ba1 2622
yabahiro 40:7f93984e8ba1 2623 if(cros==2) {
yabahiro 40:7f93984e8ba1 2624 //mode=21;
yabahiro 40:7f93984e8ba1 2625 //count=0;
yabahiro 40:7f93984e8ba1 2626 //cros=0;
yabahiro 40:7f93984e8ba1 2627 }//ゆっくりモードに入れなかった時の保険
yabahiro 40:7f93984e8ba1 2628
yabahiro 40:7f93984e8ba1 2629 switch(g[2]) {
yabahiro 40:7f93984e8ba1 2630 case 98:
yabahiro 40:7f93984e8ba1 2631 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 2632 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 2633 motor[TIRE_FL].pwm = normal;
yabahiro 40:7f93984e8ba1 2634 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 2635 motor[TIRE_BR].pwm = normal;
yabahiro 40:7f93984e8ba1 2636 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 2637 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 2638 motor[TIRE_BL].dir = BACK;
yabahiro 41:e1dd6d97f17d 2639 if(count>50000) {
yabahiro 40:7f93984e8ba1 2640 cross++;
yabahiro 40:7f93984e8ba1 2641 count=0;
yabahiro 40:7f93984e8ba1 2642 }
yabahiro 40:7f93984e8ba1 2643 mtc2=true;
yabahiro 40:7f93984e8ba1 2644 if(cross==1) {
yabahiro 40:7f93984e8ba1 2645 fast=30;
yabahiro 40:7f93984e8ba1 2646 normal=20;
yabahiro 40:7f93984e8ba1 2647 slow=20;
yabahiro 40:7f93984e8ba1 2648 }
yabahiro 40:7f93984e8ba1 2649 if(cross==2) {
yabahiro 40:7f93984e8ba1 2650 mode=21;
yabahiro 40:7f93984e8ba1 2651 cross=0;
yabahiro 41:e1dd6d97f17d 2652 count=0;
yabahiro 40:7f93984e8ba1 2653 }
yabahiro 40:7f93984e8ba1 2654 break;
yabahiro 40:7f93984e8ba1 2655 case 0:
yabahiro 40:7f93984e8ba1 2656 motor[TIRE_FR].pwm = fast;
yabahiro 40:7f93984e8ba1 2657 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 2658 motor[TIRE_FL].pwm = fast;
yabahiro 40:7f93984e8ba1 2659 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 2660 motor[TIRE_BR].pwm = fast;
yabahiro 40:7f93984e8ba1 2661 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 2662 motor[TIRE_BL].pwm = fast;
yabahiro 40:7f93984e8ba1 2663 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 2664 mtc2=true;
yabahiro 40:7f93984e8ba1 2665 break;
yabahiro 40:7f93984e8ba1 2666 case 255:
yabahiro 40:7f93984e8ba1 2667 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 2668 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 2669 motor[TIRE_FL].pwm = fast;
yabahiro 40:7f93984e8ba1 2670 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 2671 motor[TIRE_BR].pwm = fast;
yabahiro 40:7f93984e8ba1 2672 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 2673 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 2674 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 2675 mtc2=true;
yabahiro 40:7f93984e8ba1 2676 break;
yabahiro 40:7f93984e8ba1 2677 case 253:
yabahiro 40:7f93984e8ba1 2678 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 2679 motor[TIRE_FR].dir = FREE;
yabahiro 40:7f93984e8ba1 2680 motor[TIRE_FL].pwm = slow;
yabahiro 40:7f93984e8ba1 2681 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 2682 motor[TIRE_BR].pwm = slow;
yabahiro 40:7f93984e8ba1 2683 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 2684 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 2685 motor[TIRE_BL].dir = FREE;
yabahiro 40:7f93984e8ba1 2686 mtc2=true;
yabahiro 40:7f93984e8ba1 2687 break;
yabahiro 40:7f93984e8ba1 2688 case 254:
yabahiro 40:7f93984e8ba1 2689 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 2690 motor[TIRE_FR].dir = FREE;
yabahiro 40:7f93984e8ba1 2691 motor[TIRE_FL].pwm = normal;
yabahiro 40:7f93984e8ba1 2692 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 2693 motor[TIRE_BR].pwm = normal;
yabahiro 40:7f93984e8ba1 2694 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 2695 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 2696 motor[TIRE_BL].dir = FREE;
yabahiro 40:7f93984e8ba1 2697 mtc2=true;
yabahiro 40:7f93984e8ba1 2698 break;
yabahiro 40:7f93984e8ba1 2699 case 1:
yabahiro 40:7f93984e8ba1 2700 motor[TIRE_FR].pwm = fast;
yabahiro 40:7f93984e8ba1 2701 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 2702 motor[TIRE_FL].pwm = slow;
yabahiro 40:7f93984e8ba1 2703 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 2704 motor[TIRE_BR].pwm = slow;
yabahiro 40:7f93984e8ba1 2705 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 2706 motor[TIRE_BL].pwm = fast;
yabahiro 40:7f93984e8ba1 2707 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 2708 mtc2=true;
yabahiro 40:7f93984e8ba1 2709 break;
yabahiro 40:7f93984e8ba1 2710 case 3:
yabahiro 40:7f93984e8ba1 2711 motor[TIRE_FR].pwm = slow;
yabahiro 40:7f93984e8ba1 2712 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 2713 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 2714 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 2715 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 2716 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 2717 motor[TIRE_BL].pwm = slow;
yabahiro 40:7f93984e8ba1 2718 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 2719 mtc2=true;
yabahiro 40:7f93984e8ba1 2720 break;
yabahiro 40:7f93984e8ba1 2721 case 2:
yabahiro 40:7f93984e8ba1 2722 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 2723 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 2724 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 2725 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 2726 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 2727 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 2728 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 2729 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 2730 mtc2=true;
yabahiro 40:7f93984e8ba1 2731 break;
yabahiro 40:7f93984e8ba1 2732 }
yabahiro 40:7f93984e8ba1 2733 if(g[2]!=98&&mtc2==true) {
yabahiro 40:7f93984e8ba1 2734 switch(g[3]) {
yabahiro 40:7f93984e8ba1 2735 case 0:
yabahiro 40:7f93984e8ba1 2736 mtc2=false;
yabahiro 40:7f93984e8ba1 2737 break;
yabahiro 40:7f93984e8ba1 2738 case 255:
yabahiro 40:7f93984e8ba1 2739 motor[TIRE_BL].pwm += 5;
yabahiro 40:7f93984e8ba1 2740 mtc2=false;
yabahiro 40:7f93984e8ba1 2741 break;
yabahiro 40:7f93984e8ba1 2742 case 253:
yabahiro 40:7f93984e8ba1 2743 motor[TIRE_BL].pwm += 10;
yabahiro 40:7f93984e8ba1 2744 mtc2=false;
yabahiro 40:7f93984e8ba1 2745 break;
yabahiro 40:7f93984e8ba1 2746 case 254:
yabahiro 40:7f93984e8ba1 2747 motor[TIRE_BL].pwm += 20;
yabahiro 40:7f93984e8ba1 2748 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 2749 mtc2=false;
yabahiro 40:7f93984e8ba1 2750 break;
yabahiro 40:7f93984e8ba1 2751 case 1:
yabahiro 40:7f93984e8ba1 2752 motor[TIRE_FL].pwm += 5;
yabahiro 40:7f93984e8ba1 2753 mtc2=false;
yabahiro 40:7f93984e8ba1 2754 break;
yabahiro 40:7f93984e8ba1 2755 case 3:
yabahiro 40:7f93984e8ba1 2756 motor[TIRE_FL].pwm += 10;
yabahiro 40:7f93984e8ba1 2757 mtc2=false;
yabahiro 40:7f93984e8ba1 2758 break;
yabahiro 40:7f93984e8ba1 2759 case 2:
yabahiro 40:7f93984e8ba1 2760 motor[TIRE_FL].pwm += 20;
yabahiro 40:7f93984e8ba1 2761 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 2762 mtc2=false;
yabahiro 40:7f93984e8ba1 2763 break;
yabahiro 40:7f93984e8ba1 2764 }
yabahiro 40:7f93984e8ba1 2765 }
yabahiro 40:7f93984e8ba1 2766 } else if(mode==21) {
yabahiro 40:7f93984e8ba1 2767 motor[TIRE_FR].pwm = 20;
yabahiro 41:e1dd6d97f17d 2768 motor[TIRE_FR].dir = BRAKE;
yabahiro 41:e1dd6d97f17d 2769 motor[TIRE_FL].pwm = 20;
yabahiro 41:e1dd6d97f17d 2770 motor[TIRE_FL].dir = BRAKE;
yabahiro 41:e1dd6d97f17d 2771 motor[TIRE_BR].pwm = 20;
yabahiro 41:e1dd6d97f17d 2772 motor[TIRE_BR].dir = BRAKE;
yabahiro 41:e1dd6d97f17d 2773 motor[TIRE_BL].pwm = 20;
yabahiro 41:e1dd6d97f17d 2774 motor[TIRE_BL].dir = BRAKE;
yabahiro 41:e1dd6d97f17d 2775 if(count<=100000) {
yabahiro 41:e1dd6d97f17d 2776 mode=22;
yabahiro 41:e1dd6d97f17d 2777 }
yabahiro 41:e1dd6d97f17d 2778 } else if(mode==22) {
yabahiro 41:e1dd6d97f17d 2779 motor[TIRE_FR].pwm = 20;
yabahiro 40:7f93984e8ba1 2780 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 2781 motor[TIRE_FL].pwm = 20;
yabahiro 40:7f93984e8ba1 2782 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 2783 motor[TIRE_BR].pwm = 20;
yabahiro 40:7f93984e8ba1 2784 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 2785 motor[TIRE_BL].pwm = 20;
yabahiro 40:7f93984e8ba1 2786 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 2787 if(g[2]!=98) {
yabahiro 40:7f93984e8ba1 2788 mode=30;
yabahiro 40:7f93984e8ba1 2789 }
yabahiro 40:7f93984e8ba1 2790 } else if(mode==30) {
yabahiro 41:e1dd6d97f17d 2791 motor[TIRE_FR].pwm = 64;
yabahiro 40:7f93984e8ba1 2792 motor[TIRE_FR].dir = FOR;
yabahiro 40:7f93984e8ba1 2793 motor[TIRE_FL].pwm = 60;
yabahiro 40:7f93984e8ba1 2794 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 2795 motor[TIRE_BR].pwm = 60;
yabahiro 40:7f93984e8ba1 2796 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 2797 motor[TIRE_BL].pwm = 60;
yabahiro 40:7f93984e8ba1 2798 motor[TIRE_BL].dir = BACK;
yabahiro 40:7f93984e8ba1 2799 if(g[1]==98) {
yabahiro 40:7f93984e8ba1 2800 mode=31;
yabahiro 41:e1dd6d97f17d 2801 count=0;
yabahiro 40:7f93984e8ba1 2802 }
yabahiro 40:7f93984e8ba1 2803 } else if(mode==31) {
yabahiro 41:e1dd6d97f17d 2804 motor[TIRE_FR].pwm = 10;
yabahiro 41:e1dd6d97f17d 2805 motor[TIRE_FR].dir = FREE;
yabahiro 41:e1dd6d97f17d 2806 motor[TIRE_FL].pwm = 10;
yabahiro 41:e1dd6d97f17d 2807 motor[TIRE_FL].dir = FREE;
yabahiro 41:e1dd6d97f17d 2808 motor[TIRE_BR].pwm = 10;
yabahiro 41:e1dd6d97f17d 2809 motor[TIRE_BR].dir = FREE;
yabahiro 41:e1dd6d97f17d 2810 motor[TIRE_BL].pwm = 10;
yabahiro 41:e1dd6d97f17d 2811 motor[TIRE_BL].dir = FREE;
yabahiro 41:e1dd6d97f17d 2812 if(count>=10000) {
yabahiro 41:e1dd6d97f17d 2813 mode=32;
yabahiro 40:7f93984e8ba1 2814 count=0;
yabahiro 40:7f93984e8ba1 2815 }
yabahiro 40:7f93984e8ba1 2816 } else if(mode==32) {
yabahiro 41:e1dd6d97f17d 2817 motor[TIRE_FR].pwm = 5;
yabahiro 41:e1dd6d97f17d 2818 motor[TIRE_FR].dir = BRAKE;
yabahiro 41:e1dd6d97f17d 2819 motor[TIRE_FL].pwm = 5;
yabahiro 41:e1dd6d97f17d 2820 motor[TIRE_FL].dir = BRAKE;
yabahiro 41:e1dd6d97f17d 2821 motor[TIRE_BR].pwm = 5;
yabahiro 41:e1dd6d97f17d 2822 motor[TIRE_BR].dir = BRAKE;
yabahiro 41:e1dd6d97f17d 2823 motor[TIRE_BL].pwm = 5;
yabahiro 41:e1dd6d97f17d 2824 motor[TIRE_BL].dir = BRAKE;
yabahiro 41:e1dd6d97f17d 2825 if(count>=40000) {
yabahiro 41:e1dd6d97f17d 2826 mode=33;
yabahiro 41:e1dd6d97f17d 2827 count=0;
yabahiro 41:e1dd6d97f17d 2828 }
yabahiro 41:e1dd6d97f17d 2829 } else if(mode==33) {
yabahiro 41:e1dd6d97f17d 2830 motor[TIRE_FR].pwm = 0;
yabahiro 41:e1dd6d97f17d 2831 motor[TIRE_FR].dir = FREE;
yabahiro 41:e1dd6d97f17d 2832 motor[TIRE_FL].pwm = 25;
yabahiro 41:e1dd6d97f17d 2833 motor[TIRE_FL].dir = BACK;
yabahiro 41:e1dd6d97f17d 2834 motor[TIRE_BR].pwm = 25;
yabahiro 41:e1dd6d97f17d 2835 motor[TIRE_BR].dir = FOR;
yabahiro 41:e1dd6d97f17d 2836 motor[TIRE_BL].pwm = 0;
yabahiro 41:e1dd6d97f17d 2837 motor[TIRE_BL].dir = FREE;
yabahiro 40:7f93984e8ba1 2838 if(g[3]==0) {
yabahiro 40:7f93984e8ba1 2839 count=0;
yabahiro 40:7f93984e8ba1 2840 if(Twsh==2) {
yabahiro 40:7f93984e8ba1 2841 solenoid.solenoid2 = SOLENOID_OFF;
yabahiro 40:7f93984e8ba1 2842 }
yabahiro 40:7f93984e8ba1 2843 mode=40;
yabahiro 40:7f93984e8ba1 2844 }
yabahiro 40:7f93984e8ba1 2845 } else if(mode==40) {
yabahiro 41:e1dd6d97f17d 2846 if(LIF||LIB) {
yabahiro 40:7f93984e8ba1 2847 mode=42;
yabahiro 40:7f93984e8ba1 2848 }
yabahiro 40:7f93984e8ba1 2849
yabahiro 40:7f93984e8ba1 2850 if(counts==false&&g[0]==0) {
yabahiro 40:7f93984e8ba1 2851 cros++;
yabahiro 40:7f93984e8ba1 2852 counts=true;
yabahiro 40:7f93984e8ba1 2853 }
yabahiro 40:7f93984e8ba1 2854 if(counts==true&&g[0]==99) {
yabahiro 40:7f93984e8ba1 2855 counts=false;
yabahiro 40:7f93984e8ba1 2856 }
yabahiro 40:7f93984e8ba1 2857
yabahiro 40:7f93984e8ba1 2858 if(cros==2) {
yabahiro 40:7f93984e8ba1 2859 // mode=41;
yabahiro 40:7f93984e8ba1 2860 //count=0;
yabahiro 40:7f93984e8ba1 2861 //cros=0;
yabahiro 40:7f93984e8ba1 2862 }//ゆっくりモードに入れなかった時の保険
yabahiro 40:7f93984e8ba1 2863
yabahiro 40:7f93984e8ba1 2864 switch(g[3]) {
yabahiro 40:7f93984e8ba1 2865 case 98:
yabahiro 40:7f93984e8ba1 2866 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 2867 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 2868 motor[TIRE_FL].pwm = normal;
yabahiro 40:7f93984e8ba1 2869 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 2870 motor[TIRE_BR].pwm = normal;
yabahiro 40:7f93984e8ba1 2871 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 2872 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 2873 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 2874 if(count>20000) {
yabahiro 40:7f93984e8ba1 2875 cross++;
yabahiro 40:7f93984e8ba1 2876 count=0;
yabahiro 40:7f93984e8ba1 2877 }
yabahiro 40:7f93984e8ba1 2878 mtc2=true;
yabahiro 40:7f93984e8ba1 2879 if(cross==1) {
yabahiro 40:7f93984e8ba1 2880 mode=41;
yabahiro 40:7f93984e8ba1 2881 count=0;
yabahiro 40:7f93984e8ba1 2882 cross=0;
yabahiro 40:7f93984e8ba1 2883 }
yabahiro 40:7f93984e8ba1 2884 break;
yabahiro 40:7f93984e8ba1 2885 case 0:
yabahiro 40:7f93984e8ba1 2886 motor[TIRE_FR].pwm = fast;
yabahiro 40:7f93984e8ba1 2887 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 2888 motor[TIRE_FL].pwm = fast;
yabahiro 40:7f93984e8ba1 2889 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 2890 motor[TIRE_BR].pwm = fast;
yabahiro 40:7f93984e8ba1 2891 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 2892 motor[TIRE_BL].pwm = fast;
yabahiro 40:7f93984e8ba1 2893 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 2894 mtc2=true;
yabahiro 40:7f93984e8ba1 2895 break;
yabahiro 40:7f93984e8ba1 2896 case 255:
yabahiro 40:7f93984e8ba1 2897 motor[TIRE_FR].pwm = slow;
yabahiro 40:7f93984e8ba1 2898 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 2899 motor[TIRE_FL].pwm = fast;
yabahiro 40:7f93984e8ba1 2900 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 2901 motor[TIRE_BR].pwm = fast;
yabahiro 40:7f93984e8ba1 2902 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 2903 motor[TIRE_BL].pwm = slow;
yabahiro 40:7f93984e8ba1 2904 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 2905 mtc2=true;
yabahiro 40:7f93984e8ba1 2906 break;
yabahiro 40:7f93984e8ba1 2907 case 253:
yabahiro 40:7f93984e8ba1 2908 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 2909 motor[TIRE_FR].dir = FREE;
yabahiro 40:7f93984e8ba1 2910 motor[TIRE_FL].pwm = slow;
yabahiro 40:7f93984e8ba1 2911 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 2912 motor[TIRE_BR].pwm = slow;
yabahiro 40:7f93984e8ba1 2913 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 2914 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 2915 motor[TIRE_BL].dir = FREE;
yabahiro 40:7f93984e8ba1 2916 mtc2=true;
yabahiro 40:7f93984e8ba1 2917 break;
yabahiro 40:7f93984e8ba1 2918 case 254:
yabahiro 40:7f93984e8ba1 2919 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 2920 motor[TIRE_FR].dir = FREE;
yabahiro 40:7f93984e8ba1 2921 motor[TIRE_FL].pwm = normal;
yabahiro 40:7f93984e8ba1 2922 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 2923 motor[TIRE_BR].pwm = normal;
yabahiro 40:7f93984e8ba1 2924 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 2925 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 2926 motor[TIRE_BL].dir = FREE;
yabahiro 40:7f93984e8ba1 2927 mtc2=true;
yabahiro 40:7f93984e8ba1 2928 break;
yabahiro 40:7f93984e8ba1 2929 case 1:
yabahiro 40:7f93984e8ba1 2930 motor[TIRE_FR].pwm = fast;
yabahiro 40:7f93984e8ba1 2931 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 2932 motor[TIRE_FL].pwm = slow;
yabahiro 40:7f93984e8ba1 2933 motor[TIRE_FL].dir = BACK;
yabahiro 40:7f93984e8ba1 2934 motor[TIRE_BR].pwm = slow;
yabahiro 40:7f93984e8ba1 2935 motor[TIRE_BR].dir = FOR;
yabahiro 40:7f93984e8ba1 2936 motor[TIRE_BL].pwm = fast;
yabahiro 40:7f93984e8ba1 2937 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 2938 mtc2=true;
yabahiro 40:7f93984e8ba1 2939 break;
yabahiro 40:7f93984e8ba1 2940 case 3:
yabahiro 40:7f93984e8ba1 2941 motor[TIRE_FR].pwm = slow;
yabahiro 40:7f93984e8ba1 2942 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 2943 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 2944 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 2945 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 2946 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 2947 motor[TIRE_BL].pwm = slow;
yabahiro 40:7f93984e8ba1 2948 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 2949 mtc2=true;
yabahiro 40:7f93984e8ba1 2950 break;
yabahiro 40:7f93984e8ba1 2951 case 2:
yabahiro 40:7f93984e8ba1 2952 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 2953 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 2954 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 2955 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 2956 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 2957 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 2958 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 2959 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 2960 mtc2=true;
yabahiro 40:7f93984e8ba1 2961 break;
yabahiro 40:7f93984e8ba1 2962 }
yabahiro 40:7f93984e8ba1 2963 if(g[2]!=98&&mtc2==true) {
yabahiro 40:7f93984e8ba1 2964 switch(g[2]) {
yabahiro 40:7f93984e8ba1 2965 case 0:
yabahiro 40:7f93984e8ba1 2966 mtc2=false;
yabahiro 40:7f93984e8ba1 2967 break;
yabahiro 40:7f93984e8ba1 2968 case 255:
yabahiro 40:7f93984e8ba1 2969 motor[TIRE_FR].pwm += 5;
yabahiro 40:7f93984e8ba1 2970 mtc2=false;
yabahiro 40:7f93984e8ba1 2971 break;
yabahiro 40:7f93984e8ba1 2972 case 253:
yabahiro 40:7f93984e8ba1 2973 motor[TIRE_FR].pwm += 10;
yabahiro 40:7f93984e8ba1 2974 mtc2=false;
yabahiro 40:7f93984e8ba1 2975 break;
yabahiro 40:7f93984e8ba1 2976 case 254:
yabahiro 40:7f93984e8ba1 2977 motor[TIRE_FR].pwm += 20;
yabahiro 40:7f93984e8ba1 2978 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 2979 mtc2=false;
yabahiro 40:7f93984e8ba1 2980 break;
yabahiro 40:7f93984e8ba1 2981 case 1:
yabahiro 40:7f93984e8ba1 2982 motor[TIRE_BR].pwm += 5;
yabahiro 40:7f93984e8ba1 2983 mtc2=false;
yabahiro 40:7f93984e8ba1 2984 break;
yabahiro 40:7f93984e8ba1 2985 case 3:
yabahiro 40:7f93984e8ba1 2986 motor[TIRE_BR].pwm += 10;
yabahiro 40:7f93984e8ba1 2987 mtc2=false;
yabahiro 40:7f93984e8ba1 2988 break;
yabahiro 40:7f93984e8ba1 2989 case 2:
yabahiro 40:7f93984e8ba1 2990 motor[TIRE_BR].pwm += 20;
yabahiro 40:7f93984e8ba1 2991 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 2992 mtc2=false;
yabahiro 40:7f93984e8ba1 2993 break;
yabahiro 40:7f93984e8ba1 2994 }
yabahiro 40:7f93984e8ba1 2995 }
yabahiro 40:7f93984e8ba1 2996 } else if(mode==41) {
yabahiro 41:e1dd6d97f17d 2997 if(LIF||LIB) {
yabahiro 41:e1dd6d97f17d 2998 mode=42;
yabahiro 41:e1dd6d97f17d 2999 }
yabahiro 40:7f93984e8ba1 3000 motor[TIRE_FR].pwm = 30;
yabahiro 40:7f93984e8ba1 3001 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 3002 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 3003 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 3004 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 3005 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 3006 motor[TIRE_BL].pwm = 30;
yabahiro 40:7f93984e8ba1 3007 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 3008 if(g[1]==0) {
yabahiro 40:7f93984e8ba1 3009 count=0;
yabahiro 40:7f93984e8ba1 3010 mode=70;
yabahiro 40:7f93984e8ba1 3011 normal=60;
yabahiro 40:7f93984e8ba1 3012 fast=80;
yabahiro 40:7f93984e8ba1 3013 slow=40;
yabahiro 40:7f93984e8ba1 3014 }
yabahiro 40:7f93984e8ba1 3015 } else if(mode==42) {
yabahiro 41:e1dd6d97f17d 3016 motor[TIRE_FR].pwm = 0;
yabahiro 41:e1dd6d97f17d 3017 motor[TIRE_FR].dir = FREE;
yabahiro 40:7f93984e8ba1 3018 motor[TIRE_FL].pwm = 30;
yabahiro 40:7f93984e8ba1 3019 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 3020 motor[TIRE_BR].pwm = 30;
yabahiro 40:7f93984e8ba1 3021 motor[TIRE_BR].dir = BACK;
yabahiro 41:e1dd6d97f17d 3022 motor[TIRE_BL].pwm = 0;
yabahiro 41:e1dd6d97f17d 3023 motor[TIRE_BL].dir = FREE;
yabahiro 41:e1dd6d97f17d 3024 if(g[0]==0) {
yabahiro 40:7f93984e8ba1 3025 count=0;
yabahiro 40:7f93984e8ba1 3026 mode=70;
yabahiro 40:7f93984e8ba1 3027 normal=60;
yabahiro 40:7f93984e8ba1 3028 fast=80;
yabahiro 40:7f93984e8ba1 3029 slow=40;
yabahiro 40:7f93984e8ba1 3030 }
yabahiro 40:7f93984e8ba1 3031
yabahiro 40:7f93984e8ba1 3032 } else if(mode==70)
yabahiro 40:7f93984e8ba1 3033 switch(g[0]) {
yabahiro 40:7f93984e8ba1 3034 case 99:
yabahiro 40:7f93984e8ba1 3035 if(count>=100000) {
yabahiro 40:7f93984e8ba1 3036 cross++;
yabahiro 40:7f93984e8ba1 3037 mode=100;
yabahiro 40:7f93984e8ba1 3038 count=0;
yabahiro 40:7f93984e8ba1 3039 }
yabahiro 41:e1dd6d97f17d 3040 if(cross==2) {
yabahiro 40:7f93984e8ba1 3041 cross=0;
yabahiro 40:7f93984e8ba1 3042 mode=100;
yabahiro 40:7f93984e8ba1 3043 }
yabahiro 40:7f93984e8ba1 3044 break;
yabahiro 40:7f93984e8ba1 3045 case 98:
yabahiro 40:7f93984e8ba1 3046 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 3047 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 3048 motor[TIRE_FL].pwm = normal;
yabahiro 40:7f93984e8ba1 3049 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 3050 motor[TIRE_BR].pwm = normal;
yabahiro 40:7f93984e8ba1 3051 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 3052 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 3053 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 3054 break;
yabahiro 40:7f93984e8ba1 3055 case 0:
yabahiro 40:7f93984e8ba1 3056 motor[TIRE_FR].pwm = fast;
yabahiro 40:7f93984e8ba1 3057 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 3058 motor[TIRE_FL].pwm = fast;
yabahiro 40:7f93984e8ba1 3059 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 3060 motor[TIRE_BR].pwm = fast;
yabahiro 40:7f93984e8ba1 3061 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 3062 motor[TIRE_BL].pwm = fast;
yabahiro 40:7f93984e8ba1 3063 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 3064 mtc=true;
yabahiro 40:7f93984e8ba1 3065 break;
yabahiro 40:7f93984e8ba1 3066 case 255:
yabahiro 40:7f93984e8ba1 3067 motor[TIRE_FR].pwm = fast;
yabahiro 40:7f93984e8ba1 3068 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 3069 motor[TIRE_FL].pwm = slow;
yabahiro 40:7f93984e8ba1 3070 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 3071 motor[TIRE_BR].pwm = slow;
yabahiro 40:7f93984e8ba1 3072 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 3073 motor[TIRE_BL].pwm = fast;
yabahiro 40:7f93984e8ba1 3074 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 3075 mtc=true;
yabahiro 40:7f93984e8ba1 3076 break;
yabahiro 40:7f93984e8ba1 3077 case 253:
yabahiro 40:7f93984e8ba1 3078 motor[TIRE_FR].pwm = slow;
yabahiro 40:7f93984e8ba1 3079 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 3080 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 3081 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 3082 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 3083 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 3084 motor[TIRE_BL].pwm = slow;
yabahiro 40:7f93984e8ba1 3085 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 3086 mtc=true;
yabahiro 40:7f93984e8ba1 3087 break;
yabahiro 40:7f93984e8ba1 3088 case 254:
yabahiro 40:7f93984e8ba1 3089 motor[TIRE_FR].pwm = normal;
yabahiro 40:7f93984e8ba1 3090 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 3091 motor[TIRE_FL].pwm = 0;
yabahiro 40:7f93984e8ba1 3092 motor[TIRE_FL].dir = FREE;
yabahiro 40:7f93984e8ba1 3093 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 3094 motor[TIRE_BR].dir = FREE;
yabahiro 40:7f93984e8ba1 3095 motor[TIRE_BL].pwm = normal;
yabahiro 40:7f93984e8ba1 3096 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 3097 mtc=true;
yabahiro 40:7f93984e8ba1 3098 break;
yabahiro 40:7f93984e8ba1 3099 case 1:
yabahiro 40:7f93984e8ba1 3100 motor[TIRE_FR].pwm = slow;
yabahiro 40:7f93984e8ba1 3101 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 3102 motor[TIRE_FL].pwm = fast;
yabahiro 40:7f93984e8ba1 3103 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 3104 motor[TIRE_BR].pwm = fast;
yabahiro 40:7f93984e8ba1 3105 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 3106 motor[TIRE_BL].pwm = slow;
yabahiro 40:7f93984e8ba1 3107 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 3108 mtc=true;
yabahiro 40:7f93984e8ba1 3109 break;
yabahiro 40:7f93984e8ba1 3110 case 3:
yabahiro 40:7f93984e8ba1 3111 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 3112 motor[TIRE_FR].dir = FREE;
yabahiro 40:7f93984e8ba1 3113 motor[TIRE_FL].pwm = slow;
yabahiro 40:7f93984e8ba1 3114 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 3115 motor[TIRE_BR].pwm = slow;
yabahiro 40:7f93984e8ba1 3116 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 3117 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 3118 motor[TIRE_BL].dir = FREE;
yabahiro 40:7f93984e8ba1 3119 mtc=true;
yabahiro 40:7f93984e8ba1 3120 break;
yabahiro 40:7f93984e8ba1 3121 case 2:
yabahiro 40:7f93984e8ba1 3122 motor[TIRE_FR].pwm = 0;
yabahiro 40:7f93984e8ba1 3123 motor[TIRE_FR].dir = FREE;
yabahiro 40:7f93984e8ba1 3124 motor[TIRE_FL].pwm = normal;
yabahiro 40:7f93984e8ba1 3125 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 3126 motor[TIRE_BR].pwm = normal;
yabahiro 40:7f93984e8ba1 3127 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 3128 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 3129 motor[TIRE_BL].dir = FREE;
yabahiro 40:7f93984e8ba1 3130 mtc=true;
yabahiro 40:7f93984e8ba1 3131 break;
yabahiro 40:7f93984e8ba1 3132 }
yabahiro 40:7f93984e8ba1 3133 if(g[1]!=98&&mtc==true) {
yabahiro 40:7f93984e8ba1 3134 switch(g[1]) {
yabahiro 40:7f93984e8ba1 3135 case 0:
yabahiro 40:7f93984e8ba1 3136 mtc=false;
yabahiro 40:7f93984e8ba1 3137 break;
yabahiro 40:7f93984e8ba1 3138 case 255:
yabahiro 40:7f93984e8ba1 3139 motor[TIRE_BR].pwm += 5;
yabahiro 40:7f93984e8ba1 3140 mtc=false;
yabahiro 40:7f93984e8ba1 3141 break;
yabahiro 40:7f93984e8ba1 3142 case 253:
yabahiro 40:7f93984e8ba1 3143 motor[TIRE_BR].pwm += 10;
yabahiro 40:7f93984e8ba1 3144 mtc=false;
yabahiro 40:7f93984e8ba1 3145 break;
yabahiro 40:7f93984e8ba1 3146 case 254:
yabahiro 40:7f93984e8ba1 3147 motor[TIRE_BR].pwm += 20;
yabahiro 40:7f93984e8ba1 3148 motor[TIRE_BL].pwm = 0;
yabahiro 40:7f93984e8ba1 3149 mtc=false;
yabahiro 40:7f93984e8ba1 3150 break;
yabahiro 40:7f93984e8ba1 3151 case 1:
yabahiro 40:7f93984e8ba1 3152 motor[TIRE_BL].pwm += 5;
yabahiro 40:7f93984e8ba1 3153 mtc=false;
yabahiro 40:7f93984e8ba1 3154 break;
yabahiro 40:7f93984e8ba1 3155 case 3:
yabahiro 40:7f93984e8ba1 3156 motor[TIRE_BL].pwm += 10;
yabahiro 40:7f93984e8ba1 3157 mtc=false;
yabahiro 40:7f93984e8ba1 3158 break;
yabahiro 40:7f93984e8ba1 3159 case 2:
yabahiro 40:7f93984e8ba1 3160 motor[TIRE_BL].pwm += 20;
yabahiro 40:7f93984e8ba1 3161 motor[TIRE_BR].pwm = 0;
yabahiro 40:7f93984e8ba1 3162 mtc=false;
yabahiro 40:7f93984e8ba1 3163 break;
yabahiro 40:7f93984e8ba1 3164 }
yabahiro 40:7f93984e8ba1 3165 } else if(mode==100) {
yabahiro 40:7f93984e8ba1 3166 motor[TIRE_FR].pwm = 20;
yabahiro 40:7f93984e8ba1 3167 motor[TIRE_FR].dir = BACK;
yabahiro 40:7f93984e8ba1 3168 motor[TIRE_FL].pwm = 20;
yabahiro 40:7f93984e8ba1 3169 motor[TIRE_FL].dir = FOR;
yabahiro 40:7f93984e8ba1 3170 motor[TIRE_BR].pwm = 23;
yabahiro 40:7f93984e8ba1 3171 motor[TIRE_BR].dir = BACK;
yabahiro 40:7f93984e8ba1 3172 motor[TIRE_BL].pwm = 20;
yabahiro 40:7f93984e8ba1 3173 motor[TIRE_BL].dir = FOR;
yabahiro 40:7f93984e8ba1 3174 if(StertSW) {
yabahiro 40:7f93984e8ba1 3175 SW_flag = true;
yabahiro 40:7f93984e8ba1 3176 }
yabahiro 40:7f93984e8ba1 3177 if(SW_flag ==true) {
yabahiro 40:7f93984e8ba1 3178 motor[TIRE_FR].pwm = 100;
yabahiro 40:7f93984e8ba1 3179 motor[TIRE_FR].dir = BRAKE;
yabahiro 40:7f93984e8ba1 3180 motor[TIRE_FL].pwm = 100;
yabahiro 40:7f93984e8ba1 3181 motor[TIRE_FL].dir = BRAKE;
yabahiro 40:7f93984e8ba1 3182 motor[TIRE_BR].pwm = 100;
yabahiro 40:7f93984e8ba1 3183 motor[TIRE_BR].dir = BRAKE;
yabahiro 40:7f93984e8ba1 3184 motor[TIRE_BL].pwm = 100;
yabahiro 40:7f93984e8ba1 3185 motor[TIRE_BL].dir = BRAKE;
yabahiro 40:7f93984e8ba1 3186 fast=60;
yabahiro 40:7f93984e8ba1 3187 normal=40;
yabahiro 40:7f93984e8ba1 3188 slow=20;
yabahiro 40:7f93984e8ba1 3189 mode =1;
yabahiro 40:7f93984e8ba1 3190 cross=0;//十字数える用
yabahiro 40:7f93984e8ba1 3191 cros=0;
yabahiro 40:7f93984e8ba1 3192 count=100000;//wait代替え
yabahiro 40:7f93984e8ba1 3193 UP_flag = false;
yabahiro 40:7f93984e8ba1 3194 SW_flag = false;
yabahiro 40:7f93984e8ba1 3195 Air_flag = false;
yabahiro 40:7f93984e8ba1 3196 zyouge=false;
yabahiro 40:7f93984e8ba1 3197 zyougedo=false;
yabahiro 40:7f93984e8ba1 3198 dz1=true;
yabahiro 40:7f93984e8ba1 3199 dz1i=false;
yabahiro 40:7f93984e8ba1 3200 dz2=true;
yabahiro 40:7f93984e8ba1 3201 dz2i=false;
yabahiro 40:7f93984e8ba1 3202 dz3=true;
yabahiro 40:7f93984e8ba1 3203 dz3i=false;
yabahiro 40:7f93984e8ba1 3204 dz4=true;
yabahiro 40:7f93984e8ba1 3205 dz4i=false;
yabahiro 40:7f93984e8ba1 3206 through=false;
yabahiro 40:7f93984e8ba1 3207 counts=false;
yabahiro 40:7f93984e8ba1 3208 mtc=false;
yabahiro 40:7f93984e8ba1 3209 mtc2 = false;
yabahiro 40:7f93984e8ba1 3210 current = 0;
yabahiro 40:7f93984e8ba1 3211 if(StertSW==false) {
yabahiro 40:7f93984e8ba1 3212 SW_flag = false;
yabahiro 40:7f93984e8ba1 3213 }
yabahiro 40:7f93984e8ba1 3214 }
yabahiro 40:7f93984e8ba1 3215 }
yabahiro 40:7f93984e8ba1 3216
yabahiro 40:7f93984e8ba1 3217
yabahiro 21:1f1e9c585da8 3218
kishibekairohan 13:b6e02d6261d7 3219 }
kishibekairohan 13:b6e02d6261d7 3220 #endif
kishibekairohan 13:b6e02d6261d7 3221
kishibekairohan 13:b6e02d6261d7 3222 #if USE_PROCESS_NUM>6
yabahiro 21:1f1e9c585da8 3223 static void Process6()
kishibekairohan 13:b6e02d6261d7 3224 {
yabahiro 21:1f1e9c585da8 3225
kishibekairohan 13:b6e02d6261d7 3226 }
kishibekairohan 13:b6e02d6261d7 3227 #endif
kishibekairohan 13:b6e02d6261d7 3228
kishibekairohan 13:b6e02d6261d7 3229 #if USE_PROCESS_NUM>7
kishibekairohan 13:b6e02d6261d7 3230 static void Process7()
kishibekairohan 13:b6e02d6261d7 3231 {
yabahiro 21:1f1e9c585da8 3232
kishibekairohan 12:c09b3e08a316 3233 }
kishibekairohan 12:c09b3e08a316 3234 #endif
kishibekairohan 12:c09b3e08a316 3235
yabahiro 21:1f1e9c585da8 3236 #if USE_PROCESS_NUM>8
kishibekairohan 13:b6e02d6261d7 3237 static void Process8()
kishibekairohan 12:c09b3e08a316 3238 {
yabahiro 21:1f1e9c585da8 3239
kishibekairohan 12:c09b3e08a316 3240 }
kishibekairohan 12:c09b3e08a316 3241 #endif
kishibekairohan 12:c09b3e08a316 3242
kishibekairohan 13:b6e02d6261d7 3243 #if USE_PROCESS_NUM>9
kishibekairohan 13:b6e02d6261d7 3244 static void Process9()
kishibekairohan 12:c09b3e08a316 3245 {
yabahiro 21:1f1e9c585da8 3246
t_yamamoto 0:669ef71cba68 3247 }
t_yamamoto 0:669ef71cba68 3248 #endif
t_yamamoto 0:669ef71cba68 3249 #endif
t_yamamoto 0:669ef71cba68 3250 #pragma endregion PROCESS
t_yamamoto 0:669ef71cba68 3251
t_yamamoto 0:669ef71cba68 3252 static void AllActuatorReset()
t_yamamoto 0:669ef71cba68 3253 {
t_yamamoto 0:669ef71cba68 3254
yabahiro 21:1f1e9c585da8 3255 #ifdef USE_SOLENOID
yabahiro 21:1f1e9c585da8 3256 solenoid.all = ALL_SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 3257 #endif
t_yamamoto 0:669ef71cba68 3258
yabahiro 21:1f1e9c585da8 3259 #ifdef USE_MOTOR
yabahiro 21:1f1e9c585da8 3260 for (uint8_t i = 0; i < MOUNTING_MOTOR_NUM; i++) {
yabahiro 21:1f1e9c585da8 3261 motor[i].dir = FREE;
yabahiro 21:1f1e9c585da8 3262 motor[i].pwm = 0;
yabahiro 21:1f1e9c585da8 3263 }
yabahiro 21:1f1e9c585da8 3264 #endif
t_yamamoto 0:669ef71cba68 3265 }
t_yamamoto 0:669ef71cba68 3266
yabahiro 21:1f1e9c585da8 3267 /*
yabahiro 21:1f1e9c585da8 3268 void BuzzerTimer_func()
yabahiro 21:1f1e9c585da8 3269 {
kishibekairohan 16:3f2c2d89372b 3270 buzzer = !buzzer;
kishibekairohan 17:50dc4b449e69 3271 //LED_DEBUG0 = !LED_DEBUG0;
kishibekairohan 11:028a150943b5 3272 }
yabahiro 21:1f1e9c585da8 3273 */
yabahiro 21:1f1e9c585da8 3274 void TapeLedEms_func()
yabahiro 21:1f1e9c585da8 3275 {
kishibekairohan 16:3f2c2d89372b 3276 sendLedData.code = sendLedData.code == (uint32_t)Red ? (uint32_t)Black : (uint32_t)Red;
kishibekairohan 9:f93fc79a49ea 3277 }
kishibekairohan 16:3f2c2d89372b 3278
kishibekairohan 16:3f2c2d89372b 3279 #pragma region USER-DEFINED-FUNCTIONS
kishibekairohan 16:3f2c2d89372b 3280
kishibekairohan 16:3f2c2d89372b 3281
t_yamamoto 0:669ef71cba68 3282 #pragma endregion