aa

Dependencies:   mbed

Committer:
yabahiro
Date:
Tue Nov 05 08:38:32 2019 +0000
Revision:
39:784552c26163
Parent:
38:40e7fdf3c694
Child:
40:ed2409e0ce6b
aa

Who changed what in which revision?

UserRevisionLine numberNew contents of line
t_yamamoto 0:669ef71cba68 1 #include "mbed.h"
t_yamamoto 0:669ef71cba68 2 #include "Process.h"
Ryosei 27:dd9f27fce7d1 3 #include <stdlib.h>
7ka884 4:ba9df71868df 4 #include "../../CommonLibraries/PID/PID.h"
t_yamamoto 0:669ef71cba68 5 #include "../../Communication/RS485/ActuatorHub/ActuatorHub.h"
M_souta 21:e3b58d675c1c 6 #include "../../Communication/RS485/LineHub/LineHub.h"
t_yamamoto 0:669ef71cba68 7 #include "../../Communication/Controller/Controller.h"
M_souta 30:8f092276b2ba 8 #include "../../Switch/Switch.h"
Ryosei 27:dd9f27fce7d1 9
t_yamamoto 0:669ef71cba68 10 #include "../../LED/LED.h"
t_yamamoto 0:669ef71cba68 11 #include "../../Safty/Safty.h"
t_yamamoto 0:669ef71cba68 12 #include "../Using.h"
t_yamamoto 0:669ef71cba68 13
t_yamamoto 0:669ef71cba68 14 using namespace SWITCH;
7ka884 4:ba9df71868df 15 using namespace PID_SPACE;
Ryosei 27:dd9f27fce7d1 16
kishibekairohan 36:418ee5567687 17
M_souta 21:e3b58d675c1c 18 using namespace LINEHUB;
t_yamamoto 0:669ef71cba68 19
t_yamamoto 0:669ef71cba68 20 static CONTROLLER::ControllerData *controller;
t_yamamoto 0:669ef71cba68 21 ACTUATORHUB::MOTOR::MotorStatus motor[MOUNTING_MOTOR_NUM];
t_yamamoto 0:669ef71cba68 22 ACTUATORHUB::SOLENOID::SolenoidStatus solenoid;
t_yamamoto 0:669ef71cba68 23
t_yamamoto 0:669ef71cba68 24 static bool lock;
t_yamamoto 0:669ef71cba68 25 static bool processChangeComp;
t_yamamoto 0:669ef71cba68 26 static int current;
t_yamamoto 0:669ef71cba68 27
t_yamamoto 0:669ef71cba68 28 static void AllActuatorReset();
t_yamamoto 0:669ef71cba68 29
t_yamamoto 0:669ef71cba68 30 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 31 static void (*Process[USE_PROCESS_NUM])(void);
t_yamamoto 0:669ef71cba68 32 #endif
t_yamamoto 0:669ef71cba68 33
t_yamamoto 0:669ef71cba68 34 #pragma region USER-DEFINED_VARIABLES_AND_PROTOTYPE
t_yamamoto 0:669ef71cba68 35
t_yamamoto 0:669ef71cba68 36 /*Replace here with the definition code of your variables.*/
t_yamamoto 0:669ef71cba68 37
kishibekairohan 2:c015739085d3 38
M_souta 30:8f092276b2ba 39 //Serial pc(USBTX, USBRX);
kishibekairohan 16:3f2c2d89372b 40
Ryosei 27:dd9f27fce7d1 41 const int omni[15][15] = {
Ryosei 27:dd9f27fce7d1 42 { 0, 5, 21, 47, 83, 130, 187, 255, 255, 255, 255, 255, 255, 255, 255 },
Ryosei 27:dd9f27fce7d1 43 { -5, 0, 5, 21, 47, 83, 130, 187, 193, 208, 234, 255, 255, 255, 255 },
Ryosei 27:dd9f27fce7d1 44 { -21, -5, 0, 5, 21, 47, 83, 130, 135, 151, 177, 213, 255, 255, 255 },
Ryosei 27:dd9f27fce7d1 45 { -47, -21, 5, 0, 5, 21, 47, 83, 88, 104, 130, 167, 213, 255, 255 },
Ryosei 27:dd9f27fce7d1 46 { -83, -47, -21, 5, 0, 5, 21, 47, 52, 68, 94, 130, 177, 234, 255 },
Ryosei 27:dd9f27fce7d1 47 { -130, -83, -47, -21, 5, 0, 5, 21, 26, 42, 68, 104, 151, 208, 255 },
Ryosei 27:dd9f27fce7d1 48 { -187, -130, -83, -47, -21, -5, 0, 5, 10, 26, 52, 88, 135, 193, 255 },
Ryosei 27:dd9f27fce7d1 49 { -255, -187, -130, -83, -47, -21, -5, 0, 5, 21, 47, 83, 130, 187, 255 },
Ryosei 27:dd9f27fce7d1 50 { -255, -193, -135, -88, -52, -26, -10, -5, 0, 5, 21, 47, 83, 130, 187 },
Ryosei 27:dd9f27fce7d1 51 { -255, -208, -151, -104, -68, -42, -26, -21, -5, 0, 5, 21, 47, 83, 130 },
Ryosei 27:dd9f27fce7d1 52 { -255, -234, -177, -130, -94, -68, -52, -47, -21, -7, 0, 7, 21, 47, 83 },
Ryosei 27:dd9f27fce7d1 53 { -255, -255, -213, -167, -130, -104, -88, -83, -47, -21, -5, 0, 5, 21, 47 },
Ryosei 27:dd9f27fce7d1 54 { -255, -255, -255, -213, -177, -151, -135, -130, -83, -47, -21, -5, 0, 5, 21 },
Ryosei 27:dd9f27fce7d1 55 { -255, -255, -255, -255, -234, -208, -193, -187, -130, -83, -47, -21, -5, 0, 5 },
Ryosei 27:dd9f27fce7d1 56 { -255, -255, -255, -255, -255, -255, -255, -255, -187, -130, -83, -47, -21, -5, 0 }
M_souta 21:e3b58d675c1c 57 };
M_souta 21:e3b58d675c1c 58
M_souta 21:e3b58d675c1c 59 const int curve[15] = { -204, -150, -104, -66, -38, -17, -4, 0, 4, 17, 38, 66, 104, 150, 204 };
M_souta 21:e3b58d675c1c 60
M_souta 21:e3b58d675c1c 61 uint8_t SetStatus(int);
M_souta 21:e3b58d675c1c 62 uint8_t SetPWM(int);
M_souta 18:c694bae76e51 63
yabahiro 33:dd598bb23ad1 64 uint8_t Setpwm(int pwmVal)
yabahiro 33:dd598bb23ad1 65 {
yabahiro 33:dd598bb23ad1 66 if (pwmVal == 0 || pwmVal > 255 || pwmVal < -255) return 255;
yabahiro 33:dd598bb23ad1 67 else return abs(pwmVal);
yabahiro 33:dd598bb23ad1 68 }
yabahiro 33:dd598bb23ad1 69
kishibekairohan 35:33c6cdba5630 70 DigitalIn EMC(PC_13); //非常停止確認用
yabahiro 33:dd598bb23ad1 71
yabahiro 33:dd598bb23ad1 72 bool start_flag = true;
yabahiro 33:dd598bb23ad1 73 bool UP_flag = false;
yabahiro 33:dd598bb23ad1 74 bool SW_flag = false;
yabahiro 33:dd598bb23ad1 75 bool Air_flag = false;
yabahiro 33:dd598bb23ad1 76 bool zyouge;
yabahiro 33:dd598bb23ad1 77 bool zyougedo;
yabahiro 33:dd598bb23ad1 78 bool dz1=true;
yabahiro 33:dd598bb23ad1 79 bool dz1i=false;
yabahiro 33:dd598bb23ad1 80 bool dz2=true;
yabahiro 33:dd598bb23ad1 81 bool dz2i=false;
yabahiro 33:dd598bb23ad1 82 bool dz3=true;
yabahiro 33:dd598bb23ad1 83 bool dz3i=false;
yabahiro 33:dd598bb23ad1 84 bool dz4=true;
yabahiro 33:dd598bb23ad1 85 bool dz4i=false;
yabahiro 33:dd598bb23ad1 86 bool zone;
yabahiro 33:dd598bb23ad1 87 bool through=false;
yabahiro 33:dd598bb23ad1 88 bool counts=false;
yabahiro 33:dd598bb23ad1 89 bool mtc=false;
yabahiro 33:dd598bb23ad1 90 bool mtc2 = false;
yabahiro 33:dd598bb23ad1 91 bool emcs=false;
yabahiro 33:dd598bb23ad1 92 bool kiri;
yabahiro 33:dd598bb23ad1 93
yabahiro 33:dd598bb23ad1 94 int g[8];
yabahiro 33:dd598bb23ad1 95 int Twsh;
yabahiro 38:40e7fdf3c694 96 int testmode =0;
yabahiro 33:dd598bb23ad1 97 int mode =0;
yabahiro 33:dd598bb23ad1 98 int cross=0;//十字数える用
yabahiro 33:dd598bb23ad1 99 int cros=0;
yabahiro 33:dd598bb23ad1 100 int countss=100000;//wait代替え
yabahiro 33:dd598bb23ad1 101
yabahiro 33:dd598bb23ad1 102 ///*********PWM調整用*********///
yabahiro 33:dd598bb23ad1 103 int fast =60;
yabahiro 33:dd598bb23ad1 104 int normal = 40;
yabahiro 33:dd598bb23ad1 105 int slow = 20;
yabahiro 33:dd598bb23ad1 106
t_yamamoto 0:669ef71cba68 107 #pragma endregion USER-DEFINED_VARIABLES_AND_PROTOTYPE
t_yamamoto 0:669ef71cba68 108
t_yamamoto 0:669ef71cba68 109 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 110 #if USE_PROCESS_NUM>0
t_yamamoto 0:669ef71cba68 111 static void Process0(void);
yabahiro 33:dd598bb23ad1 112 //手動モード
t_yamamoto 0:669ef71cba68 113 #endif
t_yamamoto 0:669ef71cba68 114 #if USE_PROCESS_NUM>1
t_yamamoto 0:669ef71cba68 115 static void Process1(void);
t_yamamoto 0:669ef71cba68 116 #endif
t_yamamoto 0:669ef71cba68 117 #if USE_PROCESS_NUM>2
t_yamamoto 0:669ef71cba68 118 static void Process2(void);
t_yamamoto 0:669ef71cba68 119 #endif
t_yamamoto 0:669ef71cba68 120 #if USE_PROCESS_NUM>3
t_yamamoto 0:669ef71cba68 121 static void Process3(void);
t_yamamoto 0:669ef71cba68 122 #endif
t_yamamoto 0:669ef71cba68 123 #if USE_PROCESS_NUM>4
t_yamamoto 0:669ef71cba68 124 static void Process4(void);
t_yamamoto 0:669ef71cba68 125 #endif
t_yamamoto 0:669ef71cba68 126 #if USE_PROCESS_NUM>5
t_yamamoto 0:669ef71cba68 127 static void Process5(void);
t_yamamoto 0:669ef71cba68 128 #endif
t_yamamoto 0:669ef71cba68 129 #if USE_PROCESS_NUM>6
t_yamamoto 0:669ef71cba68 130 static void Process6(void);
t_yamamoto 0:669ef71cba68 131 #endif
t_yamamoto 0:669ef71cba68 132 #if USE_PROCESS_NUM>7
t_yamamoto 0:669ef71cba68 133 static void Process7(void);
t_yamamoto 0:669ef71cba68 134 #endif
t_yamamoto 0:669ef71cba68 135 #if USE_PROCESS_NUM>8
t_yamamoto 0:669ef71cba68 136 static void Process8(void);
t_yamamoto 0:669ef71cba68 137 #endif
t_yamamoto 0:669ef71cba68 138 #if USE_PROCESS_NUM>9
t_yamamoto 0:669ef71cba68 139 static void Process9(void);
t_yamamoto 0:669ef71cba68 140 #endif
t_yamamoto 0:669ef71cba68 141 #endif
t_yamamoto 0:669ef71cba68 142
t_yamamoto 0:669ef71cba68 143 void SystemProcessInitialize()
t_yamamoto 0:669ef71cba68 144 {
Ryosei 27:dd9f27fce7d1 145 #pragma region USER-DEFINED_VARIABLE_INIT
Ryosei 27:dd9f27fce7d1 146 /*Replace here with the initialization code of your variables.*/
Ryosei 27:dd9f27fce7d1 147
Ryosei 27:dd9f27fce7d1 148 #pragma endregion USER-DEFINED_VARIABLE_INIT
Ryosei 27:dd9f27fce7d1 149
Ryosei 27:dd9f27fce7d1 150 lock = true;
Ryosei 27:dd9f27fce7d1 151 processChangeComp = true;
Ryosei 27:dd9f27fce7d1 152 current = DEFAULT_PROCESS;
t_yamamoto 0:669ef71cba68 153
Ryosei 27:dd9f27fce7d1 154 #ifdef USE_SUBPROCESS
Ryosei 27:dd9f27fce7d1 155 #if USE_PROCESS_NUM>0
Ryosei 27:dd9f27fce7d1 156 Process[0] = Process0;
Ryosei 27:dd9f27fce7d1 157 #endif
Ryosei 27:dd9f27fce7d1 158 #if USE_PROCESS_NUM>1
Ryosei 27:dd9f27fce7d1 159 Process[1] = Process1;
Ryosei 27:dd9f27fce7d1 160 #endif
Ryosei 27:dd9f27fce7d1 161 #if USE_PROCESS_NUM>2
Ryosei 27:dd9f27fce7d1 162 Process[2] = Process2;
Ryosei 27:dd9f27fce7d1 163 #endif
Ryosei 27:dd9f27fce7d1 164 #if USE_PROCESS_NUM>3
Ryosei 27:dd9f27fce7d1 165 Process[3] = Process3;
Ryosei 27:dd9f27fce7d1 166 #endif
Ryosei 27:dd9f27fce7d1 167 #if USE_PROCESS_NUM>4
Ryosei 27:dd9f27fce7d1 168 Process[4] = Process4;
Ryosei 27:dd9f27fce7d1 169 #endif
Ryosei 27:dd9f27fce7d1 170 #if USE_PROCESS_NUM>5
Ryosei 27:dd9f27fce7d1 171 Process[5] = Process5;
Ryosei 27:dd9f27fce7d1 172 #endif
Ryosei 27:dd9f27fce7d1 173 #if USE_PROCESS_NUM>6
Ryosei 27:dd9f27fce7d1 174 Process[6] = Process6;
Ryosei 27:dd9f27fce7d1 175 #endif
Ryosei 27:dd9f27fce7d1 176 #if USE_PROCESS_NUM>7
Ryosei 27:dd9f27fce7d1 177 Process[7] = Process7;
Ryosei 27:dd9f27fce7d1 178 #endif
Ryosei 27:dd9f27fce7d1 179 #if USE_PROCESS_NUM>8
Ryosei 27:dd9f27fce7d1 180 Process[8] = Process8;
Ryosei 27:dd9f27fce7d1 181 #endif
Ryosei 27:dd9f27fce7d1 182 #if USE_PROCESS_NUM>9
Ryosei 27:dd9f27fce7d1 183 Process[9] = Process9;
Ryosei 27:dd9f27fce7d1 184 #endif
Ryosei 27:dd9f27fce7d1 185 #endif
t_yamamoto 0:669ef71cba68 186 }
t_yamamoto 0:669ef71cba68 187
t_yamamoto 0:669ef71cba68 188 static void SystemProcessUpdate()
t_yamamoto 0:669ef71cba68 189 {
Ryosei 27:dd9f27fce7d1 190 #ifdef USE_SUBPROCESS
Ryosei 27:dd9f27fce7d1 191 if(controller->Button.HOME) lock = false;
Ryosei 27:dd9f27fce7d1 192
Ryosei 27:dd9f27fce7d1 193 if(controller->Button.START && processChangeComp) {
Ryosei 27:dd9f27fce7d1 194 current++;
Ryosei 27:dd9f27fce7d1 195 if (USE_PROCESS_NUM < current) current = USE_PROCESS_NUM;
Ryosei 27:dd9f27fce7d1 196 processChangeComp = false;
Ryosei 27:dd9f27fce7d1 197 } else if(controller->Button.SELECT && processChangeComp) {
Ryosei 27:dd9f27fce7d1 198 current--;
Ryosei 27:dd9f27fce7d1 199 if (current < 0) current = 0;
Ryosei 27:dd9f27fce7d1 200 processChangeComp = false;
Ryosei 27:dd9f27fce7d1 201 } else if(!controller->Button.SELECT && !controller->Button.START) processChangeComp = true;
Ryosei 27:dd9f27fce7d1 202 #endif
Ryosei 27:dd9f27fce7d1 203
Ryosei 27:dd9f27fce7d1 204 #ifdef USE_MOTOR
Ryosei 27:dd9f27fce7d1 205 ACTUATORHUB::MOTOR::Motor::Update(motor);
Ryosei 27:dd9f27fce7d1 206 #endif
Ryosei 27:dd9f27fce7d1 207
Ryosei 27:dd9f27fce7d1 208 #ifdef USE_SOLENOID
Ryosei 27:dd9f27fce7d1 209 ACTUATORHUB::SOLENOID::Solenoid::Update(solenoid);
Ryosei 27:dd9f27fce7d1 210 #endif
Ryosei 27:dd9f27fce7d1 211
Ryosei 27:dd9f27fce7d1 212 #ifdef USE_RS485
Ryosei 27:dd9f27fce7d1 213 ACTUATORHUB::ActuatorHub::Update();
Ryosei 27:dd9f27fce7d1 214 //LINEHUB::LineHub::Update();
Ryosei 27:dd9f27fce7d1 215 #endif
Ryosei 27:dd9f27fce7d1 216
Ryosei 27:dd9f27fce7d1 217 }
Ryosei 27:dd9f27fce7d1 218
yabahiro 39:784552c26163 219 int point1;
Ryosei 27:dd9f27fce7d1 220 void SystemProcess()
Ryosei 27:dd9f27fce7d1 221 {
Ryosei 27:dd9f27fce7d1 222 SystemProcessInitialize();
yabahiro 33:dd598bb23ad1 223
Ryosei 27:dd9f27fce7d1 224 while(1) {
yabahiro 39:784552c26163 225 //pc.printf("4:%d\n\r",g[4]);
yabahiro 33:dd598bb23ad1 226 if(EMC==0) {
yabahiro 33:dd598bb23ad1 227 fast=40;
yabahiro 33:dd598bb23ad1 228 normal=30;
yabahiro 33:dd598bb23ad1 229 slow=20;
yabahiro 33:dd598bb23ad1 230 cross=0;//十字数える用
yabahiro 33:dd598bb23ad1 231 cros=0;
yabahiro 33:dd598bb23ad1 232 countss=0;//wait代替え
yabahiro 33:dd598bb23ad1 233 UP_flag = false;
yabahiro 33:dd598bb23ad1 234 SW_flag = false;
yabahiro 33:dd598bb23ad1 235 Air_flag = false;
yabahiro 33:dd598bb23ad1 236 zyouge=false;
yabahiro 33:dd598bb23ad1 237 zyougedo=false;
yabahiro 33:dd598bb23ad1 238 dz1=true;
yabahiro 33:dd598bb23ad1 239 dz1i=false;
yabahiro 33:dd598bb23ad1 240 dz2=true;
yabahiro 33:dd598bb23ad1 241 dz2i=false;
yabahiro 33:dd598bb23ad1 242 dz3=true;
yabahiro 33:dd598bb23ad1 243 dz3i=false;
yabahiro 33:dd598bb23ad1 244 dz4=true;
yabahiro 33:dd598bb23ad1 245 dz4i=false;
yabahiro 33:dd598bb23ad1 246 through=false;
yabahiro 33:dd598bb23ad1 247 counts=false;
yabahiro 33:dd598bb23ad1 248 mtc=false;
yabahiro 33:dd598bb23ad1 249 mtc2 = false;
yabahiro 33:dd598bb23ad1 250 current = 0;
yabahiro 33:dd598bb23ad1 251 SystemProcessInitialize();
yabahiro 33:dd598bb23ad1 252 if(emcs==false) {
yabahiro 33:dd598bb23ad1 253 AllActuatorReset();
yabahiro 33:dd598bb23ad1 254 emcs=true;
yabahiro 33:dd598bb23ad1 255 }
yabahiro 33:dd598bb23ad1 256 } else {
yabahiro 33:dd598bb23ad1 257 emcs=false;
yabahiro 33:dd598bb23ad1 258 }
Ryosei 27:dd9f27fce7d1 259
yabahiro 33:dd598bb23ad1 260 if(mode==0) {
yabahiro 33:dd598bb23ad1 261 if(ZoneSW) {
kishibekairohan 35:33c6cdba5630 262 LED::LED::TapeledMode(1);
yabahiro 33:dd598bb23ad1 263 } else {
kishibekairohan 35:33c6cdba5630 264 LED::LED::TapeledMode(2);
yabahiro 33:dd598bb23ad1 265 }
yabahiro 33:dd598bb23ad1 266 }
yabahiro 33:dd598bb23ad1 267 for(int i = 0; i < 8; i++) {
yabahiro 33:dd598bb23ad1 268 g[i] = LineHub::GetPara(i);
yabahiro 33:dd598bb23ad1 269 }
yabahiro 33:dd598bb23ad1 270 if(ThSW) {
yabahiro 33:dd598bb23ad1 271 Twsh=1;
yabahiro 33:dd598bb23ad1 272 } else {
yabahiro 33:dd598bb23ad1 273 Twsh=2;
yabahiro 33:dd598bb23ad1 274 }
yabahiro 33:dd598bb23ad1 275
yabahiro 33:dd598bb23ad1 276 if(StertSW && start_flag == true) {
yabahiro 33:dd598bb23ad1 277 start_flag = false;
yabahiro 33:dd598bb23ad1 278 lock = false;
yabahiro 33:dd598bb23ad1 279 if(ZoneSW) {
yabahiro 33:dd598bb23ad1 280 countss=0;
yabahiro 33:dd598bb23ad1 281 mode=1;
yabahiro 39:784552c26163 282 current = 4;//10GATU30変更した
yabahiro 33:dd598bb23ad1 283
yabahiro 33:dd598bb23ad1 284 } else {
kishibekairohan 34:2fce61e3ebc4 285 countss = 0;
yabahiro 33:dd598bb23ad1 286 mode=1;
kishibekairohan 34:2fce61e3ebc4 287 current = 2;
yabahiro 33:dd598bb23ad1 288 }
yabahiro 33:dd598bb23ad1 289 }
yabahiro 33:dd598bb23ad1 290 if(DWSW||DOSW) {
yabahiro 33:dd598bb23ad1 291 if(DWSW) {
yabahiro 33:dd598bb23ad1 292 zyouge=true;
yabahiro 33:dd598bb23ad1 293 }
yabahiro 33:dd598bb23ad1 294 if(DOSW) {
yabahiro 33:dd598bb23ad1 295 if(DOLS) {
yabahiro 33:dd598bb23ad1 296 motor[MOTOR_0].pwm = 100;
yabahiro 33:dd598bb23ad1 297 motor[MOTOR_0].dir = BRAKE;
yabahiro 33:dd598bb23ad1 298 } else {
yabahiro 38:40e7fdf3c694 299 motor[MOTOR_0].pwm = 200;
yabahiro 33:dd598bb23ad1 300 motor[MOTOR_0].dir = BACK;
yabahiro 33:dd598bb23ad1 301 }
yabahiro 33:dd598bb23ad1 302 }
yabahiro 33:dd598bb23ad1 303 } else if(zyouge==false) {
yabahiro 33:dd598bb23ad1 304 motor[MOTOR_0].pwm = 100;
yabahiro 33:dd598bb23ad1 305 motor[MOTOR_0].dir = BRAKE;
yabahiro 33:dd598bb23ad1 306 }
yabahiro 33:dd598bb23ad1 307 if(zyouge) {
yabahiro 33:dd598bb23ad1 308 if(Twsh==1) {
yabahiro 38:40e7fdf3c694 309 motor[MOTOR_0].pwm = 255;
yabahiro 33:dd598bb23ad1 310 motor[MOTOR_0].dir = FOR;
yabahiro 33:dd598bb23ad1 311 if(UPLS) {
yabahiro 33:dd598bb23ad1 312 motor[MOTOR_0].pwm = 100;
yabahiro 33:dd598bb23ad1 313 motor[MOTOR_0].dir = BRAKE;
yabahiro 33:dd598bb23ad1 314 zyouge=false;
yabahiro 33:dd598bb23ad1 315 }
yabahiro 33:dd598bb23ad1 316 }
yabahiro 33:dd598bb23ad1 317 if(Twsh==2) {
yabahiro 33:dd598bb23ad1 318 motor[MOTOR_0].pwm = 245;
yabahiro 33:dd598bb23ad1 319 motor[MOTOR_0].dir = FOR;
yabahiro 33:dd598bb23ad1 320 if(UPLS2) {
yabahiro 33:dd598bb23ad1 321 motor[MOTOR_0].pwm = 100;
yabahiro 33:dd598bb23ad1 322 motor[MOTOR_0].dir = BRAKE;
yabahiro 33:dd598bb23ad1 323 zyouge=false;
yabahiro 33:dd598bb23ad1 324 }
yabahiro 33:dd598bb23ad1 325 }
yabahiro 33:dd598bb23ad1 326 }
yabahiro 33:dd598bb23ad1 327 if(AIRSW) {
yabahiro 33:dd598bb23ad1 328 if(SW_flag==false) {
yabahiro 33:dd598bb23ad1 329 if(Air_flag==false) {
yabahiro 33:dd598bb23ad1 330 solenoid.solenoid3 = SOLENOID_ON;
yabahiro 33:dd598bb23ad1 331 Air_flag=true;
yabahiro 33:dd598bb23ad1 332 SW_flag=true;
yabahiro 33:dd598bb23ad1 333 } else {
yabahiro 33:dd598bb23ad1 334 solenoid.solenoid3 = SOLENOID_OFF;
yabahiro 33:dd598bb23ad1 335 Air_flag=false;
yabahiro 33:dd598bb23ad1 336 SW_flag=true;
yabahiro 33:dd598bb23ad1 337 }
yabahiro 33:dd598bb23ad1 338 }
yabahiro 33:dd598bb23ad1 339 } else {
yabahiro 33:dd598bb23ad1 340 if(SW_flag==true) {
yabahiro 33:dd598bb23ad1 341 countss++;
yabahiro 33:dd598bb23ad1 342 if(countss>=2000) {
yabahiro 33:dd598bb23ad1 343 SW_flag=false;
yabahiro 33:dd598bb23ad1 344 countss=0;
yabahiro 33:dd598bb23ad1 345 }
yabahiro 33:dd598bb23ad1 346 }
yabahiro 33:dd598bb23ad1 347 }
yabahiro 33:dd598bb23ad1 348
yabahiro 33:dd598bb23ad1 349
yabahiro 33:dd598bb23ad1 350 #ifdef USE_MU
Ryosei 27:dd9f27fce7d1 351 controller = CONTROLLER::Controller::GetData();
yabahiro 33:dd598bb23ad1 352 #endif
yabahiro 33:dd598bb23ad1 353
Ryosei 27:dd9f27fce7d1 354
yabahiro 33:dd598bb23ad1 355 #ifdef USE_ERRORCHECK
yabahiro 38:40e7fdf3c694 356 if(SAFTY::ErrorCheck::Check() & SAFTY::Error::ControllerLost & start_flag) {
Ryosei 27:dd9f27fce7d1 357 CONTROLLER::Controller::DataReset();
Ryosei 27:dd9f27fce7d1 358 AllActuatorReset();
Ryosei 27:dd9f27fce7d1 359 lock = true;
Ryosei 27:dd9f27fce7d1 360 } else
yabahiro 38:40e7fdf3c694 361
yabahiro 33:dd598bb23ad1 362 #endif
Ryosei 27:dd9f27fce7d1 363 {
Ryosei 27:dd9f27fce7d1 364
yabahiro 33:dd598bb23ad1 365 #ifdef USE_SUBPROCESS
Ryosei 27:dd9f27fce7d1 366 if(!lock) {
Ryosei 27:dd9f27fce7d1 367 Process[current]();
Ryosei 27:dd9f27fce7d1 368 } else
yabahiro 33:dd598bb23ad1 369 #endif
Ryosei 27:dd9f27fce7d1 370 {
Ryosei 27:dd9f27fce7d1 371 //ロック時の処理
Ryosei 27:dd9f27fce7d1 372 }
Ryosei 27:dd9f27fce7d1 373 }
yabahiro 33:dd598bb23ad1 374
Ryosei 27:dd9f27fce7d1 375 SystemProcessUpdate();
Ryosei 27:dd9f27fce7d1 376 }
t_yamamoto 0:669ef71cba68 377 }
t_yamamoto 0:669ef71cba68 378
kishibekairohan 2:c015739085d3 379
kishibekairohan 2:c015739085d3 380
kishibekairohan 2:c015739085d3 381
t_yamamoto 0:669ef71cba68 382 #pragma region PROCESS
t_yamamoto 0:669ef71cba68 383 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 384 #if USE_PROCESS_NUM>0
Ryosei 27:dd9f27fce7d1 385 static void Process0()
Ryosei 27:dd9f27fce7d1 386 {
yabahiro 33:dd598bb23ad1 387
yabahiro 33:dd598bb23ad1 388 //AllActuatorReset();
t_yamamoto 0:669ef71cba68 389 }
t_yamamoto 0:669ef71cba68 390 #endif
t_yamamoto 0:669ef71cba68 391
t_yamamoto 0:669ef71cba68 392 #if USE_PROCESS_NUM>1
kishibekairohan 16:3f2c2d89372b 393 static void Process1()
t_yamamoto 0:669ef71cba68 394 {
kishibekairohan 35:33c6cdba5630 395 LED::LED::TapeledMode(6);
yabahiro 33:dd598bb23ad1 396 start_flag = true;
yabahiro 33:dd598bb23ad1 397 mtc=false;
yabahiro 33:dd598bb23ad1 398 mtc2 = false;
yabahiro 33:dd598bb23ad1 399 mode=1;
yabahiro 33:dd598bb23ad1 400 cross=0;
yabahiro 33:dd598bb23ad1 401 Twsh=1;
yabahiro 33:dd598bb23ad1 402 motor[TIRE_FR].dir = SetStatus(-omni[controller->AnalogL.Y][14-controller->AnalogL.X] + curve[controller->AnalogR.X]);
yabahiro 33:dd598bb23ad1 403 motor[TIRE_FL].dir = SetStatus(omni[controller->AnalogL.Y][controller->AnalogL.X] + curve[controller->AnalogR.X]);
yabahiro 33:dd598bb23ad1 404 motor[TIRE_BR].dir = SetStatus(-omni[14-controller->AnalogL.X][14-controller->AnalogL.Y] + curve[controller->AnalogR.X]);
yabahiro 33:dd598bb23ad1 405 motor[TIRE_BL].dir = SetStatus(omni[controller->AnalogL.X][14-controller->AnalogL.Y] + curve[controller->AnalogR.X]);
Ryosei 27:dd9f27fce7d1 406
yabahiro 33:dd598bb23ad1 407 motor[TIRE_FR].pwm = Setpwm(omni[controller->AnalogL.Y][14-controller->AnalogL.X]+ curve[controller->AnalogR.X])*0.2;
yabahiro 33:dd598bb23ad1 408 motor[TIRE_FL].pwm = Setpwm(omni[controller->AnalogL.Y][controller->AnalogL.X]+ curve[controller->AnalogR.X])*0.2;
yabahiro 33:dd598bb23ad1 409 motor[TIRE_BR].pwm = Setpwm(omni[14-controller->AnalogL.X][14-controller->AnalogL.Y]+ curve[controller->AnalogR.X])*0.2;
yabahiro 33:dd598bb23ad1 410 motor[TIRE_BL].pwm = Setpwm(omni[controller->AnalogL.X][14-controller->AnalogL.Y]+ curve[controller->AnalogR.X])*0.2;
yabahiro 33:dd598bb23ad1 411
yabahiro 33:dd598bb23ad1 412 if(controller->Button.UP||controller->Button.DOWN) {
yabahiro 33:dd598bb23ad1 413
yabahiro 33:dd598bb23ad1 414 if(controller->Button.UP) {
yabahiro 33:dd598bb23ad1 415 motor[MOTOR_0].pwm =200;
yabahiro 33:dd598bb23ad1 416 motor[MOTOR_0].dir = FOR;
yabahiro 33:dd598bb23ad1 417 if(UPLS) {
yabahiro 33:dd598bb23ad1 418 motor[MOTOR_0].pwm = 0;
yabahiro 33:dd598bb23ad1 419 motor[MOTOR_0].dir = BRAKE;
yabahiro 33:dd598bb23ad1 420 }
yabahiro 33:dd598bb23ad1 421 }
yabahiro 33:dd598bb23ad1 422 if(controller->Button.DOWN) {
yabahiro 33:dd598bb23ad1 423 motor[MOTOR_0].pwm = 50;
yabahiro 33:dd598bb23ad1 424 motor[MOTOR_0].dir = BACK;
yabahiro 33:dd598bb23ad1 425 }
yabahiro 33:dd598bb23ad1 426 } else {
yabahiro 33:dd598bb23ad1 427 motor[MOTOR_0].pwm = 0;
yabahiro 33:dd598bb23ad1 428 motor[MOTOR_0].dir = BRAKE;
yabahiro 33:dd598bb23ad1 429 }
yabahiro 33:dd598bb23ad1 430
yabahiro 33:dd598bb23ad1 431 if(controller->Button.Y) {
yabahiro 33:dd598bb23ad1 432 if(dz2==true) {
yabahiro 33:dd598bb23ad1 433 if(dz2i==false) {
yabahiro 33:dd598bb23ad1 434 solenoid.solenoid2 = SOLENOID_ON;
yabahiro 33:dd598bb23ad1 435 dz2i=true;
yabahiro 33:dd598bb23ad1 436 } else {
yabahiro 33:dd598bb23ad1 437 solenoid.solenoid2 = SOLENOID_OFF;
yabahiro 33:dd598bb23ad1 438 dz2i=false;
yabahiro 33:dd598bb23ad1 439 }
yabahiro 33:dd598bb23ad1 440 dz2=false;
yabahiro 33:dd598bb23ad1 441 }
yabahiro 33:dd598bb23ad1 442 } else {
yabahiro 33:dd598bb23ad1 443 dz2=true;
yabahiro 33:dd598bb23ad1 444 }
yabahiro 33:dd598bb23ad1 445
yabahiro 33:dd598bb23ad1 446 if(controller->Button.A) {
yabahiro 33:dd598bb23ad1 447 if(dz3==true) {
yabahiro 33:dd598bb23ad1 448 if(dz3i==false) {
kishibekairohan 37:e77816810627 449 solenoid.solenoid3 = SOLENOID_ON;
yabahiro 33:dd598bb23ad1 450 dz3i=true;
yabahiro 33:dd598bb23ad1 451 } else {
yabahiro 33:dd598bb23ad1 452 solenoid.solenoid3 = SOLENOID_OFF;
yabahiro 33:dd598bb23ad1 453 dz3i=false;
yabahiro 33:dd598bb23ad1 454 }
yabahiro 33:dd598bb23ad1 455 dz3=false;
yabahiro 33:dd598bb23ad1 456 }
yabahiro 33:dd598bb23ad1 457 } else {
yabahiro 33:dd598bb23ad1 458 dz3=true;
yabahiro 33:dd598bb23ad1 459 }
yabahiro 33:dd598bb23ad1 460
yabahiro 33:dd598bb23ad1 461 if(controller->Button.B) {
yabahiro 33:dd598bb23ad1 462 if(dz4==true) {
yabahiro 33:dd598bb23ad1 463 if(dz4i==false) {
yabahiro 38:40e7fdf3c694 464 solenoid.solenoid4 = SOLENOID_ON;
yabahiro 33:dd598bb23ad1 465 dz4i=true;
yabahiro 33:dd598bb23ad1 466 } else {
yabahiro 38:40e7fdf3c694 467 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 33:dd598bb23ad1 468 dz4i=false;
yabahiro 33:dd598bb23ad1 469 }
yabahiro 33:dd598bb23ad1 470 dz4=false;
yabahiro 33:dd598bb23ad1 471 }
yabahiro 33:dd598bb23ad1 472 } else {
yabahiro 33:dd598bb23ad1 473 dz4=true;
yabahiro 33:dd598bb23ad1 474 }
t_yamamoto 0:669ef71cba68 475 }
t_yamamoto 0:669ef71cba68 476 #endif
t_yamamoto 0:669ef71cba68 477
t_yamamoto 0:669ef71cba68 478 #if USE_PROCESS_NUM>2
kishibekairohan 16:3f2c2d89372b 479 static void Process2()
Ryosei 27:dd9f27fce7d1 480 {
yabahiro 33:dd598bb23ad1 481 //Oh So 青ゾーン
yabahiro 39:784552c26163 482 LED::LED::TapeledMode(2);
yabahiro 33:dd598bb23ad1 483 countss++;
yabahiro 33:dd598bb23ad1 484 if(mode==1) {//スタートゾーンから白線検知
yabahiro 33:dd598bb23ad1 485 fast=40;
yabahiro 33:dd598bb23ad1 486 normal=30;
yabahiro 33:dd598bb23ad1 487 slow=20;
yabahiro 39:784552c26163 488 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 489 motor[TIRE_FR].dir = FOR;
yabahiro 39:784552c26163 490 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 491 motor[TIRE_FL].dir = BACK;
yabahiro 39:784552c26163 492 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 493 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 494 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 495 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 496 if(g[2]==0&&countss>=100000) {
yabahiro 33:dd598bb23ad1 497 countss=100000;
yabahiro 33:dd598bb23ad1 498 cross=0;
yabahiro 33:dd598bb23ad1 499 mode=3;
yabahiro 33:dd598bb23ad1 500 }
yabahiro 33:dd598bb23ad1 501 } else if(mode==3) { //横ライントレースから縦ライントレースへ
yabahiro 33:dd598bb23ad1 502 motor[TIRE_FR].pwm = 30;
yabahiro 33:dd598bb23ad1 503 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 504 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 505 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 506 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 507 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 508 motor[TIRE_BL].pwm = 30;
yabahiro 33:dd598bb23ad1 509 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 510 if(g[1]==0) {
yabahiro 33:dd598bb23ad1 511 mode=10;
yabahiro 33:dd598bb23ad1 512 countss=100000;
yabahiro 33:dd598bb23ad1 513 }
yabahiro 33:dd598bb23ad1 514 } else if(mode==10) { //縦ライントレース
yabahiro 33:dd598bb23ad1 515 switch(g[1]) {
yabahiro 33:dd598bb23ad1 516 case 98:
yabahiro 33:dd598bb23ad1 517 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 518 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 519 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 520 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 521 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 522 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 523 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 524 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 525 mtc=true;
yabahiro 39:784552c26163 526 if(countss>80000) {
yabahiro 33:dd598bb23ad1 527 cross++;
yabahiro 33:dd598bb23ad1 528 countss=0;
yabahiro 33:dd598bb23ad1 529 }
yabahiro 39:784552c26163 530 if(cross==3) {
yabahiro 33:dd598bb23ad1 531 mode=11;
yabahiro 33:dd598bb23ad1 532 countss=0;
yabahiro 33:dd598bb23ad1 533 cross=0;
yabahiro 33:dd598bb23ad1 534 }
yabahiro 33:dd598bb23ad1 535 break;
yabahiro 33:dd598bb23ad1 536 case 0:
yabahiro 33:dd598bb23ad1 537 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 538 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 539 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 540 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 541 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 542 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 543 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 544 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 545 mtc=true;
yabahiro 33:dd598bb23ad1 546 break;
yabahiro 33:dd598bb23ad1 547 case 255:
yabahiro 33:dd598bb23ad1 548 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 549 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 550 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 551 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 552 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 553 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 554 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 555 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 556 mtc=true;
yabahiro 33:dd598bb23ad1 557 break;
yabahiro 33:dd598bb23ad1 558 case 253:
yabahiro 33:dd598bb23ad1 559 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 560 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 561 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 562 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 563 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 564 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 565 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 566 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 567 mtc=true;
yabahiro 33:dd598bb23ad1 568 break;
yabahiro 33:dd598bb23ad1 569 case 254:
yabahiro 33:dd598bb23ad1 570 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 571 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 572 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 573 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 574 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 575 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 576 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 577 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 578 mtc=true;
yabahiro 33:dd598bb23ad1 579 break;
yabahiro 33:dd598bb23ad1 580 case 1:
yabahiro 33:dd598bb23ad1 581 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 582 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 583 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 584 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 585 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 586 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 587 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 588 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 589 mtc=true;
yabahiro 33:dd598bb23ad1 590 break;
yabahiro 33:dd598bb23ad1 591 case 3:
yabahiro 33:dd598bb23ad1 592 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 593 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 594 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 595 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 596 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 597 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 598 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 599 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 600 mtc=true;
yabahiro 33:dd598bb23ad1 601 break;
yabahiro 33:dd598bb23ad1 602 case 2:
yabahiro 33:dd598bb23ad1 603 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 604 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 605 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 606 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 607 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 608 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 609 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 610 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 611 mtc=true;
yabahiro 33:dd598bb23ad1 612 break;
yabahiro 33:dd598bb23ad1 613 }
yabahiro 33:dd598bb23ad1 614 if(g[0]!=98&&mtc==true) {
yabahiro 33:dd598bb23ad1 615 switch(g[0]) {
yabahiro 33:dd598bb23ad1 616 case 0:
yabahiro 33:dd598bb23ad1 617 mtc=false;
yabahiro 33:dd598bb23ad1 618 break;
yabahiro 33:dd598bb23ad1 619 case 255:
yabahiro 33:dd598bb23ad1 620 motor[TIRE_FL].pwm += 5;
yabahiro 33:dd598bb23ad1 621 mtc=false;
yabahiro 33:dd598bb23ad1 622 break;
yabahiro 33:dd598bb23ad1 623 case 253:
yabahiro 33:dd598bb23ad1 624 motor[TIRE_FL].pwm += 10;
yabahiro 33:dd598bb23ad1 625 mtc=false;
yabahiro 33:dd598bb23ad1 626 break;
yabahiro 33:dd598bb23ad1 627 case 254:
yabahiro 33:dd598bb23ad1 628 motor[TIRE_FL].pwm += 20;
yabahiro 33:dd598bb23ad1 629 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 630 mtc=false;
yabahiro 33:dd598bb23ad1 631 break;
yabahiro 33:dd598bb23ad1 632 case 1:
yabahiro 33:dd598bb23ad1 633 motor[TIRE_FR].pwm += 5;
yabahiro 33:dd598bb23ad1 634 mtc=false;
yabahiro 33:dd598bb23ad1 635 break;
yabahiro 33:dd598bb23ad1 636 case 3:
yabahiro 33:dd598bb23ad1 637 motor[TIRE_FR].pwm += 10;
yabahiro 33:dd598bb23ad1 638 mtc=false;
yabahiro 33:dd598bb23ad1 639 break;
yabahiro 33:dd598bb23ad1 640 case 2:
yabahiro 33:dd598bb23ad1 641 motor[TIRE_FR].pwm += 20;
yabahiro 33:dd598bb23ad1 642 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 643 mtc=false;
yabahiro 33:dd598bb23ad1 644 break;
yabahiro 33:dd598bb23ad1 645 }
yabahiro 33:dd598bb23ad1 646 }
yabahiro 33:dd598bb23ad1 647 } else if(mode==11) {
yabahiro 33:dd598bb23ad1 648 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 649 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 650 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 651 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 652 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 653 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 654 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 655 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 656 if(g[2]==0) {
yabahiro 33:dd598bb23ad1 657 countss=0;
yabahiro 33:dd598bb23ad1 658 cross=0;
yabahiro 33:dd598bb23ad1 659 mode=20;
yabahiro 33:dd598bb23ad1 660 }
yabahiro 33:dd598bb23ad1 661 } else if(mode==20) {
yabahiro 39:784552c26163 662 solenoid.solenoid4= SOLENOID_ON;
yabahiro 33:dd598bb23ad1 663 switch(g[2]) {
yabahiro 33:dd598bb23ad1 664 case 98:
yabahiro 33:dd598bb23ad1 665 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 666 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 667 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 668 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 669 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 670 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 671 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 672 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 673 if(countss>30000) {
yabahiro 33:dd598bb23ad1 674 cross++;
yabahiro 33:dd598bb23ad1 675 countss=0;
yabahiro 33:dd598bb23ad1 676 }
yabahiro 33:dd598bb23ad1 677 mtc2=true;
yabahiro 39:784552c26163 678 if(cross==1) {
yabahiro 39:784552c26163 679 fast=30;
yabahiro 39:784552c26163 680 normal=20;
yabahiro 33:dd598bb23ad1 681 slow=20;
yabahiro 33:dd598bb23ad1 682 }
yabahiro 39:784552c26163 683 if(YELLOW) {
yabahiro 39:784552c26163 684 if(cross==2) {
yabahiro 39:784552c26163 685 mode=21;
yabahiro 39:784552c26163 686 countss=0;
yabahiro 39:784552c26163 687 cross=0;
yabahiro 39:784552c26163 688 }
yabahiro 39:784552c26163 689 } else {
yabahiro 39:784552c26163 690 if(cross==1) {
yabahiro 39:784552c26163 691 mode=21;
yabahiro 39:784552c26163 692 countss=0;
yabahiro 39:784552c26163 693 cross=0;
yabahiro 39:784552c26163 694 }
yabahiro 39:784552c26163 695 }
yabahiro 33:dd598bb23ad1 696 break;
yabahiro 33:dd598bb23ad1 697 case 0:
yabahiro 33:dd598bb23ad1 698 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 699 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 700 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 701 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 702 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 703 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 704 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 705 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 706 mtc2=true;
yabahiro 33:dd598bb23ad1 707 break;
yabahiro 33:dd598bb23ad1 708 case 255:
yabahiro 33:dd598bb23ad1 709 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 710 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 711 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 712 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 713 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 714 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 715 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 716 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 717 mtc2=true;
yabahiro 33:dd598bb23ad1 718 break;
yabahiro 33:dd598bb23ad1 719 case 253:
yabahiro 33:dd598bb23ad1 720 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 721 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 722 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 723 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 724 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 725 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 726 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 727 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 728 mtc2=true;
yabahiro 33:dd598bb23ad1 729 break;
yabahiro 33:dd598bb23ad1 730 case 254:
yabahiro 33:dd598bb23ad1 731 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 732 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 733 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 734 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 735 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 736 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 737 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 738 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 739 mtc2=true;
yabahiro 33:dd598bb23ad1 740 break;
yabahiro 33:dd598bb23ad1 741 case 1:
yabahiro 33:dd598bb23ad1 742 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 743 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 744 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 745 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 746 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 747 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 748 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 749 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 750 mtc2=true;
yabahiro 33:dd598bb23ad1 751 break;
yabahiro 33:dd598bb23ad1 752 case 3:
yabahiro 33:dd598bb23ad1 753 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 754 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 755 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 756 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 757 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 758 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 759 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 760 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 761 mtc2=true;
yabahiro 33:dd598bb23ad1 762 break;
yabahiro 33:dd598bb23ad1 763 case 2:
yabahiro 33:dd598bb23ad1 764 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 765 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 766 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 767 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 768 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 769 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 770 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 771 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 772 mtc2=true;
yabahiro 33:dd598bb23ad1 773 break;
yabahiro 33:dd598bb23ad1 774 }
yabahiro 33:dd598bb23ad1 775 if(g[2]!=98&&mtc2==true) {
yabahiro 33:dd598bb23ad1 776 switch(g[3]) {
yabahiro 33:dd598bb23ad1 777 case 0:
yabahiro 33:dd598bb23ad1 778 mtc2=false;
yabahiro 33:dd598bb23ad1 779 break;
yabahiro 33:dd598bb23ad1 780 case 255:
yabahiro 33:dd598bb23ad1 781 motor[TIRE_BL].pwm += 5;
yabahiro 33:dd598bb23ad1 782 mtc2=false;
yabahiro 33:dd598bb23ad1 783 break;
yabahiro 33:dd598bb23ad1 784 case 253:
yabahiro 33:dd598bb23ad1 785 motor[TIRE_BL].pwm += 10;
yabahiro 33:dd598bb23ad1 786 mtc2=false;
yabahiro 33:dd598bb23ad1 787 break;
yabahiro 33:dd598bb23ad1 788 case 254:
yabahiro 33:dd598bb23ad1 789 motor[TIRE_BL].pwm += 20;
yabahiro 33:dd598bb23ad1 790 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 791 mtc2=false;
yabahiro 33:dd598bb23ad1 792 break;
yabahiro 33:dd598bb23ad1 793 case 1:
yabahiro 33:dd598bb23ad1 794 motor[TIRE_FL].pwm += 5;
yabahiro 33:dd598bb23ad1 795 mtc2=false;
yabahiro 33:dd598bb23ad1 796 break;
yabahiro 33:dd598bb23ad1 797 case 3:
yabahiro 33:dd598bb23ad1 798 motor[TIRE_FL].pwm += 10;
yabahiro 33:dd598bb23ad1 799 mtc2=false;
yabahiro 33:dd598bb23ad1 800 break;
yabahiro 33:dd598bb23ad1 801 case 2:
yabahiro 33:dd598bb23ad1 802 motor[TIRE_FL].pwm += 20;
yabahiro 33:dd598bb23ad1 803 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 804 mtc2=false;
yabahiro 33:dd598bb23ad1 805 break;
yabahiro 33:dd598bb23ad1 806 }
yabahiro 33:dd598bb23ad1 807 }
yabahiro 33:dd598bb23ad1 808 }
yabahiro 39:784552c26163 809 if(YELLOW) {
yabahiro 39:784552c26163 810 if(mode==21) {
yabahiro 33:dd598bb23ad1 811 motor[TIRE_FR].pwm = 20;
yabahiro 33:dd598bb23ad1 812 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 813 motor[TIRE_FL].pwm = 20;
yabahiro 33:dd598bb23ad1 814 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 815 motor[TIRE_BR].pwm = 20;
yabahiro 33:dd598bb23ad1 816 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 817 motor[TIRE_BL].pwm = 20;
yabahiro 33:dd598bb23ad1 818 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 819 if(g[3]==98&&countss>=10000) {
yabahiro 39:784552c26163 820 mode=22;
yabahiro 33:dd598bb23ad1 821 countss=0;
yabahiro 39:784552c26163 822 fast=60;
yabahiro 39:784552c26163 823 normal=40;
yabahiro 39:784552c26163 824 slow=20;
yabahiro 39:784552c26163 825 }
yabahiro 39:784552c26163 826 } else if(mode==22) {
yabahiro 39:784552c26163 827 if(g[4]==3||g[4]==2) {
yabahiro 39:784552c26163 828 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 829 motor[TIRE_FR].dir = FOR;
yabahiro 39:784552c26163 830 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 831 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 832 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 833 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 834 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 835 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 836 }
yabahiro 39:784552c26163 837 if(g[4]==253||g[4]==254) {
yabahiro 39:784552c26163 838 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 839 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 840 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 841 motor[TIRE_FL].dir = BACK;
yabahiro 39:784552c26163 842 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 843 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 844 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 845 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 846 }
yabahiro 39:784552c26163 847 switch(g[2]) {
yabahiro 39:784552c26163 848 case 0:
yabahiro 39:784552c26163 849 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 850 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 851 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 852 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 853 break;
yabahiro 39:784552c26163 854 case 255:
yabahiro 39:784552c26163 855 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 856 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 857 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 858 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 859 break;
yabahiro 39:784552c26163 860 case 253:
yabahiro 39:784552c26163 861 motor[TIRE_FR].pwm = 40;
yabahiro 39:784552c26163 862 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 863 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 864 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 865 break;
yabahiro 39:784552c26163 866 case 254:
yabahiro 39:784552c26163 867 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 868 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 869 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 870 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 871 break;
yabahiro 39:784552c26163 872 case 1:
yabahiro 39:784552c26163 873 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 874 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 875 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 876 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 877 break;
yabahiro 39:784552c26163 878 case 3:
yabahiro 39:784552c26163 879 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 880 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 881 motor[TIRE_BR].pwm = 40;
yabahiro 39:784552c26163 882 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 883 break;
yabahiro 39:784552c26163 884 case 2:
yabahiro 39:784552c26163 885 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 886 motor[TIRE_FR].dir = FOR;
yabahiro 39:784552c26163 887 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 888 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 889 break;
yabahiro 39:784552c26163 890 }
yabahiro 39:784552c26163 891 switch(g[3]) {
yabahiro 39:784552c26163 892 case 0:
yabahiro 39:784552c26163 893 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 894 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 895 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 896 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 897 break;
yabahiro 39:784552c26163 898 case 255:
yabahiro 39:784552c26163 899 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 900 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 901 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 902 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 903 case 253:
yabahiro 39:784552c26163 904 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 905 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 906 motor[TIRE_BL].pwm = 40;
yabahiro 39:784552c26163 907 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 908 break;
yabahiro 39:784552c26163 909 case 254:
yabahiro 39:784552c26163 910 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 911 motor[TIRE_FL].dir = BACK;
yabahiro 39:784552c26163 912 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 913 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 914 break;
yabahiro 39:784552c26163 915 case 1:
yabahiro 39:784552c26163 916 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 917 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 918 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 919 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 920 break;
yabahiro 39:784552c26163 921 case 3:
yabahiro 39:784552c26163 922 motor[TIRE_FL].pwm = 40;
yabahiro 39:784552c26163 923 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 924 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 925 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 926 break;
yabahiro 39:784552c26163 927 case 2:
yabahiro 39:784552c26163 928 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 929 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 930 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 931 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 932 break;
yabahiro 39:784552c26163 933 }
yabahiro 39:784552c26163 934 if(g[3]==0&&g[2]==0) {
yabahiro 39:784552c26163 935 mode=23;
yabahiro 33:dd598bb23ad1 936 countss=0;
yabahiro 33:dd598bb23ad1 937 }
yabahiro 39:784552c26163 938 } else if(mode==23) {
yabahiro 39:784552c26163 939 switch(g[4]) {
yabahiro 39:784552c26163 940 case 98:
yabahiro 39:784552c26163 941 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 942 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 943 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 944 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 945 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 946 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 947 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 948 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 949 break;
yabahiro 39:784552c26163 950 case 99:
yabahiro 39:784552c26163 951 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 952 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 953 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 954 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 955 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 956 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 957 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 958 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 959 break;
yabahiro 39:784552c26163 960 case 0:
yabahiro 39:784552c26163 961 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 962 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 963 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 964 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 965 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 966 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 967 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 968 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 969 break;
yabahiro 39:784552c26163 970 case 255:
yabahiro 39:784552c26163 971 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 972 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 973 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 974 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 975 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 976 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 977 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 978 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 979 break;
yabahiro 39:784552c26163 980 case 253:
yabahiro 39:784552c26163 981 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 982 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 983 motor[TIRE_FL].pwm = slow;
yabahiro 39:784552c26163 984 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 985 motor[TIRE_BR].pwm = slow;
yabahiro 39:784552c26163 986 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 987 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 988 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 989 break;
yabahiro 39:784552c26163 990 case 254:
yabahiro 39:784552c26163 991 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 992 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 993 motor[TIRE_FL].pwm = normal;
yabahiro 39:784552c26163 994 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 995 motor[TIRE_BR].pwm = normal;
yabahiro 39:784552c26163 996 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 997 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 998 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 999 break;
yabahiro 39:784552c26163 1000 case 1:
yabahiro 39:784552c26163 1001 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1002 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1003 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1004 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1005 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1006 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1007 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1008 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1009 break;
yabahiro 39:784552c26163 1010 case 3:
yabahiro 39:784552c26163 1011 motor[TIRE_FR].pwm = slow;
yabahiro 39:784552c26163 1012 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1013 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1014 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1015 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1016 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1017 motor[TIRE_BL].pwm = slow-5;
yabahiro 39:784552c26163 1018 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1019 break;
yabahiro 39:784552c26163 1020 case 2:
yabahiro 39:784552c26163 1021 motor[TIRE_FR].pwm = normal;
yabahiro 39:784552c26163 1022 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1023 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1024 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1025 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1026 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1027 motor[TIRE_BL].pwm = normal-5;
yabahiro 39:784552c26163 1028 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1029 break;
yabahiro 39:784552c26163 1030 }
yabahiro 39:784552c26163 1031 if(DOLS==true||UPLS==true) {
yabahiro 39:784552c26163 1032 motor[MOTOR_0].pwm = 200;
yabahiro 39:784552c26163 1033 motor[MOTOR_0].dir = BRAKE;
yabahiro 39:784552c26163 1034 }
yabahiro 39:784552c26163 1035 if(g[0]==98) {
yabahiro 39:784552c26163 1036 fast=30;
yabahiro 39:784552c26163 1037 normal=20;
yabahiro 39:784552c26163 1038 slow=20;
yabahiro 39:784552c26163 1039 if(DOLS==true||UPLS==true) {
yabahiro 39:784552c26163 1040 motor[MOTOR_0].pwm = 200;
yabahiro 39:784552c26163 1041 motor[MOTOR_0].dir = BRAKE;
yabahiro 39:784552c26163 1042 } else {
yabahiro 39:784552c26163 1043 motor[MOTOR_0].pwm = 100;
yabahiro 39:784552c26163 1044 motor[MOTOR_0].dir = BACK;
yabahiro 39:784552c26163 1045 }
yabahiro 39:784552c26163 1046 }
yabahiro 39:784552c26163 1047 if(g[2]==254&&countss>=100000) {
yabahiro 39:784552c26163 1048 mode=24;
yabahiro 39:784552c26163 1049 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 33:dd598bb23ad1 1050 countss=0;
yabahiro 39:784552c26163 1051 fast=60;
yabahiro 39:784552c26163 1052 normal=40;
yabahiro 39:784552c26163 1053 slow=30;
yabahiro 39:784552c26163 1054 }
yabahiro 39:784552c26163 1055 } else if(mode==24) {
yabahiro 39:784552c26163 1056 if(DOLS==true||UPLS==true) {
yabahiro 39:784552c26163 1057 motor[MOTOR_0].pwm = 200;
yabahiro 39:784552c26163 1058 motor[MOTOR_0].dir = BRAKE;
yabahiro 39:784552c26163 1059 } else {
yabahiro 39:784552c26163 1060 motor[MOTOR_0].pwm = 100;
yabahiro 39:784552c26163 1061 motor[MOTOR_0].dir = BACK;
yabahiro 39:784552c26163 1062 }
yabahiro 39:784552c26163 1063 if(g[4]==3||g[4]==2) {
yabahiro 39:784552c26163 1064 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1065 motor[TIRE_FR].dir = FOR;
yabahiro 39:784552c26163 1066 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 1067 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1068 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 1069 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1070 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1071 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 1072 }
yabahiro 39:784552c26163 1073 if(g[4]==253||g[4]==254) {
yabahiro 39:784552c26163 1074 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1075 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1076 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 1077 motor[TIRE_FL].dir = BACK;
yabahiro 39:784552c26163 1078 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 1079 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 1080 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1081 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1082 }
yabahiro 39:784552c26163 1083 switch(g[2]) {
yabahiro 39:784552c26163 1084 case 0:
yabahiro 39:784552c26163 1085 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 1086 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1087 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 1088 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1089 break;
yabahiro 39:784552c26163 1090 case 255:
yabahiro 39:784552c26163 1091 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1092 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1093 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 1094 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1095 break;
yabahiro 39:784552c26163 1096 case 253:
yabahiro 39:784552c26163 1097 motor[TIRE_FR].pwm = 40;
yabahiro 39:784552c26163 1098 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1099 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 1100 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1101 break;
yabahiro 39:784552c26163 1102 case 254:
yabahiro 39:784552c26163 1103 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1104 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1105 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 1106 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1107 break;
yabahiro 39:784552c26163 1108 case 1:
yabahiro 39:784552c26163 1109 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 1110 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1111 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 1112 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 1113 break;
yabahiro 39:784552c26163 1114 case 3:
yabahiro 39:784552c26163 1115 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 1116 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1117 motor[TIRE_BR].pwm = 40;
yabahiro 39:784552c26163 1118 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 1119 break;
yabahiro 39:784552c26163 1120 case 2:
yabahiro 39:784552c26163 1121 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1122 motor[TIRE_FR].dir = FOR;
yabahiro 39:784552c26163 1123 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 1124 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 1125 break;
yabahiro 39:784552c26163 1126 }
yabahiro 39:784552c26163 1127 switch(g[3]) {
yabahiro 39:784552c26163 1128 case 0:
yabahiro 39:784552c26163 1129 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 1130 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1131 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 1132 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1133 break;
yabahiro 39:784552c26163 1134 case 255:
yabahiro 39:784552c26163 1135 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 1136 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1137 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1138 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 1139 case 253:
yabahiro 39:784552c26163 1140 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 1141 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1142 motor[TIRE_BL].pwm = 40;
yabahiro 39:784552c26163 1143 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 1144 break;
yabahiro 39:784552c26163 1145 case 254:
yabahiro 39:784552c26163 1146 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 1147 motor[TIRE_FL].dir = BACK;
yabahiro 39:784552c26163 1148 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1149 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 1150 break;
yabahiro 39:784552c26163 1151 case 1:
yabahiro 39:784552c26163 1152 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 1153 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1154 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 1155 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1156 break;
yabahiro 39:784552c26163 1157 case 3:
yabahiro 39:784552c26163 1158 motor[TIRE_FL].pwm = 40;
yabahiro 39:784552c26163 1159 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1160 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 1161 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1162 break;
yabahiro 39:784552c26163 1163 case 2:
yabahiro 39:784552c26163 1164 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 1165 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1166 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1167 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1168 break;
yabahiro 33:dd598bb23ad1 1169 }
yabahiro 39:784552c26163 1170 if(g[3]==0&&g[2]==0) {
yabahiro 39:784552c26163 1171 if(UPLS==true||DOLS==true) {
yabahiro 39:784552c26163 1172 motor[MOTOR_0].pwm = 200;
yabahiro 39:784552c26163 1173 motor[MOTOR_0].dir = BRAKE;
yabahiro 39:784552c26163 1174 mode=25;
yabahiro 39:784552c26163 1175 } else {
yabahiro 39:784552c26163 1176 motor[MOTOR_0].pwm = 100;
yabahiro 39:784552c26163 1177 motor[MOTOR_0].dir = BACK;
yabahiro 39:784552c26163 1178 }
yabahiro 39:784552c26163 1179 }
yabahiro 39:784552c26163 1180 } else if(mode==25) {
yabahiro 39:784552c26163 1181 switch(g[4]) {
yabahiro 39:784552c26163 1182 case 98:
yabahiro 39:784552c26163 1183 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1184 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1185 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1186 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1187 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1188 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1189 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 1190 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1191 break;
yabahiro 39:784552c26163 1192 case 99:
yabahiro 39:784552c26163 1193 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1194 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1195 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1196 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1197 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1198 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1199 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1200 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1201 break;
yabahiro 39:784552c26163 1202 case 0:
yabahiro 39:784552c26163 1203 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1204 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1205 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1206 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1207 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1208 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1209 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 1210 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1211 break;
yabahiro 39:784552c26163 1212 case 255:
yabahiro 39:784552c26163 1213 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1214 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1215 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1216 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1217 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1218 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1219 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1220 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1221 break;
yabahiro 39:784552c26163 1222 case 253:
yabahiro 39:784552c26163 1223 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1224 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1225 motor[TIRE_FL].pwm = slow;
yabahiro 39:784552c26163 1226 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1227 motor[TIRE_BR].pwm = slow;
yabahiro 39:784552c26163 1228 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1229 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 1230 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1231 break;
yabahiro 39:784552c26163 1232 case 254:
yabahiro 39:784552c26163 1233 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1234 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1235 motor[TIRE_FL].pwm = normal;
yabahiro 39:784552c26163 1236 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1237 motor[TIRE_BR].pwm = normal;
yabahiro 39:784552c26163 1238 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1239 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 1240 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1241 break;
yabahiro 39:784552c26163 1242 case 1:
yabahiro 39:784552c26163 1243 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1244 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1245 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1246 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1247 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1248 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1249 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1250 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1251 break;
yabahiro 39:784552c26163 1252 case 3:
yabahiro 39:784552c26163 1253 motor[TIRE_FR].pwm = slow;
yabahiro 39:784552c26163 1254 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1255 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1256 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1257 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1258 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1259 motor[TIRE_BL].pwm = slow-5;
yabahiro 39:784552c26163 1260 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1261 break;
yabahiro 39:784552c26163 1262 case 2:
yabahiro 39:784552c26163 1263 motor[TIRE_FR].pwm = normal;
yabahiro 39:784552c26163 1264 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1265 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1266 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1267 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1268 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1269 motor[TIRE_BL].pwm = normal-5;
yabahiro 39:784552c26163 1270 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1271 break;
yabahiro 39:784552c26163 1272 }
yabahiro 39:784552c26163 1273 if(g[1]==98) {
yabahiro 39:784552c26163 1274 mode=31;
yabahiro 33:dd598bb23ad1 1275 }
yabahiro 33:dd598bb23ad1 1276 }
yabahiro 33:dd598bb23ad1 1277 } else {
yabahiro 39:784552c26163 1278 if(mode==21) {
yabahiro 33:dd598bb23ad1 1279 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1280 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1281 motor[TIRE_FL].pwm = 30;
yabahiro 33:dd598bb23ad1 1282 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1283 motor[TIRE_BR].pwm = 30;
yabahiro 33:dd598bb23ad1 1284 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1285 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1286 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1287 if(g[1]==0) {
yabahiro 39:784552c26163 1288 mode=22;
yabahiro 39:784552c26163 1289 fast=60;
yabahiro 39:784552c26163 1290 normal=40;
yabahiro 39:784552c26163 1291 slow=20;
yabahiro 39:784552c26163 1292 }
yabahiro 39:784552c26163 1293 } else if(mode==22) {
yabahiro 39:784552c26163 1294 if(g[3]==0) {
yabahiro 39:784552c26163 1295 mode=23;
yabahiro 39:784552c26163 1296 }
yabahiro 39:784552c26163 1297 switch(g[0]) {
yabahiro 39:784552c26163 1298 case 98:
yabahiro 39:784552c26163 1299 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 39:784552c26163 1300 fast=30;
yabahiro 39:784552c26163 1301 normal=20;
yabahiro 39:784552c26163 1302 slow=20;
yabahiro 39:784552c26163 1303 motor[TIRE_FR].pwm = normal;
yabahiro 39:784552c26163 1304 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1305 motor[TIRE_FL].pwm = normal;
yabahiro 39:784552c26163 1306 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1307 motor[TIRE_BR].pwm = normal;
yabahiro 39:784552c26163 1308 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1309 motor[TIRE_BL].pwm = normal;
yabahiro 39:784552c26163 1310 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1311 break;
yabahiro 39:784552c26163 1312 case 0:
yabahiro 39:784552c26163 1313 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1314 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1315 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1316 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1317 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1318 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1319 motor[TIRE_BL].pwm = fast;
yabahiro 39:784552c26163 1320 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1321 mtc=true;
yabahiro 39:784552c26163 1322 break;
yabahiro 39:784552c26163 1323 case 255:
yabahiro 39:784552c26163 1324 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1325 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1326 motor[TIRE_FL].pwm = slow;
yabahiro 39:784552c26163 1327 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1328 motor[TIRE_BR].pwm = slow;
yabahiro 39:784552c26163 1329 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1330 motor[TIRE_BL].pwm = fast;
yabahiro 39:784552c26163 1331 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1332 mtc=true;
yabahiro 39:784552c26163 1333 break;
yabahiro 39:784552c26163 1334 case 253:
yabahiro 39:784552c26163 1335 motor[TIRE_FR].pwm = slow;
yabahiro 39:784552c26163 1336 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1337 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1338 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1339 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1340 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1341 motor[TIRE_BL].pwm = slow;
yabahiro 39:784552c26163 1342 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1343 mtc=true;
yabahiro 39:784552c26163 1344 break;
yabahiro 39:784552c26163 1345 case 254:
yabahiro 39:784552c26163 1346 motor[TIRE_FR].pwm = normal;
yabahiro 39:784552c26163 1347 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1348 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1349 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1350 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1351 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1352 motor[TIRE_BL].pwm = normal;
yabahiro 39:784552c26163 1353 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1354 mtc=true;
yabahiro 39:784552c26163 1355 break;
yabahiro 39:784552c26163 1356 case 1:
yabahiro 39:784552c26163 1357 motor[TIRE_FR].pwm = slow;
yabahiro 39:784552c26163 1358 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1359 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1360 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1361 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1362 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1363 motor[TIRE_BL].pwm = slow;
yabahiro 39:784552c26163 1364 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1365 mtc=true;
yabahiro 39:784552c26163 1366 break;
yabahiro 39:784552c26163 1367 case 3:
yabahiro 39:784552c26163 1368 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1369 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1370 motor[TIRE_FL].pwm = slow;
yabahiro 39:784552c26163 1371 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1372 motor[TIRE_BR].pwm = slow;
yabahiro 39:784552c26163 1373 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1374 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1375 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1376 mtc=true;
yabahiro 39:784552c26163 1377 break;
yabahiro 39:784552c26163 1378 case 2:
yabahiro 39:784552c26163 1379 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1380 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1381 motor[TIRE_FL].pwm = normal;
yabahiro 39:784552c26163 1382 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1383 motor[TIRE_BR].pwm = normal;
yabahiro 39:784552c26163 1384 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1385 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1386 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1387 mtc=true;
yabahiro 39:784552c26163 1388 break;
yabahiro 39:784552c26163 1389 }
yabahiro 39:784552c26163 1390 if(g[0]!=98&&mtc==true) {
yabahiro 39:784552c26163 1391 switch(g[0]) {
yabahiro 39:784552c26163 1392 case 0:
yabahiro 39:784552c26163 1393 mtc=false;
yabahiro 39:784552c26163 1394 break;
yabahiro 39:784552c26163 1395 case 255:
yabahiro 39:784552c26163 1396 motor[TIRE_BR].pwm += 5;
yabahiro 39:784552c26163 1397 mtc=false;
yabahiro 39:784552c26163 1398 break;
yabahiro 39:784552c26163 1399 case 253:
yabahiro 39:784552c26163 1400 motor[TIRE_BR].pwm += 10;
yabahiro 39:784552c26163 1401 mtc=false;
yabahiro 39:784552c26163 1402 break;
yabahiro 39:784552c26163 1403 case 254:
yabahiro 39:784552c26163 1404 motor[TIRE_BR].pwm += 20;
yabahiro 39:784552c26163 1405 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1406 mtc=false;
yabahiro 39:784552c26163 1407 break;
yabahiro 39:784552c26163 1408 case 1:
yabahiro 39:784552c26163 1409 motor[TIRE_BL].pwm += 5;
yabahiro 39:784552c26163 1410 mtc=false;
yabahiro 39:784552c26163 1411 break;
yabahiro 39:784552c26163 1412 case 3:
yabahiro 39:784552c26163 1413 motor[TIRE_BL].pwm += 10;
yabahiro 39:784552c26163 1414 mtc=false;
yabahiro 39:784552c26163 1415 break;
yabahiro 39:784552c26163 1416 case 2:
yabahiro 39:784552c26163 1417 motor[TIRE_BL].pwm += 20;
yabahiro 39:784552c26163 1418 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1419 mtc=false;
yabahiro 39:784552c26163 1420 break;
yabahiro 39:784552c26163 1421 }
yabahiro 39:784552c26163 1422 }
yabahiro 39:784552c26163 1423 } else if(mode==23) {
yabahiro 39:784552c26163 1424 if(UPLS==true||DOLS==true) {
yabahiro 39:784552c26163 1425 motor[MOTOR_0].pwm = 200;
yabahiro 39:784552c26163 1426 motor[MOTOR_0].dir = BRAKE;
yabahiro 39:784552c26163 1427 fast=60;
yabahiro 39:784552c26163 1428 normal=40;
yabahiro 39:784552c26163 1429 slow=20;
yabahiro 33:dd598bb23ad1 1430 countss=0;
yabahiro 39:784552c26163 1431 mode=24;
yabahiro 39:784552c26163 1432 } else {
yabahiro 39:784552c26163 1433 motor[MOTOR_0].pwm = 100;
yabahiro 39:784552c26163 1434 motor[MOTOR_0].dir = BACK;
yabahiro 39:784552c26163 1435 motor[TIRE_FR].pwm = 100;
yabahiro 39:784552c26163 1436 motor[TIRE_FR].dir = BRAKE;
yabahiro 39:784552c26163 1437 motor[TIRE_FL].pwm = 100;
yabahiro 39:784552c26163 1438 motor[TIRE_FL].dir = BRAKE;
yabahiro 39:784552c26163 1439 motor[TIRE_BR].pwm = 100;
yabahiro 39:784552c26163 1440 motor[TIRE_BR].dir = BRAKE;
yabahiro 39:784552c26163 1441 motor[TIRE_BL].pwm = 100;
yabahiro 39:784552c26163 1442 motor[TIRE_BL].dir = BRAKE;
yabahiro 39:784552c26163 1443 }
yabahiro 39:784552c26163 1444
yabahiro 39:784552c26163 1445 } else if(mode==24) {
yabahiro 39:784552c26163 1446 if(g[0]==98&&countss>=40000) {
yabahiro 39:784552c26163 1447 mode=31;
yabahiro 39:784552c26163 1448 countss=0;
yabahiro 39:784552c26163 1449 }
yabahiro 39:784552c26163 1450 switch(g[0]) {
yabahiro 39:784552c26163 1451 case 98:
yabahiro 39:784552c26163 1452 fast=30;
yabahiro 39:784552c26163 1453 normal=20;
yabahiro 39:784552c26163 1454 slow=20;
yabahiro 39:784552c26163 1455 motor[TIRE_FR].pwm = normal;
yabahiro 39:784552c26163 1456 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1457 motor[TIRE_FL].pwm = normal;
yabahiro 39:784552c26163 1458 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1459 motor[TIRE_BR].pwm = normal;
yabahiro 39:784552c26163 1460 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1461 motor[TIRE_BL].pwm = normal;
yabahiro 39:784552c26163 1462 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1463 break;
yabahiro 39:784552c26163 1464 case 0:
yabahiro 39:784552c26163 1465 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1466 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1467 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1468 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1469 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1470 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1471 motor[TIRE_BL].pwm = fast;
yabahiro 39:784552c26163 1472 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1473 mtc=true;
yabahiro 39:784552c26163 1474 break;
yabahiro 39:784552c26163 1475 case 255:
yabahiro 39:784552c26163 1476 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1477 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1478 motor[TIRE_FL].pwm = slow;
yabahiro 39:784552c26163 1479 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1480 motor[TIRE_BR].pwm = slow;
yabahiro 39:784552c26163 1481 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1482 motor[TIRE_BL].pwm = fast;
yabahiro 39:784552c26163 1483 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1484 mtc=true;
yabahiro 39:784552c26163 1485 break;
yabahiro 39:784552c26163 1486 case 253:
yabahiro 39:784552c26163 1487 motor[TIRE_FR].pwm = slow;
yabahiro 39:784552c26163 1488 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1489 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1490 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1491 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1492 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1493 motor[TIRE_BL].pwm = slow;
yabahiro 39:784552c26163 1494 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1495 mtc=true;
yabahiro 39:784552c26163 1496 break;
yabahiro 39:784552c26163 1497 case 254:
yabahiro 39:784552c26163 1498 motor[TIRE_FR].pwm = normal;
yabahiro 39:784552c26163 1499 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1500 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1501 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1502 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1503 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1504 motor[TIRE_BL].pwm = normal;
yabahiro 39:784552c26163 1505 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1506 mtc=true;
yabahiro 39:784552c26163 1507 break;
yabahiro 39:784552c26163 1508 case 1:
yabahiro 39:784552c26163 1509 motor[TIRE_FR].pwm = slow;
yabahiro 39:784552c26163 1510 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1511 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1512 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1513 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1514 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1515 motor[TIRE_BL].pwm = slow;
yabahiro 39:784552c26163 1516 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1517 mtc=true;
yabahiro 39:784552c26163 1518 break;
yabahiro 39:784552c26163 1519 case 3:
yabahiro 39:784552c26163 1520 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1521 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1522 motor[TIRE_FL].pwm = slow;
yabahiro 39:784552c26163 1523 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1524 motor[TIRE_BR].pwm = slow;
yabahiro 39:784552c26163 1525 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1526 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1527 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1528 mtc=true;
yabahiro 39:784552c26163 1529 break;
yabahiro 39:784552c26163 1530 case 2:
yabahiro 39:784552c26163 1531 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1532 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1533 motor[TIRE_FL].pwm = normal;
yabahiro 39:784552c26163 1534 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1535 motor[TIRE_BR].pwm = normal;
yabahiro 39:784552c26163 1536 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1537 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1538 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1539 mtc=true;
yabahiro 39:784552c26163 1540 break;
yabahiro 39:784552c26163 1541 }
yabahiro 39:784552c26163 1542 if(g[1]!=98&&mtc==true) {
yabahiro 39:784552c26163 1543 switch(g[1]) {
yabahiro 39:784552c26163 1544 case 0:
yabahiro 39:784552c26163 1545 mtc=false;
yabahiro 39:784552c26163 1546 break;
yabahiro 39:784552c26163 1547 case 255:
yabahiro 39:784552c26163 1548 motor[TIRE_BR].pwm += 5;
yabahiro 39:784552c26163 1549 mtc=false;
yabahiro 39:784552c26163 1550 break;
yabahiro 39:784552c26163 1551 case 253:
yabahiro 39:784552c26163 1552 motor[TIRE_BR].pwm += 10;
yabahiro 39:784552c26163 1553 mtc=false;
yabahiro 39:784552c26163 1554 break;
yabahiro 39:784552c26163 1555 case 254:
yabahiro 39:784552c26163 1556 motor[TIRE_BR].pwm += 20;
yabahiro 39:784552c26163 1557 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1558 mtc=false;
yabahiro 39:784552c26163 1559 break;
yabahiro 39:784552c26163 1560 case 1:
yabahiro 39:784552c26163 1561 motor[TIRE_BL].pwm += 5;
yabahiro 39:784552c26163 1562 mtc=false;
yabahiro 39:784552c26163 1563 break;
yabahiro 39:784552c26163 1564 case 3:
yabahiro 39:784552c26163 1565 motor[TIRE_BL].pwm += 10;
yabahiro 39:784552c26163 1566 mtc=false;
yabahiro 39:784552c26163 1567 break;
yabahiro 39:784552c26163 1568 case 2:
yabahiro 39:784552c26163 1569 motor[TIRE_BL].pwm += 20;
yabahiro 39:784552c26163 1570 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1571 mtc=false;
yabahiro 39:784552c26163 1572 break;
yabahiro 39:784552c26163 1573 }
yabahiro 33:dd598bb23ad1 1574 }
yabahiro 33:dd598bb23ad1 1575 }
yabahiro 33:dd598bb23ad1 1576 }
yabahiro 39:784552c26163 1577 if(mode==31) {
yabahiro 33:dd598bb23ad1 1578 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1579 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 1580 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1581 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1582 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1583 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1584 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1585 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 1586 if(countss>=5000) {
yabahiro 33:dd598bb23ad1 1587 countss=0;
yabahiro 33:dd598bb23ad1 1588 mode=33;
yabahiro 33:dd598bb23ad1 1589 }
yabahiro 33:dd598bb23ad1 1590 } else if(mode==33) {
yabahiro 33:dd598bb23ad1 1591 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1592 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1593 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1594 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1595 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1596 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1597 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1598 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1599 if(g[3]==0) {
yabahiro 39:784552c26163 1600 cross=0;
yabahiro 33:dd598bb23ad1 1601 countss=0;
yabahiro 33:dd598bb23ad1 1602 mode=40;
yabahiro 33:dd598bb23ad1 1603 }
yabahiro 33:dd598bb23ad1 1604 } else if(mode==40) {
yabahiro 33:dd598bb23ad1 1605 switch(g[3]) {
yabahiro 33:dd598bb23ad1 1606 case 98:
yabahiro 33:dd598bb23ad1 1607 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 1608 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1609 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 1610 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 1611 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 1612 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 1613 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 1614 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1615 if(countss>10000) {
yabahiro 33:dd598bb23ad1 1616 cross++;
yabahiro 33:dd598bb23ad1 1617 countss=0;
yabahiro 33:dd598bb23ad1 1618 }
yabahiro 33:dd598bb23ad1 1619 mtc2=true;
yabahiro 39:784552c26163 1620 if(cross==1) {
yabahiro 33:dd598bb23ad1 1621 mode=41;
yabahiro 33:dd598bb23ad1 1622 countss=0;
yabahiro 33:dd598bb23ad1 1623 cross=0;
yabahiro 33:dd598bb23ad1 1624 }
yabahiro 33:dd598bb23ad1 1625 break;
yabahiro 33:dd598bb23ad1 1626 case 0:
yabahiro 33:dd598bb23ad1 1627 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 1628 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1629 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 1630 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 1631 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 1632 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 1633 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 1634 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1635 mtc2=true;
yabahiro 33:dd598bb23ad1 1636 break;
yabahiro 33:dd598bb23ad1 1637 case 255:
yabahiro 33:dd598bb23ad1 1638 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 1639 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1640 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 1641 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 1642 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 1643 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 1644 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 1645 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1646 mtc2=true;
yabahiro 33:dd598bb23ad1 1647 break;
yabahiro 33:dd598bb23ad1 1648 case 253:
yabahiro 33:dd598bb23ad1 1649 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1650 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 1651 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 1652 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 1653 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 1654 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 1655 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1656 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 1657 mtc2=true;
yabahiro 33:dd598bb23ad1 1658 break;
yabahiro 33:dd598bb23ad1 1659 case 254:
yabahiro 33:dd598bb23ad1 1660 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1661 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 1662 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 1663 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 1664 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 1665 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 1666 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1667 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 1668 mtc2=true;
yabahiro 33:dd598bb23ad1 1669 break;
yabahiro 33:dd598bb23ad1 1670 case 1:
yabahiro 33:dd598bb23ad1 1671 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 1672 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1673 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 1674 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 1675 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 1676 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 1677 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 1678 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1679 mtc2=true;
yabahiro 33:dd598bb23ad1 1680 break;
yabahiro 33:dd598bb23ad1 1681 case 3:
yabahiro 33:dd598bb23ad1 1682 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 1683 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1684 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1685 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1686 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1687 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1688 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 1689 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1690 mtc2=true;
yabahiro 33:dd598bb23ad1 1691 break;
yabahiro 33:dd598bb23ad1 1692 case 2:
yabahiro 33:dd598bb23ad1 1693 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 1694 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1695 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1696 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1697 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1698 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1699 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 1700 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1701 mtc2=true;
yabahiro 33:dd598bb23ad1 1702 break;
yabahiro 33:dd598bb23ad1 1703 }
yabahiro 33:dd598bb23ad1 1704 if(g[2]!=98&&mtc2==true) {
yabahiro 33:dd598bb23ad1 1705 switch(g[2]) {
yabahiro 33:dd598bb23ad1 1706 case 0:
yabahiro 33:dd598bb23ad1 1707 mtc2=false;
yabahiro 33:dd598bb23ad1 1708 break;
yabahiro 33:dd598bb23ad1 1709 case 255:
yabahiro 39:784552c26163 1710 motor[TIRE_FL].pwm += 5;
yabahiro 33:dd598bb23ad1 1711 mtc2=false;
yabahiro 33:dd598bb23ad1 1712 break;
yabahiro 33:dd598bb23ad1 1713 case 253:
yabahiro 39:784552c26163 1714 motor[TIRE_FL].pwm += 10;
yabahiro 33:dd598bb23ad1 1715 mtc2=false;
yabahiro 33:dd598bb23ad1 1716 break;
yabahiro 33:dd598bb23ad1 1717 case 254:
yabahiro 39:784552c26163 1718 motor[TIRE_FL].pwm += 20;
yabahiro 39:784552c26163 1719 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1720 mtc2=false;
yabahiro 33:dd598bb23ad1 1721 break;
yabahiro 33:dd598bb23ad1 1722 case 1:
yabahiro 39:784552c26163 1723 motor[TIRE_BL].pwm += 5;
yabahiro 33:dd598bb23ad1 1724 mtc2=false;
yabahiro 33:dd598bb23ad1 1725 break;
yabahiro 33:dd598bb23ad1 1726 case 3:
yabahiro 39:784552c26163 1727 motor[TIRE_BL].pwm += 10;
yabahiro 33:dd598bb23ad1 1728 mtc2=false;
yabahiro 33:dd598bb23ad1 1729 break;
yabahiro 33:dd598bb23ad1 1730 case 2:
yabahiro 39:784552c26163 1731 motor[TIRE_BL].pwm += 20;
yabahiro 39:784552c26163 1732 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1733 mtc2=false;
yabahiro 33:dd598bb23ad1 1734 break;
yabahiro 33:dd598bb23ad1 1735 }
yabahiro 33:dd598bb23ad1 1736 }
yabahiro 33:dd598bb23ad1 1737 } else if(mode==41) {
yabahiro 33:dd598bb23ad1 1738 if(LIF||LIB) {
yabahiro 33:dd598bb23ad1 1739 mode=42;
yabahiro 33:dd598bb23ad1 1740 }
yabahiro 33:dd598bb23ad1 1741 motor[TIRE_FR].pwm = 30;
yabahiro 33:dd598bb23ad1 1742 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1743 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1744 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1745 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1746 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1747 motor[TIRE_BL].pwm = 30;
yabahiro 33:dd598bb23ad1 1748 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1749 if(g[1]==0) {
yabahiro 33:dd598bb23ad1 1750 countss=0;
yabahiro 33:dd598bb23ad1 1751 mode=70;
yabahiro 33:dd598bb23ad1 1752 normal=60;
yabahiro 33:dd598bb23ad1 1753 fast=70;
yabahiro 33:dd598bb23ad1 1754 slow=40;
yabahiro 33:dd598bb23ad1 1755 }
yabahiro 33:dd598bb23ad1 1756 } else if(mode==42) {
yabahiro 39:784552c26163 1757 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 1758 motor[TIRE_FR].dir = FOR;
yabahiro 39:784552c26163 1759 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1760 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1761 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1762 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1763 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 1764 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 1765 if(g[1]==0) {
yabahiro 33:dd598bb23ad1 1766 countss=0;
yabahiro 39:784552c26163 1767 mode=70;
yabahiro 33:dd598bb23ad1 1768 }
yabahiro 39:784552c26163 1769 } else if(mode==70) {
yabahiro 33:dd598bb23ad1 1770 switch(g[0]) {
yabahiro 33:dd598bb23ad1 1771 case 99:
yabahiro 33:dd598bb23ad1 1772 if(countss>=100000) {
yabahiro 33:dd598bb23ad1 1773 mode=100;
yabahiro 33:dd598bb23ad1 1774 }
yabahiro 33:dd598bb23ad1 1775 break;
yabahiro 33:dd598bb23ad1 1776 case 98:
yabahiro 33:dd598bb23ad1 1777 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 1778 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1779 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 1780 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1781 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 1782 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1783 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 1784 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1785 break;
yabahiro 33:dd598bb23ad1 1786 case 0:
yabahiro 39:784552c26163 1787 motor[TIRE_FR].pwm = 80;
yabahiro 33:dd598bb23ad1 1788 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1789 motor[TIRE_FL].pwm = 80;
yabahiro 33:dd598bb23ad1 1790 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1791 motor[TIRE_BR].pwm = 80;
yabahiro 33:dd598bb23ad1 1792 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1793 motor[TIRE_BL].pwm = 80;
yabahiro 33:dd598bb23ad1 1794 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1795 mtc=true;
yabahiro 33:dd598bb23ad1 1796 break;
yabahiro 33:dd598bb23ad1 1797 case 255:
yabahiro 33:dd598bb23ad1 1798 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 1799 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1800 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 1801 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1802 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 1803 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1804 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 1805 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1806 mtc=true;
yabahiro 33:dd598bb23ad1 1807 break;
yabahiro 33:dd598bb23ad1 1808 case 253:
yabahiro 33:dd598bb23ad1 1809 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 1810 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1811 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1812 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1813 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1814 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1815 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 1816 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1817 mtc=true;
yabahiro 33:dd598bb23ad1 1818 break;
yabahiro 33:dd598bb23ad1 1819 case 254:
yabahiro 33:dd598bb23ad1 1820 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 1821 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1822 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1823 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1824 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1825 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1826 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 1827 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1828 mtc=true;
yabahiro 33:dd598bb23ad1 1829 break;
yabahiro 33:dd598bb23ad1 1830 case 1:
yabahiro 33:dd598bb23ad1 1831 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 1832 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1833 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 1834 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1835 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 1836 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1837 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 1838 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1839 mtc=true;
yabahiro 33:dd598bb23ad1 1840 break;
yabahiro 33:dd598bb23ad1 1841 case 3:
yabahiro 33:dd598bb23ad1 1842 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1843 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 1844 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 1845 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1846 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 1847 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1848 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1849 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 1850 mtc=true;
yabahiro 33:dd598bb23ad1 1851 break;
yabahiro 33:dd598bb23ad1 1852 case 2:
yabahiro 33:dd598bb23ad1 1853 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1854 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 1855 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 1856 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1857 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 1858 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1859 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1860 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 1861 mtc=true;
yabahiro 33:dd598bb23ad1 1862 break;
yabahiro 33:dd598bb23ad1 1863 }
yabahiro 39:784552c26163 1864 if(g[1]!=98&&mtc==true) {
yabahiro 39:784552c26163 1865 switch(g[1]) {
yabahiro 39:784552c26163 1866 case 0:
yabahiro 39:784552c26163 1867 mtc=false;
yabahiro 39:784552c26163 1868 break;
yabahiro 39:784552c26163 1869 case 255:
yabahiro 39:784552c26163 1870 motor[TIRE_BR].pwm += 5;
yabahiro 39:784552c26163 1871 mtc=false;
yabahiro 39:784552c26163 1872 break;
yabahiro 39:784552c26163 1873 case 253:
yabahiro 39:784552c26163 1874 motor[TIRE_BR].pwm += 10;
yabahiro 39:784552c26163 1875 mtc=false;
yabahiro 39:784552c26163 1876 break;
yabahiro 39:784552c26163 1877 case 254:
yabahiro 39:784552c26163 1878 motor[TIRE_BR].pwm += 20;
yabahiro 39:784552c26163 1879 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1880 mtc=false;
yabahiro 39:784552c26163 1881 break;
yabahiro 39:784552c26163 1882 case 1:
yabahiro 39:784552c26163 1883 motor[TIRE_BL].pwm += 5;
yabahiro 39:784552c26163 1884 mtc=false;
yabahiro 39:784552c26163 1885 break;
yabahiro 39:784552c26163 1886 case 3:
yabahiro 39:784552c26163 1887 motor[TIRE_BL].pwm += 10;
yabahiro 39:784552c26163 1888 mtc=false;
yabahiro 39:784552c26163 1889 break;
yabahiro 39:784552c26163 1890 case 2:
yabahiro 39:784552c26163 1891 motor[TIRE_BL].pwm += 20;
yabahiro 39:784552c26163 1892 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1893 mtc=false;
yabahiro 39:784552c26163 1894 break;
yabahiro 39:784552c26163 1895 }
yabahiro 33:dd598bb23ad1 1896 }
yabahiro 33:dd598bb23ad1 1897 } else if(mode==100) {
yabahiro 39:784552c26163 1898 motor[TIRE_FR].pwm = 40;
yabahiro 33:dd598bb23ad1 1899 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1900 motor[TIRE_FL].pwm = 40;
yabahiro 33:dd598bb23ad1 1901 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1902 motor[TIRE_BR].pwm = 43;
yabahiro 33:dd598bb23ad1 1903 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1904 motor[TIRE_BL].pwm = 40;
yabahiro 33:dd598bb23ad1 1905 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1906 } else {
yabahiro 33:dd598bb23ad1 1907 }
yabahiro 39:784552c26163 1908
kishibekairohan 13:b6e02d6261d7 1909 }
kishibekairohan 13:b6e02d6261d7 1910 #endif
kishibekairohan 13:b6e02d6261d7 1911
kishibekairohan 13:b6e02d6261d7 1912 #if USE_PROCESS_NUM>3
Ryosei 27:dd9f27fce7d1 1913 static void Process3()
kishibekairohan 13:b6e02d6261d7 1914 {
yabahiro 33:dd598bb23ad1 1915 //Clearly 赤ゾーン
kishibekairohan 35:33c6cdba5630 1916 LED::LED::TapeledMode(3);
yabahiro 33:dd598bb23ad1 1917 countss++;
yabahiro 33:dd598bb23ad1 1918 if(mode==1) {//スタートゾーンから白線検知
yabahiro 33:dd598bb23ad1 1919 fast=40;
yabahiro 33:dd598bb23ad1 1920 normal=30;
yabahiro 33:dd598bb23ad1 1921 slow=20;
yabahiro 33:dd598bb23ad1 1922 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 1923 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1924 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 1925 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1926 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 1927 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1928 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 1929 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1930 if(g[2]==0&&countss>=100000) {
yabahiro 33:dd598bb23ad1 1931 countss=100000;
yabahiro 33:dd598bb23ad1 1932 cross=0;
yabahiro 33:dd598bb23ad1 1933 mode=3;
yabahiro 33:dd598bb23ad1 1934 }
yabahiro 33:dd598bb23ad1 1935 } else if(mode==3) { //横ライントレースから縦ライントレースへ
yabahiro 33:dd598bb23ad1 1936 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1937 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 1938 motor[TIRE_FL].pwm = 25;
yabahiro 33:dd598bb23ad1 1939 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1940 motor[TIRE_BR].pwm = 25;
yabahiro 33:dd598bb23ad1 1941 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1942 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1943 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 1944 if(g[0]==0) {
yabahiro 33:dd598bb23ad1 1945 mode=10;
yabahiro 33:dd598bb23ad1 1946 countss=100000;
yabahiro 33:dd598bb23ad1 1947 }
yabahiro 33:dd598bb23ad1 1948 } else if(mode==10) { //縦ライントレース
yabahiro 33:dd598bb23ad1 1949 switch(g[0]) {
yabahiro 33:dd598bb23ad1 1950 case 98:
yabahiro 33:dd598bb23ad1 1951 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 1952 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1953 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 1954 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1955 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 1956 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1957 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 1958 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1959 mtc=true;
yabahiro 33:dd598bb23ad1 1960 if(countss>80000) {
yabahiro 33:dd598bb23ad1 1961 cross++;
yabahiro 33:dd598bb23ad1 1962 countss=0;
yabahiro 33:dd598bb23ad1 1963 }
yabahiro 38:40e7fdf3c694 1964 if(cross==3) {
yabahiro 33:dd598bb23ad1 1965 mode=11;
yabahiro 33:dd598bb23ad1 1966 countss=0;
yabahiro 33:dd598bb23ad1 1967 cross=0;
yabahiro 33:dd598bb23ad1 1968 }
yabahiro 33:dd598bb23ad1 1969 break;
yabahiro 33:dd598bb23ad1 1970 case 0:
yabahiro 33:dd598bb23ad1 1971 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 1972 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1973 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 1974 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1975 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 1976 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1977 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 1978 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1979 mtc=true;
yabahiro 33:dd598bb23ad1 1980 break;
yabahiro 33:dd598bb23ad1 1981 case 255:
yabahiro 33:dd598bb23ad1 1982 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 1983 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1984 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 1985 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1986 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 1987 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1988 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 1989 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1990 mtc=true;
yabahiro 33:dd598bb23ad1 1991 break;
yabahiro 33:dd598bb23ad1 1992 case 253:
yabahiro 33:dd598bb23ad1 1993 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 1994 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1995 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1996 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1997 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1998 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1999 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 2000 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 2001 mtc=true;
yabahiro 33:dd598bb23ad1 2002 break;
yabahiro 33:dd598bb23ad1 2003 case 254:
yabahiro 33:dd598bb23ad1 2004 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 2005 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 2006 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 2007 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 2008 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 2009 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 2010 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 2011 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 2012 mtc=true;
yabahiro 33:dd598bb23ad1 2013 break;
yabahiro 33:dd598bb23ad1 2014 case 1:
yabahiro 33:dd598bb23ad1 2015 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 2016 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 2017 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 2018 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 2019 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 2020 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2021 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 2022 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 2023 mtc=true;
yabahiro 33:dd598bb23ad1 2024 break;
yabahiro 33:dd598bb23ad1 2025 case 3:
yabahiro 33:dd598bb23ad1 2026 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 2027 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 2028 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 2029 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 2030 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 2031 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2032 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2033 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 2034 mtc=true;
yabahiro 33:dd598bb23ad1 2035 break;
yabahiro 33:dd598bb23ad1 2036 case 2:
yabahiro 33:dd598bb23ad1 2037 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 2038 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 2039 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 2040 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 2041 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 2042 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2043 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2044 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 2045 mtc=true;
yabahiro 33:dd598bb23ad1 2046 break;
yabahiro 33:dd598bb23ad1 2047 }
yabahiro 33:dd598bb23ad1 2048 if(g[0]!=98&&mtc==true) {
yabahiro 33:dd598bb23ad1 2049 switch(g[1]) {
yabahiro 33:dd598bb23ad1 2050 case 0:
yabahiro 33:dd598bb23ad1 2051 mtc=false;
yabahiro 33:dd598bb23ad1 2052 break;
yabahiro 33:dd598bb23ad1 2053 case 255:
yabahiro 33:dd598bb23ad1 2054 motor[TIRE_BR].pwm += 5;
yabahiro 33:dd598bb23ad1 2055 mtc=false;
yabahiro 33:dd598bb23ad1 2056 break;
yabahiro 33:dd598bb23ad1 2057 case 253:
yabahiro 33:dd598bb23ad1 2058 motor[TIRE_BR].pwm += 10;
yabahiro 33:dd598bb23ad1 2059 mtc=false;
yabahiro 33:dd598bb23ad1 2060 break;
yabahiro 33:dd598bb23ad1 2061 case 254:
yabahiro 33:dd598bb23ad1 2062 motor[TIRE_BR].pwm += 20;
yabahiro 33:dd598bb23ad1 2063 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2064 mtc=false;
yabahiro 33:dd598bb23ad1 2065 break;
yabahiro 33:dd598bb23ad1 2066 case 1:
yabahiro 33:dd598bb23ad1 2067 motor[TIRE_BL].pwm += 5;
yabahiro 33:dd598bb23ad1 2068 mtc=false;
yabahiro 33:dd598bb23ad1 2069 break;
yabahiro 33:dd598bb23ad1 2070 case 3:
yabahiro 33:dd598bb23ad1 2071 motor[TIRE_BL].pwm += 10;
yabahiro 33:dd598bb23ad1 2072 mtc=false;
yabahiro 33:dd598bb23ad1 2073 break;
yabahiro 33:dd598bb23ad1 2074 case 2:
yabahiro 33:dd598bb23ad1 2075 motor[TIRE_BL].pwm += 20;
yabahiro 33:dd598bb23ad1 2076 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 2077 mtc=false;
yabahiro 33:dd598bb23ad1 2078 break;
yabahiro 33:dd598bb23ad1 2079 }
yabahiro 33:dd598bb23ad1 2080 }
yabahiro 33:dd598bb23ad1 2081 } else if(mode==11) {
yabahiro 33:dd598bb23ad1 2082 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 2083 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 2084 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 2085 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 2086 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 2087 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2088 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2089 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 2090 if(g[2]==0) {
yabahiro 33:dd598bb23ad1 2091 countss=0;
yabahiro 33:dd598bb23ad1 2092 cross=0;
yabahiro 33:dd598bb23ad1 2093 mode=20;
yabahiro 33:dd598bb23ad1 2094 }
yabahiro 33:dd598bb23ad1 2095 } else if(mode==20) {
yabahiro 38:40e7fdf3c694 2096 solenoid.solenoid4= SOLENOID_ON;
yabahiro 33:dd598bb23ad1 2097 switch(g[2]) {
yabahiro 33:dd598bb23ad1 2098 case 98:
yabahiro 33:dd598bb23ad1 2099 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 2100 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 2101 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 2102 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 2103 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 2104 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2105 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 2106 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2107 if(countss>30000) {
yabahiro 33:dd598bb23ad1 2108 cross++;
yabahiro 33:dd598bb23ad1 2109 countss=0;
yabahiro 33:dd598bb23ad1 2110 }
yabahiro 33:dd598bb23ad1 2111 mtc2=true;
yabahiro 38:40e7fdf3c694 2112 if(cross==1) {
yabahiro 38:40e7fdf3c694 2113 fast=30;
yabahiro 38:40e7fdf3c694 2114 normal=20;
yabahiro 33:dd598bb23ad1 2115 slow=20;
yabahiro 33:dd598bb23ad1 2116 }
yabahiro 38:40e7fdf3c694 2117 if(YELLOW) {
yabahiro 38:40e7fdf3c694 2118 if(cross==2) {
yabahiro 38:40e7fdf3c694 2119 mode=21;
yabahiro 38:40e7fdf3c694 2120 countss=0;
yabahiro 38:40e7fdf3c694 2121 cross=0;
yabahiro 38:40e7fdf3c694 2122 }
yabahiro 38:40e7fdf3c694 2123 } else {
yabahiro 38:40e7fdf3c694 2124 if(cross==1) {
yabahiro 38:40e7fdf3c694 2125 mode=21;
yabahiro 38:40e7fdf3c694 2126 countss=0;
yabahiro 38:40e7fdf3c694 2127 cross=0;
yabahiro 38:40e7fdf3c694 2128 }
yabahiro 38:40e7fdf3c694 2129 }
yabahiro 33:dd598bb23ad1 2130 break;
yabahiro 33:dd598bb23ad1 2131 case 0:
yabahiro 33:dd598bb23ad1 2132 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 2133 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 2134 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 2135 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 2136 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 2137 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2138 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 2139 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2140 mtc2=true;
yabahiro 33:dd598bb23ad1 2141 break;
yabahiro 33:dd598bb23ad1 2142 case 255:
yabahiro 33:dd598bb23ad1 2143 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 2144 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 2145 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 2146 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 2147 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 2148 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2149 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 2150 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2151 mtc2=true;
yabahiro 33:dd598bb23ad1 2152 break;
yabahiro 33:dd598bb23ad1 2153 case 253:
yabahiro 33:dd598bb23ad1 2154 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 2155 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 2156 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 2157 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 2158 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 2159 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2160 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2161 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 2162 mtc2=true;
yabahiro 33:dd598bb23ad1 2163 break;
yabahiro 33:dd598bb23ad1 2164 case 254:
yabahiro 33:dd598bb23ad1 2165 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 2166 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 2167 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 2168 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 2169 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 2170 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2171 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2172 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 2173 mtc2=true;
yabahiro 33:dd598bb23ad1 2174 break;
yabahiro 33:dd598bb23ad1 2175 case 1:
yabahiro 33:dd598bb23ad1 2176 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 2177 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 2178 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 2179 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 2180 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 2181 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2182 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 2183 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2184 mtc2=true;
yabahiro 33:dd598bb23ad1 2185 break;
yabahiro 33:dd598bb23ad1 2186 case 3:
yabahiro 33:dd598bb23ad1 2187 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 2188 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 2189 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 2190 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 2191 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 2192 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 2193 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 2194 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2195 mtc2=true;
yabahiro 33:dd598bb23ad1 2196 break;
yabahiro 33:dd598bb23ad1 2197 case 2:
yabahiro 33:dd598bb23ad1 2198 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 2199 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 2200 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 2201 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 2202 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 2203 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 2204 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 2205 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2206 mtc2=true;
yabahiro 33:dd598bb23ad1 2207 break;
yabahiro 33:dd598bb23ad1 2208 }
yabahiro 33:dd598bb23ad1 2209 if(g[2]!=98&&mtc2==true) {
yabahiro 33:dd598bb23ad1 2210 switch(g[3]) {
yabahiro 33:dd598bb23ad1 2211 case 0:
yabahiro 33:dd598bb23ad1 2212 mtc2=false;
yabahiro 33:dd598bb23ad1 2213 break;
yabahiro 33:dd598bb23ad1 2214 case 255:
yabahiro 33:dd598bb23ad1 2215 motor[TIRE_BL].pwm += 5;
yabahiro 33:dd598bb23ad1 2216 mtc2=false;
yabahiro 33:dd598bb23ad1 2217 break;
yabahiro 33:dd598bb23ad1 2218 case 253:
yabahiro 33:dd598bb23ad1 2219 motor[TIRE_BL].pwm += 10;
yabahiro 33:dd598bb23ad1 2220 mtc2=false;
yabahiro 33:dd598bb23ad1 2221 break;
yabahiro 33:dd598bb23ad1 2222 case 254:
yabahiro 33:dd598bb23ad1 2223 motor[TIRE_BL].pwm += 20;
yabahiro 33:dd598bb23ad1 2224 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 2225 mtc2=false;
yabahiro 33:dd598bb23ad1 2226 break;
yabahiro 33:dd598bb23ad1 2227 case 1:
yabahiro 33:dd598bb23ad1 2228 motor[TIRE_FL].pwm += 5;
yabahiro 33:dd598bb23ad1 2229 mtc2=false;
yabahiro 33:dd598bb23ad1 2230 break;
yabahiro 33:dd598bb23ad1 2231 case 3:
yabahiro 33:dd598bb23ad1 2232 motor[TIRE_FL].pwm += 10;
yabahiro 33:dd598bb23ad1 2233 mtc2=false;
yabahiro 33:dd598bb23ad1 2234 break;
yabahiro 33:dd598bb23ad1 2235 case 2:
yabahiro 33:dd598bb23ad1 2236 motor[TIRE_FL].pwm += 20;
yabahiro 33:dd598bb23ad1 2237 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2238 mtc2=false;
yabahiro 33:dd598bb23ad1 2239 break;
yabahiro 33:dd598bb23ad1 2240 }
yabahiro 33:dd598bb23ad1 2241 }
yabahiro 33:dd598bb23ad1 2242 }
yabahiro 38:40e7fdf3c694 2243 if(YELLOW) {
yabahiro 38:40e7fdf3c694 2244 if(mode==21) {
yabahiro 33:dd598bb23ad1 2245 motor[TIRE_FR].pwm = 20;
yabahiro 33:dd598bb23ad1 2246 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 2247 motor[TIRE_FL].pwm = 20;
yabahiro 33:dd598bb23ad1 2248 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 2249 motor[TIRE_BR].pwm = 20;
yabahiro 33:dd598bb23ad1 2250 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 2251 motor[TIRE_BL].pwm = 20;
yabahiro 33:dd598bb23ad1 2252 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 2253 if(g[3]==98&&countss>=10000) {
yabahiro 38:40e7fdf3c694 2254 mode=22;
yabahiro 33:dd598bb23ad1 2255 countss=0;
yabahiro 38:40e7fdf3c694 2256 fast=60;
yabahiro 38:40e7fdf3c694 2257 normal=40;
yabahiro 38:40e7fdf3c694 2258 slow=20;
yabahiro 38:40e7fdf3c694 2259 }
yabahiro 38:40e7fdf3c694 2260 } else if(mode==22) {
yabahiro 38:40e7fdf3c694 2261 if(g[4]==3||g[4]==2) {
yabahiro 38:40e7fdf3c694 2262 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2263 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2264 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2265 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2266 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2267 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 2268 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2269 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2270 }
yabahiro 38:40e7fdf3c694 2271 if(g[4]==253||g[4]==254) {
yabahiro 38:40e7fdf3c694 2272 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2273 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2274 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2275 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2276 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2277 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2278 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2279 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 2280 }
yabahiro 38:40e7fdf3c694 2281 switch(g[2]) {
yabahiro 38:40e7fdf3c694 2282 case 0:
yabahiro 38:40e7fdf3c694 2283 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 2284 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2285 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 2286 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2287 break;
yabahiro 38:40e7fdf3c694 2288 case 255:
yabahiro 38:40e7fdf3c694 2289 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2290 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2291 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 2292 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2293 break;
yabahiro 38:40e7fdf3c694 2294 case 253:
yabahiro 38:40e7fdf3c694 2295 motor[TIRE_FR].pwm = 40;
yabahiro 38:40e7fdf3c694 2296 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2297 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 2298 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2299 break;
yabahiro 38:40e7fdf3c694 2300 case 254:
yabahiro 38:40e7fdf3c694 2301 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2302 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2303 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2304 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 2305 break;
yabahiro 38:40e7fdf3c694 2306 case 1:
yabahiro 38:40e7fdf3c694 2307 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 2308 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2309 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2310 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2311 break;
yabahiro 38:40e7fdf3c694 2312 case 3:
yabahiro 38:40e7fdf3c694 2313 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 2314 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2315 motor[TIRE_BR].pwm = 40;
yabahiro 38:40e7fdf3c694 2316 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2317 break;
yabahiro 38:40e7fdf3c694 2318 case 2:
yabahiro 38:40e7fdf3c694 2319 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2320 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2321 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2322 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2323 break;
yabahiro 38:40e7fdf3c694 2324 }
yabahiro 38:40e7fdf3c694 2325 switch(g[3]) {
yabahiro 38:40e7fdf3c694 2326 case 0:
yabahiro 38:40e7fdf3c694 2327 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 2328 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2329 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 2330 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2331 break;
yabahiro 38:40e7fdf3c694 2332 case 255:
yabahiro 38:40e7fdf3c694 2333 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 2334 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2335 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2336 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2337 case 253:
yabahiro 38:40e7fdf3c694 2338 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 2339 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2340 motor[TIRE_BL].pwm = 40;
yabahiro 38:40e7fdf3c694 2341 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2342 break;
yabahiro 38:40e7fdf3c694 2343 case 254:
yabahiro 38:40e7fdf3c694 2344 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2345 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2346 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2347 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2348 break;
yabahiro 38:40e7fdf3c694 2349 case 1:
yabahiro 38:40e7fdf3c694 2350 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2351 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2352 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 2353 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2354 break;
yabahiro 38:40e7fdf3c694 2355 case 3:
yabahiro 38:40e7fdf3c694 2356 motor[TIRE_FL].pwm = 40;
yabahiro 38:40e7fdf3c694 2357 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2358 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 2359 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2360 break;
yabahiro 38:40e7fdf3c694 2361 case 2:
yabahiro 38:40e7fdf3c694 2362 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2363 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2364 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2365 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 2366 break;
yabahiro 38:40e7fdf3c694 2367 }
yabahiro 38:40e7fdf3c694 2368 if(g[3]==0&&g[2]==0) {
yabahiro 38:40e7fdf3c694 2369 mode=23;
yabahiro 33:dd598bb23ad1 2370 countss=0;
yabahiro 33:dd598bb23ad1 2371 }
yabahiro 38:40e7fdf3c694 2372 } else if(mode==23) {
yabahiro 38:40e7fdf3c694 2373 switch(g[4]) {
yabahiro 38:40e7fdf3c694 2374 case 98:
yabahiro 38:40e7fdf3c694 2375 motor[TIRE_FR].pwm = fast;
yabahiro 38:40e7fdf3c694 2376 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2377 motor[TIRE_FL].pwm = fast;
yabahiro 38:40e7fdf3c694 2378 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2379 motor[TIRE_BR].pwm = fast;
yabahiro 38:40e7fdf3c694 2380 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2381 motor[TIRE_BL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2382 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2383 break;
yabahiro 38:40e7fdf3c694 2384 case 99:
yabahiro 38:40e7fdf3c694 2385 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2386 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2387 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2388 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2389 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2390 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2391 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2392 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2393 break;
yabahiro 38:40e7fdf3c694 2394 case 0:
yabahiro 38:40e7fdf3c694 2395 motor[TIRE_FR].pwm = fast;
yabahiro 38:40e7fdf3c694 2396 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2397 motor[TIRE_FL].pwm = fast;
yabahiro 38:40e7fdf3c694 2398 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2399 motor[TIRE_BR].pwm = fast;
yabahiro 38:40e7fdf3c694 2400 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2401 motor[TIRE_BL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2402 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2403 break;
yabahiro 38:40e7fdf3c694 2404 case 255:
yabahiro 38:40e7fdf3c694 2405 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2406 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2407 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2408 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2409 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2410 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2411 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2412 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2413 break;
yabahiro 38:40e7fdf3c694 2414 case 253:
yabahiro 38:40e7fdf3c694 2415 motor[TIRE_FR].pwm = slow;
yabahiro 38:40e7fdf3c694 2416 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2417 motor[TIRE_FL].pwm = fast;
yabahiro 38:40e7fdf3c694 2418 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2419 motor[TIRE_BR].pwm = fast;
yabahiro 38:40e7fdf3c694 2420 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2421 motor[TIRE_BL].pwm = slow-5;
yabahiro 38:40e7fdf3c694 2422 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2423 break;
yabahiro 38:40e7fdf3c694 2424 case 254:
yabahiro 38:40e7fdf3c694 2425 motor[TIRE_FR].pwm = normal;
yabahiro 38:40e7fdf3c694 2426 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2427 motor[TIRE_FL].pwm = fast;
yabahiro 38:40e7fdf3c694 2428 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2429 motor[TIRE_BR].pwm = fast;
yabahiro 38:40e7fdf3c694 2430 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2431 motor[TIRE_BL].pwm = normal-5;
yabahiro 38:40e7fdf3c694 2432 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2433 break;
yabahiro 38:40e7fdf3c694 2434 case 1:
yabahiro 38:40e7fdf3c694 2435 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2436 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2437 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2438 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2439 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2440 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2441 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2442 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2443 break;
yabahiro 38:40e7fdf3c694 2444 case 3:
yabahiro 38:40e7fdf3c694 2445 motor[TIRE_FR].pwm = fast;
yabahiro 38:40e7fdf3c694 2446 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2447 motor[TIRE_FL].pwm = slow;
yabahiro 38:40e7fdf3c694 2448 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2449 motor[TIRE_BR].pwm = slow;
yabahiro 38:40e7fdf3c694 2450 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2451 motor[TIRE_BL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2452 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2453 break;
yabahiro 38:40e7fdf3c694 2454 case 2:
yabahiro 38:40e7fdf3c694 2455 motor[TIRE_FR].pwm = fast;
yabahiro 38:40e7fdf3c694 2456 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2457 motor[TIRE_FL].pwm = normal;
yabahiro 38:40e7fdf3c694 2458 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2459 motor[TIRE_BR].pwm = normal;
yabahiro 38:40e7fdf3c694 2460 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2461 motor[TIRE_BL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2462 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2463 break;
yabahiro 33:dd598bb23ad1 2464 }
yabahiro 38:40e7fdf3c694 2465 if(DOLS==true||UPLS==true) {
yabahiro 38:40e7fdf3c694 2466 motor[MOTOR_0].pwm = 200;
yabahiro 38:40e7fdf3c694 2467 motor[MOTOR_0].dir = BRAKE;
yabahiro 38:40e7fdf3c694 2468 }
yabahiro 38:40e7fdf3c694 2469 if(g[1]==98) {
yabahiro 38:40e7fdf3c694 2470 fast=30;
yabahiro 38:40e7fdf3c694 2471 normal=20;
yabahiro 38:40e7fdf3c694 2472 slow=20;
yabahiro 38:40e7fdf3c694 2473 if(DOLS==true||UPLS==true) {
yabahiro 38:40e7fdf3c694 2474 motor[MOTOR_0].pwm = 200;
yabahiro 38:40e7fdf3c694 2475 motor[MOTOR_0].dir = BRAKE;
yabahiro 38:40e7fdf3c694 2476 } else {
yabahiro 38:40e7fdf3c694 2477 motor[MOTOR_0].pwm = 100;
yabahiro 38:40e7fdf3c694 2478 motor[MOTOR_0].dir = BACK;
yabahiro 38:40e7fdf3c694 2479 }
yabahiro 38:40e7fdf3c694 2480 }
yabahiro 38:40e7fdf3c694 2481 if(g[3]==254&&countss>=100000) {
yabahiro 38:40e7fdf3c694 2482 mode=24;
yabahiro 38:40e7fdf3c694 2483 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 33:dd598bb23ad1 2484 countss=0;
yabahiro 38:40e7fdf3c694 2485 fast=60;
yabahiro 38:40e7fdf3c694 2486 normal=40;
yabahiro 38:40e7fdf3c694 2487 slow=30;
yabahiro 33:dd598bb23ad1 2488 }
yabahiro 33:dd598bb23ad1 2489 } else if(mode==24) {
yabahiro 38:40e7fdf3c694 2490 if(DOLS==true||UPLS==true) {
yabahiro 38:40e7fdf3c694 2491 motor[MOTOR_0].pwm = 200;
yabahiro 38:40e7fdf3c694 2492 motor[MOTOR_0].dir = BRAKE;
yabahiro 38:40e7fdf3c694 2493 } else {
yabahiro 38:40e7fdf3c694 2494 motor[MOTOR_0].pwm = 100;
yabahiro 38:40e7fdf3c694 2495 motor[MOTOR_0].dir = BACK;
yabahiro 38:40e7fdf3c694 2496 }
yabahiro 38:40e7fdf3c694 2497 if(g[4]==3||g[4]==2) {
yabahiro 38:40e7fdf3c694 2498 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2499 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2500 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2501 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2502 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2503 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 2504 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2505 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2506 }
yabahiro 38:40e7fdf3c694 2507 if(g[4]==253||g[4]==254) {
yabahiro 38:40e7fdf3c694 2508 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2509 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2510 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2511 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2512 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2513 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2514 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2515 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 2516 }
yabahiro 38:40e7fdf3c694 2517 switch(g[2]) {
yabahiro 38:40e7fdf3c694 2518 case 0:
yabahiro 38:40e7fdf3c694 2519 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 2520 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2521 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 2522 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2523 break;
yabahiro 38:40e7fdf3c694 2524 case 255:
yabahiro 38:40e7fdf3c694 2525 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2526 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2527 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 2528 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2529 break;
yabahiro 38:40e7fdf3c694 2530 case 253:
yabahiro 38:40e7fdf3c694 2531 motor[TIRE_FR].pwm = 40;
yabahiro 38:40e7fdf3c694 2532 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2533 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 2534 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2535 break;
yabahiro 38:40e7fdf3c694 2536 case 254:
yabahiro 38:40e7fdf3c694 2537 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2538 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2539 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2540 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 2541 break;
yabahiro 38:40e7fdf3c694 2542 case 1:
yabahiro 38:40e7fdf3c694 2543 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 2544 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2545 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2546 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2547 break;
yabahiro 38:40e7fdf3c694 2548 case 3:
yabahiro 38:40e7fdf3c694 2549 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 2550 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2551 motor[TIRE_BR].pwm = 40;
yabahiro 38:40e7fdf3c694 2552 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2553 break;
yabahiro 38:40e7fdf3c694 2554 case 2:
yabahiro 38:40e7fdf3c694 2555 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2556 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2557 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2558 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2559 break;
yabahiro 38:40e7fdf3c694 2560 }
yabahiro 38:40e7fdf3c694 2561 switch(g[3]) {
yabahiro 38:40e7fdf3c694 2562 case 0:
yabahiro 38:40e7fdf3c694 2563 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 2564 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2565 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 2566 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2567 break;
yabahiro 38:40e7fdf3c694 2568 case 255:
yabahiro 38:40e7fdf3c694 2569 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 2570 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2571 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2572 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2573 case 253:
yabahiro 38:40e7fdf3c694 2574 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 2575 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2576 motor[TIRE_BL].pwm = 40;
yabahiro 38:40e7fdf3c694 2577 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2578 break;
yabahiro 38:40e7fdf3c694 2579 case 254:
yabahiro 38:40e7fdf3c694 2580 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2581 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2582 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2583 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2584 break;
yabahiro 38:40e7fdf3c694 2585 case 1:
yabahiro 38:40e7fdf3c694 2586 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2587 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2588 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 2589 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2590 break;
yabahiro 38:40e7fdf3c694 2591 case 3:
yabahiro 38:40e7fdf3c694 2592 motor[TIRE_FL].pwm = 40;
yabahiro 38:40e7fdf3c694 2593 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2594 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 2595 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2596 break;
yabahiro 38:40e7fdf3c694 2597 case 2:
yabahiro 38:40e7fdf3c694 2598 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2599 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2600 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2601 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 2602 break;
yabahiro 38:40e7fdf3c694 2603 }
yabahiro 38:40e7fdf3c694 2604 if(g[3]==0&&g[2]==0) {
yabahiro 38:40e7fdf3c694 2605 if(UPLS==true||DOLS==true) {
yabahiro 38:40e7fdf3c694 2606 motor[MOTOR_0].pwm = 200;
yabahiro 38:40e7fdf3c694 2607 motor[MOTOR_0].dir = BRAKE;
yabahiro 38:40e7fdf3c694 2608 mode=25;
yabahiro 38:40e7fdf3c694 2609 } else {
yabahiro 38:40e7fdf3c694 2610 motor[MOTOR_0].pwm = 100;
yabahiro 38:40e7fdf3c694 2611 motor[MOTOR_0].dir = BACK;
yabahiro 38:40e7fdf3c694 2612 }
yabahiro 38:40e7fdf3c694 2613 }
yabahiro 38:40e7fdf3c694 2614 } else if(mode==25) {
yabahiro 38:40e7fdf3c694 2615 switch(g[4]) {
yabahiro 38:40e7fdf3c694 2616 case 98:
yabahiro 38:40e7fdf3c694 2617 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 2618 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2619 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 2620 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2621 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 2622 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2623 motor[TIRE_BL].pwm = 55;
yabahiro 38:40e7fdf3c694 2624 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2625 break;
yabahiro 38:40e7fdf3c694 2626 case 99:
yabahiro 38:40e7fdf3c694 2627 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2628 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2629 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2630 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2631 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2632 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2633 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2634 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2635 break;
yabahiro 38:40e7fdf3c694 2636 case 0:
yabahiro 38:40e7fdf3c694 2637 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 2638 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2639 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 2640 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2641 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 2642 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2643 motor[TIRE_BL].pwm = 55;
yabahiro 38:40e7fdf3c694 2644 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2645 break;
yabahiro 38:40e7fdf3c694 2646 case 255:
yabahiro 38:40e7fdf3c694 2647 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2648 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2649 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2650 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2651 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2652 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2653 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2654 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2655 break;
yabahiro 38:40e7fdf3c694 2656 case 253:
yabahiro 38:40e7fdf3c694 2657 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 2658 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2659 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 2660 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2661 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 2662 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2663 motor[TIRE_BL].pwm = 15;
yabahiro 38:40e7fdf3c694 2664 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2665 break;
yabahiro 38:40e7fdf3c694 2666 case 254:
yabahiro 38:40e7fdf3c694 2667 motor[TIRE_FR].pwm = 40;
yabahiro 38:40e7fdf3c694 2668 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2669 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 2670 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2671 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 2672 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2673 motor[TIRE_BL].pwm = 35;
yabahiro 38:40e7fdf3c694 2674 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2675 break;
yabahiro 38:40e7fdf3c694 2676 case 1:
yabahiro 38:40e7fdf3c694 2677 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2678 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2679 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2680 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2681 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2682 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2683 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2684 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2685 break;
yabahiro 38:40e7fdf3c694 2686 case 3:
yabahiro 38:40e7fdf3c694 2687 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 2688 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2689 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 2690 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2691 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 2692 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2693 motor[TIRE_BL].pwm = 55;
yabahiro 38:40e7fdf3c694 2694 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2695 break;
yabahiro 38:40e7fdf3c694 2696 case 2:
yabahiro 38:40e7fdf3c694 2697 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 2698 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2699 motor[TIRE_FL].pwm = 40;
yabahiro 38:40e7fdf3c694 2700 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2701 motor[TIRE_BR].pwm = 40;
yabahiro 38:40e7fdf3c694 2702 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2703 motor[TIRE_BL].pwm = 55;
yabahiro 38:40e7fdf3c694 2704 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2705 break;
yabahiro 38:40e7fdf3c694 2706 }
yabahiro 38:40e7fdf3c694 2707 if(g[1]==98) {
yabahiro 38:40e7fdf3c694 2708 mode=31;
yabahiro 33:dd598bb23ad1 2709 }
yabahiro 33:dd598bb23ad1 2710 }
yabahiro 33:dd598bb23ad1 2711 } else {
yabahiro 38:40e7fdf3c694 2712 if(mode==21) {
yabahiro 38:40e7fdf3c694 2713 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2714 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2715 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2716 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2717 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2718 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2719 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2720 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2721 if(g[1]==0) {
yabahiro 38:40e7fdf3c694 2722 mode=22;
yabahiro 38:40e7fdf3c694 2723 fast=60;
yabahiro 38:40e7fdf3c694 2724 normal=40;
yabahiro 38:40e7fdf3c694 2725 slow=20;
yabahiro 38:40e7fdf3c694 2726 }
yabahiro 38:40e7fdf3c694 2727 } else if(mode==22) {
yabahiro 38:40e7fdf3c694 2728 if(g[3]==0) {
yabahiro 38:40e7fdf3c694 2729 mode=23;
yabahiro 38:40e7fdf3c694 2730 }
yabahiro 38:40e7fdf3c694 2731 switch(g[1]) {
yabahiro 38:40e7fdf3c694 2732 case 98:
yabahiro 38:40e7fdf3c694 2733 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 38:40e7fdf3c694 2734 fast=30;
yabahiro 38:40e7fdf3c694 2735 normal=20;
yabahiro 38:40e7fdf3c694 2736 slow=20;
yabahiro 38:40e7fdf3c694 2737 motor[TIRE_FR].pwm = normal;
yabahiro 38:40e7fdf3c694 2738 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2739 motor[TIRE_FL].pwm = normal;
yabahiro 38:40e7fdf3c694 2740 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2741 motor[TIRE_BR].pwm = normal;
yabahiro 38:40e7fdf3c694 2742 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2743 motor[TIRE_BL].pwm = normal;
yabahiro 38:40e7fdf3c694 2744 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2745 break;
yabahiro 38:40e7fdf3c694 2746 case 0:
yabahiro 38:40e7fdf3c694 2747 motor[TIRE_FR].pwm = fast;
yabahiro 38:40e7fdf3c694 2748 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2749 motor[TIRE_FL].pwm = fast;
yabahiro 38:40e7fdf3c694 2750 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2751 motor[TIRE_BR].pwm = fast;
yabahiro 38:40e7fdf3c694 2752 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2753 motor[TIRE_BL].pwm = fast;
yabahiro 38:40e7fdf3c694 2754 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2755 mtc=true;
yabahiro 38:40e7fdf3c694 2756 break;
yabahiro 38:40e7fdf3c694 2757 case 255:
yabahiro 38:40e7fdf3c694 2758 motor[TIRE_FR].pwm = fast;
yabahiro 38:40e7fdf3c694 2759 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2760 motor[TIRE_FL].pwm = slow;
yabahiro 38:40e7fdf3c694 2761 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2762 motor[TIRE_BR].pwm = slow;
yabahiro 38:40e7fdf3c694 2763 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2764 motor[TIRE_BL].pwm = fast;
yabahiro 38:40e7fdf3c694 2765 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2766 mtc=true;
yabahiro 38:40e7fdf3c694 2767 break;
yabahiro 38:40e7fdf3c694 2768 case 253:
yabahiro 38:40e7fdf3c694 2769 motor[TIRE_FR].pwm = slow;
yabahiro 38:40e7fdf3c694 2770 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2771 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2772 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2773 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2774 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2775 motor[TIRE_BL].pwm = slow;
yabahiro 38:40e7fdf3c694 2776 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2777 mtc=true;
yabahiro 38:40e7fdf3c694 2778 break;
yabahiro 38:40e7fdf3c694 2779 case 254:
yabahiro 38:40e7fdf3c694 2780 motor[TIRE_FR].pwm = normal;
yabahiro 38:40e7fdf3c694 2781 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2782 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2783 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2784 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2785 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2786 motor[TIRE_BL].pwm = normal;
yabahiro 38:40e7fdf3c694 2787 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2788 mtc=true;
yabahiro 38:40e7fdf3c694 2789 break;
yabahiro 38:40e7fdf3c694 2790 case 1:
yabahiro 38:40e7fdf3c694 2791 motor[TIRE_FR].pwm = slow;
yabahiro 38:40e7fdf3c694 2792 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2793 motor[TIRE_FL].pwm = fast;
yabahiro 38:40e7fdf3c694 2794 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2795 motor[TIRE_BR].pwm = fast;
yabahiro 38:40e7fdf3c694 2796 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2797 motor[TIRE_BL].pwm = slow;
yabahiro 38:40e7fdf3c694 2798 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2799 mtc=true;
yabahiro 38:40e7fdf3c694 2800 break;
yabahiro 38:40e7fdf3c694 2801 case 3:
yabahiro 38:40e7fdf3c694 2802 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2803 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2804 motor[TIRE_FL].pwm = slow;
yabahiro 38:40e7fdf3c694 2805 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2806 motor[TIRE_BR].pwm = slow;
yabahiro 38:40e7fdf3c694 2807 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2808 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2809 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2810 mtc=true;
yabahiro 38:40e7fdf3c694 2811 break;
yabahiro 38:40e7fdf3c694 2812 case 2:
yabahiro 38:40e7fdf3c694 2813 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2814 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2815 motor[TIRE_FL].pwm = normal;
yabahiro 38:40e7fdf3c694 2816 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2817 motor[TIRE_BR].pwm = normal;
yabahiro 38:40e7fdf3c694 2818 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2819 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2820 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2821 mtc=true;
yabahiro 38:40e7fdf3c694 2822 break;
yabahiro 38:40e7fdf3c694 2823 }
yabahiro 38:40e7fdf3c694 2824 if(g[1]!=98&&mtc==true) {
yabahiro 38:40e7fdf3c694 2825 switch(g[0]) {
yabahiro 38:40e7fdf3c694 2826 case 0:
yabahiro 38:40e7fdf3c694 2827 mtc=false;
yabahiro 38:40e7fdf3c694 2828 break;
yabahiro 38:40e7fdf3c694 2829 case 255:
yabahiro 38:40e7fdf3c694 2830 motor[TIRE_FL].pwm += 5;
yabahiro 38:40e7fdf3c694 2831 mtc=false;
yabahiro 38:40e7fdf3c694 2832 break;
yabahiro 38:40e7fdf3c694 2833 case 253:
yabahiro 38:40e7fdf3c694 2834 motor[TIRE_FL].pwm += 10;
yabahiro 38:40e7fdf3c694 2835 mtc=false;
yabahiro 38:40e7fdf3c694 2836 break;
yabahiro 38:40e7fdf3c694 2837 case 254:
yabahiro 38:40e7fdf3c694 2838 motor[TIRE_FL].pwm += 20;
yabahiro 38:40e7fdf3c694 2839 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2840 mtc=false;
yabahiro 38:40e7fdf3c694 2841 break;
yabahiro 38:40e7fdf3c694 2842 case 1:
yabahiro 38:40e7fdf3c694 2843 motor[TIRE_FR].pwm += 5;
yabahiro 38:40e7fdf3c694 2844 mtc=false;
yabahiro 38:40e7fdf3c694 2845 break;
yabahiro 38:40e7fdf3c694 2846 case 3:
yabahiro 38:40e7fdf3c694 2847 motor[TIRE_FR].pwm += 10;
yabahiro 38:40e7fdf3c694 2848 mtc=false;
yabahiro 38:40e7fdf3c694 2849 break;
yabahiro 38:40e7fdf3c694 2850 case 2:
yabahiro 38:40e7fdf3c694 2851 motor[TIRE_FR].pwm += 20;
yabahiro 38:40e7fdf3c694 2852 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2853 mtc=false;
yabahiro 38:40e7fdf3c694 2854 break;
yabahiro 38:40e7fdf3c694 2855 }
yabahiro 38:40e7fdf3c694 2856 }
yabahiro 38:40e7fdf3c694 2857 } else if(mode==23) {
yabahiro 38:40e7fdf3c694 2858 if(UPLS==true||DOLS==true) {
yabahiro 38:40e7fdf3c694 2859 motor[MOTOR_0].pwm = 200;
yabahiro 38:40e7fdf3c694 2860 motor[MOTOR_0].dir = BRAKE;
yabahiro 38:40e7fdf3c694 2861 fast=60;
yabahiro 38:40e7fdf3c694 2862 normal=40;
yabahiro 38:40e7fdf3c694 2863 slow=20;
yabahiro 33:dd598bb23ad1 2864 countss=0;
yabahiro 38:40e7fdf3c694 2865 mode=24;
yabahiro 38:40e7fdf3c694 2866 } else {
yabahiro 38:40e7fdf3c694 2867 motor[MOTOR_0].pwm = 100;
yabahiro 38:40e7fdf3c694 2868 motor[MOTOR_0].dir = BACK;
yabahiro 38:40e7fdf3c694 2869 motor[TIRE_FR].pwm = 100;
yabahiro 38:40e7fdf3c694 2870 motor[TIRE_FR].dir = BRAKE;
yabahiro 38:40e7fdf3c694 2871 motor[TIRE_FL].pwm = 100;
yabahiro 38:40e7fdf3c694 2872 motor[TIRE_FL].dir = BRAKE;
yabahiro 38:40e7fdf3c694 2873 motor[TIRE_BR].pwm = 100;
yabahiro 38:40e7fdf3c694 2874 motor[TIRE_BR].dir = BRAKE;
yabahiro 38:40e7fdf3c694 2875 motor[TIRE_BL].pwm = 100;
yabahiro 38:40e7fdf3c694 2876 motor[TIRE_BL].dir = BRAKE;
yabahiro 38:40e7fdf3c694 2877 }
yabahiro 38:40e7fdf3c694 2878
yabahiro 38:40e7fdf3c694 2879 } else if(mode==24) {
yabahiro 38:40e7fdf3c694 2880 if(g[1]==98&&countss>=40000) {
yabahiro 38:40e7fdf3c694 2881 mode=31;
yabahiro 38:40e7fdf3c694 2882 countss=0;
yabahiro 38:40e7fdf3c694 2883 }
yabahiro 38:40e7fdf3c694 2884 switch(g[1]) {
yabahiro 38:40e7fdf3c694 2885 case 98:
yabahiro 38:40e7fdf3c694 2886 fast=30;
yabahiro 38:40e7fdf3c694 2887 normal=20;
yabahiro 38:40e7fdf3c694 2888 slow=20;
yabahiro 38:40e7fdf3c694 2889 motor[TIRE_FR].pwm = normal;
yabahiro 38:40e7fdf3c694 2890 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2891 motor[TIRE_FL].pwm = normal;
yabahiro 38:40e7fdf3c694 2892 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2893 motor[TIRE_BR].pwm = normal;
yabahiro 38:40e7fdf3c694 2894 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2895 motor[TIRE_BL].pwm = normal;
yabahiro 38:40e7fdf3c694 2896 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2897 break;
yabahiro 38:40e7fdf3c694 2898 case 0:
yabahiro 38:40e7fdf3c694 2899 motor[TIRE_FR].pwm = fast;
yabahiro 38:40e7fdf3c694 2900 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2901 motor[TIRE_FL].pwm = fast;
yabahiro 38:40e7fdf3c694 2902 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2903 motor[TIRE_BR].pwm = fast;
yabahiro 38:40e7fdf3c694 2904 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2905 motor[TIRE_BL].pwm = fast;
yabahiro 38:40e7fdf3c694 2906 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2907 mtc=true;
yabahiro 38:40e7fdf3c694 2908 break;
yabahiro 38:40e7fdf3c694 2909 case 255:
yabahiro 38:40e7fdf3c694 2910 motor[TIRE_FR].pwm = fast;
yabahiro 38:40e7fdf3c694 2911 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2912 motor[TIRE_FL].pwm = slow;
yabahiro 38:40e7fdf3c694 2913 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2914 motor[TIRE_BR].pwm = slow;
yabahiro 38:40e7fdf3c694 2915 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2916 motor[TIRE_BL].pwm = fast;
yabahiro 38:40e7fdf3c694 2917 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2918 mtc=true;
yabahiro 38:40e7fdf3c694 2919 break;
yabahiro 38:40e7fdf3c694 2920 case 253:
yabahiro 38:40e7fdf3c694 2921 motor[TIRE_FR].pwm = slow;
yabahiro 38:40e7fdf3c694 2922 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2923 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2924 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2925 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2926 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2927 motor[TIRE_BL].pwm = slow;
yabahiro 38:40e7fdf3c694 2928 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2929 mtc=true;
yabahiro 38:40e7fdf3c694 2930 break;
yabahiro 38:40e7fdf3c694 2931 case 254:
yabahiro 38:40e7fdf3c694 2932 motor[TIRE_FR].pwm = normal;
yabahiro 38:40e7fdf3c694 2933 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2934 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2935 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2936 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2937 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2938 motor[TIRE_BL].pwm = normal;
yabahiro 38:40e7fdf3c694 2939 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2940 mtc=true;
yabahiro 38:40e7fdf3c694 2941 break;
yabahiro 38:40e7fdf3c694 2942 case 1:
yabahiro 38:40e7fdf3c694 2943 motor[TIRE_FR].pwm = slow;
yabahiro 38:40e7fdf3c694 2944 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2945 motor[TIRE_FL].pwm = fast;
yabahiro 38:40e7fdf3c694 2946 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2947 motor[TIRE_BR].pwm = fast;
yabahiro 38:40e7fdf3c694 2948 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2949 motor[TIRE_BL].pwm = slow;
yabahiro 38:40e7fdf3c694 2950 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2951 mtc=true;
yabahiro 38:40e7fdf3c694 2952 break;
yabahiro 38:40e7fdf3c694 2953 case 3:
yabahiro 38:40e7fdf3c694 2954 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2955 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2956 motor[TIRE_FL].pwm = slow;
yabahiro 38:40e7fdf3c694 2957 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2958 motor[TIRE_BR].pwm = slow;
yabahiro 38:40e7fdf3c694 2959 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2960 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2961 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2962 mtc=true;
yabahiro 38:40e7fdf3c694 2963 break;
yabahiro 38:40e7fdf3c694 2964 case 2:
yabahiro 38:40e7fdf3c694 2965 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2966 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2967 motor[TIRE_FL].pwm = normal;
yabahiro 38:40e7fdf3c694 2968 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2969 motor[TIRE_BR].pwm = normal;
yabahiro 38:40e7fdf3c694 2970 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2971 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2972 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2973 mtc=true;
yabahiro 38:40e7fdf3c694 2974 break;
yabahiro 38:40e7fdf3c694 2975 }
yabahiro 38:40e7fdf3c694 2976 if(g[1]!=98&&mtc==true) {
yabahiro 38:40e7fdf3c694 2977 switch(g[0]) {
yabahiro 38:40e7fdf3c694 2978 case 0:
yabahiro 38:40e7fdf3c694 2979 mtc=false;
yabahiro 38:40e7fdf3c694 2980 break;
yabahiro 38:40e7fdf3c694 2981 case 255:
yabahiro 38:40e7fdf3c694 2982 motor[TIRE_FL].pwm += 5;
yabahiro 38:40e7fdf3c694 2983 mtc=false;
yabahiro 38:40e7fdf3c694 2984 break;
yabahiro 38:40e7fdf3c694 2985 case 253:
yabahiro 38:40e7fdf3c694 2986 motor[TIRE_FL].pwm += 10;
yabahiro 38:40e7fdf3c694 2987 mtc=false;
yabahiro 38:40e7fdf3c694 2988 break;
yabahiro 38:40e7fdf3c694 2989 case 254:
yabahiro 38:40e7fdf3c694 2990 motor[TIRE_FL].pwm += 20;
yabahiro 38:40e7fdf3c694 2991 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2992 mtc=false;
yabahiro 38:40e7fdf3c694 2993 break;
yabahiro 38:40e7fdf3c694 2994 case 1:
yabahiro 38:40e7fdf3c694 2995 motor[TIRE_FR].pwm += 5;
yabahiro 38:40e7fdf3c694 2996 mtc=false;
yabahiro 38:40e7fdf3c694 2997 break;
yabahiro 38:40e7fdf3c694 2998 case 3:
yabahiro 38:40e7fdf3c694 2999 motor[TIRE_FR].pwm += 10;
yabahiro 38:40e7fdf3c694 3000 mtc=false;
yabahiro 38:40e7fdf3c694 3001 break;
yabahiro 38:40e7fdf3c694 3002 case 2:
yabahiro 38:40e7fdf3c694 3003 motor[TIRE_FR].pwm += 20;
yabahiro 38:40e7fdf3c694 3004 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 3005 mtc=false;
yabahiro 38:40e7fdf3c694 3006 break;
yabahiro 38:40e7fdf3c694 3007 }
yabahiro 33:dd598bb23ad1 3008 }
yabahiro 33:dd598bb23ad1 3009 }
yabahiro 33:dd598bb23ad1 3010 }
yabahiro 38:40e7fdf3c694 3011 if(mode==31) {
yabahiro 33:dd598bb23ad1 3012 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3013 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 3014 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3015 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3016 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3017 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 3018 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3019 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 3020 if(countss>=5000) {
yabahiro 33:dd598bb23ad1 3021 countss=0;
yabahiro 33:dd598bb23ad1 3022 mode=32;
yabahiro 33:dd598bb23ad1 3023 }
yabahiro 33:dd598bb23ad1 3024 } else if(mode==32) {
yabahiro 33:dd598bb23ad1 3025 motor[TIRE_FR].pwm = 10;
yabahiro 33:dd598bb23ad1 3026 motor[TIRE_FR].dir = BRAKE;
yabahiro 33:dd598bb23ad1 3027 motor[TIRE_FL].pwm = 10;
yabahiro 33:dd598bb23ad1 3028 motor[TIRE_FL].dir = BRAKE;
yabahiro 33:dd598bb23ad1 3029 motor[TIRE_BR].pwm = 10;
yabahiro 33:dd598bb23ad1 3030 motor[TIRE_BR].dir = BRAKE;
yabahiro 33:dd598bb23ad1 3031 motor[TIRE_BL].pwm = 10;
yabahiro 33:dd598bb23ad1 3032 motor[TIRE_BL].dir = BRAKE;
yabahiro 33:dd598bb23ad1 3033 if(countss>=40000) {
yabahiro 33:dd598bb23ad1 3034 mode=33;
yabahiro 33:dd598bb23ad1 3035 countss=0;
yabahiro 33:dd598bb23ad1 3036 }
yabahiro 33:dd598bb23ad1 3037 } else if(mode==33) {
yabahiro 33:dd598bb23ad1 3038 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 3039 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 3040 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 3041 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3042 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 3043 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3044 motor[TIRE_BL].pwm = 00;
yabahiro 38:40e7fdf3c694 3045 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3046 if(g[3]==0) {
yabahiro 38:40e7fdf3c694 3047 cross=0;
yabahiro 33:dd598bb23ad1 3048 countss=0;
yabahiro 33:dd598bb23ad1 3049 mode=40;
yabahiro 33:dd598bb23ad1 3050 }
yabahiro 33:dd598bb23ad1 3051 } else if(mode==40) {
yabahiro 33:dd598bb23ad1 3052 switch(g[3]) {
yabahiro 33:dd598bb23ad1 3053 case 98:
yabahiro 33:dd598bb23ad1 3054 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 3055 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 3056 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 3057 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3058 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 3059 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3060 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 3061 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 3062 if(countss>10000) {
yabahiro 33:dd598bb23ad1 3063 cross++;
yabahiro 33:dd598bb23ad1 3064 countss=0;
yabahiro 33:dd598bb23ad1 3065 }
yabahiro 33:dd598bb23ad1 3066 mtc2=true;
yabahiro 38:40e7fdf3c694 3067 if(cross==1) {
yabahiro 33:dd598bb23ad1 3068 mode=41;
yabahiro 33:dd598bb23ad1 3069 countss=0;
yabahiro 33:dd598bb23ad1 3070 cross=0;
yabahiro 33:dd598bb23ad1 3071 }
yabahiro 33:dd598bb23ad1 3072 break;
yabahiro 33:dd598bb23ad1 3073 case 0:
yabahiro 33:dd598bb23ad1 3074 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 3075 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 3076 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 3077 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3078 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 3079 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3080 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 3081 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 3082 mtc2=true;
yabahiro 33:dd598bb23ad1 3083 break;
yabahiro 33:dd598bb23ad1 3084 case 255:
yabahiro 33:dd598bb23ad1 3085 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 3086 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 3087 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 3088 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3089 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 3090 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3091 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 3092 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 3093 mtc2=true;
yabahiro 33:dd598bb23ad1 3094 break;
yabahiro 33:dd598bb23ad1 3095 case 253:
yabahiro 33:dd598bb23ad1 3096 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3097 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 3098 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 3099 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3100 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 3101 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3102 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3103 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 3104 mtc2=true;
yabahiro 33:dd598bb23ad1 3105 break;
yabahiro 33:dd598bb23ad1 3106 case 254:
yabahiro 33:dd598bb23ad1 3107 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3108 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 3109 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 3110 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3111 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 3112 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3113 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3114 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 3115 mtc2=true;
yabahiro 33:dd598bb23ad1 3116 break;
yabahiro 33:dd598bb23ad1 3117 case 1:
yabahiro 33:dd598bb23ad1 3118 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 3119 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 3120 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 3121 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3122 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 3123 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3124 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 3125 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 3126 mtc2=true;
yabahiro 33:dd598bb23ad1 3127 break;
yabahiro 33:dd598bb23ad1 3128 case 3:
yabahiro 33:dd598bb23ad1 3129 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 3130 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 3131 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3132 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3133 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3134 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 3135 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 3136 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 3137 mtc2=true;
yabahiro 33:dd598bb23ad1 3138 break;
yabahiro 33:dd598bb23ad1 3139 case 2:
yabahiro 33:dd598bb23ad1 3140 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 3141 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 3142 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3143 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3144 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3145 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 3146 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 3147 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 3148 mtc2=true;
yabahiro 33:dd598bb23ad1 3149 break;
yabahiro 33:dd598bb23ad1 3150 }
yabahiro 33:dd598bb23ad1 3151 if(g[2]!=98&&mtc2==true) {
yabahiro 33:dd598bb23ad1 3152 switch(g[2]) {
yabahiro 33:dd598bb23ad1 3153 case 0:
yabahiro 33:dd598bb23ad1 3154 mtc2=false;
yabahiro 33:dd598bb23ad1 3155 break;
yabahiro 33:dd598bb23ad1 3156 case 255:
yabahiro 33:dd598bb23ad1 3157 motor[TIRE_FL].pwm += 5;
yabahiro 33:dd598bb23ad1 3158 mtc2=false;
yabahiro 33:dd598bb23ad1 3159 break;
yabahiro 33:dd598bb23ad1 3160 case 253:
yabahiro 33:dd598bb23ad1 3161 motor[TIRE_FL].pwm += 10;
yabahiro 33:dd598bb23ad1 3162 mtc2=false;
yabahiro 33:dd598bb23ad1 3163 break;
yabahiro 33:dd598bb23ad1 3164 case 254:
yabahiro 33:dd598bb23ad1 3165 motor[TIRE_FL].pwm += 20;
yabahiro 33:dd598bb23ad1 3166 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3167 mtc2=false;
yabahiro 33:dd598bb23ad1 3168 break;
yabahiro 33:dd598bb23ad1 3169 case 1:
yabahiro 33:dd598bb23ad1 3170 motor[TIRE_BL].pwm += 5;
yabahiro 33:dd598bb23ad1 3171 mtc2=false;
yabahiro 33:dd598bb23ad1 3172 break;
yabahiro 33:dd598bb23ad1 3173 case 3:
yabahiro 33:dd598bb23ad1 3174 motor[TIRE_BL].pwm += 10;
yabahiro 33:dd598bb23ad1 3175 mtc2=false;
yabahiro 33:dd598bb23ad1 3176 break;
yabahiro 33:dd598bb23ad1 3177 case 2:
yabahiro 33:dd598bb23ad1 3178 motor[TIRE_BL].pwm += 20;
yabahiro 33:dd598bb23ad1 3179 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3180 mtc2=false;
yabahiro 33:dd598bb23ad1 3181 break;
yabahiro 33:dd598bb23ad1 3182 }
yabahiro 33:dd598bb23ad1 3183 }
yabahiro 33:dd598bb23ad1 3184 } else if(mode==41) {
yabahiro 33:dd598bb23ad1 3185 if(LIF||LIB) {
yabahiro 33:dd598bb23ad1 3186 mode=42;
yabahiro 33:dd598bb23ad1 3187 }
yabahiro 33:dd598bb23ad1 3188 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3189 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 3190 motor[TIRE_FL].pwm = 30;
yabahiro 33:dd598bb23ad1 3191 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3192 motor[TIRE_BR].pwm = 30;
yabahiro 33:dd598bb23ad1 3193 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3194 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3195 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 3196 if(g[1]==0) {
yabahiro 33:dd598bb23ad1 3197 countss=0;
yabahiro 33:dd598bb23ad1 3198 mode=70;
yabahiro 33:dd598bb23ad1 3199 normal=60;
yabahiro 33:dd598bb23ad1 3200 fast=70;
yabahiro 33:dd598bb23ad1 3201 slow=40;
yabahiro 33:dd598bb23ad1 3202 }
yabahiro 33:dd598bb23ad1 3203 } else if(mode==42) {
yabahiro 33:dd598bb23ad1 3204 motor[TIRE_FR].pwm = 20;
yabahiro 33:dd598bb23ad1 3205 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3206 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3207 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3208 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3209 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 3210 motor[TIRE_BL].pwm = 20;
yabahiro 33:dd598bb23ad1 3211 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3212 if(g[1]==0) {
yabahiro 33:dd598bb23ad1 3213 countss=0;
yabahiro 33:dd598bb23ad1 3214 mode=70;
yabahiro 33:dd598bb23ad1 3215 }
yabahiro 33:dd598bb23ad1 3216 } else if(mode==70) {
yabahiro 33:dd598bb23ad1 3217 switch(g[1]) {
yabahiro 33:dd598bb23ad1 3218 case 99:
yabahiro 33:dd598bb23ad1 3219 if(countss>=100000) {
yabahiro 33:dd598bb23ad1 3220 mode=100;
yabahiro 33:dd598bb23ad1 3221 }
yabahiro 33:dd598bb23ad1 3222 break;
yabahiro 33:dd598bb23ad1 3223 case 98:
yabahiro 33:dd598bb23ad1 3224 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 3225 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3226 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 3227 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3228 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 3229 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3230 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 3231 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3232 break;
yabahiro 33:dd598bb23ad1 3233 case 0:
yabahiro 33:dd598bb23ad1 3234 motor[TIRE_FR].pwm = 80;
yabahiro 33:dd598bb23ad1 3235 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3236 motor[TIRE_FL].pwm = 80;
yabahiro 33:dd598bb23ad1 3237 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3238 motor[TIRE_BR].pwm = 80;
yabahiro 33:dd598bb23ad1 3239 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3240 motor[TIRE_BL].pwm = 80;
yabahiro 33:dd598bb23ad1 3241 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3242 mtc=true;
yabahiro 33:dd598bb23ad1 3243 break;
yabahiro 33:dd598bb23ad1 3244 case 255:
yabahiro 33:dd598bb23ad1 3245 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 3246 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3247 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 3248 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3249 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 3250 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3251 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 3252 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3253 mtc=true;
yabahiro 33:dd598bb23ad1 3254 break;
yabahiro 33:dd598bb23ad1 3255 case 253:
yabahiro 33:dd598bb23ad1 3256 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 3257 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3258 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3259 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3260 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3261 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 3262 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 3263 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3264 mtc=true;
yabahiro 33:dd598bb23ad1 3265 break;
yabahiro 33:dd598bb23ad1 3266 case 254:
yabahiro 33:dd598bb23ad1 3267 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 3268 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3269 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3270 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3271 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3272 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 3273 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 3274 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3275 mtc=true;
yabahiro 33:dd598bb23ad1 3276 break;
yabahiro 33:dd598bb23ad1 3277 case 1:
yabahiro 33:dd598bb23ad1 3278 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 3279 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3280 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 3281 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3282 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 3283 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3284 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 3285 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3286 mtc=true;
yabahiro 33:dd598bb23ad1 3287 break;
yabahiro 33:dd598bb23ad1 3288 case 3:
yabahiro 33:dd598bb23ad1 3289 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3290 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 3291 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 3292 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3293 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 3294 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3295 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3296 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 3297 mtc=true;
yabahiro 33:dd598bb23ad1 3298 break;
yabahiro 33:dd598bb23ad1 3299 case 2:
yabahiro 33:dd598bb23ad1 3300 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3301 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 3302 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 3303 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3304 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 3305 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3306 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3307 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 3308 mtc=true;
yabahiro 33:dd598bb23ad1 3309 break;
yabahiro 33:dd598bb23ad1 3310 }
yabahiro 33:dd598bb23ad1 3311 if(g[1]!=98&&mtc==true) {
yabahiro 33:dd598bb23ad1 3312 switch(g[0]) {
yabahiro 33:dd598bb23ad1 3313 case 0:
yabahiro 33:dd598bb23ad1 3314 mtc=false;
yabahiro 33:dd598bb23ad1 3315 break;
yabahiro 33:dd598bb23ad1 3316 case 255:
yabahiro 33:dd598bb23ad1 3317 motor[TIRE_FL].pwm += 5;
yabahiro 33:dd598bb23ad1 3318 mtc=false;
yabahiro 33:dd598bb23ad1 3319 break;
yabahiro 33:dd598bb23ad1 3320 case 253:
yabahiro 33:dd598bb23ad1 3321 motor[TIRE_FL].pwm += 10;
yabahiro 33:dd598bb23ad1 3322 mtc=false;
yabahiro 33:dd598bb23ad1 3323 break;
yabahiro 33:dd598bb23ad1 3324 case 254:
yabahiro 33:dd598bb23ad1 3325 motor[TIRE_FL].pwm += 20;
yabahiro 33:dd598bb23ad1 3326 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3327 mtc=false;
yabahiro 33:dd598bb23ad1 3328 break;
yabahiro 33:dd598bb23ad1 3329 case 1:
yabahiro 33:dd598bb23ad1 3330 motor[TIRE_FR].pwm += 5;
yabahiro 33:dd598bb23ad1 3331 mtc=false;
yabahiro 33:dd598bb23ad1 3332 break;
yabahiro 33:dd598bb23ad1 3333 case 3:
yabahiro 33:dd598bb23ad1 3334 motor[TIRE_FR].pwm += 10;
yabahiro 33:dd598bb23ad1 3335 mtc=false;
yabahiro 33:dd598bb23ad1 3336 break;
yabahiro 33:dd598bb23ad1 3337 case 2:
yabahiro 33:dd598bb23ad1 3338 motor[TIRE_FR].pwm += 20;
yabahiro 33:dd598bb23ad1 3339 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3340 mtc=false;
yabahiro 33:dd598bb23ad1 3341 break;
yabahiro 33:dd598bb23ad1 3342 }
yabahiro 33:dd598bb23ad1 3343 }
yabahiro 33:dd598bb23ad1 3344 } else if(mode==100) {
yabahiro 38:40e7fdf3c694 3345 motor[TIRE_FR].pwm = 40;
yabahiro 33:dd598bb23ad1 3346 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3347 motor[TIRE_FL].pwm = 40;
yabahiro 33:dd598bb23ad1 3348 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3349 motor[TIRE_BR].pwm = 43;
yabahiro 33:dd598bb23ad1 3350 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3351 motor[TIRE_BL].pwm = 40;
yabahiro 33:dd598bb23ad1 3352 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3353 } else {
yabahiro 33:dd598bb23ad1 3354 }
yabahiro 33:dd598bb23ad1 3355
kishibekairohan 13:b6e02d6261d7 3356 }
kishibekairohan 13:b6e02d6261d7 3357 #endif
kishibekairohan 13:b6e02d6261d7 3358
kishibekairohan 13:b6e02d6261d7 3359 #if USE_PROCESS_NUM>4
Ryosei 27:dd9f27fce7d1 3360 static void Process4()
M_souta 22:7d93f79a3686 3361 {
yabahiro 38:40e7fdf3c694 3362 //中間トレーステスト
yabahiro 38:40e7fdf3c694 3363 switch(g[4]) {
yabahiro 38:40e7fdf3c694 3364 case 98:
yabahiro 39:784552c26163 3365 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 3366 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 3367 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 3368 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 3369 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 3370 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 3371 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 3372 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 3373 break;
yabahiro 38:40e7fdf3c694 3374 case 99:
yabahiro 38:40e7fdf3c694 3375 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 3376 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3377 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 3378 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3379 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 3380 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3381 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 3382 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3383 break;
yabahiro 38:40e7fdf3c694 3384 case 0:
yabahiro 39:784552c26163 3385 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 3386 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 3387 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 3388 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 3389 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 3390 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 3391 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 3392 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 3393 break;
yabahiro 38:40e7fdf3c694 3394 case 255:
yabahiro 38:40e7fdf3c694 3395 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 3396 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3397 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 3398 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3399 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 3400 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3401 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 3402 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3403 break;
yabahiro 38:40e7fdf3c694 3404 case 253:
yabahiro 39:784552c26163 3405 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 3406 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 3407 motor[TIRE_FL].pwm = slow;
yabahiro 39:784552c26163 3408 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 3409 motor[TIRE_BR].pwm = slow;
yabahiro 39:784552c26163 3410 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 3411 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 3412 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 3413 break;
yabahiro 38:40e7fdf3c694 3414 case 254:
yabahiro 39:784552c26163 3415 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 3416 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 3417 motor[TIRE_FL].pwm = normal;
yabahiro 39:784552c26163 3418 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 3419 motor[TIRE_BR].pwm = normal;
yabahiro 39:784552c26163 3420 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 3421 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 3422 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 3423 break;
yabahiro 38:40e7fdf3c694 3424 case 1:
yabahiro 38:40e7fdf3c694 3425 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 3426 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3427 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 3428 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3429 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 3430 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3431 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 3432 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3433 break;
yabahiro 38:40e7fdf3c694 3434 case 3:
yabahiro 39:784552c26163 3435 motor[TIRE_FR].pwm = slow;
yabahiro 39:784552c26163 3436 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 3437 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 3438 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 3439 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 3440 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 3441 motor[TIRE_BL].pwm = slow-5;
yabahiro 39:784552c26163 3442 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 3443 break;
yabahiro 38:40e7fdf3c694 3444 case 2:
yabahiro 39:784552c26163 3445 motor[TIRE_FR].pwm = normal;
yabahiro 39:784552c26163 3446 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 3447 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 3448 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 3449 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 3450 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 3451 motor[TIRE_BL].pwm = normal-5;
yabahiro 39:784552c26163 3452 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 3453 break;
yabahiro 38:40e7fdf3c694 3454 }
yabahiro 33:dd598bb23ad1 3455
kishibekairohan 13:b6e02d6261d7 3456 }
kishibekairohan 13:b6e02d6261d7 3457 #endif
kishibekairohan 13:b6e02d6261d7 3458
kishibekairohan 13:b6e02d6261d7 3459 #if USE_PROCESS_NUM>5
Ryosei 27:dd9f27fce7d1 3460 static void Process5()
Ryosei 27:dd9f27fce7d1 3461 {
yabahiro 38:40e7fdf3c694 3462 if(g[4]==3||g[4]==2) {
yabahiro 38:40e7fdf3c694 3463 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 3464 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3465 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 3466 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 3467 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 3468 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 3469 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 3470 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3471 }
yabahiro 38:40e7fdf3c694 3472 if(g[4]==253||g[4]==254) {
yabahiro 38:40e7fdf3c694 3473 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 3474 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 3475 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 3476 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3477 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 3478 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3479 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 3480 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 3481 }
yabahiro 38:40e7fdf3c694 3482 switch(g[2]) {
yabahiro 38:40e7fdf3c694 3483 case 0:
yabahiro 38:40e7fdf3c694 3484 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 3485 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3486 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 3487 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3488 break;
yabahiro 38:40e7fdf3c694 3489 case 255:
yabahiro 38:40e7fdf3c694 3490 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 3491 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 3492 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 3493 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3494 break;
yabahiro 38:40e7fdf3c694 3495 case 253:
yabahiro 38:40e7fdf3c694 3496 motor[TIRE_FR].pwm = 40;
yabahiro 38:40e7fdf3c694 3497 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 3498 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 3499 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3500 break;
yabahiro 38:40e7fdf3c694 3501 case 254:
yabahiro 38:40e7fdf3c694 3502 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 3503 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 3504 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 3505 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 3506 break;
yabahiro 38:40e7fdf3c694 3507 case 1:
yabahiro 38:40e7fdf3c694 3508 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 3509 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3510 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 3511 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3512 break;
yabahiro 38:40e7fdf3c694 3513 case 3:
yabahiro 38:40e7fdf3c694 3514 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 3515 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3516 motor[TIRE_BR].pwm = 40;
yabahiro 38:40e7fdf3c694 3517 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3518 break;
yabahiro 38:40e7fdf3c694 3519 case 2:
yabahiro 38:40e7fdf3c694 3520 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 3521 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3522 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 3523 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3524 break;
yabahiro 38:40e7fdf3c694 3525 }
yabahiro 38:40e7fdf3c694 3526 switch(g[3]) {
yabahiro 38:40e7fdf3c694 3527 case 0:
yabahiro 38:40e7fdf3c694 3528 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 3529 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3530 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 3531 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3532 break;
yabahiro 38:40e7fdf3c694 3533 case 255:
yabahiro 38:40e7fdf3c694 3534 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 3535 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3536 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 3537 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3538 case 253:
yabahiro 38:40e7fdf3c694 3539 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 3540 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3541 motor[TIRE_BL].pwm = 40;
yabahiro 38:40e7fdf3c694 3542 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3543 break;
yabahiro 38:40e7fdf3c694 3544 case 254:
yabahiro 38:40e7fdf3c694 3545 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 3546 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3547 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 3548 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3549 break;
yabahiro 38:40e7fdf3c694 3550 case 1:
yabahiro 38:40e7fdf3c694 3551 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 3552 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 3553 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 3554 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3555 break;
yabahiro 38:40e7fdf3c694 3556 case 3:
yabahiro 38:40e7fdf3c694 3557 motor[TIRE_FL].pwm = 40;
yabahiro 38:40e7fdf3c694 3558 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 3559 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 3560 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3561 break;
yabahiro 38:40e7fdf3c694 3562 case 2:
yabahiro 38:40e7fdf3c694 3563 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 3564 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 3565 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 3566 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 3567 break;
yabahiro 38:40e7fdf3c694 3568 }
kishibekairohan 13:b6e02d6261d7 3569 }
kishibekairohan 13:b6e02d6261d7 3570 #endif
kishibekairohan 13:b6e02d6261d7 3571
kishibekairohan 13:b6e02d6261d7 3572 #if USE_PROCESS_NUM>6
Ryosei 27:dd9f27fce7d1 3573 static void Process6()
kishibekairohan 13:b6e02d6261d7 3574 {
yabahiro 38:40e7fdf3c694 3575 //修正して中間トレーステスト
yabahiro 38:40e7fdf3c694 3576 if(testmode==0) {
yabahiro 38:40e7fdf3c694 3577 if(g[4]==3||g[4]==2) {
yabahiro 38:40e7fdf3c694 3578 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 3579 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3580 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 3581 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 3582 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 3583 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 3584 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 3585 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3586 }
yabahiro 38:40e7fdf3c694 3587 if(g[4]==253||g[4]==254) {
yabahiro 38:40e7fdf3c694 3588 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 3589 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 3590 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 3591 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3592 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 3593 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3594 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 3595 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 3596 }
yabahiro 38:40e7fdf3c694 3597 switch(g[2]) {
yabahiro 38:40e7fdf3c694 3598 case 0:
yabahiro 38:40e7fdf3c694 3599 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 3600 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3601 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 3602 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3603 break;
yabahiro 38:40e7fdf3c694 3604 case 255:
yabahiro 38:40e7fdf3c694 3605 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 3606 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 3607 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 3608 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3609 break;
yabahiro 38:40e7fdf3c694 3610 case 253:
yabahiro 38:40e7fdf3c694 3611 motor[TIRE_FR].pwm = 40;
yabahiro 38:40e7fdf3c694 3612 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 3613 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 3614 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3615 break;
yabahiro 38:40e7fdf3c694 3616 case 254:
yabahiro 38:40e7fdf3c694 3617 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 3618 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 3619 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 3620 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 3621 break;
yabahiro 38:40e7fdf3c694 3622 case 1:
yabahiro 38:40e7fdf3c694 3623 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 3624 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3625 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 3626 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3627 break;
yabahiro 38:40e7fdf3c694 3628 case 3:
yabahiro 38:40e7fdf3c694 3629 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 3630 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3631 motor[TIRE_BR].pwm = 40;
yabahiro 38:40e7fdf3c694 3632 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3633 break;
yabahiro 38:40e7fdf3c694 3634 case 2:
yabahiro 38:40e7fdf3c694 3635 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 3636 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3637 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 3638 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3639 break;
yabahiro 38:40e7fdf3c694 3640 }
yabahiro 38:40e7fdf3c694 3641 switch(g[3]) {
yabahiro 38:40e7fdf3c694 3642 case 0:
yabahiro 38:40e7fdf3c694 3643 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 3644 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3645 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 3646 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3647 break;
yabahiro 38:40e7fdf3c694 3648 case 255:
yabahiro 38:40e7fdf3c694 3649 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 3650 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3651 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 3652 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3653 case 253:
yabahiro 38:40e7fdf3c694 3654 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 3655 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3656 motor[TIRE_BL].pwm = 40;
yabahiro 38:40e7fdf3c694 3657 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3658 break;
yabahiro 38:40e7fdf3c694 3659 case 254:
yabahiro 38:40e7fdf3c694 3660 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 3661 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3662 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 3663 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3664 break;
yabahiro 38:40e7fdf3c694 3665 case 1:
yabahiro 38:40e7fdf3c694 3666 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 3667 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 3668 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 3669 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3670 break;
yabahiro 38:40e7fdf3c694 3671 case 3:
yabahiro 38:40e7fdf3c694 3672 motor[TIRE_FL].pwm = 40;
yabahiro 38:40e7fdf3c694 3673 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 3674 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 3675 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3676 break;
yabahiro 38:40e7fdf3c694 3677 case 2:
yabahiro 38:40e7fdf3c694 3678 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 3679 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 3680 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 3681 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 3682 break;
yabahiro 38:40e7fdf3c694 3683 }
yabahiro 38:40e7fdf3c694 3684 if(g[3]==0&&g[2]==0) {
yabahiro 38:40e7fdf3c694 3685 testmode=1;
yabahiro 38:40e7fdf3c694 3686 }
yabahiro 38:40e7fdf3c694 3687 } else if(testmode==1) {
yabahiro 38:40e7fdf3c694 3688 switch(g[4]) {
yabahiro 38:40e7fdf3c694 3689 case 98:
yabahiro 38:40e7fdf3c694 3690 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 3691 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3692 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 3693 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3694 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 3695 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3696 motor[TIRE_BL].pwm = 60;
yabahiro 38:40e7fdf3c694 3697 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3698 break;
yabahiro 38:40e7fdf3c694 3699 case 99:
yabahiro 38:40e7fdf3c694 3700 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 3701 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3702 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 3703 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3704 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 3705 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3706 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 3707 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3708 break;
yabahiro 38:40e7fdf3c694 3709 case 0:
yabahiro 38:40e7fdf3c694 3710 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 3711 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3712 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 3713 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3714 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 3715 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3716 motor[TIRE_BL].pwm = 60;
yabahiro 38:40e7fdf3c694 3717 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3718 break;
yabahiro 38:40e7fdf3c694 3719 case 255:
yabahiro 38:40e7fdf3c694 3720 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 3721 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3722 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 3723 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3724 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 3725 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3726 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 3727 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3728 break;
yabahiro 38:40e7fdf3c694 3729 case 253:
yabahiro 38:40e7fdf3c694 3730 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 3731 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3732 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 3733 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3734 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 3735 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3736 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 3737 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3738 break;
yabahiro 38:40e7fdf3c694 3739 case 254:
yabahiro 38:40e7fdf3c694 3740 motor[TIRE_FR].pwm = 40;
yabahiro 38:40e7fdf3c694 3741 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3742 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 3743 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3744 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 3745 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3746 motor[TIRE_BL].pwm = 40;
yabahiro 38:40e7fdf3c694 3747 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3748 break;
yabahiro 38:40e7fdf3c694 3749 case 1:
yabahiro 38:40e7fdf3c694 3750 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 3751 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3752 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 3753 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3754 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 3755 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3756 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 3757 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3758 break;
yabahiro 38:40e7fdf3c694 3759 case 3:
yabahiro 38:40e7fdf3c694 3760 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 3761 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3762 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 3763 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3764 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 3765 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3766 motor[TIRE_BL].pwm = 60;
yabahiro 38:40e7fdf3c694 3767 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3768 break;
yabahiro 38:40e7fdf3c694 3769 case 2:
yabahiro 38:40e7fdf3c694 3770 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 3771 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3772 motor[TIRE_FL].pwm = 40;
yabahiro 38:40e7fdf3c694 3773 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3774 motor[TIRE_BR].pwm = 40;
yabahiro 38:40e7fdf3c694 3775 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3776 motor[TIRE_BL].pwm = 60;
yabahiro 38:40e7fdf3c694 3777 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3778 break;
yabahiro 38:40e7fdf3c694 3779 }
yabahiro 38:40e7fdf3c694 3780 if(g[1]==98) {
yabahiro 38:40e7fdf3c694 3781 testmode=2;
yabahiro 38:40e7fdf3c694 3782 }
yabahiro 38:40e7fdf3c694 3783 } else if(testmode==2) {
yabahiro 38:40e7fdf3c694 3784 if(g[4]==3||g[4]==2) {
yabahiro 38:40e7fdf3c694 3785 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 3786 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3787 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 3788 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 3789 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 3790 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 3791 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 3792 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3793 }
yabahiro 38:40e7fdf3c694 3794 if(g[4]==253||g[4]==254) {
yabahiro 38:40e7fdf3c694 3795 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 3796 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 3797 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 3798 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3799 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 3800 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3801 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 3802 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 3803 }
yabahiro 38:40e7fdf3c694 3804 switch(g[2]) {
yabahiro 38:40e7fdf3c694 3805 case 0:
yabahiro 38:40e7fdf3c694 3806 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 3807 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3808 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 3809 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3810 break;
yabahiro 38:40e7fdf3c694 3811 case 255:
yabahiro 38:40e7fdf3c694 3812 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 3813 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 3814 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 3815 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3816 break;
yabahiro 38:40e7fdf3c694 3817 case 253:
yabahiro 38:40e7fdf3c694 3818 motor[TIRE_FR].pwm = 40;
yabahiro 38:40e7fdf3c694 3819 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 3820 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 3821 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3822 break;
yabahiro 38:40e7fdf3c694 3823 case 254:
yabahiro 38:40e7fdf3c694 3824 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 3825 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 3826 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 3827 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 3828 break;
yabahiro 38:40e7fdf3c694 3829 case 1:
yabahiro 38:40e7fdf3c694 3830 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 3831 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3832 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 3833 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3834 break;
yabahiro 38:40e7fdf3c694 3835 case 3:
yabahiro 38:40e7fdf3c694 3836 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 3837 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3838 motor[TIRE_BR].pwm = 40;
yabahiro 38:40e7fdf3c694 3839 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3840 break;
yabahiro 38:40e7fdf3c694 3841 case 2:
yabahiro 38:40e7fdf3c694 3842 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 3843 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3844 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 3845 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3846 break;
yabahiro 38:40e7fdf3c694 3847 }
yabahiro 38:40e7fdf3c694 3848 switch(g[3]) {
yabahiro 38:40e7fdf3c694 3849 case 0:
yabahiro 38:40e7fdf3c694 3850 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 3851 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3852 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 3853 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3854 break;
yabahiro 38:40e7fdf3c694 3855 case 255:
yabahiro 38:40e7fdf3c694 3856 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 3857 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3858 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 3859 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3860 case 253:
yabahiro 38:40e7fdf3c694 3861 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 3862 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3863 motor[TIRE_BL].pwm = 40;
yabahiro 38:40e7fdf3c694 3864 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3865 break;
yabahiro 38:40e7fdf3c694 3866 case 254:
yabahiro 38:40e7fdf3c694 3867 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 3868 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3869 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 3870 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3871 break;
yabahiro 38:40e7fdf3c694 3872 case 1:
yabahiro 38:40e7fdf3c694 3873 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 3874 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 3875 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 3876 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3877 break;
yabahiro 38:40e7fdf3c694 3878 case 3:
yabahiro 38:40e7fdf3c694 3879 motor[TIRE_FL].pwm = 40;
yabahiro 38:40e7fdf3c694 3880 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 3881 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 3882 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3883 break;
yabahiro 38:40e7fdf3c694 3884 case 2:
yabahiro 38:40e7fdf3c694 3885 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 3886 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 3887 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 3888 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 3889 break;
yabahiro 38:40e7fdf3c694 3890 }
yabahiro 38:40e7fdf3c694 3891 if(g[3]==0&&g[2]==0) {
yabahiro 38:40e7fdf3c694 3892 testmode=3;
yabahiro 38:40e7fdf3c694 3893 }
yabahiro 38:40e7fdf3c694 3894 } else if(testmode==3) {
yabahiro 38:40e7fdf3c694 3895 switch(g[4]) {
yabahiro 38:40e7fdf3c694 3896 case 98:
yabahiro 38:40e7fdf3c694 3897 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 3898 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3899 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 3900 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3901 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 3902 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3903 motor[TIRE_BL].pwm = 60;
yabahiro 38:40e7fdf3c694 3904 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3905 break;
yabahiro 38:40e7fdf3c694 3906 case 99:
yabahiro 38:40e7fdf3c694 3907 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 3908 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3909 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 3910 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3911 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 3912 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3913 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 3914 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3915 break;
yabahiro 38:40e7fdf3c694 3916 case 0:
yabahiro 38:40e7fdf3c694 3917 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 3918 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3919 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 3920 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3921 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 3922 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3923 motor[TIRE_BL].pwm = 60;
yabahiro 38:40e7fdf3c694 3924 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3925 break;
yabahiro 38:40e7fdf3c694 3926 case 255:
yabahiro 38:40e7fdf3c694 3927 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 3928 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3929 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 3930 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3931 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 3932 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3933 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 3934 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3935 break;
yabahiro 38:40e7fdf3c694 3936 case 253:
yabahiro 38:40e7fdf3c694 3937 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 3938 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3939 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 3940 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3941 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 3942 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3943 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 3944 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3945 break;
yabahiro 38:40e7fdf3c694 3946 case 254:
yabahiro 38:40e7fdf3c694 3947 motor[TIRE_FR].pwm = 40;
yabahiro 38:40e7fdf3c694 3948 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3949 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 3950 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3951 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 3952 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3953 motor[TIRE_BL].pwm = 40;
yabahiro 38:40e7fdf3c694 3954 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3955 break;
yabahiro 38:40e7fdf3c694 3956 case 1:
yabahiro 38:40e7fdf3c694 3957 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 3958 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3959 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 3960 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3961 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 3962 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3963 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 3964 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3965 break;
yabahiro 38:40e7fdf3c694 3966 case 3:
yabahiro 38:40e7fdf3c694 3967 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 3968 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3969 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 3970 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3971 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 3972 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3973 motor[TIRE_BL].pwm = 60;
yabahiro 38:40e7fdf3c694 3974 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3975 break;
yabahiro 38:40e7fdf3c694 3976 case 2:
yabahiro 38:40e7fdf3c694 3977 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 3978 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 3979 motor[TIRE_FL].pwm = 40;
yabahiro 38:40e7fdf3c694 3980 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 3981 motor[TIRE_BR].pwm = 40;
yabahiro 38:40e7fdf3c694 3982 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 3983 motor[TIRE_BL].pwm = 60;
yabahiro 38:40e7fdf3c694 3984 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 3985 break;
yabahiro 38:40e7fdf3c694 3986 }
yabahiro 38:40e7fdf3c694 3987 if(g[1]==98) {
yabahiro 38:40e7fdf3c694 3988 testmode=4;
yabahiro 38:40e7fdf3c694 3989 }
yabahiro 38:40e7fdf3c694 3990 } else if(testmode==4) {
yabahiro 38:40e7fdf3c694 3991 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 3992 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 3993 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 3994 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 3995 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 3996 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 3997 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 3998 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3999 }
Ryosei 27:dd9f27fce7d1 4000
kishibekairohan 13:b6e02d6261d7 4001 }
kishibekairohan 13:b6e02d6261d7 4002 #endif
kishibekairohan 13:b6e02d6261d7 4003
kishibekairohan 13:b6e02d6261d7 4004 #if USE_PROCESS_NUM>7
kishibekairohan 13:b6e02d6261d7 4005 static void Process7()
kishibekairohan 13:b6e02d6261d7 4006 {
yabahiro 33:dd598bb23ad1 4007
kishibekairohan 12:c09b3e08a316 4008 }
kishibekairohan 12:c09b3e08a316 4009 #endif
kishibekairohan 12:c09b3e08a316 4010
Ryosei 27:dd9f27fce7d1 4011 #if USE_PROCESS_NUM>8
kishibekairohan 13:b6e02d6261d7 4012 static void Process8()
kishibekairohan 12:c09b3e08a316 4013 {
yabahiro 33:dd598bb23ad1 4014
kishibekairohan 12:c09b3e08a316 4015 }
kishibekairohan 12:c09b3e08a316 4016 #endif
kishibekairohan 12:c09b3e08a316 4017
kishibekairohan 13:b6e02d6261d7 4018 #if USE_PROCESS_NUM>9
kishibekairohan 13:b6e02d6261d7 4019 static void Process9()
kishibekairohan 12:c09b3e08a316 4020 {
Ryosei 27:dd9f27fce7d1 4021
t_yamamoto 0:669ef71cba68 4022 }
t_yamamoto 0:669ef71cba68 4023 #endif
t_yamamoto 0:669ef71cba68 4024 #endif
t_yamamoto 0:669ef71cba68 4025 #pragma endregion PROCESS
t_yamamoto 0:669ef71cba68 4026
t_yamamoto 0:669ef71cba68 4027 static void AllActuatorReset()
t_yamamoto 0:669ef71cba68 4028 {
yabahiro 33:dd598bb23ad1 4029 #ifdef USE_SOLENOID
yabahiro 33:dd598bb23ad1 4030 solenoid.all = ALL_SOLENOID_OFF;
yabahiro 33:dd598bb23ad1 4031 #endif
yabahiro 33:dd598bb23ad1 4032
yabahiro 33:dd598bb23ad1 4033 #ifdef USE_MOTOR
yabahiro 33:dd598bb23ad1 4034 for (uint8_t i = 0; i < MOUNTING_MOTOR_NUM; i++) {
yabahiro 33:dd598bb23ad1 4035 motor[i].dir = FREE;
yabahiro 33:dd598bb23ad1 4036 motor[i].pwm = 0;
yabahiro 33:dd598bb23ad1 4037 }
yabahiro 33:dd598bb23ad1 4038 #endif
t_yamamoto 0:669ef71cba68 4039 }
t_yamamoto 0:669ef71cba68 4040
kishibekairohan 16:3f2c2d89372b 4041 #pragma region USER-DEFINED-FUNCTIONS
M_souta 29:44d5454ce8fa 4042
M_souta 29:44d5454ce8fa 4043 uint8_t SetStatus(int pwmVal)
Ryosei 27:dd9f27fce7d1 4044 {
M_souta 29:44d5454ce8fa 4045 if (pwmVal < 0) return BACK;
M_souta 29:44d5454ce8fa 4046 else if (pwmVal > 0) return FOR;
M_souta 29:44d5454ce8fa 4047 else if (pwmVal == 0) return BRAKE;
M_souta 29:44d5454ce8fa 4048 else return BRAKE;
M_souta 22:7d93f79a3686 4049 }
kishibekairohan 16:3f2c2d89372b 4050
M_souta 29:44d5454ce8fa 4051 uint8_t SetPWM(int pwmVal)
Ryosei 27:dd9f27fce7d1 4052 {
M_souta 29:44d5454ce8fa 4053 if (pwmVal == 0 || pwmVal > 255 || pwmVal < -255) return 255;
M_souta 29:44d5454ce8fa 4054 else return abs(pwmVal);
M_souta 22:7d93f79a3686 4055 }
kishibekairohan 16:3f2c2d89372b 4056
t_yamamoto 0:669ef71cba68 4057 #pragma endregion