aa

Dependencies:   mbed

Committer:
kishibekairohan
Date:
Sat Nov 09 06:17:24 2019 +0000
Revision:
42:980af34f6fe3
Parent:
41:99a1158f3eca
Child:
43:1bb4fbe7d4c6
aoakjfdok

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 33:dd598bb23ad1 97 int slow = 20;
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]);
kishibekairohan 41:99a1158f3eca 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;
yabahiro 39:784552c26163 478 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 479 motor[TIRE_FR].dir = FOR;
yabahiro 39:784552c26163 480 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 481 motor[TIRE_FL].dir = BACK;
yabahiro 39:784552c26163 482 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 483 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 484 motor[TIRE_BL].pwm = normal;
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 33:dd598bb23ad1 491 } else if(mode==3) { //横ライントレースから縦ライントレースへ
yabahiro 33:dd598bb23ad1 492 motor[TIRE_FR].pwm = 30;
yabahiro 33:dd598bb23ad1 493 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 494 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 495 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 496 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 497 motor[TIRE_BR].dir = FREE;
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 33:dd598bb23ad1 504 } else if(mode==10) { //縦ライントレース
yabahiro 33:dd598bb23ad1 505 switch(g[1]) {
yabahiro 33:dd598bb23ad1 506 case 98:
yabahiro 33:dd598bb23ad1 507 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 508 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 509 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 510 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 511 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 512 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 513 motor[TIRE_BL].pwm = normal;
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 39:784552c26163 520 if(cross==3) {
yabahiro 33:dd598bb23ad1 521 mode=11;
yabahiro 33:dd598bb23ad1 522 countss=0;
yabahiro 33:dd598bb23ad1 523 cross=0;
yabahiro 33:dd598bb23ad1 524 }
yabahiro 33:dd598bb23ad1 525 break;
yabahiro 33:dd598bb23ad1 526 case 0:
yabahiro 33:dd598bb23ad1 527 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 528 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 529 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 530 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 531 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 532 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 533 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 534 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 535 mtc=true;
yabahiro 33:dd598bb23ad1 536 break;
yabahiro 33:dd598bb23ad1 537 case 255:
yabahiro 33:dd598bb23ad1 538 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 539 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 540 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 541 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 542 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 543 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 544 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 545 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 546 mtc=true;
yabahiro 33:dd598bb23ad1 547 break;
yabahiro 33:dd598bb23ad1 548 case 253:
yabahiro 33:dd598bb23ad1 549 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 550 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 551 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 552 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 553 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 554 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 555 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 556 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 557 mtc=true;
yabahiro 33:dd598bb23ad1 558 break;
yabahiro 33:dd598bb23ad1 559 case 254:
yabahiro 33:dd598bb23ad1 560 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 561 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 562 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 563 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 564 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 565 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 566 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 567 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 568 mtc=true;
yabahiro 33:dd598bb23ad1 569 break;
yabahiro 33:dd598bb23ad1 570 case 1:
yabahiro 33:dd598bb23ad1 571 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 572 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 573 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 574 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 575 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 576 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 577 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 578 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 579 mtc=true;
yabahiro 33:dd598bb23ad1 580 break;
yabahiro 33:dd598bb23ad1 581 case 3:
yabahiro 33:dd598bb23ad1 582 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 583 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 584 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 585 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 586 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 587 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 588 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 589 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 590 mtc=true;
yabahiro 33:dd598bb23ad1 591 break;
yabahiro 33:dd598bb23ad1 592 case 2:
yabahiro 33:dd598bb23ad1 593 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 594 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 595 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 596 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 597 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 598 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 599 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 600 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 601 mtc=true;
yabahiro 33:dd598bb23ad1 602 break;
yabahiro 33:dd598bb23ad1 603 }
yabahiro 33:dd598bb23ad1 604 if(g[0]!=98&&mtc==true) {
yabahiro 33:dd598bb23ad1 605 switch(g[0]) {
yabahiro 33:dd598bb23ad1 606 case 0:
yabahiro 33:dd598bb23ad1 607 mtc=false;
yabahiro 33:dd598bb23ad1 608 break;
yabahiro 33:dd598bb23ad1 609 case 255:
yabahiro 33:dd598bb23ad1 610 motor[TIRE_FL].pwm += 5;
yabahiro 33:dd598bb23ad1 611 mtc=false;
yabahiro 33:dd598bb23ad1 612 break;
yabahiro 33:dd598bb23ad1 613 case 253:
yabahiro 33:dd598bb23ad1 614 motor[TIRE_FL].pwm += 10;
yabahiro 33:dd598bb23ad1 615 mtc=false;
yabahiro 33:dd598bb23ad1 616 break;
yabahiro 33:dd598bb23ad1 617 case 254:
yabahiro 33:dd598bb23ad1 618 motor[TIRE_FL].pwm += 20;
yabahiro 33:dd598bb23ad1 619 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 620 mtc=false;
yabahiro 33:dd598bb23ad1 621 break;
yabahiro 33:dd598bb23ad1 622 case 1:
yabahiro 33:dd598bb23ad1 623 motor[TIRE_FR].pwm += 5;
yabahiro 33:dd598bb23ad1 624 mtc=false;
yabahiro 33:dd598bb23ad1 625 break;
yabahiro 33:dd598bb23ad1 626 case 3:
yabahiro 33:dd598bb23ad1 627 motor[TIRE_FR].pwm += 10;
yabahiro 33:dd598bb23ad1 628 mtc=false;
yabahiro 33:dd598bb23ad1 629 break;
yabahiro 33:dd598bb23ad1 630 case 2:
yabahiro 33:dd598bb23ad1 631 motor[TIRE_FR].pwm += 20;
yabahiro 33:dd598bb23ad1 632 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 633 mtc=false;
yabahiro 33:dd598bb23ad1 634 break;
yabahiro 33:dd598bb23ad1 635 }
yabahiro 33:dd598bb23ad1 636 }
yabahiro 33:dd598bb23ad1 637 } else if(mode==11) {
yabahiro 33:dd598bb23ad1 638 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 639 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 640 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 641 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 642 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 643 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 644 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 645 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 646 if(g[2]==0) {
yabahiro 33:dd598bb23ad1 647 countss=0;
yabahiro 33:dd598bb23ad1 648 cross=0;
yabahiro 33:dd598bb23ad1 649 mode=20;
yabahiro 33:dd598bb23ad1 650 }
yabahiro 33:dd598bb23ad1 651 } else if(mode==20) {
yabahiro 39:784552c26163 652 solenoid.solenoid4= SOLENOID_ON;
yabahiro 33:dd598bb23ad1 653 switch(g[2]) {
yabahiro 33:dd598bb23ad1 654 case 98:
yabahiro 33:dd598bb23ad1 655 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 656 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 657 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 658 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 659 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 660 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 661 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 662 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 663 if(countss>30000) {
yabahiro 33:dd598bb23ad1 664 cross++;
yabahiro 33:dd598bb23ad1 665 countss=0;
yabahiro 33:dd598bb23ad1 666 }
yabahiro 33:dd598bb23ad1 667 mtc2=true;
yabahiro 39:784552c26163 668 if(cross==1) {
yabahiro 39:784552c26163 669 fast=30;
yabahiro 39:784552c26163 670 normal=20;
yabahiro 33:dd598bb23ad1 671 slow=20;
yabahiro 33:dd598bb23ad1 672 }
yabahiro 39:784552c26163 673 if(YELLOW) {
yabahiro 39:784552c26163 674 if(cross==2) {
yabahiro 39:784552c26163 675 mode=21;
yabahiro 39:784552c26163 676 countss=0;
yabahiro 39:784552c26163 677 cross=0;
yabahiro 39:784552c26163 678 }
yabahiro 39:784552c26163 679 } else {
yabahiro 39:784552c26163 680 if(cross==1) {
yabahiro 39:784552c26163 681 mode=21;
yabahiro 39:784552c26163 682 countss=0;
yabahiro 39:784552c26163 683 cross=0;
yabahiro 39:784552c26163 684 }
yabahiro 39:784552c26163 685 }
yabahiro 33:dd598bb23ad1 686 break;
yabahiro 33:dd598bb23ad1 687 case 0:
yabahiro 33:dd598bb23ad1 688 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 689 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 690 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 691 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 692 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 693 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 694 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 695 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 696 mtc2=true;
yabahiro 33:dd598bb23ad1 697 break;
yabahiro 33:dd598bb23ad1 698 case 255:
yabahiro 33:dd598bb23ad1 699 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 700 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 701 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 702 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 703 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 704 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 705 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 706 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 707 mtc2=true;
yabahiro 33:dd598bb23ad1 708 break;
yabahiro 33:dd598bb23ad1 709 case 253:
yabahiro 33:dd598bb23ad1 710 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 711 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 712 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 713 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 714 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 715 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 716 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 717 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 718 mtc2=true;
yabahiro 33:dd598bb23ad1 719 break;
yabahiro 33:dd598bb23ad1 720 case 254:
yabahiro 33:dd598bb23ad1 721 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 722 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 723 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 724 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 725 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 726 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 727 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 728 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 729 mtc2=true;
yabahiro 33:dd598bb23ad1 730 break;
yabahiro 33:dd598bb23ad1 731 case 1:
yabahiro 33:dd598bb23ad1 732 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 733 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 734 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 735 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 736 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 737 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 738 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 739 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 740 mtc2=true;
yabahiro 33:dd598bb23ad1 741 break;
yabahiro 33:dd598bb23ad1 742 case 3:
yabahiro 33:dd598bb23ad1 743 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 744 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 745 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 746 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 747 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 748 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 749 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 750 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 751 mtc2=true;
yabahiro 33:dd598bb23ad1 752 break;
yabahiro 33:dd598bb23ad1 753 case 2:
yabahiro 33:dd598bb23ad1 754 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 755 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 756 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 757 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 758 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 759 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 760 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 761 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 762 mtc2=true;
yabahiro 33:dd598bb23ad1 763 break;
yabahiro 33:dd598bb23ad1 764 }
yabahiro 33:dd598bb23ad1 765 if(g[2]!=98&&mtc2==true) {
yabahiro 33:dd598bb23ad1 766 switch(g[3]) {
yabahiro 33:dd598bb23ad1 767 case 0:
yabahiro 33:dd598bb23ad1 768 mtc2=false;
yabahiro 33:dd598bb23ad1 769 break;
yabahiro 33:dd598bb23ad1 770 case 255:
yabahiro 33:dd598bb23ad1 771 motor[TIRE_BL].pwm += 5;
yabahiro 33:dd598bb23ad1 772 mtc2=false;
yabahiro 33:dd598bb23ad1 773 break;
yabahiro 33:dd598bb23ad1 774 case 253:
yabahiro 33:dd598bb23ad1 775 motor[TIRE_BL].pwm += 10;
yabahiro 33:dd598bb23ad1 776 mtc2=false;
yabahiro 33:dd598bb23ad1 777 break;
yabahiro 33:dd598bb23ad1 778 case 254:
yabahiro 33:dd598bb23ad1 779 motor[TIRE_BL].pwm += 20;
yabahiro 33:dd598bb23ad1 780 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 781 mtc2=false;
yabahiro 33:dd598bb23ad1 782 break;
yabahiro 33:dd598bb23ad1 783 case 1:
yabahiro 33:dd598bb23ad1 784 motor[TIRE_FL].pwm += 5;
yabahiro 33:dd598bb23ad1 785 mtc2=false;
yabahiro 33:dd598bb23ad1 786 break;
yabahiro 33:dd598bb23ad1 787 case 3:
yabahiro 33:dd598bb23ad1 788 motor[TIRE_FL].pwm += 10;
yabahiro 33:dd598bb23ad1 789 mtc2=false;
yabahiro 33:dd598bb23ad1 790 break;
yabahiro 33:dd598bb23ad1 791 case 2:
yabahiro 33:dd598bb23ad1 792 motor[TIRE_FL].pwm += 20;
yabahiro 33:dd598bb23ad1 793 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 794 mtc2=false;
yabahiro 33:dd598bb23ad1 795 break;
yabahiro 33:dd598bb23ad1 796 }
yabahiro 33:dd598bb23ad1 797 }
yabahiro 33:dd598bb23ad1 798 }
yabahiro 39:784552c26163 799 if(YELLOW) {
yabahiro 39:784552c26163 800 if(mode==21) {
yabahiro 33:dd598bb23ad1 801 motor[TIRE_FR].pwm = 20;
yabahiro 33:dd598bb23ad1 802 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 803 motor[TIRE_FL].pwm = 20;
yabahiro 33:dd598bb23ad1 804 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 805 motor[TIRE_BR].pwm = 20;
yabahiro 33:dd598bb23ad1 806 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 807 motor[TIRE_BL].pwm = 20;
yabahiro 33:dd598bb23ad1 808 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 809 if(g[3]==98&&countss>=10000) {
yabahiro 39:784552c26163 810 mode=22;
yabahiro 33:dd598bb23ad1 811 countss=0;
yabahiro 39:784552c26163 812 fast=60;
yabahiro 39:784552c26163 813 normal=40;
yabahiro 39:784552c26163 814 slow=20;
yabahiro 39:784552c26163 815 }
yabahiro 39:784552c26163 816 } else if(mode==22) {
yabahiro 39:784552c26163 817 if(g[4]==3||g[4]==2) {
yabahiro 39:784552c26163 818 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 819 motor[TIRE_FR].dir = FOR;
yabahiro 39:784552c26163 820 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 821 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 822 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 823 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 824 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 825 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 826 }
yabahiro 39:784552c26163 827 if(g[4]==253||g[4]==254) {
yabahiro 39:784552c26163 828 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 829 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 830 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 831 motor[TIRE_FL].dir = BACK;
yabahiro 39:784552c26163 832 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 833 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 834 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 835 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 836 }
yabahiro 39:784552c26163 837 switch(g[2]) {
yabahiro 39:784552c26163 838 case 0:
yabahiro 39:784552c26163 839 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 840 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 841 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 842 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 843 break;
yabahiro 39:784552c26163 844 case 255:
yabahiro 39:784552c26163 845 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 846 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 847 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 848 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 849 break;
yabahiro 39:784552c26163 850 case 253:
yabahiro 39:784552c26163 851 motor[TIRE_FR].pwm = 40;
yabahiro 39:784552c26163 852 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 853 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 854 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 855 break;
yabahiro 39:784552c26163 856 case 254:
yabahiro 39:784552c26163 857 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 858 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 859 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 860 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 861 break;
yabahiro 39:784552c26163 862 case 1:
yabahiro 39:784552c26163 863 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 864 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 865 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 866 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 867 break;
yabahiro 39:784552c26163 868 case 3:
yabahiro 39:784552c26163 869 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 870 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 871 motor[TIRE_BR].pwm = 40;
yabahiro 39:784552c26163 872 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 873 break;
yabahiro 39:784552c26163 874 case 2:
yabahiro 39:784552c26163 875 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 876 motor[TIRE_FR].dir = FOR;
yabahiro 39:784552c26163 877 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 878 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 879 break;
yabahiro 39:784552c26163 880 }
yabahiro 39:784552c26163 881 switch(g[3]) {
yabahiro 39:784552c26163 882 case 0:
yabahiro 39:784552c26163 883 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 884 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 885 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 886 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 887 break;
yabahiro 39:784552c26163 888 case 255:
yabahiro 39:784552c26163 889 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 890 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 891 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 892 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 893 case 253:
yabahiro 39:784552c26163 894 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 895 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 896 motor[TIRE_BL].pwm = 40;
yabahiro 39:784552c26163 897 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 898 break;
yabahiro 39:784552c26163 899 case 254:
yabahiro 39:784552c26163 900 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 901 motor[TIRE_FL].dir = BACK;
yabahiro 39:784552c26163 902 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 903 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 904 break;
yabahiro 39:784552c26163 905 case 1:
yabahiro 39:784552c26163 906 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 907 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 908 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 909 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 910 break;
yabahiro 39:784552c26163 911 case 3:
yabahiro 39:784552c26163 912 motor[TIRE_FL].pwm = 40;
yabahiro 39:784552c26163 913 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 914 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 915 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 916 break;
yabahiro 39:784552c26163 917 case 2:
yabahiro 39:784552c26163 918 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 919 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 920 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 921 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 922 break;
yabahiro 39:784552c26163 923 }
yabahiro 39:784552c26163 924 if(g[3]==0&&g[2]==0) {
yabahiro 39:784552c26163 925 mode=23;
yabahiro 33:dd598bb23ad1 926 countss=0;
yabahiro 33:dd598bb23ad1 927 }
yabahiro 39:784552c26163 928 } else if(mode==23) {
yabahiro 39:784552c26163 929 switch(g[4]) {
yabahiro 39:784552c26163 930 case 98:
yabahiro 39:784552c26163 931 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 932 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 933 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 934 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 935 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 936 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 937 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 938 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 939 break;
yabahiro 39:784552c26163 940 case 99:
yabahiro 39:784552c26163 941 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 942 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 943 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 944 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 945 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 946 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 947 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 948 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 949 break;
yabahiro 39:784552c26163 950 case 0:
yabahiro 39:784552c26163 951 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 952 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 953 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 954 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 955 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 956 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 957 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 958 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 959 break;
yabahiro 39:784552c26163 960 case 255:
yabahiro 39:784552c26163 961 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 962 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 963 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 964 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 965 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 966 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 967 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 968 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 969 break;
yabahiro 39:784552c26163 970 case 253:
yabahiro 39:784552c26163 971 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 972 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 973 motor[TIRE_FL].pwm = slow;
yabahiro 39:784552c26163 974 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 975 motor[TIRE_BR].pwm = slow;
yabahiro 39:784552c26163 976 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 977 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 978 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 979 break;
yabahiro 39:784552c26163 980 case 254:
yabahiro 39:784552c26163 981 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 982 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 983 motor[TIRE_FL].pwm = normal;
yabahiro 39:784552c26163 984 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 985 motor[TIRE_BR].pwm = normal;
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 1:
yabahiro 39:784552c26163 991 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 992 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 993 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 994 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 995 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 996 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 997 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 998 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 999 break;
yabahiro 39:784552c26163 1000 case 3:
yabahiro 39:784552c26163 1001 motor[TIRE_FR].pwm = slow;
yabahiro 39:784552c26163 1002 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1003 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1004 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1005 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1006 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1007 motor[TIRE_BL].pwm = slow-5;
yabahiro 39:784552c26163 1008 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1009 break;
yabahiro 39:784552c26163 1010 case 2:
yabahiro 39:784552c26163 1011 motor[TIRE_FR].pwm = normal;
yabahiro 39:784552c26163 1012 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1013 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1014 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1015 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1016 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1017 motor[TIRE_BL].pwm = normal-5;
yabahiro 39:784552c26163 1018 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1019 break;
yabahiro 39:784552c26163 1020 }
yabahiro 39:784552c26163 1021 if(DOLS==true||UPLS==true) {
yabahiro 39:784552c26163 1022 motor[MOTOR_0].pwm = 200;
yabahiro 39:784552c26163 1023 motor[MOTOR_0].dir = BRAKE;
yabahiro 39:784552c26163 1024 }
yabahiro 39:784552c26163 1025 if(g[0]==98) {
yabahiro 39:784552c26163 1026 fast=30;
yabahiro 39:784552c26163 1027 normal=20;
yabahiro 39:784552c26163 1028 slow=20;
yabahiro 39:784552c26163 1029 if(DOLS==true||UPLS==true) {
yabahiro 39:784552c26163 1030 motor[MOTOR_0].pwm = 200;
yabahiro 39:784552c26163 1031 motor[MOTOR_0].dir = BRAKE;
yabahiro 39:784552c26163 1032 } else {
yabahiro 39:784552c26163 1033 motor[MOTOR_0].pwm = 100;
yabahiro 39:784552c26163 1034 motor[MOTOR_0].dir = BACK;
yabahiro 39:784552c26163 1035 }
yabahiro 39:784552c26163 1036 }
yabahiro 39:784552c26163 1037 if(g[2]==254&&countss>=100000) {
yabahiro 39:784552c26163 1038 mode=24;
yabahiro 39:784552c26163 1039 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 33:dd598bb23ad1 1040 countss=0;
yabahiro 39:784552c26163 1041 fast=60;
yabahiro 39:784552c26163 1042 normal=40;
yabahiro 39:784552c26163 1043 slow=30;
yabahiro 39:784552c26163 1044 }
yabahiro 39:784552c26163 1045 } else if(mode==24) {
yabahiro 39:784552c26163 1046 if(DOLS==true||UPLS==true) {
yabahiro 39:784552c26163 1047 motor[MOTOR_0].pwm = 200;
yabahiro 39:784552c26163 1048 motor[MOTOR_0].dir = BRAKE;
yabahiro 39:784552c26163 1049 } else {
yabahiro 39:784552c26163 1050 motor[MOTOR_0].pwm = 100;
yabahiro 39:784552c26163 1051 motor[MOTOR_0].dir = BACK;
yabahiro 39:784552c26163 1052 }
yabahiro 39:784552c26163 1053 if(g[4]==3||g[4]==2) {
yabahiro 39:784552c26163 1054 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1055 motor[TIRE_FR].dir = FOR;
yabahiro 39:784552c26163 1056 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 1057 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1058 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 1059 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1060 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1061 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 1062 }
yabahiro 39:784552c26163 1063 if(g[4]==253||g[4]==254) {
yabahiro 39:784552c26163 1064 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1065 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1066 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 1067 motor[TIRE_FL].dir = BACK;
yabahiro 39:784552c26163 1068 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 1069 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 1070 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1071 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1072 }
yabahiro 39:784552c26163 1073 switch(g[2]) {
yabahiro 39:784552c26163 1074 case 0:
yabahiro 39:784552c26163 1075 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 1076 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1077 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 1078 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1079 break;
yabahiro 39:784552c26163 1080 case 255:
yabahiro 39:784552c26163 1081 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1082 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1083 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 1084 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1085 break;
yabahiro 39:784552c26163 1086 case 253:
yabahiro 39:784552c26163 1087 motor[TIRE_FR].pwm = 40;
yabahiro 39:784552c26163 1088 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1089 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 1090 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1091 break;
yabahiro 39:784552c26163 1092 case 254:
yabahiro 39:784552c26163 1093 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1094 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1095 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 1096 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1097 break;
yabahiro 39:784552c26163 1098 case 1:
yabahiro 39:784552c26163 1099 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 1100 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1101 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 1102 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 1103 break;
yabahiro 39:784552c26163 1104 case 3:
yabahiro 39:784552c26163 1105 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 1106 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1107 motor[TIRE_BR].pwm = 40;
yabahiro 39:784552c26163 1108 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 1109 break;
yabahiro 39:784552c26163 1110 case 2:
yabahiro 39:784552c26163 1111 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1112 motor[TIRE_FR].dir = FOR;
yabahiro 39:784552c26163 1113 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 1114 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 1115 break;
yabahiro 39:784552c26163 1116 }
yabahiro 39:784552c26163 1117 switch(g[3]) {
yabahiro 39:784552c26163 1118 case 0:
yabahiro 39:784552c26163 1119 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 1120 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1121 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 1122 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1123 break;
yabahiro 39:784552c26163 1124 case 255:
yabahiro 39:784552c26163 1125 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 1126 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1127 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1128 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 1129 case 253:
yabahiro 39:784552c26163 1130 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 1131 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1132 motor[TIRE_BL].pwm = 40;
yabahiro 39:784552c26163 1133 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 1134 break;
yabahiro 39:784552c26163 1135 case 254:
yabahiro 39:784552c26163 1136 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 1137 motor[TIRE_FL].dir = BACK;
yabahiro 39:784552c26163 1138 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1139 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 1140 break;
yabahiro 39:784552c26163 1141 case 1:
yabahiro 39:784552c26163 1142 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 1143 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1144 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 1145 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1146 break;
yabahiro 39:784552c26163 1147 case 3:
yabahiro 39:784552c26163 1148 motor[TIRE_FL].pwm = 40;
yabahiro 39:784552c26163 1149 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1150 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 1151 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1152 break;
yabahiro 39:784552c26163 1153 case 2:
yabahiro 39:784552c26163 1154 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 1155 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1156 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1157 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1158 break;
yabahiro 33:dd598bb23ad1 1159 }
yabahiro 39:784552c26163 1160 if(g[3]==0&&g[2]==0) {
yabahiro 39:784552c26163 1161 if(UPLS==true||DOLS==true) {
yabahiro 39:784552c26163 1162 motor[MOTOR_0].pwm = 200;
yabahiro 39:784552c26163 1163 motor[MOTOR_0].dir = BRAKE;
yabahiro 39:784552c26163 1164 mode=25;
yabahiro 39:784552c26163 1165 } else {
yabahiro 39:784552c26163 1166 motor[MOTOR_0].pwm = 100;
yabahiro 39:784552c26163 1167 motor[MOTOR_0].dir = BACK;
yabahiro 39:784552c26163 1168 }
yabahiro 39:784552c26163 1169 }
yabahiro 39:784552c26163 1170 } else if(mode==25) {
yabahiro 39:784552c26163 1171 switch(g[4]) {
yabahiro 39:784552c26163 1172 case 98:
yabahiro 39:784552c26163 1173 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1174 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1175 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1176 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1177 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1178 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1179 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 1180 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1181 break;
yabahiro 39:784552c26163 1182 case 99:
yabahiro 39:784552c26163 1183 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1184 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1185 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1186 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1187 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1188 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1189 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1190 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1191 break;
yabahiro 39:784552c26163 1192 case 0:
yabahiro 39:784552c26163 1193 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1194 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1195 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1196 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1197 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1198 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1199 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 1200 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1201 break;
yabahiro 39:784552c26163 1202 case 255:
yabahiro 39:784552c26163 1203 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1204 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1205 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1206 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1207 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1208 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1209 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1210 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1211 break;
yabahiro 39:784552c26163 1212 case 253:
yabahiro 39:784552c26163 1213 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1214 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1215 motor[TIRE_FL].pwm = slow;
yabahiro 39:784552c26163 1216 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1217 motor[TIRE_BR].pwm = slow;
yabahiro 39:784552c26163 1218 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1219 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 1220 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1221 break;
yabahiro 39:784552c26163 1222 case 254:
yabahiro 39:784552c26163 1223 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1224 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1225 motor[TIRE_FL].pwm = normal;
yabahiro 39:784552c26163 1226 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1227 motor[TIRE_BR].pwm = normal;
yabahiro 39:784552c26163 1228 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1229 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 1230 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1231 break;
yabahiro 39:784552c26163 1232 case 1:
yabahiro 39:784552c26163 1233 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1234 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1235 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1236 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1237 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1238 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1239 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1240 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1241 break;
yabahiro 39:784552c26163 1242 case 3:
yabahiro 39:784552c26163 1243 motor[TIRE_FR].pwm = slow;
yabahiro 39:784552c26163 1244 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1245 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1246 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1247 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1248 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1249 motor[TIRE_BL].pwm = slow-5;
yabahiro 39:784552c26163 1250 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1251 break;
yabahiro 39:784552c26163 1252 case 2:
yabahiro 39:784552c26163 1253 motor[TIRE_FR].pwm = normal;
yabahiro 39:784552c26163 1254 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1255 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1256 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1257 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1258 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1259 motor[TIRE_BL].pwm = normal-5;
yabahiro 39:784552c26163 1260 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1261 break;
yabahiro 39:784552c26163 1262 }
yabahiro 39:784552c26163 1263 if(g[1]==98) {
yabahiro 39:784552c26163 1264 mode=31;
yabahiro 33:dd598bb23ad1 1265 }
yabahiro 33:dd598bb23ad1 1266 }
yabahiro 33:dd598bb23ad1 1267 } else {
yabahiro 39:784552c26163 1268 if(mode==21) {
yabahiro 33:dd598bb23ad1 1269 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1270 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1271 motor[TIRE_FL].pwm = 30;
yabahiro 33:dd598bb23ad1 1272 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1273 motor[TIRE_BR].pwm = 30;
yabahiro 33:dd598bb23ad1 1274 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1275 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1276 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1277 if(g[1]==0) {
yabahiro 39:784552c26163 1278 mode=22;
yabahiro 39:784552c26163 1279 fast=60;
yabahiro 39:784552c26163 1280 normal=40;
yabahiro 39:784552c26163 1281 slow=20;
yabahiro 39:784552c26163 1282 }
yabahiro 39:784552c26163 1283 } else if(mode==22) {
yabahiro 39:784552c26163 1284 if(g[3]==0) {
yabahiro 39:784552c26163 1285 mode=23;
yabahiro 39:784552c26163 1286 }
yabahiro 39:784552c26163 1287 switch(g[0]) {
yabahiro 39:784552c26163 1288 case 98:
yabahiro 39:784552c26163 1289 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 39:784552c26163 1290 fast=30;
yabahiro 39:784552c26163 1291 normal=20;
yabahiro 39:784552c26163 1292 slow=20;
yabahiro 39:784552c26163 1293 motor[TIRE_FR].pwm = normal;
yabahiro 39:784552c26163 1294 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1295 motor[TIRE_FL].pwm = normal;
yabahiro 39:784552c26163 1296 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1297 motor[TIRE_BR].pwm = normal;
yabahiro 39:784552c26163 1298 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1299 motor[TIRE_BL].pwm = normal;
yabahiro 39:784552c26163 1300 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1301 break;
yabahiro 39:784552c26163 1302 case 0:
yabahiro 39:784552c26163 1303 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1304 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1305 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1306 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1307 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1308 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1309 motor[TIRE_BL].pwm = fast;
yabahiro 39:784552c26163 1310 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1311 mtc=true;
yabahiro 39:784552c26163 1312 break;
yabahiro 39:784552c26163 1313 case 255:
yabahiro 39:784552c26163 1314 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1315 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1316 motor[TIRE_FL].pwm = slow;
yabahiro 39:784552c26163 1317 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1318 motor[TIRE_BR].pwm = slow;
yabahiro 39:784552c26163 1319 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1320 motor[TIRE_BL].pwm = fast;
yabahiro 39:784552c26163 1321 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1322 mtc=true;
yabahiro 39:784552c26163 1323 break;
yabahiro 39:784552c26163 1324 case 253:
yabahiro 39:784552c26163 1325 motor[TIRE_FR].pwm = slow;
yabahiro 39:784552c26163 1326 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1327 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1328 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1329 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1330 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1331 motor[TIRE_BL].pwm = slow;
yabahiro 39:784552c26163 1332 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1333 mtc=true;
yabahiro 39:784552c26163 1334 break;
yabahiro 39:784552c26163 1335 case 254:
yabahiro 39:784552c26163 1336 motor[TIRE_FR].pwm = normal;
yabahiro 39:784552c26163 1337 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1338 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1339 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1340 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1341 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1342 motor[TIRE_BL].pwm = normal;
yabahiro 39:784552c26163 1343 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1344 mtc=true;
yabahiro 39:784552c26163 1345 break;
yabahiro 39:784552c26163 1346 case 1:
yabahiro 39:784552c26163 1347 motor[TIRE_FR].pwm = slow;
yabahiro 39:784552c26163 1348 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1349 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1350 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1351 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1352 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1353 motor[TIRE_BL].pwm = slow;
yabahiro 39:784552c26163 1354 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1355 mtc=true;
yabahiro 39:784552c26163 1356 break;
yabahiro 39:784552c26163 1357 case 3:
yabahiro 39:784552c26163 1358 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1359 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1360 motor[TIRE_FL].pwm = slow;
yabahiro 39:784552c26163 1361 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1362 motor[TIRE_BR].pwm = slow;
yabahiro 39:784552c26163 1363 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1364 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1365 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1366 mtc=true;
yabahiro 39:784552c26163 1367 break;
yabahiro 39:784552c26163 1368 case 2:
yabahiro 39:784552c26163 1369 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1370 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1371 motor[TIRE_FL].pwm = normal;
yabahiro 39:784552c26163 1372 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1373 motor[TIRE_BR].pwm = normal;
yabahiro 39:784552c26163 1374 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1375 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1376 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1377 mtc=true;
yabahiro 39:784552c26163 1378 break;
yabahiro 39:784552c26163 1379 }
yabahiro 39:784552c26163 1380 if(g[0]!=98&&mtc==true) {
yabahiro 39:784552c26163 1381 switch(g[0]) {
yabahiro 39:784552c26163 1382 case 0:
yabahiro 39:784552c26163 1383 mtc=false;
yabahiro 39:784552c26163 1384 break;
yabahiro 39:784552c26163 1385 case 255:
yabahiro 39:784552c26163 1386 motor[TIRE_BR].pwm += 5;
yabahiro 39:784552c26163 1387 mtc=false;
yabahiro 39:784552c26163 1388 break;
yabahiro 39:784552c26163 1389 case 253:
yabahiro 39:784552c26163 1390 motor[TIRE_BR].pwm += 10;
yabahiro 39:784552c26163 1391 mtc=false;
yabahiro 39:784552c26163 1392 break;
yabahiro 39:784552c26163 1393 case 254:
yabahiro 39:784552c26163 1394 motor[TIRE_BR].pwm += 20;
yabahiro 39:784552c26163 1395 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1396 mtc=false;
yabahiro 39:784552c26163 1397 break;
yabahiro 39:784552c26163 1398 case 1:
yabahiro 39:784552c26163 1399 motor[TIRE_BL].pwm += 5;
yabahiro 39:784552c26163 1400 mtc=false;
yabahiro 39:784552c26163 1401 break;
yabahiro 39:784552c26163 1402 case 3:
yabahiro 39:784552c26163 1403 motor[TIRE_BL].pwm += 10;
yabahiro 39:784552c26163 1404 mtc=false;
yabahiro 39:784552c26163 1405 break;
yabahiro 39:784552c26163 1406 case 2:
yabahiro 39:784552c26163 1407 motor[TIRE_BL].pwm += 20;
yabahiro 39:784552c26163 1408 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1409 mtc=false;
yabahiro 39:784552c26163 1410 break;
yabahiro 39:784552c26163 1411 }
yabahiro 39:784552c26163 1412 }
yabahiro 39:784552c26163 1413 } else if(mode==23) {
yabahiro 39:784552c26163 1414 if(UPLS==true||DOLS==true) {
yabahiro 39:784552c26163 1415 motor[MOTOR_0].pwm = 200;
yabahiro 39:784552c26163 1416 motor[MOTOR_0].dir = BRAKE;
yabahiro 39:784552c26163 1417 fast=60;
yabahiro 39:784552c26163 1418 normal=40;
yabahiro 39:784552c26163 1419 slow=20;
yabahiro 33:dd598bb23ad1 1420 countss=0;
yabahiro 39:784552c26163 1421 mode=24;
yabahiro 39:784552c26163 1422 } else {
yabahiro 39:784552c26163 1423 motor[MOTOR_0].pwm = 100;
yabahiro 39:784552c26163 1424 motor[MOTOR_0].dir = BACK;
yabahiro 39:784552c26163 1425 motor[TIRE_FR].pwm = 100;
yabahiro 39:784552c26163 1426 motor[TIRE_FR].dir = BRAKE;
yabahiro 39:784552c26163 1427 motor[TIRE_FL].pwm = 100;
yabahiro 39:784552c26163 1428 motor[TIRE_FL].dir = BRAKE;
yabahiro 39:784552c26163 1429 motor[TIRE_BR].pwm = 100;
yabahiro 39:784552c26163 1430 motor[TIRE_BR].dir = BRAKE;
yabahiro 39:784552c26163 1431 motor[TIRE_BL].pwm = 100;
yabahiro 39:784552c26163 1432 motor[TIRE_BL].dir = BRAKE;
yabahiro 39:784552c26163 1433 }
yabahiro 39:784552c26163 1434
yabahiro 39:784552c26163 1435 } else if(mode==24) {
yabahiro 39:784552c26163 1436 if(g[0]==98&&countss>=40000) {
yabahiro 39:784552c26163 1437 mode=31;
yabahiro 39:784552c26163 1438 countss=0;
yabahiro 39:784552c26163 1439 }
yabahiro 39:784552c26163 1440 switch(g[0]) {
yabahiro 39:784552c26163 1441 case 98:
yabahiro 39:784552c26163 1442 fast=30;
yabahiro 39:784552c26163 1443 normal=20;
yabahiro 39:784552c26163 1444 slow=20;
yabahiro 39:784552c26163 1445 motor[TIRE_FR].pwm = normal;
yabahiro 39:784552c26163 1446 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1447 motor[TIRE_FL].pwm = normal;
yabahiro 39:784552c26163 1448 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1449 motor[TIRE_BR].pwm = normal;
yabahiro 39:784552c26163 1450 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1451 motor[TIRE_BL].pwm = normal;
yabahiro 39:784552c26163 1452 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1453 break;
yabahiro 39:784552c26163 1454 case 0:
yabahiro 39:784552c26163 1455 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1456 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1457 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1458 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1459 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1460 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1461 motor[TIRE_BL].pwm = fast;
yabahiro 39:784552c26163 1462 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1463 mtc=true;
yabahiro 39:784552c26163 1464 break;
yabahiro 39:784552c26163 1465 case 255:
yabahiro 39:784552c26163 1466 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1467 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1468 motor[TIRE_FL].pwm = slow;
yabahiro 39:784552c26163 1469 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1470 motor[TIRE_BR].pwm = slow;
yabahiro 39:784552c26163 1471 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1472 motor[TIRE_BL].pwm = fast;
yabahiro 39:784552c26163 1473 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1474 mtc=true;
yabahiro 39:784552c26163 1475 break;
yabahiro 39:784552c26163 1476 case 253:
yabahiro 39:784552c26163 1477 motor[TIRE_FR].pwm = slow;
yabahiro 39:784552c26163 1478 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1479 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1480 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1481 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1482 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1483 motor[TIRE_BL].pwm = slow;
yabahiro 39:784552c26163 1484 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1485 mtc=true;
yabahiro 39:784552c26163 1486 break;
yabahiro 39:784552c26163 1487 case 254:
yabahiro 39:784552c26163 1488 motor[TIRE_FR].pwm = normal;
yabahiro 39:784552c26163 1489 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1490 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1491 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1492 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1493 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1494 motor[TIRE_BL].pwm = normal;
yabahiro 39:784552c26163 1495 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1496 mtc=true;
yabahiro 39:784552c26163 1497 break;
yabahiro 39:784552c26163 1498 case 1:
yabahiro 39:784552c26163 1499 motor[TIRE_FR].pwm = slow;
yabahiro 39:784552c26163 1500 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1501 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1502 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1503 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1504 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1505 motor[TIRE_BL].pwm = slow;
yabahiro 39:784552c26163 1506 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1507 mtc=true;
yabahiro 39:784552c26163 1508 break;
yabahiro 39:784552c26163 1509 case 3:
yabahiro 39:784552c26163 1510 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1511 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1512 motor[TIRE_FL].pwm = slow;
yabahiro 39:784552c26163 1513 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1514 motor[TIRE_BR].pwm = slow;
yabahiro 39:784552c26163 1515 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1516 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1517 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1518 mtc=true;
yabahiro 39:784552c26163 1519 break;
yabahiro 39:784552c26163 1520 case 2:
yabahiro 39:784552c26163 1521 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1522 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1523 motor[TIRE_FL].pwm = normal;
yabahiro 39:784552c26163 1524 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1525 motor[TIRE_BR].pwm = normal;
yabahiro 39:784552c26163 1526 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1527 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1528 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1529 mtc=true;
yabahiro 39:784552c26163 1530 break;
yabahiro 39:784552c26163 1531 }
yabahiro 39:784552c26163 1532 if(g[1]!=98&&mtc==true) {
yabahiro 39:784552c26163 1533 switch(g[1]) {
yabahiro 39:784552c26163 1534 case 0:
yabahiro 39:784552c26163 1535 mtc=false;
yabahiro 39:784552c26163 1536 break;
yabahiro 39:784552c26163 1537 case 255:
yabahiro 39:784552c26163 1538 motor[TIRE_BR].pwm += 5;
yabahiro 39:784552c26163 1539 mtc=false;
yabahiro 39:784552c26163 1540 break;
yabahiro 39:784552c26163 1541 case 253:
yabahiro 39:784552c26163 1542 motor[TIRE_BR].pwm += 10;
yabahiro 39:784552c26163 1543 mtc=false;
yabahiro 39:784552c26163 1544 break;
yabahiro 39:784552c26163 1545 case 254:
yabahiro 39:784552c26163 1546 motor[TIRE_BR].pwm += 20;
yabahiro 39:784552c26163 1547 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1548 mtc=false;
yabahiro 39:784552c26163 1549 break;
yabahiro 39:784552c26163 1550 case 1:
yabahiro 39:784552c26163 1551 motor[TIRE_BL].pwm += 5;
yabahiro 39:784552c26163 1552 mtc=false;
yabahiro 39:784552c26163 1553 break;
yabahiro 39:784552c26163 1554 case 3:
yabahiro 39:784552c26163 1555 motor[TIRE_BL].pwm += 10;
yabahiro 39:784552c26163 1556 mtc=false;
yabahiro 39:784552c26163 1557 break;
yabahiro 39:784552c26163 1558 case 2:
yabahiro 39:784552c26163 1559 motor[TIRE_BL].pwm += 20;
yabahiro 39:784552c26163 1560 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1561 mtc=false;
yabahiro 39:784552c26163 1562 break;
yabahiro 39:784552c26163 1563 }
yabahiro 33:dd598bb23ad1 1564 }
yabahiro 33:dd598bb23ad1 1565 }
yabahiro 33:dd598bb23ad1 1566 }
yabahiro 39:784552c26163 1567 if(mode==31) {
yabahiro 33:dd598bb23ad1 1568 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1569 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 1570 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1571 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1572 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1573 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1574 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1575 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 1576 if(countss>=5000) {
yabahiro 33:dd598bb23ad1 1577 countss=0;
yabahiro 33:dd598bb23ad1 1578 mode=33;
yabahiro 33:dd598bb23ad1 1579 }
yabahiro 33:dd598bb23ad1 1580 } else if(mode==33) {
yabahiro 33:dd598bb23ad1 1581 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1582 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1583 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1584 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1585 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1586 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1587 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1588 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1589 if(g[3]==0) {
yabahiro 39:784552c26163 1590 cross=0;
yabahiro 33:dd598bb23ad1 1591 countss=0;
yabahiro 33:dd598bb23ad1 1592 mode=40;
yabahiro 33:dd598bb23ad1 1593 }
yabahiro 33:dd598bb23ad1 1594 } else if(mode==40) {
yabahiro 33:dd598bb23ad1 1595 switch(g[3]) {
yabahiro 33:dd598bb23ad1 1596 case 98:
yabahiro 33:dd598bb23ad1 1597 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 1598 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1599 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 1600 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 1601 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 1602 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 1603 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 1604 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1605 if(countss>10000) {
yabahiro 33:dd598bb23ad1 1606 cross++;
yabahiro 33:dd598bb23ad1 1607 countss=0;
yabahiro 33:dd598bb23ad1 1608 }
yabahiro 33:dd598bb23ad1 1609 mtc2=true;
yabahiro 39:784552c26163 1610 if(cross==1) {
yabahiro 33:dd598bb23ad1 1611 mode=41;
yabahiro 33:dd598bb23ad1 1612 countss=0;
yabahiro 33:dd598bb23ad1 1613 cross=0;
yabahiro 33:dd598bb23ad1 1614 }
yabahiro 33:dd598bb23ad1 1615 break;
yabahiro 33:dd598bb23ad1 1616 case 0:
yabahiro 33:dd598bb23ad1 1617 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 1618 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1619 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 1620 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 1621 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 1622 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 1623 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 1624 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1625 mtc2=true;
yabahiro 33:dd598bb23ad1 1626 break;
yabahiro 33:dd598bb23ad1 1627 case 255:
yabahiro 33:dd598bb23ad1 1628 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 1629 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1630 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 1631 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 1632 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 1633 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 1634 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 1635 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1636 mtc2=true;
yabahiro 33:dd598bb23ad1 1637 break;
yabahiro 33:dd598bb23ad1 1638 case 253:
yabahiro 33:dd598bb23ad1 1639 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1640 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 1641 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 1642 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 1643 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 1644 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 1645 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1646 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 1647 mtc2=true;
yabahiro 33:dd598bb23ad1 1648 break;
yabahiro 33:dd598bb23ad1 1649 case 254:
yabahiro 33:dd598bb23ad1 1650 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1651 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 1652 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 1653 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 1654 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 1655 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 1656 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1657 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 1658 mtc2=true;
yabahiro 33:dd598bb23ad1 1659 break;
yabahiro 33:dd598bb23ad1 1660 case 1:
yabahiro 33:dd598bb23ad1 1661 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 1662 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1663 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 1664 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 1665 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 1666 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 1667 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 1668 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1669 mtc2=true;
yabahiro 33:dd598bb23ad1 1670 break;
yabahiro 33:dd598bb23ad1 1671 case 3:
yabahiro 33:dd598bb23ad1 1672 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 1673 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1674 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1675 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1676 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1677 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1678 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 1679 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1680 mtc2=true;
yabahiro 33:dd598bb23ad1 1681 break;
yabahiro 33:dd598bb23ad1 1682 case 2:
yabahiro 33:dd598bb23ad1 1683 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 1684 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1685 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1686 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1687 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1688 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1689 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 1690 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1691 mtc2=true;
yabahiro 33:dd598bb23ad1 1692 break;
yabahiro 33:dd598bb23ad1 1693 }
yabahiro 33:dd598bb23ad1 1694 if(g[2]!=98&&mtc2==true) {
yabahiro 33:dd598bb23ad1 1695 switch(g[2]) {
yabahiro 33:dd598bb23ad1 1696 case 0:
yabahiro 33:dd598bb23ad1 1697 mtc2=false;
yabahiro 33:dd598bb23ad1 1698 break;
yabahiro 33:dd598bb23ad1 1699 case 255:
yabahiro 39:784552c26163 1700 motor[TIRE_FL].pwm += 5;
yabahiro 33:dd598bb23ad1 1701 mtc2=false;
yabahiro 33:dd598bb23ad1 1702 break;
yabahiro 33:dd598bb23ad1 1703 case 253:
yabahiro 39:784552c26163 1704 motor[TIRE_FL].pwm += 10;
yabahiro 33:dd598bb23ad1 1705 mtc2=false;
yabahiro 33:dd598bb23ad1 1706 break;
yabahiro 33:dd598bb23ad1 1707 case 254:
yabahiro 39:784552c26163 1708 motor[TIRE_FL].pwm += 20;
yabahiro 39:784552c26163 1709 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1710 mtc2=false;
yabahiro 33:dd598bb23ad1 1711 break;
yabahiro 33:dd598bb23ad1 1712 case 1:
yabahiro 39:784552c26163 1713 motor[TIRE_BL].pwm += 5;
yabahiro 33:dd598bb23ad1 1714 mtc2=false;
yabahiro 33:dd598bb23ad1 1715 break;
yabahiro 33:dd598bb23ad1 1716 case 3:
yabahiro 39:784552c26163 1717 motor[TIRE_BL].pwm += 10;
yabahiro 33:dd598bb23ad1 1718 mtc2=false;
yabahiro 33:dd598bb23ad1 1719 break;
yabahiro 33:dd598bb23ad1 1720 case 2:
yabahiro 39:784552c26163 1721 motor[TIRE_BL].pwm += 20;
yabahiro 39:784552c26163 1722 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1723 mtc2=false;
yabahiro 33:dd598bb23ad1 1724 break;
yabahiro 33:dd598bb23ad1 1725 }
yabahiro 33:dd598bb23ad1 1726 }
yabahiro 33:dd598bb23ad1 1727 } else if(mode==41) {
yabahiro 33:dd598bb23ad1 1728 if(LIF||LIB) {
yabahiro 33:dd598bb23ad1 1729 mode=42;
yabahiro 33:dd598bb23ad1 1730 }
yabahiro 33:dd598bb23ad1 1731 motor[TIRE_FR].pwm = 30;
yabahiro 33:dd598bb23ad1 1732 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1733 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1734 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1735 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1736 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1737 motor[TIRE_BL].pwm = 30;
yabahiro 33:dd598bb23ad1 1738 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1739 if(g[1]==0) {
yabahiro 33:dd598bb23ad1 1740 countss=0;
yabahiro 33:dd598bb23ad1 1741 mode=70;
yabahiro 33:dd598bb23ad1 1742 normal=60;
yabahiro 33:dd598bb23ad1 1743 fast=70;
yabahiro 33:dd598bb23ad1 1744 slow=40;
yabahiro 33:dd598bb23ad1 1745 }
yabahiro 33:dd598bb23ad1 1746 } else if(mode==42) {
yabahiro 39:784552c26163 1747 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 1748 motor[TIRE_FR].dir = FOR;
yabahiro 39:784552c26163 1749 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1750 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1751 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1752 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1753 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 1754 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 1755 if(g[1]==0) {
yabahiro 33:dd598bb23ad1 1756 countss=0;
yabahiro 39:784552c26163 1757 mode=70;
yabahiro 33:dd598bb23ad1 1758 }
yabahiro 39:784552c26163 1759 } else if(mode==70) {
yabahiro 33:dd598bb23ad1 1760 switch(g[0]) {
yabahiro 33:dd598bb23ad1 1761 case 99:
yabahiro 33:dd598bb23ad1 1762 if(countss>=100000) {
yabahiro 33:dd598bb23ad1 1763 mode=100;
yabahiro 33:dd598bb23ad1 1764 }
yabahiro 33:dd598bb23ad1 1765 break;
yabahiro 33:dd598bb23ad1 1766 case 98:
yabahiro 33:dd598bb23ad1 1767 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 1768 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1769 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 1770 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1771 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 1772 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1773 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 1774 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1775 break;
yabahiro 33:dd598bb23ad1 1776 case 0:
yabahiro 39:784552c26163 1777 motor[TIRE_FR].pwm = 80;
yabahiro 33:dd598bb23ad1 1778 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1779 motor[TIRE_FL].pwm = 80;
yabahiro 33:dd598bb23ad1 1780 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1781 motor[TIRE_BR].pwm = 80;
yabahiro 33:dd598bb23ad1 1782 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1783 motor[TIRE_BL].pwm = 80;
yabahiro 33:dd598bb23ad1 1784 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1785 mtc=true;
yabahiro 33:dd598bb23ad1 1786 break;
yabahiro 33:dd598bb23ad1 1787 case 255:
yabahiro 33:dd598bb23ad1 1788 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 1789 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1790 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 1791 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1792 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 1793 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1794 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 1795 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1796 mtc=true;
yabahiro 33:dd598bb23ad1 1797 break;
yabahiro 33:dd598bb23ad1 1798 case 253:
yabahiro 33:dd598bb23ad1 1799 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 1800 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1801 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1802 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1803 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1804 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1805 motor[TIRE_BL].pwm = slow;
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 254:
yabahiro 33:dd598bb23ad1 1810 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 1811 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1812 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1813 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1814 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1815 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1816 motor[TIRE_BL].pwm = normal;
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 1:
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 = fast;
yabahiro 33:dd598bb23ad1 1824 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1825 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 1826 motor[TIRE_BR].dir = BACK;
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 3:
yabahiro 33:dd598bb23ad1 1832 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1833 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 1834 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 1835 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1836 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 1837 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1838 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1839 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 1840 mtc=true;
yabahiro 33:dd598bb23ad1 1841 break;
yabahiro 33:dd598bb23ad1 1842 case 2:
yabahiro 33:dd598bb23ad1 1843 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1844 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 1845 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 1846 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1847 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 1848 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1849 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1850 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 1851 mtc=true;
yabahiro 33:dd598bb23ad1 1852 break;
yabahiro 33:dd598bb23ad1 1853 }
yabahiro 39:784552c26163 1854 if(g[1]!=98&&mtc==true) {
yabahiro 39:784552c26163 1855 switch(g[1]) {
yabahiro 39:784552c26163 1856 case 0:
yabahiro 39:784552c26163 1857 mtc=false;
yabahiro 39:784552c26163 1858 break;
yabahiro 39:784552c26163 1859 case 255:
yabahiro 39:784552c26163 1860 motor[TIRE_BR].pwm += 5;
yabahiro 39:784552c26163 1861 mtc=false;
yabahiro 39:784552c26163 1862 break;
yabahiro 39:784552c26163 1863 case 253:
yabahiro 39:784552c26163 1864 motor[TIRE_BR].pwm += 10;
yabahiro 39:784552c26163 1865 mtc=false;
yabahiro 39:784552c26163 1866 break;
yabahiro 39:784552c26163 1867 case 254:
yabahiro 39:784552c26163 1868 motor[TIRE_BR].pwm += 20;
yabahiro 39:784552c26163 1869 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1870 mtc=false;
yabahiro 39:784552c26163 1871 break;
yabahiro 39:784552c26163 1872 case 1:
yabahiro 39:784552c26163 1873 motor[TIRE_BL].pwm += 5;
yabahiro 39:784552c26163 1874 mtc=false;
yabahiro 39:784552c26163 1875 break;
yabahiro 39:784552c26163 1876 case 3:
yabahiro 39:784552c26163 1877 motor[TIRE_BL].pwm += 10;
yabahiro 39:784552c26163 1878 mtc=false;
yabahiro 39:784552c26163 1879 break;
yabahiro 39:784552c26163 1880 case 2:
yabahiro 39:784552c26163 1881 motor[TIRE_BL].pwm += 20;
yabahiro 39:784552c26163 1882 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1883 mtc=false;
yabahiro 39:784552c26163 1884 break;
yabahiro 39:784552c26163 1885 }
yabahiro 33:dd598bb23ad1 1886 }
yabahiro 33:dd598bb23ad1 1887 } else if(mode==100) {
yabahiro 39:784552c26163 1888 motor[TIRE_FR].pwm = 40;
yabahiro 33:dd598bb23ad1 1889 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1890 motor[TIRE_FL].pwm = 40;
yabahiro 33:dd598bb23ad1 1891 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1892 motor[TIRE_BR].pwm = 43;
yabahiro 33:dd598bb23ad1 1893 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1894 motor[TIRE_BL].pwm = 40;
yabahiro 33:dd598bb23ad1 1895 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1896 } else {
yabahiro 33:dd598bb23ad1 1897 }
yabahiro 39:784552c26163 1898
kishibekairohan 13:b6e02d6261d7 1899 }
kishibekairohan 13:b6e02d6261d7 1900 #endif
kishibekairohan 13:b6e02d6261d7 1901
kishibekairohan 13:b6e02d6261d7 1902 #if USE_PROCESS_NUM>3
Ryosei 27:dd9f27fce7d1 1903 static void Process3()
kishibekairohan 13:b6e02d6261d7 1904 {
yabahiro 33:dd598bb23ad1 1905 //Clearly 赤ゾーン
kishibekairohan 35:33c6cdba5630 1906 LED::LED::TapeledMode(3);
yabahiro 33:dd598bb23ad1 1907 countss++;
yabahiro 33:dd598bb23ad1 1908 if(mode==1) {//スタートゾーンから白線検知
yabahiro 33:dd598bb23ad1 1909 fast=40;
yabahiro 33:dd598bb23ad1 1910 normal=30;
yabahiro 33:dd598bb23ad1 1911 slow=20;
kishibekairohan 42:980af34f6fe3 1912 motor[TIRE_FR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 1913 motor[TIRE_FR].dir = BACK;
kishibekairohan 42:980af34f6fe3 1914 motor[TIRE_FL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 1915 motor[TIRE_FL].dir = FOR;
kishibekairohan 42:980af34f6fe3 1916 motor[TIRE_BR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 1917 motor[TIRE_BR].dir = BACK;
kishibekairohan 42:980af34f6fe3 1918 motor[TIRE_BL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 1919 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1920 if(g[2]==0&&countss>=100000) {
yabahiro 33:dd598bb23ad1 1921 countss=100000;
yabahiro 33:dd598bb23ad1 1922 cross=0;
yabahiro 33:dd598bb23ad1 1923 mode=3;
yabahiro 33:dd598bb23ad1 1924 }
yabahiro 33:dd598bb23ad1 1925 } else if(mode==3) { //横ライントレースから縦ライントレースへ
yabahiro 33:dd598bb23ad1 1926 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1927 motor[TIRE_FR].dir = FREE;
kishibekairohan 42:980af34f6fe3 1928 motor[TIRE_FL].pwm = 30;
yabahiro 33:dd598bb23ad1 1929 motor[TIRE_FL].dir = FOR;
kishibekairohan 42:980af34f6fe3 1930 motor[TIRE_BR].pwm = 30;
yabahiro 33:dd598bb23ad1 1931 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1932 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1933 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 1934 if(g[0]==0) {
yabahiro 33:dd598bb23ad1 1935 mode=10;
yabahiro 33:dd598bb23ad1 1936 countss=100000;
yabahiro 33:dd598bb23ad1 1937 }
yabahiro 33:dd598bb23ad1 1938 } else if(mode==10) { //縦ライントレース
yabahiro 33:dd598bb23ad1 1939 switch(g[0]) {
yabahiro 33:dd598bb23ad1 1940 case 98:
kishibekairohan 42:980af34f6fe3 1941 motor[TIRE_FR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 1942 motor[TIRE_FR].dir = BACK;
kishibekairohan 42:980af34f6fe3 1943 motor[TIRE_FL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 1944 motor[TIRE_FL].dir = FOR;
kishibekairohan 42:980af34f6fe3 1945 motor[TIRE_BR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 1946 motor[TIRE_BR].dir = BACK;
kishibekairohan 42:980af34f6fe3 1947 motor[TIRE_BL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 1948 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1949 mtc=true;
yabahiro 33:dd598bb23ad1 1950 if(countss>80000) {
yabahiro 33:dd598bb23ad1 1951 cross++;
yabahiro 33:dd598bb23ad1 1952 countss=0;
yabahiro 33:dd598bb23ad1 1953 }
kishibekairohan 42:980af34f6fe3 1954 /*
kishibekairohan 42:980af34f6fe3 1955 if(cross==2){
kishibekairohan 42:980af34f6fe3 1956 fast = 30;
kishibekairohan 42:980af34f6fe3 1957 normal = 20;
kishibekairohan 42:980af34f6fe3 1958 slow = 20;
kishibekairohan 42:980af34f6fe3 1959 }
kishibekairohan 42:980af34f6fe3 1960 */
yabahiro 38:40e7fdf3c694 1961 if(cross==3) {
yabahiro 33:dd598bb23ad1 1962 mode=11;
yabahiro 33:dd598bb23ad1 1963 countss=0;
yabahiro 33:dd598bb23ad1 1964 cross=0;
yabahiro 33:dd598bb23ad1 1965 }
yabahiro 33:dd598bb23ad1 1966 break;
kishibekairohan 42:980af34f6fe3 1967 //+15した
yabahiro 33:dd598bb23ad1 1968 case 0:
kishibekairohan 42:980af34f6fe3 1969 motor[TIRE_FR].pwm = fast+20;
yabahiro 33:dd598bb23ad1 1970 motor[TIRE_FR].dir = BACK;
kishibekairohan 42:980af34f6fe3 1971 motor[TIRE_FL].pwm = fast+20;
yabahiro 33:dd598bb23ad1 1972 motor[TIRE_FL].dir = FOR;
kishibekairohan 42:980af34f6fe3 1973 motor[TIRE_BR].pwm = fast+20;
yabahiro 33:dd598bb23ad1 1974 motor[TIRE_BR].dir = BACK;
kishibekairohan 42:980af34f6fe3 1975 motor[TIRE_BL].pwm = fast+20;
yabahiro 33:dd598bb23ad1 1976 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1977 mtc=true;
yabahiro 33:dd598bb23ad1 1978 break;
yabahiro 33:dd598bb23ad1 1979 case 255:
kishibekairohan 42:980af34f6fe3 1980 motor[TIRE_FR].pwm = fast+20;
yabahiro 33:dd598bb23ad1 1981 motor[TIRE_FR].dir = BACK;
kishibekairohan 42:980af34f6fe3 1982 motor[TIRE_FL].pwm = slow+20;
yabahiro 33:dd598bb23ad1 1983 motor[TIRE_FL].dir = FOR;
kishibekairohan 42:980af34f6fe3 1984 motor[TIRE_BR].pwm = slow+20;
yabahiro 33:dd598bb23ad1 1985 motor[TIRE_BR].dir = BACK;
kishibekairohan 42:980af34f6fe3 1986 motor[TIRE_BL].pwm = fast+20;
yabahiro 33:dd598bb23ad1 1987 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1988 mtc=true;
yabahiro 33:dd598bb23ad1 1989 break;
yabahiro 33:dd598bb23ad1 1990 case 253:
kishibekairohan 42:980af34f6fe3 1991 motor[TIRE_FR].pwm = slow+20;
yabahiro 33:dd598bb23ad1 1992 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1993 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1994 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1995 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1996 motor[TIRE_BR].dir = FREE;
kishibekairohan 42:980af34f6fe3 1997 motor[TIRE_BL].pwm = slow+20;
yabahiro 33:dd598bb23ad1 1998 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1999 mtc=true;
yabahiro 33:dd598bb23ad1 2000 break;
yabahiro 33:dd598bb23ad1 2001 case 254:
kishibekairohan 42:980af34f6fe3 2002 motor[TIRE_FR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 2003 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 2004 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 2005 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 2006 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 2007 motor[TIRE_BR].dir = FREE;
kishibekairohan 42:980af34f6fe3 2008 motor[TIRE_BL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 2009 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 2010 mtc=true;
yabahiro 33:dd598bb23ad1 2011 break;
yabahiro 33:dd598bb23ad1 2012 case 1:
kishibekairohan 42:980af34f6fe3 2013 motor[TIRE_FR].pwm = slow+20;
yabahiro 33:dd598bb23ad1 2014 motor[TIRE_FR].dir = BACK;
kishibekairohan 42:980af34f6fe3 2015 motor[TIRE_FL].pwm = fast+20;
yabahiro 33:dd598bb23ad1 2016 motor[TIRE_FL].dir = FOR;
kishibekairohan 42:980af34f6fe3 2017 motor[TIRE_BR].pwm = fast+20;
yabahiro 33:dd598bb23ad1 2018 motor[TIRE_BR].dir = BACK;
kishibekairohan 42:980af34f6fe3 2019 motor[TIRE_BL].pwm = slow+20;
yabahiro 33:dd598bb23ad1 2020 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 2021 mtc=true;
yabahiro 33:dd598bb23ad1 2022 break;
yabahiro 33:dd598bb23ad1 2023 case 3:
yabahiro 33:dd598bb23ad1 2024 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 2025 motor[TIRE_FR].dir = FREE;
kishibekairohan 42:980af34f6fe3 2026 motor[TIRE_FL].pwm = slow+20;
yabahiro 33:dd598bb23ad1 2027 motor[TIRE_FL].dir = FOR;
kishibekairohan 42:980af34f6fe3 2028 motor[TIRE_BR].pwm = slow+20;
yabahiro 33:dd598bb23ad1 2029 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2030 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2031 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 2032 mtc=true;
yabahiro 33:dd598bb23ad1 2033 break;
yabahiro 33:dd598bb23ad1 2034 case 2:
yabahiro 33:dd598bb23ad1 2035 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 2036 motor[TIRE_FR].dir = FREE;
kishibekairohan 42:980af34f6fe3 2037 motor[TIRE_FL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 2038 motor[TIRE_FL].dir = FOR;
kishibekairohan 42:980af34f6fe3 2039 motor[TIRE_BR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 2040 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2041 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2042 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 2043 mtc=true;
yabahiro 33:dd598bb23ad1 2044 break;
yabahiro 33:dd598bb23ad1 2045 }
yabahiro 33:dd598bb23ad1 2046 if(g[0]!=98&&mtc==true) {
yabahiro 33:dd598bb23ad1 2047 switch(g[1]) {
yabahiro 33:dd598bb23ad1 2048 case 0:
yabahiro 33:dd598bb23ad1 2049 mtc=false;
yabahiro 33:dd598bb23ad1 2050 break;
yabahiro 33:dd598bb23ad1 2051 case 255:
yabahiro 33:dd598bb23ad1 2052 motor[TIRE_BR].pwm += 5;
yabahiro 33:dd598bb23ad1 2053 mtc=false;
yabahiro 33:dd598bb23ad1 2054 break;
yabahiro 33:dd598bb23ad1 2055 case 253:
yabahiro 33:dd598bb23ad1 2056 motor[TIRE_BR].pwm += 10;
yabahiro 33:dd598bb23ad1 2057 mtc=false;
yabahiro 33:dd598bb23ad1 2058 break;
yabahiro 33:dd598bb23ad1 2059 case 254:
yabahiro 33:dd598bb23ad1 2060 motor[TIRE_BR].pwm += 20;
yabahiro 33:dd598bb23ad1 2061 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2062 mtc=false;
yabahiro 33:dd598bb23ad1 2063 break;
yabahiro 33:dd598bb23ad1 2064 case 1:
yabahiro 33:dd598bb23ad1 2065 motor[TIRE_BL].pwm += 5;
yabahiro 33:dd598bb23ad1 2066 mtc=false;
yabahiro 33:dd598bb23ad1 2067 break;
yabahiro 33:dd598bb23ad1 2068 case 3:
yabahiro 33:dd598bb23ad1 2069 motor[TIRE_BL].pwm += 10;
yabahiro 33:dd598bb23ad1 2070 mtc=false;
yabahiro 33:dd598bb23ad1 2071 break;
yabahiro 33:dd598bb23ad1 2072 case 2:
yabahiro 33:dd598bb23ad1 2073 motor[TIRE_BL].pwm += 20;
yabahiro 33:dd598bb23ad1 2074 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 2075 mtc=false;
yabahiro 33:dd598bb23ad1 2076 break;
yabahiro 33:dd598bb23ad1 2077 }
yabahiro 33:dd598bb23ad1 2078 }
yabahiro 33:dd598bb23ad1 2079 } else if(mode==11) {
yabahiro 33:dd598bb23ad1 2080 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 2081 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 2082 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 2083 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 2084 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 2085 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2086 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2087 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 2088 if(g[2]==0) {
yabahiro 33:dd598bb23ad1 2089 countss=0;
yabahiro 33:dd598bb23ad1 2090 cross=0;
yabahiro 33:dd598bb23ad1 2091 mode=20;
yabahiro 33:dd598bb23ad1 2092 }
yabahiro 33:dd598bb23ad1 2093 } else if(mode==20) {
yabahiro 38:40e7fdf3c694 2094 solenoid.solenoid4= SOLENOID_ON;
yabahiro 33:dd598bb23ad1 2095 switch(g[2]) {
yabahiro 33:dd598bb23ad1 2096 case 98:
kishibekairohan 42:980af34f6fe3 2097 motor[TIRE_FR].pwm = normal+10;
yabahiro 33:dd598bb23ad1 2098 motor[TIRE_FR].dir = FOR;
kishibekairohan 42:980af34f6fe3 2099 motor[TIRE_FL].pwm = normal+10;
yabahiro 33:dd598bb23ad1 2100 motor[TIRE_FL].dir = FOR;
kishibekairohan 42:980af34f6fe3 2101 motor[TIRE_BR].pwm = normal+10;
yabahiro 33:dd598bb23ad1 2102 motor[TIRE_BR].dir = BACK;
kishibekairohan 42:980af34f6fe3 2103 motor[TIRE_BL].pwm = normal+10;
yabahiro 33:dd598bb23ad1 2104 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2105 if(countss>30000) {
yabahiro 33:dd598bb23ad1 2106 cross++;
yabahiro 33:dd598bb23ad1 2107 countss=0;
yabahiro 33:dd598bb23ad1 2108 }
yabahiro 33:dd598bb23ad1 2109 mtc2=true;
kishibekairohan 42:980af34f6fe3 2110 //change
yabahiro 38:40e7fdf3c694 2111 if(cross==1) {
yabahiro 38:40e7fdf3c694 2112 fast=30;
yabahiro 38:40e7fdf3c694 2113 normal=20;
yabahiro 33:dd598bb23ad1 2114 slow=20;
yabahiro 33:dd598bb23ad1 2115 }
yabahiro 38:40e7fdf3c694 2116 if(YELLOW) {
yabahiro 38:40e7fdf3c694 2117 if(cross==2) {
yabahiro 38:40e7fdf3c694 2118 mode=21;
yabahiro 38:40e7fdf3c694 2119 countss=0;
yabahiro 38:40e7fdf3c694 2120 cross=0;
yabahiro 38:40e7fdf3c694 2121 }
yabahiro 38:40e7fdf3c694 2122 } else {
yabahiro 40:ed2409e0ce6b 2123 if(cross==3) {
yabahiro 38:40e7fdf3c694 2124 mode=21;
yabahiro 38:40e7fdf3c694 2125 countss=0;
yabahiro 38:40e7fdf3c694 2126 cross=0;
yabahiro 38:40e7fdf3c694 2127 }
yabahiro 38:40e7fdf3c694 2128 }
yabahiro 33:dd598bb23ad1 2129 break;
yabahiro 33:dd598bb23ad1 2130 case 0:
kishibekairohan 42:980af34f6fe3 2131 motor[TIRE_FR].pwm = fast+15;
yabahiro 33:dd598bb23ad1 2132 motor[TIRE_FR].dir = FOR;
kishibekairohan 42:980af34f6fe3 2133 motor[TIRE_FL].pwm = fast+15;
yabahiro 33:dd598bb23ad1 2134 motor[TIRE_FL].dir = FOR;
kishibekairohan 42:980af34f6fe3 2135 motor[TIRE_BR].pwm = fast+15;
yabahiro 33:dd598bb23ad1 2136 motor[TIRE_BR].dir = BACK;
kishibekairohan 42:980af34f6fe3 2137 motor[TIRE_BL].pwm = fast+15;
yabahiro 33:dd598bb23ad1 2138 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2139 mtc2=true;
yabahiro 33:dd598bb23ad1 2140 break;
yabahiro 33:dd598bb23ad1 2141 case 255:
kishibekairohan 42:980af34f6fe3 2142 motor[TIRE_FR].pwm = normal+15;
yabahiro 33:dd598bb23ad1 2143 motor[TIRE_FR].dir = FOR;
kishibekairohan 42:980af34f6fe3 2144 motor[TIRE_FL].pwm = fast+15;
yabahiro 33:dd598bb23ad1 2145 motor[TIRE_FL].dir = FOR;
kishibekairohan 42:980af34f6fe3 2146 motor[TIRE_BR].pwm = fast+15;
yabahiro 33:dd598bb23ad1 2147 motor[TIRE_BR].dir = BACK;
kishibekairohan 42:980af34f6fe3 2148 motor[TIRE_BL].pwm = normal+15;
yabahiro 33:dd598bb23ad1 2149 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2150 mtc2=true;
yabahiro 33:dd598bb23ad1 2151 break;
yabahiro 33:dd598bb23ad1 2152 case 253:
yabahiro 33:dd598bb23ad1 2153 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 2154 motor[TIRE_FR].dir = FREE;
kishibekairohan 42:980af34f6fe3 2155 motor[TIRE_FL].pwm = slow+15;
yabahiro 33:dd598bb23ad1 2156 motor[TIRE_FL].dir = FOR;
kishibekairohan 42:980af34f6fe3 2157 motor[TIRE_BR].pwm = slow+15;
yabahiro 33:dd598bb23ad1 2158 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2159 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2160 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 2161 mtc2=true;
yabahiro 33:dd598bb23ad1 2162 break;
yabahiro 33:dd598bb23ad1 2163 case 254:
yabahiro 33:dd598bb23ad1 2164 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 2165 motor[TIRE_FR].dir = FREE;
kishibekairohan 42:980af34f6fe3 2166 motor[TIRE_FL].pwm = normal+15;
yabahiro 33:dd598bb23ad1 2167 motor[TIRE_FL].dir = FOR;
kishibekairohan 42:980af34f6fe3 2168 motor[TIRE_BR].pwm = normal+15;
yabahiro 33:dd598bb23ad1 2169 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2170 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2171 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 2172 mtc2=true;
yabahiro 33:dd598bb23ad1 2173 break;
yabahiro 33:dd598bb23ad1 2174 case 1:
kishibekairohan 42:980af34f6fe3 2175 motor[TIRE_FR].pwm = fast+15;
yabahiro 33:dd598bb23ad1 2176 motor[TIRE_FR].dir = FOR;
kishibekairohan 42:980af34f6fe3 2177 motor[TIRE_FL].pwm = slow+15;
yabahiro 33:dd598bb23ad1 2178 motor[TIRE_FL].dir = FOR;
kishibekairohan 42:980af34f6fe3 2179 motor[TIRE_BR].pwm = slow+15;
yabahiro 33:dd598bb23ad1 2180 motor[TIRE_BR].dir = BACK;
kishibekairohan 42:980af34f6fe3 2181 motor[TIRE_BL].pwm = fast+15;
yabahiro 33:dd598bb23ad1 2182 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2183 mtc2=true;
yabahiro 33:dd598bb23ad1 2184 break;
yabahiro 33:dd598bb23ad1 2185 case 3:
kishibekairohan 42:980af34f6fe3 2186 motor[TIRE_FR].pwm = slow+15;
yabahiro 33:dd598bb23ad1 2187 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 2188 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 2189 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 2190 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 2191 motor[TIRE_BR].dir = FREE;
kishibekairohan 42:980af34f6fe3 2192 motor[TIRE_BL].pwm = slow+15;
yabahiro 33:dd598bb23ad1 2193 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2194 mtc2=true;
yabahiro 33:dd598bb23ad1 2195 break;
yabahiro 33:dd598bb23ad1 2196 case 2:
kishibekairohan 42:980af34f6fe3 2197 motor[TIRE_FR].pwm = normal+15;
yabahiro 33:dd598bb23ad1 2198 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 2199 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 2200 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 2201 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 2202 motor[TIRE_BR].dir = FREE;
kishibekairohan 42:980af34f6fe3 2203 motor[TIRE_BL].pwm = normal+15;
yabahiro 33:dd598bb23ad1 2204 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2205 mtc2=true;
yabahiro 33:dd598bb23ad1 2206 break;
yabahiro 33:dd598bb23ad1 2207 }
yabahiro 33:dd598bb23ad1 2208 if(g[2]!=98&&mtc2==true) {
yabahiro 33:dd598bb23ad1 2209 switch(g[3]) {
yabahiro 33:dd598bb23ad1 2210 case 0:
yabahiro 33:dd598bb23ad1 2211 mtc2=false;
yabahiro 33:dd598bb23ad1 2212 break;
yabahiro 33:dd598bb23ad1 2213 case 255:
yabahiro 33:dd598bb23ad1 2214 motor[TIRE_BL].pwm += 5;
yabahiro 33:dd598bb23ad1 2215 mtc2=false;
yabahiro 33:dd598bb23ad1 2216 break;
yabahiro 33:dd598bb23ad1 2217 case 253:
yabahiro 33:dd598bb23ad1 2218 motor[TIRE_BL].pwm += 10;
yabahiro 33:dd598bb23ad1 2219 mtc2=false;
yabahiro 33:dd598bb23ad1 2220 break;
yabahiro 33:dd598bb23ad1 2221 case 254:
yabahiro 33:dd598bb23ad1 2222 motor[TIRE_BL].pwm += 20;
yabahiro 33:dd598bb23ad1 2223 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 2224 mtc2=false;
yabahiro 33:dd598bb23ad1 2225 break;
yabahiro 33:dd598bb23ad1 2226 case 1:
yabahiro 33:dd598bb23ad1 2227 motor[TIRE_FL].pwm += 5;
yabahiro 33:dd598bb23ad1 2228 mtc2=false;
yabahiro 33:dd598bb23ad1 2229 break;
yabahiro 33:dd598bb23ad1 2230 case 3:
yabahiro 33:dd598bb23ad1 2231 motor[TIRE_FL].pwm += 10;
yabahiro 33:dd598bb23ad1 2232 mtc2=false;
yabahiro 33:dd598bb23ad1 2233 break;
yabahiro 33:dd598bb23ad1 2234 case 2:
yabahiro 33:dd598bb23ad1 2235 motor[TIRE_FL].pwm += 20;
yabahiro 33:dd598bb23ad1 2236 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2237 mtc2=false;
yabahiro 33:dd598bb23ad1 2238 break;
yabahiro 33:dd598bb23ad1 2239 }
yabahiro 33:dd598bb23ad1 2240 }
yabahiro 33:dd598bb23ad1 2241 }
yabahiro 38:40e7fdf3c694 2242 if(YELLOW) {
yabahiro 38:40e7fdf3c694 2243 if(mode==21) {
yabahiro 33:dd598bb23ad1 2244 motor[TIRE_FR].pwm = 20;
yabahiro 33:dd598bb23ad1 2245 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 2246 motor[TIRE_FL].pwm = 20;
yabahiro 33:dd598bb23ad1 2247 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 2248 motor[TIRE_BR].pwm = 20;
yabahiro 33:dd598bb23ad1 2249 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 2250 motor[TIRE_BL].pwm = 20;
yabahiro 33:dd598bb23ad1 2251 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 2252 if(g[3]==98&&countss>=10000) {
yabahiro 38:40e7fdf3c694 2253 mode=22;
yabahiro 33:dd598bb23ad1 2254 countss=0;
yabahiro 38:40e7fdf3c694 2255 fast=60;
yabahiro 38:40e7fdf3c694 2256 normal=40;
yabahiro 38:40e7fdf3c694 2257 slow=20;
yabahiro 38:40e7fdf3c694 2258 }
yabahiro 38:40e7fdf3c694 2259 } else if(mode==22) {
yabahiro 38:40e7fdf3c694 2260 if(g[4]==3||g[4]==2) {
yabahiro 38:40e7fdf3c694 2261 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2262 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2263 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2264 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2265 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2266 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 2267 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2268 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2269 }
yabahiro 38:40e7fdf3c694 2270 if(g[4]==253||g[4]==254) {
yabahiro 38:40e7fdf3c694 2271 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2272 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2273 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2274 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2275 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2276 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2277 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2278 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 2279 }
yabahiro 38:40e7fdf3c694 2280 switch(g[2]) {
yabahiro 38:40e7fdf3c694 2281 case 0:
yabahiro 38:40e7fdf3c694 2282 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 2283 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2284 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 2285 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2286 break;
yabahiro 38:40e7fdf3c694 2287 case 255:
yabahiro 38:40e7fdf3c694 2288 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2289 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2290 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 2291 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2292 break;
yabahiro 38:40e7fdf3c694 2293 case 253:
yabahiro 38:40e7fdf3c694 2294 motor[TIRE_FR].pwm = 40;
yabahiro 38:40e7fdf3c694 2295 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2296 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 2297 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2298 break;
yabahiro 38:40e7fdf3c694 2299 case 254:
yabahiro 38:40e7fdf3c694 2300 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2301 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2302 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2303 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 2304 break;
yabahiro 38:40e7fdf3c694 2305 case 1:
yabahiro 38:40e7fdf3c694 2306 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 2307 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2308 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2309 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2310 break;
yabahiro 38:40e7fdf3c694 2311 case 3:
yabahiro 38:40e7fdf3c694 2312 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 2313 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2314 motor[TIRE_BR].pwm = 40;
yabahiro 38:40e7fdf3c694 2315 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2316 break;
yabahiro 38:40e7fdf3c694 2317 case 2:
yabahiro 38:40e7fdf3c694 2318 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2319 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2320 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2321 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2322 break;
yabahiro 38:40e7fdf3c694 2323 }
yabahiro 38:40e7fdf3c694 2324 switch(g[3]) {
yabahiro 38:40e7fdf3c694 2325 case 0:
yabahiro 38:40e7fdf3c694 2326 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 2327 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2328 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 2329 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2330 break;
yabahiro 38:40e7fdf3c694 2331 case 255:
yabahiro 38:40e7fdf3c694 2332 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 2333 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2334 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2335 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2336 case 253:
yabahiro 38:40e7fdf3c694 2337 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 2338 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2339 motor[TIRE_BL].pwm = 40;
yabahiro 38:40e7fdf3c694 2340 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2341 break;
yabahiro 38:40e7fdf3c694 2342 case 254:
yabahiro 38:40e7fdf3c694 2343 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2344 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2345 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2346 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2347 break;
yabahiro 38:40e7fdf3c694 2348 case 1:
yabahiro 38:40e7fdf3c694 2349 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2350 motor[TIRE_FL].dir = FOR;
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 3:
yabahiro 38:40e7fdf3c694 2355 motor[TIRE_FL].pwm = 40;
yabahiro 38:40e7fdf3c694 2356 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2357 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 2358 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2359 break;
yabahiro 38:40e7fdf3c694 2360 case 2:
yabahiro 38:40e7fdf3c694 2361 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2362 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2363 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2364 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 2365 break;
yabahiro 38:40e7fdf3c694 2366 }
yabahiro 38:40e7fdf3c694 2367 if(g[3]==0&&g[2]==0) {
yabahiro 38:40e7fdf3c694 2368 mode=23;
yabahiro 33:dd598bb23ad1 2369 countss=0;
yabahiro 33:dd598bb23ad1 2370 }
yabahiro 38:40e7fdf3c694 2371 } else if(mode==23) {
yabahiro 38:40e7fdf3c694 2372 switch(g[4]) {
yabahiro 38:40e7fdf3c694 2373 case 98:
kishibekairohan 41:99a1158f3eca 2374 motor[TIRE_FR].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2375 motor[TIRE_FR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2376 motor[TIRE_FL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2377 motor[TIRE_FL].dir = BACK;
kishibekairohan 41:99a1158f3eca 2378 motor[TIRE_BR].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2379 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2380 motor[TIRE_BL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2381 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2382 break;
yabahiro 38:40e7fdf3c694 2383 case 99:
yabahiro 38:40e7fdf3c694 2384 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2385 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2386 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2387 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2388 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2389 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2390 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2391 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2392 break;
yabahiro 38:40e7fdf3c694 2393 case 0:
kishibekairohan 41:99a1158f3eca 2394 motor[TIRE_FR].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2395 motor[TIRE_FR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2396 motor[TIRE_FL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2397 motor[TIRE_FL].dir = BACK;
kishibekairohan 41:99a1158f3eca 2398 motor[TIRE_BR].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2399 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2400 motor[TIRE_BL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2401 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2402 break;
yabahiro 38:40e7fdf3c694 2403 case 255:
yabahiro 38:40e7fdf3c694 2404 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2405 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2406 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2407 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2408 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2409 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2410 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2411 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2412 break;
yabahiro 38:40e7fdf3c694 2413 case 253:
kishibekairohan 41:99a1158f3eca 2414 motor[TIRE_FR].pwm = slow-5;
yabahiro 38:40e7fdf3c694 2415 motor[TIRE_FR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2416 motor[TIRE_FL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2417 motor[TIRE_FL].dir = BACK;
kishibekairohan 41:99a1158f3eca 2418 motor[TIRE_BR].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2419 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2420 motor[TIRE_BL].pwm = slow-5;
yabahiro 38:40e7fdf3c694 2421 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2422 break;
yabahiro 38:40e7fdf3c694 2423 case 254:
kishibekairohan 41:99a1158f3eca 2424 motor[TIRE_FR].pwm = normal-5;
yabahiro 38:40e7fdf3c694 2425 motor[TIRE_FR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2426 motor[TIRE_FL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2427 motor[TIRE_FL].dir = BACK;
kishibekairohan 41:99a1158f3eca 2428 motor[TIRE_BR].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2429 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2430 motor[TIRE_BL].pwm = normal-5;
yabahiro 38:40e7fdf3c694 2431 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2432 break;
yabahiro 38:40e7fdf3c694 2433 case 1:
yabahiro 38:40e7fdf3c694 2434 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2435 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2436 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2437 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2438 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2439 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2440 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2441 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2442 break;
yabahiro 38:40e7fdf3c694 2443 case 3:
kishibekairohan 41:99a1158f3eca 2444 motor[TIRE_FR].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2445 motor[TIRE_FR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2446 motor[TIRE_FL].pwm = slow-5;
yabahiro 38:40e7fdf3c694 2447 motor[TIRE_FL].dir = BACK;
kishibekairohan 41:99a1158f3eca 2448 motor[TIRE_BR].pwm = slow-5;
yabahiro 38:40e7fdf3c694 2449 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2450 motor[TIRE_BL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2451 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2452 break;
yabahiro 38:40e7fdf3c694 2453 case 2:
kishibekairohan 41:99a1158f3eca 2454 motor[TIRE_FR].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2455 motor[TIRE_FR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2456 motor[TIRE_FL].pwm = normal-5;
yabahiro 38:40e7fdf3c694 2457 motor[TIRE_FL].dir = BACK;
kishibekairohan 41:99a1158f3eca 2458 motor[TIRE_BR].pwm = normal-5;
yabahiro 38:40e7fdf3c694 2459 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2460 motor[TIRE_BL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2461 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2462 break;
yabahiro 33:dd598bb23ad1 2463 }
yabahiro 38:40e7fdf3c694 2464 if(DOLS==true||UPLS==true) {
yabahiro 38:40e7fdf3c694 2465 motor[MOTOR_0].pwm = 200;
yabahiro 38:40e7fdf3c694 2466 motor[MOTOR_0].dir = BRAKE;
yabahiro 38:40e7fdf3c694 2467 }
yabahiro 38:40e7fdf3c694 2468 if(g[1]==98) {
kishibekairohan 42:980af34f6fe3 2469 //Change
kishibekairohan 42:980af34f6fe3 2470 fast=20;
kishibekairohan 42:980af34f6fe3 2471 normal=15;
kishibekairohan 42:980af34f6fe3 2472 slow=10;
yabahiro 38:40e7fdf3c694 2473 if(DOLS==true||UPLS==true) {
yabahiro 38:40e7fdf3c694 2474 motor[MOTOR_0].pwm = 200;
yabahiro 38:40e7fdf3c694 2475 motor[MOTOR_0].dir = BRAKE;
yabahiro 38:40e7fdf3c694 2476 } else {
yabahiro 38:40e7fdf3c694 2477 motor[MOTOR_0].pwm = 100;
yabahiro 38:40e7fdf3c694 2478 motor[MOTOR_0].dir = BACK;
yabahiro 38:40e7fdf3c694 2479 }
yabahiro 38:40e7fdf3c694 2480 }
yabahiro 38:40e7fdf3c694 2481 if(g[3]==254&&countss>=100000) {
yabahiro 38:40e7fdf3c694 2482 mode=24;
yabahiro 38:40e7fdf3c694 2483 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 33:dd598bb23ad1 2484 countss=0;
yabahiro 38:40e7fdf3c694 2485 fast=60;
yabahiro 38:40e7fdf3c694 2486 normal=40;
kishibekairohan 42:980af34f6fe3 2487 slow=20;
yabahiro 33:dd598bb23ad1 2488 }
yabahiro 33:dd598bb23ad1 2489 } else if(mode==24) {
yabahiro 38:40e7fdf3c694 2490 if(DOLS==true||UPLS==true) {
yabahiro 38:40e7fdf3c694 2491 motor[MOTOR_0].pwm = 200;
yabahiro 38:40e7fdf3c694 2492 motor[MOTOR_0].dir = BRAKE;
yabahiro 38:40e7fdf3c694 2493 } else {
yabahiro 38:40e7fdf3c694 2494 motor[MOTOR_0].pwm = 100;
yabahiro 38:40e7fdf3c694 2495 motor[MOTOR_0].dir = BACK;
yabahiro 38:40e7fdf3c694 2496 }
yabahiro 38:40e7fdf3c694 2497 if(g[4]==3||g[4]==2) {
yabahiro 38:40e7fdf3c694 2498 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2499 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2500 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2501 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2502 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2503 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 2504 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2505 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2506 }
yabahiro 38:40e7fdf3c694 2507 if(g[4]==253||g[4]==254) {
yabahiro 38:40e7fdf3c694 2508 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2509 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2510 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2511 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2512 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2513 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2514 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2515 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 2516 }
yabahiro 38:40e7fdf3c694 2517 switch(g[2]) {
yabahiro 38:40e7fdf3c694 2518 case 0:
yabahiro 38:40e7fdf3c694 2519 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 2520 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2521 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 2522 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2523 break;
yabahiro 38:40e7fdf3c694 2524 case 255:
yabahiro 38:40e7fdf3c694 2525 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2526 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2527 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 2528 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2529 break;
yabahiro 38:40e7fdf3c694 2530 case 253:
yabahiro 38:40e7fdf3c694 2531 motor[TIRE_FR].pwm = 40;
yabahiro 38:40e7fdf3c694 2532 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2533 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 2534 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2535 break;
yabahiro 38:40e7fdf3c694 2536 case 254:
yabahiro 38:40e7fdf3c694 2537 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2538 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2539 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2540 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 2541 break;
yabahiro 38:40e7fdf3c694 2542 case 1:
yabahiro 38:40e7fdf3c694 2543 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 2544 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2545 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2546 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2547 break;
yabahiro 38:40e7fdf3c694 2548 case 3:
yabahiro 38:40e7fdf3c694 2549 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 2550 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2551 motor[TIRE_BR].pwm = 40;
yabahiro 38:40e7fdf3c694 2552 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2553 break;
yabahiro 38:40e7fdf3c694 2554 case 2:
yabahiro 38:40e7fdf3c694 2555 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2556 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2557 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2558 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2559 break;
yabahiro 38:40e7fdf3c694 2560 }
yabahiro 38:40e7fdf3c694 2561 switch(g[3]) {
yabahiro 38:40e7fdf3c694 2562 case 0:
yabahiro 38:40e7fdf3c694 2563 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 2564 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2565 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 2566 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2567 break;
yabahiro 38:40e7fdf3c694 2568 case 255:
yabahiro 38:40e7fdf3c694 2569 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 2570 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2571 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2572 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2573 case 253:
yabahiro 38:40e7fdf3c694 2574 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 2575 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2576 motor[TIRE_BL].pwm = 40;
yabahiro 38:40e7fdf3c694 2577 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2578 break;
yabahiro 38:40e7fdf3c694 2579 case 254:
yabahiro 38:40e7fdf3c694 2580 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2581 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2582 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2583 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2584 break;
yabahiro 38:40e7fdf3c694 2585 case 1:
yabahiro 38:40e7fdf3c694 2586 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2587 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2588 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 2589 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2590 break;
yabahiro 38:40e7fdf3c694 2591 case 3:
yabahiro 38:40e7fdf3c694 2592 motor[TIRE_FL].pwm = 40;
yabahiro 38:40e7fdf3c694 2593 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2594 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 2595 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2596 break;
yabahiro 38:40e7fdf3c694 2597 case 2:
yabahiro 38:40e7fdf3c694 2598 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2599 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2600 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2601 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 2602 break;
yabahiro 38:40e7fdf3c694 2603 }
yabahiro 38:40e7fdf3c694 2604 if(g[3]==0&&g[2]==0) {
yabahiro 38:40e7fdf3c694 2605 if(UPLS==true||DOLS==true) {
yabahiro 38:40e7fdf3c694 2606 motor[MOTOR_0].pwm = 200;
yabahiro 38:40e7fdf3c694 2607 motor[MOTOR_0].dir = BRAKE;
yabahiro 38:40e7fdf3c694 2608 mode=25;
yabahiro 38:40e7fdf3c694 2609 } else {
yabahiro 38:40e7fdf3c694 2610 motor[MOTOR_0].pwm = 100;
yabahiro 38:40e7fdf3c694 2611 motor[MOTOR_0].dir = BACK;
yabahiro 38:40e7fdf3c694 2612 }
yabahiro 38:40e7fdf3c694 2613 }
yabahiro 38:40e7fdf3c694 2614 } else if(mode==25) {
yabahiro 38:40e7fdf3c694 2615 switch(g[4]) {
yabahiro 38:40e7fdf3c694 2616 case 98:
yabahiro 38:40e7fdf3c694 2617 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 2618 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2619 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 2620 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2621 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 2622 motor[TIRE_BR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2623 motor[TIRE_BL].pwm = 60;
yabahiro 38:40e7fdf3c694 2624 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2625 break;
yabahiro 38:40e7fdf3c694 2626 case 99:
yabahiro 38:40e7fdf3c694 2627 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2628 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2629 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2630 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2631 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2632 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2633 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2634 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2635 break;
yabahiro 38:40e7fdf3c694 2636 case 0:
yabahiro 38:40e7fdf3c694 2637 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 2638 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2639 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 2640 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2641 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 2642 motor[TIRE_BR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2643 motor[TIRE_BL].pwm = 60;
yabahiro 38:40e7fdf3c694 2644 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2645 break;
yabahiro 38:40e7fdf3c694 2646 case 255:
yabahiro 38:40e7fdf3c694 2647 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2648 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2649 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2650 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2651 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2652 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2653 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2654 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2655 break;
yabahiro 38:40e7fdf3c694 2656 case 253:
yabahiro 38:40e7fdf3c694 2657 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 2658 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2659 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 2660 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2661 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 2662 motor[TIRE_BR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2663 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 2664 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2665 break;
yabahiro 38:40e7fdf3c694 2666 case 254:
yabahiro 38:40e7fdf3c694 2667 motor[TIRE_FR].pwm = 40;
yabahiro 38:40e7fdf3c694 2668 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2669 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 2670 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2671 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 2672 motor[TIRE_BR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2673 motor[TIRE_BL].pwm = 40;
yabahiro 38:40e7fdf3c694 2674 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2675 break;
yabahiro 38:40e7fdf3c694 2676 case 1:
yabahiro 38:40e7fdf3c694 2677 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2678 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2679 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2680 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2681 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2682 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2683 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2684 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2685 break;
yabahiro 38:40e7fdf3c694 2686 case 3:
yabahiro 38:40e7fdf3c694 2687 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 2688 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2689 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 2690 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2691 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 2692 motor[TIRE_BR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2693 motor[TIRE_BL].pwm = 60;
yabahiro 38:40e7fdf3c694 2694 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2695 break;
yabahiro 38:40e7fdf3c694 2696 case 2:
yabahiro 38:40e7fdf3c694 2697 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 2698 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2699 motor[TIRE_FL].pwm = 40;
yabahiro 38:40e7fdf3c694 2700 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2701 motor[TIRE_BR].pwm = 40;
yabahiro 38:40e7fdf3c694 2702 motor[TIRE_BR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2703 motor[TIRE_BL].pwm = 60;
yabahiro 38:40e7fdf3c694 2704 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2705 break;
yabahiro 38:40e7fdf3c694 2706 }
yabahiro 38:40e7fdf3c694 2707 if(g[1]==98) {
yabahiro 38:40e7fdf3c694 2708 mode=31;
yabahiro 33:dd598bb23ad1 2709 }
yabahiro 33:dd598bb23ad1 2710 }
yabahiro 33:dd598bb23ad1 2711 } else {
yabahiro 38:40e7fdf3c694 2712 if(mode==21) {
yabahiro 38:40e7fdf3c694 2713 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2714 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2715 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2716 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2717 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2718 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2719 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2720 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2721 if(g[1]==0) {
yabahiro 38:40e7fdf3c694 2722 mode=22;
yabahiro 38:40e7fdf3c694 2723 fast=60;
yabahiro 38:40e7fdf3c694 2724 normal=40;
yabahiro 38:40e7fdf3c694 2725 slow=20;
yabahiro 38:40e7fdf3c694 2726 }
yabahiro 38:40e7fdf3c694 2727 } else if(mode==22) {
yabahiro 40:ed2409e0ce6b 2728 if(g[1]==98) {
yabahiro 40:ed2409e0ce6b 2729 slow=20;
yabahiro 40:ed2409e0ce6b 2730 normal=20;
yabahiro 40:ed2409e0ce6b 2731 fast=30;
yabahiro 40:ed2409e0ce6b 2732 }
yabahiro 40:ed2409e0ce6b 2733 if(g[3]==0){
yabahiro 40:ed2409e0ce6b 2734 slow=30;
yabahiro 40:ed2409e0ce6b 2735 normal=40;
yabahiro 40:ed2409e0ce6b 2736 fast=60;
yabahiro 38:40e7fdf3c694 2737 mode=23;
yabahiro 40:ed2409e0ce6b 2738 }
yabahiro 38:40e7fdf3c694 2739 switch(g[1]) {
yabahiro 38:40e7fdf3c694 2740 case 98:
yabahiro 38:40e7fdf3c694 2741 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 38:40e7fdf3c694 2742 fast=30;
yabahiro 38:40e7fdf3c694 2743 normal=20;
yabahiro 38:40e7fdf3c694 2744 slow=20;
yabahiro 38:40e7fdf3c694 2745 motor[TIRE_FR].pwm = normal;
yabahiro 38:40e7fdf3c694 2746 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2747 motor[TIRE_FL].pwm = normal;
yabahiro 38:40e7fdf3c694 2748 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2749 motor[TIRE_BR].pwm = normal;
yabahiro 38:40e7fdf3c694 2750 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2751 motor[TIRE_BL].pwm = normal;
yabahiro 38:40e7fdf3c694 2752 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2753 break;
yabahiro 38:40e7fdf3c694 2754 case 0:
yabahiro 38:40e7fdf3c694 2755 motor[TIRE_FR].pwm = fast;
yabahiro 38:40e7fdf3c694 2756 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2757 motor[TIRE_FL].pwm = fast;
yabahiro 38:40e7fdf3c694 2758 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2759 motor[TIRE_BR].pwm = fast;
yabahiro 38:40e7fdf3c694 2760 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2761 motor[TIRE_BL].pwm = fast;
yabahiro 38:40e7fdf3c694 2762 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2763 mtc=true;
yabahiro 38:40e7fdf3c694 2764 break;
yabahiro 38:40e7fdf3c694 2765 case 255:
yabahiro 38:40e7fdf3c694 2766 motor[TIRE_FR].pwm = fast;
yabahiro 38:40e7fdf3c694 2767 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2768 motor[TIRE_FL].pwm = slow;
yabahiro 38:40e7fdf3c694 2769 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2770 motor[TIRE_BR].pwm = slow;
yabahiro 38:40e7fdf3c694 2771 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2772 motor[TIRE_BL].pwm = fast;
yabahiro 38:40e7fdf3c694 2773 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2774 mtc=true;
yabahiro 38:40e7fdf3c694 2775 break;
yabahiro 38:40e7fdf3c694 2776 case 253:
yabahiro 38:40e7fdf3c694 2777 motor[TIRE_FR].pwm = slow;
yabahiro 38:40e7fdf3c694 2778 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2779 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2780 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2781 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2782 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2783 motor[TIRE_BL].pwm = slow;
yabahiro 38:40e7fdf3c694 2784 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2785 mtc=true;
yabahiro 38:40e7fdf3c694 2786 break;
yabahiro 38:40e7fdf3c694 2787 case 254:
yabahiro 38:40e7fdf3c694 2788 motor[TIRE_FR].pwm = normal;
yabahiro 38:40e7fdf3c694 2789 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2790 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2791 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2792 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2793 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2794 motor[TIRE_BL].pwm = normal;
yabahiro 38:40e7fdf3c694 2795 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2796 mtc=true;
yabahiro 38:40e7fdf3c694 2797 break;
yabahiro 38:40e7fdf3c694 2798 case 1:
yabahiro 38:40e7fdf3c694 2799 motor[TIRE_FR].pwm = slow;
yabahiro 38:40e7fdf3c694 2800 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2801 motor[TIRE_FL].pwm = fast;
yabahiro 38:40e7fdf3c694 2802 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2803 motor[TIRE_BR].pwm = fast;
yabahiro 38:40e7fdf3c694 2804 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2805 motor[TIRE_BL].pwm = slow;
yabahiro 38:40e7fdf3c694 2806 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2807 mtc=true;
yabahiro 38:40e7fdf3c694 2808 break;
yabahiro 38:40e7fdf3c694 2809 case 3:
yabahiro 38:40e7fdf3c694 2810 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2811 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2812 motor[TIRE_FL].pwm = slow;
yabahiro 38:40e7fdf3c694 2813 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2814 motor[TIRE_BR].pwm = slow;
yabahiro 38:40e7fdf3c694 2815 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2816 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2817 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2818 mtc=true;
yabahiro 38:40e7fdf3c694 2819 break;
yabahiro 38:40e7fdf3c694 2820 case 2:
yabahiro 38:40e7fdf3c694 2821 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2822 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2823 motor[TIRE_FL].pwm = normal;
yabahiro 38:40e7fdf3c694 2824 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2825 motor[TIRE_BR].pwm = normal;
yabahiro 38:40e7fdf3c694 2826 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2827 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2828 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2829 mtc=true;
yabahiro 38:40e7fdf3c694 2830 break;
yabahiro 38:40e7fdf3c694 2831 }
yabahiro 38:40e7fdf3c694 2832 if(g[1]!=98&&mtc==true) {
yabahiro 38:40e7fdf3c694 2833 switch(g[0]) {
yabahiro 38:40e7fdf3c694 2834 case 0:
yabahiro 38:40e7fdf3c694 2835 mtc=false;
yabahiro 38:40e7fdf3c694 2836 break;
yabahiro 38:40e7fdf3c694 2837 case 255:
yabahiro 38:40e7fdf3c694 2838 motor[TIRE_FL].pwm += 5;
yabahiro 38:40e7fdf3c694 2839 mtc=false;
yabahiro 38:40e7fdf3c694 2840 break;
yabahiro 38:40e7fdf3c694 2841 case 253:
yabahiro 38:40e7fdf3c694 2842 motor[TIRE_FL].pwm += 10;
yabahiro 38:40e7fdf3c694 2843 mtc=false;
yabahiro 38:40e7fdf3c694 2844 break;
yabahiro 38:40e7fdf3c694 2845 case 254:
yabahiro 38:40e7fdf3c694 2846 motor[TIRE_FL].pwm += 20;
yabahiro 38:40e7fdf3c694 2847 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2848 mtc=false;
yabahiro 38:40e7fdf3c694 2849 break;
yabahiro 38:40e7fdf3c694 2850 case 1:
yabahiro 38:40e7fdf3c694 2851 motor[TIRE_FR].pwm += 5;
yabahiro 38:40e7fdf3c694 2852 mtc=false;
yabahiro 38:40e7fdf3c694 2853 break;
yabahiro 38:40e7fdf3c694 2854 case 3:
yabahiro 38:40e7fdf3c694 2855 motor[TIRE_FR].pwm += 10;
yabahiro 38:40e7fdf3c694 2856 mtc=false;
yabahiro 38:40e7fdf3c694 2857 break;
yabahiro 38:40e7fdf3c694 2858 case 2:
yabahiro 38:40e7fdf3c694 2859 motor[TIRE_FR].pwm += 20;
yabahiro 38:40e7fdf3c694 2860 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2861 mtc=false;
yabahiro 38:40e7fdf3c694 2862 break;
yabahiro 38:40e7fdf3c694 2863 }
yabahiro 38:40e7fdf3c694 2864 }
yabahiro 40:ed2409e0ce6b 2865 }else if(mode==23) {
yabahiro 38:40e7fdf3c694 2866 if(UPLS==true||DOLS==true) {
yabahiro 38:40e7fdf3c694 2867 motor[MOTOR_0].pwm = 200;
yabahiro 38:40e7fdf3c694 2868 motor[MOTOR_0].dir = BRAKE;
yabahiro 38:40e7fdf3c694 2869 fast=60;
yabahiro 38:40e7fdf3c694 2870 normal=40;
yabahiro 38:40e7fdf3c694 2871 slow=20;
yabahiro 33:dd598bb23ad1 2872 countss=0;
yabahiro 38:40e7fdf3c694 2873 mode=24;
yabahiro 38:40e7fdf3c694 2874 } else {
yabahiro 38:40e7fdf3c694 2875 motor[MOTOR_0].pwm = 100;
yabahiro 38:40e7fdf3c694 2876 motor[MOTOR_0].dir = BACK;
yabahiro 38:40e7fdf3c694 2877 }
yabahiro 40:ed2409e0ce6b 2878 motor[TIRE_FR].pwm = 100;
yabahiro 40:ed2409e0ce6b 2879 motor[TIRE_FR].dir = BRAKE;
yabahiro 40:ed2409e0ce6b 2880 motor[TIRE_FL].pwm = 100;
yabahiro 40:ed2409e0ce6b 2881 motor[TIRE_FL].dir = BRAKE;
yabahiro 40:ed2409e0ce6b 2882 motor[TIRE_BR].pwm = 100;
yabahiro 40:ed2409e0ce6b 2883 motor[TIRE_BR].dir = BRAKE;
yabahiro 40:ed2409e0ce6b 2884 motor[TIRE_BL].pwm = 100;
yabahiro 40:ed2409e0ce6b 2885 motor[TIRE_BL].dir = BRAKE;
yabahiro 38:40e7fdf3c694 2886 } else if(mode==24) {
yabahiro 38:40e7fdf3c694 2887 if(g[1]==98&&countss>=40000) {
yabahiro 38:40e7fdf3c694 2888 mode=31;
yabahiro 38:40e7fdf3c694 2889 countss=0;
yabahiro 38:40e7fdf3c694 2890 }
yabahiro 38:40e7fdf3c694 2891 switch(g[1]) {
yabahiro 38:40e7fdf3c694 2892 case 98:
yabahiro 38:40e7fdf3c694 2893 fast=30;
yabahiro 38:40e7fdf3c694 2894 normal=20;
yabahiro 38:40e7fdf3c694 2895 slow=20;
yabahiro 38:40e7fdf3c694 2896 motor[TIRE_FR].pwm = normal;
yabahiro 38:40e7fdf3c694 2897 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2898 motor[TIRE_FL].pwm = normal;
yabahiro 38:40e7fdf3c694 2899 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2900 motor[TIRE_BR].pwm = normal;
yabahiro 38:40e7fdf3c694 2901 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2902 motor[TIRE_BL].pwm = normal;
yabahiro 38:40e7fdf3c694 2903 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2904 break;
yabahiro 38:40e7fdf3c694 2905 case 0:
yabahiro 38:40e7fdf3c694 2906 motor[TIRE_FR].pwm = fast;
yabahiro 38:40e7fdf3c694 2907 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2908 motor[TIRE_FL].pwm = fast;
yabahiro 38:40e7fdf3c694 2909 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2910 motor[TIRE_BR].pwm = fast;
yabahiro 38:40e7fdf3c694 2911 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2912 motor[TIRE_BL].pwm = fast;
yabahiro 38:40e7fdf3c694 2913 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2914 mtc=true;
yabahiro 38:40e7fdf3c694 2915 break;
yabahiro 38:40e7fdf3c694 2916 case 255:
yabahiro 38:40e7fdf3c694 2917 motor[TIRE_FR].pwm = fast;
yabahiro 38:40e7fdf3c694 2918 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2919 motor[TIRE_FL].pwm = slow;
yabahiro 38:40e7fdf3c694 2920 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2921 motor[TIRE_BR].pwm = slow;
yabahiro 38:40e7fdf3c694 2922 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2923 motor[TIRE_BL].pwm = fast;
yabahiro 38:40e7fdf3c694 2924 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2925 mtc=true;
yabahiro 38:40e7fdf3c694 2926 break;
yabahiro 38:40e7fdf3c694 2927 case 253:
yabahiro 38:40e7fdf3c694 2928 motor[TIRE_FR].pwm = slow;
yabahiro 38:40e7fdf3c694 2929 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2930 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2931 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2932 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2933 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2934 motor[TIRE_BL].pwm = slow;
yabahiro 38:40e7fdf3c694 2935 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2936 mtc=true;
yabahiro 38:40e7fdf3c694 2937 break;
yabahiro 38:40e7fdf3c694 2938 case 254:
yabahiro 38:40e7fdf3c694 2939 motor[TIRE_FR].pwm = normal;
yabahiro 38:40e7fdf3c694 2940 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2941 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2942 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2943 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2944 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2945 motor[TIRE_BL].pwm = normal;
yabahiro 38:40e7fdf3c694 2946 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2947 mtc=true;
yabahiro 38:40e7fdf3c694 2948 break;
yabahiro 38:40e7fdf3c694 2949 case 1:
yabahiro 38:40e7fdf3c694 2950 motor[TIRE_FR].pwm = slow;
yabahiro 38:40e7fdf3c694 2951 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2952 motor[TIRE_FL].pwm = fast;
yabahiro 38:40e7fdf3c694 2953 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2954 motor[TIRE_BR].pwm = fast;
yabahiro 38:40e7fdf3c694 2955 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2956 motor[TIRE_BL].pwm = slow;
yabahiro 38:40e7fdf3c694 2957 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2958 mtc=true;
yabahiro 38:40e7fdf3c694 2959 break;
yabahiro 38:40e7fdf3c694 2960 case 3:
yabahiro 38:40e7fdf3c694 2961 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2962 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2963 motor[TIRE_FL].pwm = slow;
yabahiro 38:40e7fdf3c694 2964 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2965 motor[TIRE_BR].pwm = slow;
yabahiro 38:40e7fdf3c694 2966 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2967 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2968 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2969 mtc=true;
yabahiro 38:40e7fdf3c694 2970 break;
yabahiro 38:40e7fdf3c694 2971 case 2:
yabahiro 38:40e7fdf3c694 2972 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2973 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2974 motor[TIRE_FL].pwm = normal;
yabahiro 38:40e7fdf3c694 2975 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2976 motor[TIRE_BR].pwm = normal;
yabahiro 38:40e7fdf3c694 2977 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2978 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2979 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2980 mtc=true;
yabahiro 38:40e7fdf3c694 2981 break;
yabahiro 38:40e7fdf3c694 2982 }
yabahiro 38:40e7fdf3c694 2983 if(g[1]!=98&&mtc==true) {
yabahiro 38:40e7fdf3c694 2984 switch(g[0]) {
yabahiro 38:40e7fdf3c694 2985 case 0:
yabahiro 38:40e7fdf3c694 2986 mtc=false;
yabahiro 38:40e7fdf3c694 2987 break;
yabahiro 38:40e7fdf3c694 2988 case 255:
yabahiro 38:40e7fdf3c694 2989 motor[TIRE_FL].pwm += 5;
yabahiro 38:40e7fdf3c694 2990 mtc=false;
yabahiro 38:40e7fdf3c694 2991 break;
yabahiro 38:40e7fdf3c694 2992 case 253:
yabahiro 38:40e7fdf3c694 2993 motor[TIRE_FL].pwm += 10;
yabahiro 38:40e7fdf3c694 2994 mtc=false;
yabahiro 38:40e7fdf3c694 2995 break;
yabahiro 38:40e7fdf3c694 2996 case 254:
yabahiro 38:40e7fdf3c694 2997 motor[TIRE_FL].pwm += 20;
yabahiro 38:40e7fdf3c694 2998 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2999 mtc=false;
yabahiro 38:40e7fdf3c694 3000 break;
yabahiro 38:40e7fdf3c694 3001 case 1:
yabahiro 38:40e7fdf3c694 3002 motor[TIRE_FR].pwm += 5;
yabahiro 38:40e7fdf3c694 3003 mtc=false;
yabahiro 38:40e7fdf3c694 3004 break;
yabahiro 38:40e7fdf3c694 3005 case 3:
yabahiro 38:40e7fdf3c694 3006 motor[TIRE_FR].pwm += 10;
yabahiro 38:40e7fdf3c694 3007 mtc=false;
yabahiro 38:40e7fdf3c694 3008 break;
yabahiro 38:40e7fdf3c694 3009 case 2:
yabahiro 38:40e7fdf3c694 3010 motor[TIRE_FR].pwm += 20;
yabahiro 38:40e7fdf3c694 3011 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 3012 mtc=false;
yabahiro 38:40e7fdf3c694 3013 break;
yabahiro 38:40e7fdf3c694 3014 }
yabahiro 33:dd598bb23ad1 3015 }
yabahiro 33:dd598bb23ad1 3016 }
yabahiro 33:dd598bb23ad1 3017 }
yabahiro 38:40e7fdf3c694 3018 if(mode==31) {
yabahiro 33:dd598bb23ad1 3019 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3020 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 3021 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3022 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3023 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3024 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 3025 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3026 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 3027 if(countss>=5000) {
yabahiro 33:dd598bb23ad1 3028 countss=0;
yabahiro 33:dd598bb23ad1 3029 mode=32;
yabahiro 33:dd598bb23ad1 3030 }
yabahiro 33:dd598bb23ad1 3031 } else if(mode==32) {
yabahiro 33:dd598bb23ad1 3032 motor[TIRE_FR].pwm = 10;
yabahiro 33:dd598bb23ad1 3033 motor[TIRE_FR].dir = BRAKE;
yabahiro 33:dd598bb23ad1 3034 motor[TIRE_FL].pwm = 10;
yabahiro 33:dd598bb23ad1 3035 motor[TIRE_FL].dir = BRAKE;
yabahiro 33:dd598bb23ad1 3036 motor[TIRE_BR].pwm = 10;
yabahiro 33:dd598bb23ad1 3037 motor[TIRE_BR].dir = BRAKE;
yabahiro 33:dd598bb23ad1 3038 motor[TIRE_BL].pwm = 10;
yabahiro 33:dd598bb23ad1 3039 motor[TIRE_BL].dir = BRAKE;
yabahiro 33:dd598bb23ad1 3040 if(countss>=40000) {
yabahiro 33:dd598bb23ad1 3041 mode=33;
yabahiro 33:dd598bb23ad1 3042 countss=0;
yabahiro 33:dd598bb23ad1 3043 }
yabahiro 33:dd598bb23ad1 3044 } else if(mode==33) {
yabahiro 33:dd598bb23ad1 3045 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 3046 motor[TIRE_FR].dir = FREE;
kishibekairohan 42:980af34f6fe3 3047 motor[TIRE_FL].pwm = 40;
yabahiro 38:40e7fdf3c694 3048 motor[TIRE_FL].dir = BACK;
kishibekairohan 42:980af34f6fe3 3049 motor[TIRE_BR].pwm = 40;
yabahiro 38:40e7fdf3c694 3050 motor[TIRE_BR].dir = FOR;
kishibekairohan 41:99a1158f3eca 3051 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 3052 motor[TIRE_BL].dir = FREE;
kishibekairohan 42:980af34f6fe3 3053 if(g[3]==0&&g[2]==0) {
yabahiro 38:40e7fdf3c694 3054 cross=0;
yabahiro 33:dd598bb23ad1 3055 countss=0;
yabahiro 33:dd598bb23ad1 3056 mode=40;
yabahiro 33:dd598bb23ad1 3057 }
yabahiro 33:dd598bb23ad1 3058 } else if(mode==40) {
yabahiro 33:dd598bb23ad1 3059 switch(g[3]) {
yabahiro 33:dd598bb23ad1 3060 case 98:
yabahiro 33:dd598bb23ad1 3061 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 3062 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 3063 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 3064 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3065 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 3066 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3067 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 3068 motor[TIRE_BL].dir = FOR;
kishibekairohan 42:980af34f6fe3 3069 if(countss>10000) {
yabahiro 33:dd598bb23ad1 3070 cross++;
yabahiro 33:dd598bb23ad1 3071 countss=0;
yabahiro 33:dd598bb23ad1 3072 }
yabahiro 33:dd598bb23ad1 3073 mtc2=true;
yabahiro 33:dd598bb23ad1 3074 break;
yabahiro 33:dd598bb23ad1 3075 case 0:
yabahiro 33:dd598bb23ad1 3076 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 3077 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 3078 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 3079 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3080 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 3081 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3082 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 3083 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 3084 mtc2=true;
yabahiro 33:dd598bb23ad1 3085 break;
yabahiro 33:dd598bb23ad1 3086 case 255:
yabahiro 33:dd598bb23ad1 3087 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 3088 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 3089 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 3090 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3091 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 3092 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3093 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 3094 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 3095 mtc2=true;
yabahiro 33:dd598bb23ad1 3096 break;
yabahiro 33:dd598bb23ad1 3097 case 253:
yabahiro 33:dd598bb23ad1 3098 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3099 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 3100 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 3101 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3102 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 3103 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3104 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3105 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 3106 mtc2=true;
yabahiro 33:dd598bb23ad1 3107 break;
yabahiro 33:dd598bb23ad1 3108 case 254:
yabahiro 33:dd598bb23ad1 3109 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3110 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 3111 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 3112 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3113 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 3114 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3115 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3116 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 3117 mtc2=true;
yabahiro 33:dd598bb23ad1 3118 break;
yabahiro 33:dd598bb23ad1 3119 case 1:
yabahiro 33:dd598bb23ad1 3120 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 3121 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 3122 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 3123 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3124 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 3125 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3126 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 3127 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 3128 mtc2=true;
yabahiro 33:dd598bb23ad1 3129 break;
yabahiro 33:dd598bb23ad1 3130 case 3:
yabahiro 33:dd598bb23ad1 3131 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 3132 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 3133 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3134 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3135 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3136 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 3137 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 3138 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 3139 mtc2=true;
yabahiro 33:dd598bb23ad1 3140 break;
yabahiro 33:dd598bb23ad1 3141 case 2:
yabahiro 33:dd598bb23ad1 3142 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 3143 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 3144 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3145 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3146 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3147 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 3148 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 3149 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 3150 mtc2=true;
yabahiro 33:dd598bb23ad1 3151 break;
yabahiro 33:dd598bb23ad1 3152 }
yabahiro 33:dd598bb23ad1 3153 if(g[2]!=98&&mtc2==true) {
yabahiro 33:dd598bb23ad1 3154 switch(g[2]) {
yabahiro 33:dd598bb23ad1 3155 case 0:
yabahiro 33:dd598bb23ad1 3156 mtc2=false;
yabahiro 33:dd598bb23ad1 3157 break;
yabahiro 33:dd598bb23ad1 3158 case 255:
yabahiro 33:dd598bb23ad1 3159 motor[TIRE_FL].pwm += 5;
yabahiro 33:dd598bb23ad1 3160 mtc2=false;
yabahiro 33:dd598bb23ad1 3161 break;
yabahiro 33:dd598bb23ad1 3162 case 253:
yabahiro 33:dd598bb23ad1 3163 motor[TIRE_FL].pwm += 10;
yabahiro 33:dd598bb23ad1 3164 mtc2=false;
yabahiro 33:dd598bb23ad1 3165 break;
yabahiro 33:dd598bb23ad1 3166 case 254:
yabahiro 33:dd598bb23ad1 3167 motor[TIRE_FL].pwm += 20;
yabahiro 33:dd598bb23ad1 3168 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3169 mtc2=false;
yabahiro 33:dd598bb23ad1 3170 break;
yabahiro 33:dd598bb23ad1 3171 case 1:
yabahiro 33:dd598bb23ad1 3172 motor[TIRE_BL].pwm += 5;
yabahiro 33:dd598bb23ad1 3173 mtc2=false;
yabahiro 33:dd598bb23ad1 3174 break;
yabahiro 33:dd598bb23ad1 3175 case 3:
yabahiro 33:dd598bb23ad1 3176 motor[TIRE_BL].pwm += 10;
yabahiro 33:dd598bb23ad1 3177 mtc2=false;
yabahiro 33:dd598bb23ad1 3178 break;
yabahiro 33:dd598bb23ad1 3179 case 2:
yabahiro 33:dd598bb23ad1 3180 motor[TIRE_BL].pwm += 20;
yabahiro 33:dd598bb23ad1 3181 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3182 mtc2=false;
yabahiro 33:dd598bb23ad1 3183 break;
yabahiro 33:dd598bb23ad1 3184 }
yabahiro 33:dd598bb23ad1 3185 }
kishibekairohan 42:980af34f6fe3 3186
kishibekairohan 42:980af34f6fe3 3187 if(LIF||LIB) {
kishibekairohan 42:980af34f6fe3 3188 mode=41;
kishibekairohan 42:980af34f6fe3 3189 countss=0;
kishibekairohan 42:980af34f6fe3 3190 cross=0;
kishibekairohan 42:980af34f6fe3 3191 }
kishibekairohan 42:980af34f6fe3 3192 if(YELLOW) {
kishibekairohan 42:980af34f6fe3 3193 if(cross==1) {
kishibekairohan 42:980af34f6fe3 3194 mode=41;
kishibekairohan 42:980af34f6fe3 3195 countss=0;
kishibekairohan 42:980af34f6fe3 3196 cross=0;
kishibekairohan 42:980af34f6fe3 3197 }
kishibekairohan 42:980af34f6fe3 3198 } else {
kishibekairohan 42:980af34f6fe3 3199 if(cross==3) {
kishibekairohan 42:980af34f6fe3 3200 mode=41;
kishibekairohan 42:980af34f6fe3 3201 countss=0;
kishibekairohan 42:980af34f6fe3 3202 cross=0;
kishibekairohan 42:980af34f6fe3 3203 }
kishibekairohan 42:980af34f6fe3 3204 }
kishibekairohan 42:980af34f6fe3 3205
yabahiro 33:dd598bb23ad1 3206 } else if(mode==41) {
yabahiro 33:dd598bb23ad1 3207 if(LIF||LIB) {
yabahiro 33:dd598bb23ad1 3208 mode=42;
yabahiro 33:dd598bb23ad1 3209 }
yabahiro 33:dd598bb23ad1 3210 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3211 motor[TIRE_FR].dir = FREE;
kishibekairohan 42:980af34f6fe3 3212 motor[TIRE_FL].pwm = 40;
yabahiro 33:dd598bb23ad1 3213 motor[TIRE_FL].dir = BACK;
kishibekairohan 42:980af34f6fe3 3214 motor[TIRE_BR].pwm = 40;
yabahiro 33:dd598bb23ad1 3215 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3216 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3217 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 3218 if(g[1]==0) {
yabahiro 33:dd598bb23ad1 3219 countss=0;
yabahiro 33:dd598bb23ad1 3220 mode=70;
kishibekairohan 42:980af34f6fe3 3221 normal=80;
kishibekairohan 42:980af34f6fe3 3222 fast=100;
kishibekairohan 42:980af34f6fe3 3223 slow=60;
yabahiro 33:dd598bb23ad1 3224 }
yabahiro 33:dd598bb23ad1 3225 } else if(mode==42) {
kishibekairohan 42:980af34f6fe3 3226 motor[TIRE_FR].pwm = 40;
yabahiro 33:dd598bb23ad1 3227 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3228 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3229 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3230 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3231 motor[TIRE_BR].dir = FREE;
kishibekairohan 42:980af34f6fe3 3232 motor[TIRE_BL].pwm = 40;
yabahiro 33:dd598bb23ad1 3233 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3234 if(g[1]==0) {
yabahiro 33:dd598bb23ad1 3235 countss=0;
yabahiro 33:dd598bb23ad1 3236 mode=70;
yabahiro 33:dd598bb23ad1 3237 }
yabahiro 33:dd598bb23ad1 3238 } else if(mode==70) {
yabahiro 33:dd598bb23ad1 3239 switch(g[1]) {
yabahiro 33:dd598bb23ad1 3240 case 99:
yabahiro 33:dd598bb23ad1 3241 if(countss>=100000) {
yabahiro 33:dd598bb23ad1 3242 mode=100;
yabahiro 33:dd598bb23ad1 3243 }
yabahiro 33:dd598bb23ad1 3244 break;
yabahiro 33:dd598bb23ad1 3245 case 98:
yabahiro 33:dd598bb23ad1 3246 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 3247 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3248 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 3249 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3250 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 3251 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3252 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 3253 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3254 break;
yabahiro 33:dd598bb23ad1 3255 case 0:
kishibekairohan 42:980af34f6fe3 3256 motor[TIRE_FR].pwm = 100;
yabahiro 33:dd598bb23ad1 3257 motor[TIRE_FR].dir = FOR;
kishibekairohan 42:980af34f6fe3 3258 motor[TIRE_FL].pwm = 100;
yabahiro 33:dd598bb23ad1 3259 motor[TIRE_FL].dir = BACK;
kishibekairohan 42:980af34f6fe3 3260 motor[TIRE_BR].pwm = 100;
yabahiro 33:dd598bb23ad1 3261 motor[TIRE_BR].dir = FOR;
kishibekairohan 42:980af34f6fe3 3262 motor[TIRE_BL].pwm = 100;
yabahiro 33:dd598bb23ad1 3263 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3264 mtc=true;
yabahiro 33:dd598bb23ad1 3265 break;
yabahiro 33:dd598bb23ad1 3266 case 255:
yabahiro 33:dd598bb23ad1 3267 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 3268 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3269 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 3270 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3271 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 3272 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3273 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 3274 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3275 mtc=true;
yabahiro 33:dd598bb23ad1 3276 break;
yabahiro 33:dd598bb23ad1 3277 case 253:
yabahiro 33:dd598bb23ad1 3278 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 3279 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3280 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3281 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3282 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3283 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 3284 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 3285 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3286 mtc=true;
yabahiro 33:dd598bb23ad1 3287 break;
yabahiro 33:dd598bb23ad1 3288 case 254:
yabahiro 33:dd598bb23ad1 3289 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 3290 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3291 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3292 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3293 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3294 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 3295 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 3296 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3297 mtc=true;
yabahiro 33:dd598bb23ad1 3298 break;
yabahiro 33:dd598bb23ad1 3299 case 1:
yabahiro 33:dd598bb23ad1 3300 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 3301 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3302 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 3303 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3304 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 3305 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3306 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 3307 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3308 mtc=true;
yabahiro 33:dd598bb23ad1 3309 break;
yabahiro 33:dd598bb23ad1 3310 case 3:
yabahiro 33:dd598bb23ad1 3311 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3312 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 3313 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 3314 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3315 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 3316 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3317 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3318 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 3319 mtc=true;
yabahiro 33:dd598bb23ad1 3320 break;
yabahiro 33:dd598bb23ad1 3321 case 2:
yabahiro 33:dd598bb23ad1 3322 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3323 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 3324 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 3325 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 3326 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 3327 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3328 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3329 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 3330 mtc=true;
yabahiro 33:dd598bb23ad1 3331 break;
yabahiro 33:dd598bb23ad1 3332 }
yabahiro 33:dd598bb23ad1 3333 if(g[1]!=98&&mtc==true) {
yabahiro 33:dd598bb23ad1 3334 switch(g[0]) {
yabahiro 33:dd598bb23ad1 3335 case 0:
yabahiro 33:dd598bb23ad1 3336 mtc=false;
yabahiro 33:dd598bb23ad1 3337 break;
yabahiro 33:dd598bb23ad1 3338 case 255:
yabahiro 33:dd598bb23ad1 3339 motor[TIRE_FL].pwm += 5;
yabahiro 33:dd598bb23ad1 3340 mtc=false;
yabahiro 33:dd598bb23ad1 3341 break;
yabahiro 33:dd598bb23ad1 3342 case 253:
yabahiro 33:dd598bb23ad1 3343 motor[TIRE_FL].pwm += 10;
yabahiro 33:dd598bb23ad1 3344 mtc=false;
yabahiro 33:dd598bb23ad1 3345 break;
yabahiro 33:dd598bb23ad1 3346 case 254:
yabahiro 33:dd598bb23ad1 3347 motor[TIRE_FL].pwm += 20;
yabahiro 33:dd598bb23ad1 3348 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3349 mtc=false;
yabahiro 33:dd598bb23ad1 3350 break;
yabahiro 33:dd598bb23ad1 3351 case 1:
yabahiro 33:dd598bb23ad1 3352 motor[TIRE_FR].pwm += 5;
yabahiro 33:dd598bb23ad1 3353 mtc=false;
yabahiro 33:dd598bb23ad1 3354 break;
yabahiro 33:dd598bb23ad1 3355 case 3:
yabahiro 33:dd598bb23ad1 3356 motor[TIRE_FR].pwm += 10;
yabahiro 33:dd598bb23ad1 3357 mtc=false;
yabahiro 33:dd598bb23ad1 3358 break;
yabahiro 33:dd598bb23ad1 3359 case 2:
yabahiro 33:dd598bb23ad1 3360 motor[TIRE_FR].pwm += 20;
yabahiro 33:dd598bb23ad1 3361 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3362 mtc=false;
yabahiro 33:dd598bb23ad1 3363 break;
yabahiro 33:dd598bb23ad1 3364 }
yabahiro 33:dd598bb23ad1 3365 }
yabahiro 33:dd598bb23ad1 3366 } else if(mode==100) {
kishibekairohan 42:980af34f6fe3 3367 motor[TIRE_FR].pwm = 50;
yabahiro 33:dd598bb23ad1 3368 motor[TIRE_FR].dir = FOR;
kishibekairohan 42:980af34f6fe3 3369 motor[TIRE_FL].pwm = 50;
yabahiro 33:dd598bb23ad1 3370 motor[TIRE_FL].dir = BACK;
kishibekairohan 42:980af34f6fe3 3371 motor[TIRE_BR].pwm = 50;
yabahiro 33:dd598bb23ad1 3372 motor[TIRE_BR].dir = FOR;
kishibekairohan 42:980af34f6fe3 3373 motor[TIRE_BL].pwm = 50;
yabahiro 33:dd598bb23ad1 3374 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3375 } else {
yabahiro 33:dd598bb23ad1 3376 }
yabahiro 33:dd598bb23ad1 3377
kishibekairohan 13:b6e02d6261d7 3378 }
kishibekairohan 13:b6e02d6261d7 3379 #endif
kishibekairohan 13:b6e02d6261d7 3380
kishibekairohan 13:b6e02d6261d7 3381 #if USE_PROCESS_NUM>4
Ryosei 27:dd9f27fce7d1 3382 static void Process4()
M_souta 22:7d93f79a3686 3383 {
yabahiro 33:dd598bb23ad1 3384
kishibekairohan 13:b6e02d6261d7 3385 }
kishibekairohan 13:b6e02d6261d7 3386 #endif
kishibekairohan 13:b6e02d6261d7 3387
kishibekairohan 13:b6e02d6261d7 3388 #if USE_PROCESS_NUM>5
Ryosei 27:dd9f27fce7d1 3389 static void Process5()
Ryosei 27:dd9f27fce7d1 3390 {
kishibekairohan 42:980af34f6fe3 3391
kishibekairohan 13:b6e02d6261d7 3392 }
kishibekairohan 13:b6e02d6261d7 3393 #endif
kishibekairohan 13:b6e02d6261d7 3394
kishibekairohan 13:b6e02d6261d7 3395 #if USE_PROCESS_NUM>6
Ryosei 27:dd9f27fce7d1 3396 static void Process6()
kishibekairohan 13:b6e02d6261d7 3397 {
Ryosei 27:dd9f27fce7d1 3398
kishibekairohan 13:b6e02d6261d7 3399 }
kishibekairohan 13:b6e02d6261d7 3400 #endif
kishibekairohan 13:b6e02d6261d7 3401
kishibekairohan 13:b6e02d6261d7 3402 #if USE_PROCESS_NUM>7
kishibekairohan 13:b6e02d6261d7 3403 static void Process7()
kishibekairohan 13:b6e02d6261d7 3404 {
yabahiro 33:dd598bb23ad1 3405
kishibekairohan 12:c09b3e08a316 3406 }
kishibekairohan 12:c09b3e08a316 3407 #endif
kishibekairohan 12:c09b3e08a316 3408
Ryosei 27:dd9f27fce7d1 3409 #if USE_PROCESS_NUM>8
kishibekairohan 13:b6e02d6261d7 3410 static void Process8()
kishibekairohan 12:c09b3e08a316 3411 {
yabahiro 33:dd598bb23ad1 3412
kishibekairohan 12:c09b3e08a316 3413 }
kishibekairohan 12:c09b3e08a316 3414 #endif
kishibekairohan 12:c09b3e08a316 3415
kishibekairohan 13:b6e02d6261d7 3416 #if USE_PROCESS_NUM>9
kishibekairohan 13:b6e02d6261d7 3417 static void Process9()
kishibekairohan 12:c09b3e08a316 3418 {
Ryosei 27:dd9f27fce7d1 3419
t_yamamoto 0:669ef71cba68 3420 }
t_yamamoto 0:669ef71cba68 3421 #endif
t_yamamoto 0:669ef71cba68 3422 #endif
t_yamamoto 0:669ef71cba68 3423 #pragma endregion PROCESS
t_yamamoto 0:669ef71cba68 3424
t_yamamoto 0:669ef71cba68 3425 static void AllActuatorReset()
t_yamamoto 0:669ef71cba68 3426 {
yabahiro 33:dd598bb23ad1 3427 #ifdef USE_SOLENOID
yabahiro 33:dd598bb23ad1 3428 solenoid.all = ALL_SOLENOID_OFF;
yabahiro 33:dd598bb23ad1 3429 #endif
yabahiro 33:dd598bb23ad1 3430
yabahiro 33:dd598bb23ad1 3431 #ifdef USE_MOTOR
yabahiro 33:dd598bb23ad1 3432 for (uint8_t i = 0; i < MOUNTING_MOTOR_NUM; i++) {
yabahiro 33:dd598bb23ad1 3433 motor[i].dir = FREE;
yabahiro 33:dd598bb23ad1 3434 motor[i].pwm = 0;
yabahiro 33:dd598bb23ad1 3435 }
yabahiro 33:dd598bb23ad1 3436 #endif
t_yamamoto 0:669ef71cba68 3437 }
t_yamamoto 0:669ef71cba68 3438
kishibekairohan 16:3f2c2d89372b 3439 #pragma region USER-DEFINED-FUNCTIONS
M_souta 29:44d5454ce8fa 3440
M_souta 29:44d5454ce8fa 3441 uint8_t SetStatus(int pwmVal)
Ryosei 27:dd9f27fce7d1 3442 {
M_souta 29:44d5454ce8fa 3443 if (pwmVal < 0) return BACK;
M_souta 29:44d5454ce8fa 3444 else if (pwmVal > 0) return FOR;
M_souta 29:44d5454ce8fa 3445 else if (pwmVal == 0) return BRAKE;
M_souta 29:44d5454ce8fa 3446 else return BRAKE;
M_souta 22:7d93f79a3686 3447 }
kishibekairohan 16:3f2c2d89372b 3448
M_souta 29:44d5454ce8fa 3449 uint8_t SetPWM(int pwmVal)
Ryosei 27:dd9f27fce7d1 3450 {
M_souta 29:44d5454ce8fa 3451 if (pwmVal == 0 || pwmVal > 255 || pwmVal < -255) return 255;
M_souta 29:44d5454ce8fa 3452 else return abs(pwmVal);
M_souta 22:7d93f79a3686 3453 }
kishibekairohan 16:3f2c2d89372b 3454
t_yamamoto 0:669ef71cba68 3455 #pragma endregion