aa

Dependencies:   mbed

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