aa

Dependencies:   mbed TrapezoidControl QEI

Committer:
yabahiro
Date:
Wed Sep 18 11:36:53 2019 +0000
Revision:
28:9cd36721cf83
Parent:
27:545148741493
Child:
29:c78a46f51209
aaa

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kishibekairohan 13:b6e02d6261d7 1
t_yamamoto 0:669ef71cba68 2 #include "mbed.h"
t_yamamoto 0:669ef71cba68 3 #include "Process.h"
7ka884 4:ba9df71868df 4 #include "QEI.h"
t_yamamoto 0:669ef71cba68 5
7ka884 4:ba9df71868df 6 #include "../../CommonLibraries/PID/PID.h"
t_yamamoto 0:669ef71cba68 7 #include "../../Communication/RS485/ActuatorHub/ActuatorHub.h"
yabahiro 21:1f1e9c585da8 8 #include "../../Communication/RS485/LineHub/LineHub.h"
t_yamamoto 0:669ef71cba68 9 #include "../../Communication/Controller/Controller.h"
t_yamamoto 0:669ef71cba68 10 #include "../../Input/ExternalInt/ExternalInt.h"
t_yamamoto 0:669ef71cba68 11 #include "../../Input/Switch/Switch.h"
t_yamamoto 0:669ef71cba68 12 #include "../../Input/Potentiometer/Potentiometer.h"
kishibekairohan 16:3f2c2d89372b 13 #include "../../Input/Encoder/Encoder.h"
t_yamamoto 0:669ef71cba68 14 #include "../../LED/LED.h"
t_yamamoto 0:669ef71cba68 15 #include "../../Safty/Safty.h"
t_yamamoto 0:669ef71cba68 16 #include "../Using.h"
t_yamamoto 0:669ef71cba68 17
t_yamamoto 0:669ef71cba68 18 using namespace SWITCH;
7ka884 4:ba9df71868df 19 using namespace PID_SPACE;
kishibekairohan 16:3f2c2d89372b 20 using namespace ENCODER;
yabahiro 21:1f1e9c585da8 21 using namespace LINEHUB;
t_yamamoto 0:669ef71cba68 22
t_yamamoto 0:669ef71cba68 23 static CONTROLLER::ControllerData *controller;
t_yamamoto 0:669ef71cba68 24 ACTUATORHUB::MOTOR::MotorStatus motor[MOUNTING_MOTOR_NUM];
t_yamamoto 0:669ef71cba68 25 ACTUATORHUB::SOLENOID::SolenoidStatus solenoid;
t_yamamoto 0:669ef71cba68 26
t_yamamoto 0:669ef71cba68 27 static bool lock;
t_yamamoto 0:669ef71cba68 28 static bool processChangeComp;
t_yamamoto 0:669ef71cba68 29 static int current;
t_yamamoto 0:669ef71cba68 30
t_yamamoto 0:669ef71cba68 31 static void AllActuatorReset();
t_yamamoto 0:669ef71cba68 32
t_yamamoto 0:669ef71cba68 33 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 34 static void (*Process[USE_PROCESS_NUM])(void);
t_yamamoto 0:669ef71cba68 35 #endif
t_yamamoto 0:669ef71cba68 36
t_yamamoto 0:669ef71cba68 37 #pragma region USER-DEFINED_VARIABLES_AND_PROTOTYPE
t_yamamoto 0:669ef71cba68 38
t_yamamoto 0:669ef71cba68 39 /*Replace here with the definition code of your variables.*/
t_yamamoto 0:669ef71cba68 40
kishibekairohan 2:c015739085d3 41 Serial pc(USBTX, USBRX);
kishibekairohan 2:c015739085d3 42
kishibekairohan 16:3f2c2d89372b 43 //**************Encoder***************
kishibekairohan 16:3f2c2d89372b 44 const int PerRev = 256;
kishibekairohan 16:3f2c2d89372b 45 QEI ECD_0(ECD_A_0,ECD_B_0,NC,PerRev,QEI::X4_ENCODING);
kishibekairohan 16:3f2c2d89372b 46 QEI ECD_1(ECD_A_1,ECD_B_1,NC,PerRev,QEI::X4_ENCODING);
kishibekairohan 16:3f2c2d89372b 47 QEI ECD_2(ECD_A_2,ECD_B_2,NC,PerRev,QEI::X4_ENCODING);
kishibekairohan 16:3f2c2d89372b 48 QEI ECD_3(ECD_A_3,ECD_B_3,NC,PerRev,QEI::X4_ENCODING);
kishibekairohan 16:3f2c2d89372b 49 //**************Encoder***************
kishibekairohan 7:e88c5d47a3be 50
kishibekairohan 16:3f2c2d89372b 51 //**************Buzzer****************
kishibekairohan 11:028a150943b5 52 //DigitalOut buzzer(BUZZER_PIN);
kishibekairohan 9:f93fc79a49ea 53 void BuzzerTimer_func();
kishibekairohan 9:f93fc79a49ea 54 Ticker BuzzerTimer;
kishibekairohan 16:3f2c2d89372b 55 bool EMGflag = false;
yabahiro 21:1f1e9c585da8 56 //PWMOut buzzer(BUZZER_PIN);
kishibekairohan 16:3f2c2d89372b 57 //**************Buzzer****************
kishibekairohan 11:028a150943b5 58
kishibekairohan 11:028a150943b5 59 //************TapeLed*****************
kishibekairohan 11:028a150943b5 60 void TapeLedEms_func();
kishibekairohan 11:028a150943b5 61 TapeLedData tapeLED;
kishibekairohan 11:028a150943b5 62 TapeLedData sendLedData;
kishibekairohan 11:028a150943b5 63 TapeLED_Mode ledMode = Normal;
kishibekairohan 11:028a150943b5 64 Ticker tapeLedTimer;
kishibekairohan 11:028a150943b5 65 //************TapaLed*****************
kishibekairohan 16:3f2c2d89372b 66
M_souta 18:c694bae76e51 67 float tireProRPM[4];
M_souta 18:c694bae76e51 68 float tireTarRPM[4];
yabahiro 21:1f1e9c585da8 69 float tirepwm[4];
yabahiro 21:1f1e9c585da8 70
yabahiro 21:1f1e9c585da8 71 const int omni[15][15] = {
yabahiro 21:1f1e9c585da8 72 { 0, 5, 21, 47, 83, 130, 187, 255, 255, 255, 255, 255, 255, 255, 255 },
yabahiro 21:1f1e9c585da8 73 { -5, 0, 5, 21, 47, 83, 130, 187, 193, 208, 234, 255, 255, 255, 255 },
yabahiro 21:1f1e9c585da8 74 { -21, -5, 0, 5, 21, 47, 83, 130, 135, 151, 177, 213, 255, 255, 255 },
yabahiro 21:1f1e9c585da8 75 { -47, -21, 5, 0, 5, 21, 47, 83, 88, 104, 130, 167, 213, 255, 255 },
yabahiro 21:1f1e9c585da8 76 { -83, -47, -21, 5, 0, 5, 21, 47, 52, 68, 94, 130, 177, 234, 255 },
yabahiro 21:1f1e9c585da8 77 { -130, -83, -47, -21, 5, 0, 5, 21, 26, 42, 68, 104, 151, 208, 255 },
yabahiro 21:1f1e9c585da8 78 { -187, -130, -83, -47, -21, -5, 0, 5, 10, 26, 52, 88, 135, 193, 255 },
yabahiro 21:1f1e9c585da8 79 { -255, -187, -130, -83, -47, -21, -5, 0, 5, 21, 47, 83, 130, 187, 255 },
yabahiro 21:1f1e9c585da8 80 { -255, -193, -135, -88, -52, -26, -10, -5, 0, 5, 21, 47, 83, 130, 187 },
yabahiro 21:1f1e9c585da8 81 { -255, -208, -151, -104, -68, -42, -26, -21, -5, 0, 5, 21, 47, 83, 130 },
yabahiro 21:1f1e9c585da8 82 { -255, -234, -177, -130, -94, -68, -52, -47, -21, -7, 0, 7, 21, 47, 83 },
yabahiro 21:1f1e9c585da8 83 { -255, -255, -213, -167, -130, -104, -88, -83, -47, -21, -5, 0, 5, 21, 47 },
yabahiro 21:1f1e9c585da8 84 { -255, -255, -255, -213, -177, -151, -135, -130, -83, -47, -21, -5, 0, 5, 21 },
yabahiro 21:1f1e9c585da8 85 { -255, -255, -255, -255, -234, -208, -193, -187, -130, -83, -47, -21, -5, 0, 5 },
yabahiro 21:1f1e9c585da8 86 { -255, -255, -255, -255, -255, -255, -255, -255, -187, -130, -83, -47, -21, -5, 0 }
yabahiro 21:1f1e9c585da8 87 };
yabahiro 21:1f1e9c585da8 88
yabahiro 21:1f1e9c585da8 89 const int curve[15] = { -152, -98, -54, -18, 0, 0, 0, 0, 0, 0, 0, 18, 54, 98, 152 };
yabahiro 21:1f1e9c585da8 90 //{-200,-146,-102,-66,-36,-16,0,0,0,16,36,66,102,146,200}
yabahiro 21:1f1e9c585da8 91
yabahiro 21:1f1e9c585da8 92 uint8_t SetStatus(int);
yabahiro 21:1f1e9c585da8 93 uint8_t SetStatus(int pwmVal)
yabahiro 21:1f1e9c585da8 94 {
yabahiro 21:1f1e9c585da8 95 if (pwmVal < 0) return BACK;
yabahiro 21:1f1e9c585da8 96 else if (pwmVal > 0) return FOR;
yabahiro 21:1f1e9c585da8 97 else if (pwmVal == 0) return BRAKE;
yabahiro 21:1f1e9c585da8 98 else return BRAKE;
yabahiro 21:1f1e9c585da8 99 }
yabahiro 21:1f1e9c585da8 100 uint8_t Setpwm(int);
yabahiro 21:1f1e9c585da8 101 uint8_t Setpwm(int pwmVal)
yabahiro 21:1f1e9c585da8 102 {
yabahiro 21:1f1e9c585da8 103 if (pwmVal == 0 || pwmVal > 255 || pwmVal < -255) return 255;
yabahiro 21:1f1e9c585da8 104 else return abs(pwmVal);
yabahiro 21:1f1e9c585da8 105 }
M_souta 18:c694bae76e51 106
t_yamamoto 0:669ef71cba68 107 #pragma endregion USER-DEFINED_VARIABLES_AND_PROTOTYPE
t_yamamoto 0:669ef71cba68 108
t_yamamoto 0:669ef71cba68 109 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 110 #if USE_PROCESS_NUM>0
t_yamamoto 0:669ef71cba68 111 static void Process0(void);
t_yamamoto 0:669ef71cba68 112 #endif
t_yamamoto 0:669ef71cba68 113 #if USE_PROCESS_NUM>1
t_yamamoto 0:669ef71cba68 114 static void Process1(void);
t_yamamoto 0:669ef71cba68 115 #endif
t_yamamoto 0:669ef71cba68 116 #if USE_PROCESS_NUM>2
t_yamamoto 0:669ef71cba68 117 static void Process2(void);
t_yamamoto 0:669ef71cba68 118 #endif
t_yamamoto 0:669ef71cba68 119 #if USE_PROCESS_NUM>3
t_yamamoto 0:669ef71cba68 120 static void Process3(void);
t_yamamoto 0:669ef71cba68 121 #endif
t_yamamoto 0:669ef71cba68 122 #if USE_PROCESS_NUM>4
t_yamamoto 0:669ef71cba68 123 static void Process4(void);
t_yamamoto 0:669ef71cba68 124 #endif
t_yamamoto 0:669ef71cba68 125 #if USE_PROCESS_NUM>5
t_yamamoto 0:669ef71cba68 126 static void Process5(void);
t_yamamoto 0:669ef71cba68 127 #endif
t_yamamoto 0:669ef71cba68 128 #if USE_PROCESS_NUM>6
t_yamamoto 0:669ef71cba68 129 static void Process6(void);
t_yamamoto 0:669ef71cba68 130 #endif
t_yamamoto 0:669ef71cba68 131 #if USE_PROCESS_NUM>7
t_yamamoto 0:669ef71cba68 132 static void Process7(void);
t_yamamoto 0:669ef71cba68 133 #endif
t_yamamoto 0:669ef71cba68 134 #if USE_PROCESS_NUM>8
t_yamamoto 0:669ef71cba68 135 static void Process8(void);
t_yamamoto 0:669ef71cba68 136 #endif
t_yamamoto 0:669ef71cba68 137 #if USE_PROCESS_NUM>9
t_yamamoto 0:669ef71cba68 138 static void Process9(void);
t_yamamoto 0:669ef71cba68 139 #endif
t_yamamoto 0:669ef71cba68 140 #endif
t_yamamoto 0:669ef71cba68 141
t_yamamoto 0:669ef71cba68 142 void SystemProcessInitialize()
t_yamamoto 0:669ef71cba68 143 {
yabahiro 21:1f1e9c585da8 144 #pragma region USER-DEFINED_VARIABLE_INIT
yabahiro 21:1f1e9c585da8 145 /*Replace here with the initialization code of your variables.*/
yabahiro 21:1f1e9c585da8 146 #pragma endregion USER-DEFINED_VARIABLE_INIT
t_yamamoto 0:669ef71cba68 147
yabahiro 21:1f1e9c585da8 148 lock = true;
yabahiro 21:1f1e9c585da8 149 processChangeComp = true;
yabahiro 21:1f1e9c585da8 150 current = DEFAULT_PROCESS;
t_yamamoto 0:669ef71cba68 151
yabahiro 21:1f1e9c585da8 152 #ifdef USE_SUBPROCESS
yabahiro 21:1f1e9c585da8 153 #if USE_PROCESS_NUM>0
yabahiro 21:1f1e9c585da8 154 Process[0] = Process0;
yabahiro 21:1f1e9c585da8 155 #endif
yabahiro 21:1f1e9c585da8 156 #if USE_PROCESS_NUM>1
yabahiro 21:1f1e9c585da8 157 Process[1] = Process1;
yabahiro 21:1f1e9c585da8 158 #endif
yabahiro 21:1f1e9c585da8 159 #if USE_PROCESS_NUM>2
yabahiro 21:1f1e9c585da8 160 Process[2] = Process2;
yabahiro 21:1f1e9c585da8 161 #endif
yabahiro 21:1f1e9c585da8 162 #if USE_PROCESS_NUM>3
yabahiro 21:1f1e9c585da8 163 Process[3] = Process3;
yabahiro 21:1f1e9c585da8 164 #endif
yabahiro 21:1f1e9c585da8 165 #if USE_PROCESS_NUM>4
yabahiro 21:1f1e9c585da8 166 Process[4] = Process4;
yabahiro 21:1f1e9c585da8 167 #endif
yabahiro 21:1f1e9c585da8 168 #if USE_PROCESS_NUM>5
yabahiro 21:1f1e9c585da8 169 Process[5] = Process5;
yabahiro 21:1f1e9c585da8 170 #endif
yabahiro 21:1f1e9c585da8 171 #if USE_PROCESS_NUM>6
yabahiro 21:1f1e9c585da8 172 Process[6] = Process6;
yabahiro 21:1f1e9c585da8 173 #endif
yabahiro 21:1f1e9c585da8 174 #if USE_PROCESS_NUM>7
yabahiro 21:1f1e9c585da8 175 Process[7] = Process7;
yabahiro 21:1f1e9c585da8 176 #endif
yabahiro 21:1f1e9c585da8 177 #if USE_PROCESS_NUM>8
yabahiro 21:1f1e9c585da8 178 Process[8] = Process8;
yabahiro 21:1f1e9c585da8 179 #endif
yabahiro 21:1f1e9c585da8 180 #if USE_PROCESS_NUM>9
yabahiro 21:1f1e9c585da8 181 Process[9] = Process9;
yabahiro 21:1f1e9c585da8 182 #endif
yabahiro 21:1f1e9c585da8 183 #endif
t_yamamoto 0:669ef71cba68 184 }
t_yamamoto 0:669ef71cba68 185
t_yamamoto 0:669ef71cba68 186 static void SystemProcessUpdate()
t_yamamoto 0:669ef71cba68 187 {
yabahiro 21:1f1e9c585da8 188 #ifdef USE_SUBPROCESS
yabahiro 21:1f1e9c585da8 189 if(controller->Button.HOME) lock = false;
yabahiro 21:1f1e9c585da8 190
yabahiro 21:1f1e9c585da8 191 if(controller->Button.START && processChangeComp) {
yabahiro 21:1f1e9c585da8 192 current++;
yabahiro 21:1f1e9c585da8 193 if (USE_PROCESS_NUM < current) current = USE_PROCESS_NUM;
yabahiro 21:1f1e9c585da8 194 processChangeComp = false;
yabahiro 21:1f1e9c585da8 195 } else if(controller->Button.SELECT && processChangeComp) {
yabahiro 21:1f1e9c585da8 196 current--;
yabahiro 21:1f1e9c585da8 197 if (current < 0) current = 0;
yabahiro 21:1f1e9c585da8 198 processChangeComp = false;
yabahiro 21:1f1e9c585da8 199 } else if(!controller->Button.SELECT && !controller->Button.START) processChangeComp = true;
yabahiro 21:1f1e9c585da8 200 #endif
yabahiro 21:1f1e9c585da8 201
yabahiro 21:1f1e9c585da8 202 #ifdef USE_MOTOR
yabahiro 21:1f1e9c585da8 203 ACTUATORHUB::MOTOR::Motor::Update(motor);
yabahiro 21:1f1e9c585da8 204 #endif
yabahiro 21:1f1e9c585da8 205
yabahiro 21:1f1e9c585da8 206 #ifdef USE_SOLENOID
yabahiro 21:1f1e9c585da8 207 ACTUATORHUB::SOLENOID::Solenoid::Update(solenoid);
yabahiro 21:1f1e9c585da8 208 #endif
yabahiro 21:1f1e9c585da8 209
yabahiro 21:1f1e9c585da8 210 #ifdef USE_RS485
yabahiro 21:1f1e9c585da8 211 ACTUATORHUB::ActuatorHub::Update();
yabahiro 21:1f1e9c585da8 212 #endif
yabahiro 21:1f1e9c585da8 213
yabahiro 21:1f1e9c585da8 214 }
yabahiro 21:1f1e9c585da8 215
yabahiro 21:1f1e9c585da8 216 int g[8];
yabahiro 21:1f1e9c585da8 217
yabahiro 21:1f1e9c585da8 218 void SystemProcess()
yabahiro 21:1f1e9c585da8 219 {
yabahiro 21:1f1e9c585da8 220 SystemProcessInitialize();
yabahiro 21:1f1e9c585da8 221
yabahiro 21:1f1e9c585da8 222 while(1) {
yabahiro 21:1f1e9c585da8 223 for(int i = 0; i < 8; i++) {
yabahiro 21:1f1e9c585da8 224 g[i] = LineHub::GetPara(i);
yabahiro 21:1f1e9c585da8 225 }
t_yamamoto 0:669ef71cba68 226
yabahiro 21:1f1e9c585da8 227 #ifdef USE_MU
yabahiro 21:1f1e9c585da8 228 controller = CONTROLLER::Controller::GetData();
yabahiro 21:1f1e9c585da8 229 #endif
yabahiro 21:1f1e9c585da8 230
yabahiro 21:1f1e9c585da8 231 #ifdef USE_ERRORCHECK
yabahiro 21:1f1e9c585da8 232 if(SAFTY::ErrorCheck::Check() & SAFTY::Error::ControllerLost) {
yabahiro 21:1f1e9c585da8 233 CONTROLLER::Controller::DataReset();
yabahiro 21:1f1e9c585da8 234 AllActuatorReset();
yabahiro 21:1f1e9c585da8 235 lock = true;
yabahiro 21:1f1e9c585da8 236 } else
yabahiro 21:1f1e9c585da8 237 #endif
yabahiro 21:1f1e9c585da8 238 {
yabahiro 21:1f1e9c585da8 239
yabahiro 21:1f1e9c585da8 240 #ifdef USE_SUBPROCESS
yabahiro 21:1f1e9c585da8 241 if(!lock) {
yabahiro 21:1f1e9c585da8 242 Process[current]();
yabahiro 21:1f1e9c585da8 243 } else
yabahiro 21:1f1e9c585da8 244 #endif
yabahiro 21:1f1e9c585da8 245 {
yabahiro 21:1f1e9c585da8 246 //ロック時の処理
yabahiro 21:1f1e9c585da8 247 }
yabahiro 21:1f1e9c585da8 248 }
yabahiro 21:1f1e9c585da8 249 /*
yabahiro 21:1f1e9c585da8 250 //Emergency!
yabahiro 21:1f1e9c585da8 251 if(!EMG_0 && !EMG_1 && !EMGflag) {
yabahiro 21:1f1e9c585da8 252 buzzer = 0;
yabahiro 21:1f1e9c585da8 253 BuzzerTimer.attach(BuzzerTimer_func, 1);
yabahiro 21:1f1e9c585da8 254 EMGflag = true;
yabahiro 21:1f1e9c585da8 255 LED_DEBUG0 = 1;
yabahiro 21:1f1e9c585da8 256 }
yabahiro 21:1f1e9c585da8 257 if(EMG_0 && EMG_1 && EMGflag) {
yabahiro 21:1f1e9c585da8 258 buzzer = 1;
yabahiro 21:1f1e9c585da8 259 BuzzerTimer.detach();
yabahiro 21:1f1e9c585da8 260 EMGflag = false;
yabahiro 21:1f1e9c585da8 261 }
yabahiro 21:1f1e9c585da8 262 */
yabahiro 21:1f1e9c585da8 263 SystemProcessUpdate();
yabahiro 21:1f1e9c585da8 264 }
t_yamamoto 0:669ef71cba68 265 }
t_yamamoto 0:669ef71cba68 266
kishibekairohan 2:c015739085d3 267
yabahiro 25:38d4964e8aad 268 int Twsh;
kishibekairohan 2:c015739085d3 269
t_yamamoto 0:669ef71cba68 270 #pragma region PROCESS
t_yamamoto 0:669ef71cba68 271 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 272 #if USE_PROCESS_NUM>0
yabahiro 27:545148741493 273
yabahiro 21:1f1e9c585da8 274 static void Process0()
yabahiro 21:1f1e9c585da8 275 {
yabahiro 25:38d4964e8aad 276 if(StertSW) {
yabahiro 28:9cd36721cf83 277 current = 2;
yabahiro 28:9cd36721cf83 278 Twsh=3;
yabahiro 25:38d4964e8aad 279 }
t_yamamoto 0:669ef71cba68 280 }
t_yamamoto 0:669ef71cba68 281 #endif
t_yamamoto 0:669ef71cba68 282
t_yamamoto 0:669ef71cba68 283 #if USE_PROCESS_NUM>1
yabahiro 21:1f1e9c585da8 284
yabahiro 21:1f1e9c585da8 285 bool dz1=true;
yabahiro 21:1f1e9c585da8 286 bool dz1i=false;
yabahiro 21:1f1e9c585da8 287 bool dz2=true;
yabahiro 21:1f1e9c585da8 288 bool dz2i=false;
yabahiro 21:1f1e9c585da8 289 bool dz3=true;
yabahiro 21:1f1e9c585da8 290 bool dz3i=false;
yabahiro 21:1f1e9c585da8 291 bool dz4=true;
yabahiro 21:1f1e9c585da8 292 bool dz4i=false;
yabahiro 21:1f1e9c585da8 293
yabahiro 27:545148741493 294 int mode =1;
yabahiro 27:545148741493 295 int cross=0;//十字数える用
yabahiro 27:545148741493 296 int count=100000;//wait代替え
yabahiro 21:1f1e9c585da8 297
kishibekairohan 22:c47f29caded6 298
kishibekairohan 16:3f2c2d89372b 299 static void Process1()
t_yamamoto 0:669ef71cba68 300 {
yabahiro 27:545148741493 301 count=100000;
yabahiro 28:9cd36721cf83 302 mode=0;
yabahiro 27:545148741493 303 cross=0;
yabahiro 21:1f1e9c585da8 304 motor[TIRE_FR].dir = SetStatus(-omni[controller->AnalogL.Y][14-controller->AnalogL.X] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 305 motor[TIRE_FL].dir = SetStatus(omni[controller->AnalogL.Y][controller->AnalogL.X] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 306 motor[TIRE_BR].dir = SetStatus(-omni[14-controller->AnalogL.X][14-controller->AnalogL.Y] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 307 motor[TIRE_BL].dir = SetStatus(omni[controller->AnalogL.X][14-controller->AnalogL.Y] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 308
yabahiro 21:1f1e9c585da8 309 motor[TIRE_FR].pwm = Setpwm(omni[controller->AnalogL.Y][14-controller->AnalogL.X]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 310 motor[TIRE_FL].pwm = Setpwm(omni[controller->AnalogL.Y][controller->AnalogL.X]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 311 motor[TIRE_BR].pwm = Setpwm(omni[14-controller->AnalogL.X][14-controller->AnalogL.Y]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 312 motor[TIRE_BL].pwm = Setpwm(omni[controller->AnalogL.X][14-controller->AnalogL.Y]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 313
yabahiro 21:1f1e9c585da8 314 if(controller->Button.UP||controller->Button.DOWN) {
yabahiro 21:1f1e9c585da8 315
yabahiro 21:1f1e9c585da8 316 if(controller->Button.UP) {
yabahiro 21:1f1e9c585da8 317 motor[MOTOR_0].pwm = 110;
yabahiro 21:1f1e9c585da8 318 motor[MOTOR_0].dir = FOR;
yabahiro 21:1f1e9c585da8 319 }
yabahiro 21:1f1e9c585da8 320 if(controller->Button.DOWN) {
yabahiro 21:1f1e9c585da8 321 motor[MOTOR_0].pwm = 50;
yabahiro 21:1f1e9c585da8 322 motor[MOTOR_0].dir = BACK;
yabahiro 21:1f1e9c585da8 323 }
yabahiro 21:1f1e9c585da8 324 } else {
yabahiro 21:1f1e9c585da8 325 motor[MOTOR_0].pwm = 0;
yabahiro 21:1f1e9c585da8 326 motor[MOTOR_0].dir = BRAKE;
yabahiro 21:1f1e9c585da8 327 }
yabahiro 21:1f1e9c585da8 328 if(controller->Button.X) {
yabahiro 21:1f1e9c585da8 329 if(dz1==true) {
yabahiro 21:1f1e9c585da8 330 if(dz1i==false) {
yabahiro 21:1f1e9c585da8 331 solenoid.solenoid1 = SOLENOID_ON;
yabahiro 21:1f1e9c585da8 332 dz1i=true;
yabahiro 21:1f1e9c585da8 333 } else {
yabahiro 21:1f1e9c585da8 334 solenoid.solenoid1 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 335 dz1i=false;
yabahiro 21:1f1e9c585da8 336 }
yabahiro 21:1f1e9c585da8 337 dz1=false;
yabahiro 21:1f1e9c585da8 338 }
yabahiro 21:1f1e9c585da8 339 } else {
yabahiro 21:1f1e9c585da8 340 dz1=true;
yabahiro 21:1f1e9c585da8 341 }
yabahiro 21:1f1e9c585da8 342
yabahiro 21:1f1e9c585da8 343 if(controller->Button.Y) {
yabahiro 21:1f1e9c585da8 344 if(dz2==true) {
yabahiro 21:1f1e9c585da8 345 if(dz2i==false) {
yabahiro 21:1f1e9c585da8 346 solenoid.solenoid2 = SOLENOID_ON;
yabahiro 21:1f1e9c585da8 347 dz2i=true;
yabahiro 21:1f1e9c585da8 348 } else {
yabahiro 21:1f1e9c585da8 349 solenoid.solenoid2 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 350 dz2i=false;
yabahiro 21:1f1e9c585da8 351 }
yabahiro 21:1f1e9c585da8 352 dz2=false;
yabahiro 21:1f1e9c585da8 353 }
yabahiro 21:1f1e9c585da8 354 } else {
yabahiro 21:1f1e9c585da8 355 dz2=true;
yabahiro 21:1f1e9c585da8 356 }
yabahiro 21:1f1e9c585da8 357
yabahiro 21:1f1e9c585da8 358 if(controller->Button.A) {
yabahiro 21:1f1e9c585da8 359 if(dz3==true) {
yabahiro 21:1f1e9c585da8 360 if(dz3i==false) {
yabahiro 21:1f1e9c585da8 361 solenoid.solenoid3 = SOLENOID_ON;
yabahiro 21:1f1e9c585da8 362 dz3i=true;
yabahiro 21:1f1e9c585da8 363 } else {
yabahiro 21:1f1e9c585da8 364 solenoid.solenoid3 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 365 dz3i=false;
yabahiro 21:1f1e9c585da8 366 }
yabahiro 21:1f1e9c585da8 367 dz3=false;
yabahiro 21:1f1e9c585da8 368 }
yabahiro 21:1f1e9c585da8 369 } else {
yabahiro 21:1f1e9c585da8 370 dz3=true;
yabahiro 21:1f1e9c585da8 371 }
yabahiro 21:1f1e9c585da8 372
yabahiro 21:1f1e9c585da8 373 if(controller->Button.B) {
yabahiro 21:1f1e9c585da8 374 if(dz4==true) {
yabahiro 21:1f1e9c585da8 375 if(dz4i==false) {
yabahiro 21:1f1e9c585da8 376 solenoid.solenoid4 = SOLENOID_ON;
yabahiro 21:1f1e9c585da8 377 dz4i=true;
yabahiro 21:1f1e9c585da8 378 } else {
yabahiro 21:1f1e9c585da8 379 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 380 dz4i=false;
yabahiro 21:1f1e9c585da8 381 }
yabahiro 21:1f1e9c585da8 382 dz4=false;
yabahiro 21:1f1e9c585da8 383 }
yabahiro 21:1f1e9c585da8 384 } else {
yabahiro 21:1f1e9c585da8 385 dz4=true;
yabahiro 21:1f1e9c585da8 386 }
yabahiro 21:1f1e9c585da8 387 /*
yabahiro 21:1f1e9c585da8 388 if(controller->Button.RIGHT){
yabahiro 21:1f1e9c585da8 389 motor[MOTOR_1].dir = FOR;
yabahiro 21:1f1e9c585da8 390 motor[MOTOR_1].pwm = 60;
yabahiro 21:1f1e9c585da8 391 if (ARM_1){
yabahiro 21:1f1e9c585da8 392 motor[MOTOR_1].dir = BRAKE;
yabahiro 21:1f1e9c585da8 393 }
yabahiro 21:1f1e9c585da8 394 }
yabahiro 21:1f1e9c585da8 395 else if(controller->Button.LEFT){
yabahiro 21:1f1e9c585da8 396 motor[MOTOR_1].dir = BACK;
yabahiro 21:1f1e9c585da8 397 motor[MOTOR_1].pwm = 60;
yabahiro 21:1f1e9c585da8 398 if (ARM_0){
yabahiro 21:1f1e9c585da8 399 motor[MOTOR_1].dir = BRAKE;
yabahiro 21:1f1e9c585da8 400 }
yabahiro 21:1f1e9c585da8 401 }
yabahiro 21:1f1e9c585da8 402 */
t_yamamoto 0:669ef71cba68 403 }
t_yamamoto 0:669ef71cba68 404 #endif
t_yamamoto 0:669ef71cba68 405
t_yamamoto 0:669ef71cba68 406 #if USE_PROCESS_NUM>2
yabahiro 21:1f1e9c585da8 407 bool mtc=false;
kishibekairohan 22:c47f29caded6 408 //追加
kishibekairohan 22:c47f29caded6 409 bool mtc2 = false;
yabahiro 21:1f1e9c585da8 410
kishibekairohan 16:3f2c2d89372b 411 static void Process2()
yabahiro 21:1f1e9c585da8 412 {
yabahiro 21:1f1e9c585da8 413 // printf("1:%d 2:%d 3:%d 4:%d 5:%d 6:%d 7:%d 8:%d\n\r",g[0],g[1],g[2],g[3],g[4],g[5],g[6],g[7]);
yabahiro 27:545148741493 414 count++;
yabahiro 28:9cd36721cf83 415 if(mode==0&&StertSW) {
yabahiro 28:9cd36721cf83 416 if(ThSW) {
yabahiro 28:9cd36721cf83 417 Twsh=1;
yabahiro 28:9cd36721cf83 418 mode=1;
yabahiro 28:9cd36721cf83 419 } else {
yabahiro 28:9cd36721cf83 420 Twsh=2;
yabahiro 28:9cd36721cf83 421 mode=1;
yabahiro 28:9cd36721cf83 422 }
yabahiro 28:9cd36721cf83 423 }
yabahiro 27:545148741493 424 if(mode==1) {//スタートゾーンから白線検知
kishibekairohan 26:be5121da0f77 425 motor[TIRE_FR].pwm = 30;
yabahiro 25:38d4964e8aad 426 motor[TIRE_FR].dir = BACK;
kishibekairohan 26:be5121da0f77 427 motor[TIRE_FL].pwm = 30;
yabahiro 25:38d4964e8aad 428 motor[TIRE_FL].dir = FOR;
kishibekairohan 26:be5121da0f77 429 motor[TIRE_BR].pwm = 30;
yabahiro 25:38d4964e8aad 430 motor[TIRE_BR].dir = BACK;
kishibekairohan 26:be5121da0f77 431 motor[TIRE_BL].pwm = 30;
yabahiro 25:38d4964e8aad 432 motor[TIRE_BL].dir = FOR;
yabahiro 27:545148741493 433 if(g[2]==0) {
yabahiro 27:545148741493 434 count=100000;
yabahiro 27:545148741493 435 cross=0;
yabahiro 25:38d4964e8aad 436 mode=2;
yabahiro 25:38d4964e8aad 437 }
yabahiro 27:545148741493 438 } else if(mode==2) {//横移動
yabahiro 27:545148741493 439 if(g[2]==0) {
yabahiro 27:545148741493 440 count=100000;
yabahiro 27:545148741493 441 cross=0;
yabahiro 27:545148741493 442 mode=3;
yabahiro 27:545148741493 443 mtc2=true;
yabahiro 27:545148741493 444 } else {
yabahiro 27:545148741493 445 motor[TIRE_FR].pwm = 30;
yabahiro 27:545148741493 446 motor[TIRE_FR].dir = FOR;
yabahiro 27:545148741493 447 motor[TIRE_FL].pwm = 30;
yabahiro 27:545148741493 448 motor[TIRE_FL].dir = FOR;
yabahiro 27:545148741493 449 motor[TIRE_BR].pwm = 30;
yabahiro 27:545148741493 450 motor[TIRE_BR].dir = BACK;
yabahiro 27:545148741493 451 motor[TIRE_BL].pwm = 30;
yabahiro 27:545148741493 452 motor[TIRE_BL].dir = BACK;
yabahiro 25:38d4964e8aad 453 }
yabahiro 27:545148741493 454 } else if(mode==3) { //横ライントレースから縦ライントレースへ
yabahiro 25:38d4964e8aad 455 motor[TIRE_FR].pwm = 0;
yabahiro 25:38d4964e8aad 456 motor[TIRE_FR].dir = FREE;
yabahiro 27:545148741493 457 motor[TIRE_FL].pwm = 20;
yabahiro 25:38d4964e8aad 458 motor[TIRE_FL].dir = FOR;
yabahiro 27:545148741493 459 motor[TIRE_BR].pwm = 20;
yabahiro 25:38d4964e8aad 460 motor[TIRE_BR].dir = BACK;
yabahiro 25:38d4964e8aad 461 motor[TIRE_BL].pwm = 0;
yabahiro 25:38d4964e8aad 462 motor[TIRE_BL].dir = FREE;
yabahiro 27:545148741493 463 if(count>100000&&g[0]==0) {
yabahiro 27:545148741493 464 count=0;
yabahiro 27:545148741493 465 mode=10;
yabahiro 25:38d4964e8aad 466 }
yabahiro 27:545148741493 467 } else if(mode==4) { //横ライントレースから縦ライントレースへ
yabahiro 25:38d4964e8aad 468 motor[TIRE_FR].pwm = 15;
yabahiro 25:38d4964e8aad 469 motor[TIRE_FR].dir = BACK;
yabahiro 25:38d4964e8aad 470 motor[TIRE_FL].pwm = 15;
yabahiro 25:38d4964e8aad 471 motor[TIRE_FL].dir = BACK;
yabahiro 25:38d4964e8aad 472 motor[TIRE_BR].pwm = 15;
yabahiro 25:38d4964e8aad 473 motor[TIRE_BR].dir = FOR;
yabahiro 25:38d4964e8aad 474 motor[TIRE_BL].pwm = 15;
yabahiro 25:38d4964e8aad 475 motor[TIRE_BL].dir = FOR;
yabahiro 27:545148741493 476 if(count>30000&&g[0]==0) {
yabahiro 27:545148741493 477 count=0;
yabahiro 27:545148741493 478 cross=0;
yabahiro 25:38d4964e8aad 479 mode=10;
yabahiro 25:38d4964e8aad 480 }
yabahiro 27:545148741493 481 } else if(g[0]!=99&&mode==10) { //縦ライントレース
yabahiro 21:1f1e9c585da8 482 switch(g[0]) {
yabahiro 21:1f1e9c585da8 483 case 98:
yabahiro 21:1f1e9c585da8 484 motor[TIRE_FR].pwm = 30;
yabahiro 21:1f1e9c585da8 485 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 486 motor[TIRE_FL].pwm = 30;
yabahiro 21:1f1e9c585da8 487 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 488 motor[TIRE_BR].pwm = 30;
yabahiro 21:1f1e9c585da8 489 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 490 motor[TIRE_BL].pwm = 30;
yabahiro 21:1f1e9c585da8 491 motor[TIRE_BL].dir = FOR;
yabahiro 27:545148741493 492 if(count>100000) {
yabahiro 27:545148741493 493 cross++;
yabahiro 27:545148741493 494 count=0;
yabahiro 21:1f1e9c585da8 495 }
yabahiro 21:1f1e9c585da8 496 mtc=true;
yabahiro 28:9cd36721cf83 497 if(cross==Twsh) {
yabahiro 23:694ecfa97839 498 mode=11;
yabahiro 27:545148741493 499 count=0;
yabahiro 21:1f1e9c585da8 500 }
yabahiro 21:1f1e9c585da8 501 break;
yabahiro 21:1f1e9c585da8 502 case 0:
yabahiro 21:1f1e9c585da8 503 motor[TIRE_FR].pwm = 60;
yabahiro 21:1f1e9c585da8 504 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 505 motor[TIRE_FL].pwm = 60;
yabahiro 21:1f1e9c585da8 506 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 507 motor[TIRE_BR].pwm = 60;
yabahiro 21:1f1e9c585da8 508 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 509 motor[TIRE_BL].pwm = 60;
yabahiro 21:1f1e9c585da8 510 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 511 mtc=true;
yabahiro 21:1f1e9c585da8 512 break;
yabahiro 21:1f1e9c585da8 513 case 255:
yabahiro 21:1f1e9c585da8 514 motor[TIRE_FR].pwm = 60;
yabahiro 21:1f1e9c585da8 515 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 516 motor[TIRE_FL].pwm = 40;
yabahiro 21:1f1e9c585da8 517 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 518 motor[TIRE_BR].pwm = 40;
yabahiro 21:1f1e9c585da8 519 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 520 motor[TIRE_BL].pwm = 60;
yabahiro 21:1f1e9c585da8 521 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 522 mtc=true;
yabahiro 21:1f1e9c585da8 523 break;
yabahiro 21:1f1e9c585da8 524 case 253:
yabahiro 21:1f1e9c585da8 525 motor[TIRE_FR].pwm = 20;
yabahiro 21:1f1e9c585da8 526 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 527 motor[TIRE_FL].pwm = 0;
yabahiro 21:1f1e9c585da8 528 motor[TIRE_FL].dir = FREE;
yabahiro 21:1f1e9c585da8 529 motor[TIRE_BR].pwm = 0;
yabahiro 21:1f1e9c585da8 530 motor[TIRE_BR].dir = FREE;
yabahiro 21:1f1e9c585da8 531 motor[TIRE_BL].pwm = 20;
yabahiro 21:1f1e9c585da8 532 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 533 mtc=true;
yabahiro 21:1f1e9c585da8 534 break;
yabahiro 21:1f1e9c585da8 535 case 254:
yabahiro 21:1f1e9c585da8 536 motor[TIRE_FR].pwm = 30;
yabahiro 21:1f1e9c585da8 537 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 538 motor[TIRE_FL].pwm = 0;
yabahiro 21:1f1e9c585da8 539 motor[TIRE_FL].dir = FREE;
yabahiro 21:1f1e9c585da8 540 motor[TIRE_BR].pwm = 0;
yabahiro 21:1f1e9c585da8 541 motor[TIRE_BR].dir = FREE;
yabahiro 21:1f1e9c585da8 542 motor[TIRE_BL].pwm = 30;
yabahiro 21:1f1e9c585da8 543 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 544 mtc=true;
yabahiro 21:1f1e9c585da8 545 break;
yabahiro 21:1f1e9c585da8 546 case 1:
yabahiro 21:1f1e9c585da8 547 motor[TIRE_FR].pwm = 40;
yabahiro 21:1f1e9c585da8 548 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 549 motor[TIRE_FL].pwm = 60;
yabahiro 21:1f1e9c585da8 550 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 551 motor[TIRE_BR].pwm = 60;
yabahiro 21:1f1e9c585da8 552 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 553 motor[TIRE_BL].pwm = 40;
yabahiro 21:1f1e9c585da8 554 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 555 mtc=true;
yabahiro 21:1f1e9c585da8 556 break;
yabahiro 21:1f1e9c585da8 557 case 3:
yabahiro 21:1f1e9c585da8 558 motor[TIRE_FR].pwm = 0;
yabahiro 21:1f1e9c585da8 559 motor[TIRE_FR].dir = FREE;
yabahiro 21:1f1e9c585da8 560 motor[TIRE_FL].pwm = 20;
yabahiro 21:1f1e9c585da8 561 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 562 motor[TIRE_BR].pwm = 20;
yabahiro 21:1f1e9c585da8 563 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 564 motor[TIRE_BL].pwm = 0;
yabahiro 21:1f1e9c585da8 565 motor[TIRE_BL].dir = FREE;
yabahiro 21:1f1e9c585da8 566 mtc=true;
yabahiro 21:1f1e9c585da8 567 break;
yabahiro 21:1f1e9c585da8 568 case 2:
yabahiro 21:1f1e9c585da8 569 motor[TIRE_FR].pwm = 0;
yabahiro 21:1f1e9c585da8 570 motor[TIRE_FR].dir = FREE;
yabahiro 21:1f1e9c585da8 571 motor[TIRE_FL].pwm = 30;
yabahiro 21:1f1e9c585da8 572 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 573 motor[TIRE_BR].pwm = 30;
yabahiro 21:1f1e9c585da8 574 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 575 motor[TIRE_BL].pwm = 0;
yabahiro 21:1f1e9c585da8 576 motor[TIRE_BL].dir = FREE;
yabahiro 21:1f1e9c585da8 577 mtc=true;
yabahiro 21:1f1e9c585da8 578 break;
yabahiro 21:1f1e9c585da8 579 }
yabahiro 21:1f1e9c585da8 580 if(g[0]!=98&&mtc==true) {
yabahiro 21:1f1e9c585da8 581 switch(g[1]) {
yabahiro 21:1f1e9c585da8 582 case 0:
yabahiro 21:1f1e9c585da8 583 mtc=false;
yabahiro 21:1f1e9c585da8 584 break;
yabahiro 21:1f1e9c585da8 585 case 255:
yabahiro 21:1f1e9c585da8 586 motor[TIRE_BR].pwm += 5;
yabahiro 21:1f1e9c585da8 587 mtc=false;
yabahiro 21:1f1e9c585da8 588 break;
yabahiro 21:1f1e9c585da8 589 case 253:
yabahiro 21:1f1e9c585da8 590 motor[TIRE_BR].pwm += 10;
yabahiro 21:1f1e9c585da8 591 mtc=false;
yabahiro 21:1f1e9c585da8 592 break;
yabahiro 21:1f1e9c585da8 593 case 254:
yabahiro 21:1f1e9c585da8 594 motor[TIRE_BR].pwm += 20;
yabahiro 21:1f1e9c585da8 595 motor[TIRE_BL].pwm = 0;
yabahiro 21:1f1e9c585da8 596 mtc=false;
yabahiro 21:1f1e9c585da8 597 break;
yabahiro 21:1f1e9c585da8 598 case 1:
yabahiro 21:1f1e9c585da8 599 motor[TIRE_BL].pwm += 5;
yabahiro 21:1f1e9c585da8 600 mtc=false;
yabahiro 21:1f1e9c585da8 601 break;
yabahiro 21:1f1e9c585da8 602 case 3:
yabahiro 21:1f1e9c585da8 603 motor[TIRE_BL].pwm += 10;
yabahiro 21:1f1e9c585da8 604 mtc=false;
yabahiro 21:1f1e9c585da8 605 break;
yabahiro 21:1f1e9c585da8 606 case 2:
yabahiro 21:1f1e9c585da8 607 motor[TIRE_BL].pwm += 20;
yabahiro 21:1f1e9c585da8 608 motor[TIRE_BR].pwm = 0;
yabahiro 21:1f1e9c585da8 609 mtc=false;
yabahiro 21:1f1e9c585da8 610 break;
yabahiro 21:1f1e9c585da8 611 }
yabahiro 21:1f1e9c585da8 612 }
yabahiro 23:694ecfa97839 613 } else if(mode==11) {
yabahiro 25:38d4964e8aad 614 motor[TIRE_FR].pwm = 0;
yabahiro 25:38d4964e8aad 615 motor[TIRE_FR].dir = FREE;
yabahiro 23:694ecfa97839 616 motor[TIRE_FL].pwm = 15;
yabahiro 21:1f1e9c585da8 617 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 618 motor[TIRE_BR].pwm = 15;
yabahiro 21:1f1e9c585da8 619 motor[TIRE_BR].dir = BACK;
yabahiro 25:38d4964e8aad 620 motor[TIRE_BL].pwm = 0;
yabahiro 25:38d4964e8aad 621 motor[TIRE_BL].dir = FREE;
yabahiro 27:545148741493 622 if(count>5000&&g[2]==0) {
yabahiro 27:545148741493 623 count=0;
yabahiro 23:694ecfa97839 624 mode=12;
yabahiro 21:1f1e9c585da8 625 }
yabahiro 23:694ecfa97839 626 } else if(mode==12) {
yabahiro 21:1f1e9c585da8 627 motor[TIRE_FR].pwm = 15;
yabahiro 21:1f1e9c585da8 628 motor[TIRE_FR].dir = FOR;
yabahiro 21:1f1e9c585da8 629 motor[TIRE_FL].pwm = 15;
yabahiro 21:1f1e9c585da8 630 motor[TIRE_FL].dir = BACK;
yabahiro 21:1f1e9c585da8 631 motor[TIRE_BR].pwm = 15;
yabahiro 21:1f1e9c585da8 632 motor[TIRE_BR].dir = FOR;
yabahiro 21:1f1e9c585da8 633 motor[TIRE_BL].pwm = 15;
yabahiro 21:1f1e9c585da8 634 motor[TIRE_BL].dir = BACK;
yabahiro 27:545148741493 635 if(count>10000&&g[2]==0) {
yabahiro 27:545148741493 636 count=0;
yabahiro 27:545148741493 637 cross=0;
yabahiro 23:694ecfa97839 638 mode=20;
yabahiro 21:1f1e9c585da8 639 }
yabahiro 23:694ecfa97839 640 } else if(mode==20) {
yabahiro 23:694ecfa97839 641 switch(g[2]) {
kishibekairohan 22:c47f29caded6 642 case 98:
kishibekairohan 22:c47f29caded6 643 motor[TIRE_FR].pwm = 30;
kishibekairohan 22:c47f29caded6 644 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 645 motor[TIRE_FL].pwm = 30;
kishibekairohan 22:c47f29caded6 646 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 647 motor[TIRE_BR].pwm = 30;
kishibekairohan 22:c47f29caded6 648 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 649 motor[TIRE_BL].pwm = 30;
kishibekairohan 22:c47f29caded6 650 motor[TIRE_BL].dir = BACK;
yabahiro 28:9cd36721cf83 651 if(count>70000) {
yabahiro 27:545148741493 652 cross++;
yabahiro 27:545148741493 653 count=0;
kishibekairohan 22:c47f29caded6 654 }
kishibekairohan 22:c47f29caded6 655 mtc2=true;
yabahiro 27:545148741493 656 if(cross==3) {
yabahiro 23:694ecfa97839 657 mode=21;
yabahiro 27:545148741493 658 count=0;
yabahiro 27:545148741493 659 cross=0;
kishibekairohan 22:c47f29caded6 660 }
kishibekairohan 22:c47f29caded6 661 break;
kishibekairohan 22:c47f29caded6 662 case 0:
kishibekairohan 22:c47f29caded6 663 motor[TIRE_FR].pwm = 60;
kishibekairohan 22:c47f29caded6 664 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 665 motor[TIRE_FL].pwm = 60;
kishibekairohan 22:c47f29caded6 666 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 667 motor[TIRE_BR].pwm = 60;
kishibekairohan 22:c47f29caded6 668 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 669 motor[TIRE_BL].pwm = 60;
kishibekairohan 22:c47f29caded6 670 motor[TIRE_BL].dir = BACK;
kishibekairohan 22:c47f29caded6 671 mtc2=true;
kishibekairohan 22:c47f29caded6 672 break;
kishibekairohan 22:c47f29caded6 673 case 255:
kishibekairohan 22:c47f29caded6 674 motor[TIRE_FR].pwm = 40;
kishibekairohan 22:c47f29caded6 675 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 676 motor[TIRE_FL].pwm = 60;
kishibekairohan 22:c47f29caded6 677 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 678 motor[TIRE_BR].pwm = 60;
kishibekairohan 22:c47f29caded6 679 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 680 motor[TIRE_BL].pwm = 40;
kishibekairohan 22:c47f29caded6 681 motor[TIRE_BL].dir = BACK;
kishibekairohan 22:c47f29caded6 682 mtc2=true;
kishibekairohan 22:c47f29caded6 683 break;
kishibekairohan 22:c47f29caded6 684 case 253:
kishibekairohan 22:c47f29caded6 685 motor[TIRE_FR].pwm = 0;
kishibekairohan 22:c47f29caded6 686 motor[TIRE_FR].dir = FREE;
kishibekairohan 22:c47f29caded6 687 motor[TIRE_FL].pwm = 20;
kishibekairohan 22:c47f29caded6 688 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 689 motor[TIRE_BR].pwm = 20;
kishibekairohan 22:c47f29caded6 690 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 691 motor[TIRE_BL].pwm = 0;
kishibekairohan 22:c47f29caded6 692 motor[TIRE_BL].dir = FREE;
kishibekairohan 22:c47f29caded6 693 mtc2=true;
kishibekairohan 22:c47f29caded6 694 break;
kishibekairohan 22:c47f29caded6 695 case 254:
kishibekairohan 22:c47f29caded6 696 motor[TIRE_FR].pwm = 0;
kishibekairohan 22:c47f29caded6 697 motor[TIRE_FR].dir = FREE;
kishibekairohan 22:c47f29caded6 698 motor[TIRE_FL].pwm = 30;
kishibekairohan 22:c47f29caded6 699 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 700 motor[TIRE_BR].pwm = 30;
kishibekairohan 22:c47f29caded6 701 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 702 motor[TIRE_BL].pwm = 0;
kishibekairohan 22:c47f29caded6 703 motor[TIRE_BL].dir = FREE;
kishibekairohan 22:c47f29caded6 704 mtc2=true;
kishibekairohan 22:c47f29caded6 705 break;
kishibekairohan 22:c47f29caded6 706 case 1:
kishibekairohan 22:c47f29caded6 707 motor[TIRE_FR].pwm = 60;
kishibekairohan 22:c47f29caded6 708 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 709 motor[TIRE_FL].pwm = 40;
kishibekairohan 22:c47f29caded6 710 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 711 motor[TIRE_BR].pwm = 40;
kishibekairohan 22:c47f29caded6 712 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 713 motor[TIRE_BL].pwm = 60;
kishibekairohan 22:c47f29caded6 714 motor[TIRE_BL].dir = BACK;
kishibekairohan 22:c47f29caded6 715 mtc2=true;
kishibekairohan 22:c47f29caded6 716 break;
kishibekairohan 22:c47f29caded6 717 case 3:
kishibekairohan 22:c47f29caded6 718 motor[TIRE_FR].pwm = 20;
kishibekairohan 22:c47f29caded6 719 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 720 motor[TIRE_FL].pwm = 0;
kishibekairohan 22:c47f29caded6 721 motor[TIRE_FL].dir = FREE;
kishibekairohan 22:c47f29caded6 722 motor[TIRE_BR].pwm = 0;
kishibekairohan 22:c47f29caded6 723 motor[TIRE_BR].dir = FREE;
kishibekairohan 22:c47f29caded6 724 motor[TIRE_BL].pwm = 20;
kishibekairohan 22:c47f29caded6 725 motor[TIRE_BL].dir = BACK;
kishibekairohan 22:c47f29caded6 726 mtc2=true;
kishibekairohan 22:c47f29caded6 727 break;
kishibekairohan 22:c47f29caded6 728 case 2:
kishibekairohan 22:c47f29caded6 729 motor[TIRE_FR].pwm = 30;
kishibekairohan 22:c47f29caded6 730 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 731 motor[TIRE_FL].pwm = 0;
kishibekairohan 22:c47f29caded6 732 motor[TIRE_FL].dir = FREE;
kishibekairohan 22:c47f29caded6 733 motor[TIRE_BR].pwm = 0;
kishibekairohan 22:c47f29caded6 734 motor[TIRE_BR].dir = FREE;
kishibekairohan 22:c47f29caded6 735 motor[TIRE_BL].pwm = 30;
kishibekairohan 22:c47f29caded6 736 motor[TIRE_BL].dir = BACK;
kishibekairohan 22:c47f29caded6 737 mtc2=true;
kishibekairohan 22:c47f29caded6 738 break;
kishibekairohan 22:c47f29caded6 739 }
kishibekairohan 22:c47f29caded6 740 if(g[2]!=98&&mtc2==true) {
kishibekairohan 22:c47f29caded6 741 switch(g[3]) {
kishibekairohan 22:c47f29caded6 742 case 0:
kishibekairohan 22:c47f29caded6 743 mtc2=false;
kishibekairohan 22:c47f29caded6 744 break;
kishibekairohan 22:c47f29caded6 745 case 255:
kishibekairohan 22:c47f29caded6 746 motor[TIRE_BL].pwm += 5;
kishibekairohan 22:c47f29caded6 747 mtc2=false;
kishibekairohan 22:c47f29caded6 748 break;
kishibekairohan 22:c47f29caded6 749 case 253:
kishibekairohan 22:c47f29caded6 750 motor[TIRE_BL].pwm += 10;
kishibekairohan 22:c47f29caded6 751 mtc2=false;
kishibekairohan 22:c47f29caded6 752 break;
kishibekairohan 22:c47f29caded6 753 case 254:
kishibekairohan 22:c47f29caded6 754 motor[TIRE_BL].pwm += 20;
kishibekairohan 22:c47f29caded6 755 motor[TIRE_FL].pwm = 0;
kishibekairohan 22:c47f29caded6 756 mtc2=false;
kishibekairohan 22:c47f29caded6 757 break;
kishibekairohan 22:c47f29caded6 758 case 1:
kishibekairohan 22:c47f29caded6 759 motor[TIRE_FL].pwm += 5;
kishibekairohan 22:c47f29caded6 760 mtc2=false;
kishibekairohan 22:c47f29caded6 761 break;
kishibekairohan 22:c47f29caded6 762 case 3:
kishibekairohan 22:c47f29caded6 763 motor[TIRE_FL].pwm += 10;
kishibekairohan 22:c47f29caded6 764 mtc2=false;
kishibekairohan 22:c47f29caded6 765 break;
kishibekairohan 22:c47f29caded6 766 case 2:
kishibekairohan 22:c47f29caded6 767 motor[TIRE_FL].pwm += 20;
kishibekairohan 22:c47f29caded6 768 motor[TIRE_BL].pwm = 0;
kishibekairohan 22:c47f29caded6 769 mtc2=false;
kishibekairohan 22:c47f29caded6 770 break;
kishibekairohan 22:c47f29caded6 771 }
kishibekairohan 22:c47f29caded6 772 }
yabahiro 23:694ecfa97839 773 } else if(mode==21) {
yabahiro 25:38d4964e8aad 774 motor[TIRE_FR].pwm = 0;
yabahiro 25:38d4964e8aad 775 motor[TIRE_FR].dir = FREE;
yabahiro 23:694ecfa97839 776 motor[TIRE_FL].pwm = 15;
yabahiro 23:694ecfa97839 777 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 778 motor[TIRE_BR].pwm = 15;
yabahiro 23:694ecfa97839 779 motor[TIRE_BR].dir = BACK;
yabahiro 25:38d4964e8aad 780 motor[TIRE_BL].pwm = 0;
yabahiro 25:38d4964e8aad 781 motor[TIRE_BL].dir = FREE;
yabahiro 28:9cd36721cf83 782 if(count>2000&&g[0]==0) {
yabahiro 27:545148741493 783 count=0;
yabahiro 23:694ecfa97839 784 mode=22;
yabahiro 23:694ecfa97839 785 }
yabahiro 23:694ecfa97839 786 } else if(mode==22) {
yabahiro 23:694ecfa97839 787 motor[TIRE_FR].pwm = 15;
yabahiro 23:694ecfa97839 788 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 789 motor[TIRE_FL].pwm = 15;
yabahiro 23:694ecfa97839 790 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 791 motor[TIRE_BR].pwm = 15;
yabahiro 23:694ecfa97839 792 motor[TIRE_BR].dir = FOR;
yabahiro 23:694ecfa97839 793 motor[TIRE_BL].pwm = 15;
yabahiro 23:694ecfa97839 794 motor[TIRE_BL].dir = FOR;
yabahiro 28:9cd36721cf83 795 if(count>5000&&g[0]==0) {
yabahiro 27:545148741493 796 count=0;
yabahiro 27:545148741493 797 cross=0;
yabahiro 23:694ecfa97839 798 mode=30;
yabahiro 23:694ecfa97839 799 }
yabahiro 23:694ecfa97839 800 } else if(mode==30) {
yabahiro 23:694ecfa97839 801 switch(g[0]) {
yabahiro 23:694ecfa97839 802 case 98:
yabahiro 23:694ecfa97839 803 motor[TIRE_FR].pwm = 30;
yabahiro 23:694ecfa97839 804 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 805 motor[TIRE_FL].pwm = 30;
yabahiro 23:694ecfa97839 806 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 807 motor[TIRE_BR].pwm = 30;
yabahiro 23:694ecfa97839 808 motor[TIRE_BR].dir = BACK;
yabahiro 23:694ecfa97839 809 motor[TIRE_BL].pwm = 30;
yabahiro 23:694ecfa97839 810 motor[TIRE_BL].dir = FOR;
yabahiro 27:545148741493 811 if(count>100000) {
yabahiro 27:545148741493 812 cross++;
yabahiro 27:545148741493 813 count=0;
yabahiro 23:694ecfa97839 814 }
yabahiro 23:694ecfa97839 815 mtc=true;
yabahiro 27:545148741493 816 if(cross==1) {
yabahiro 23:694ecfa97839 817 mode=31;
yabahiro 27:545148741493 818 count=0;
yabahiro 23:694ecfa97839 819 }
yabahiro 23:694ecfa97839 820 break;
yabahiro 23:694ecfa97839 821 case 0:
yabahiro 23:694ecfa97839 822 motor[TIRE_FR].pwm = 60;
yabahiro 23:694ecfa97839 823 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 824 motor[TIRE_FL].pwm = 60;
yabahiro 23:694ecfa97839 825 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 826 motor[TIRE_BR].pwm = 60;
yabahiro 23:694ecfa97839 827 motor[TIRE_BR].dir = BACK;
yabahiro 23:694ecfa97839 828 motor[TIRE_BL].pwm = 60;
yabahiro 23:694ecfa97839 829 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 830 mtc=true;
yabahiro 23:694ecfa97839 831 break;
yabahiro 23:694ecfa97839 832 case 255:
yabahiro 23:694ecfa97839 833 motor[TIRE_FR].pwm = 60;
yabahiro 23:694ecfa97839 834 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 835 motor[TIRE_FL].pwm = 40;
yabahiro 23:694ecfa97839 836 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 837 motor[TIRE_BR].pwm = 40;
yabahiro 23:694ecfa97839 838 motor[TIRE_BR].dir = BACK;
yabahiro 23:694ecfa97839 839 motor[TIRE_BL].pwm = 60;
yabahiro 23:694ecfa97839 840 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 841 mtc=true;
yabahiro 23:694ecfa97839 842 break;
yabahiro 23:694ecfa97839 843 case 253:
yabahiro 23:694ecfa97839 844 motor[TIRE_FR].pwm = 20;
yabahiro 23:694ecfa97839 845 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 846 motor[TIRE_FL].pwm = 0;
yabahiro 23:694ecfa97839 847 motor[TIRE_FL].dir = FREE;
yabahiro 23:694ecfa97839 848 motor[TIRE_BR].pwm = 0;
yabahiro 23:694ecfa97839 849 motor[TIRE_BR].dir = FREE;
yabahiro 23:694ecfa97839 850 motor[TIRE_BL].pwm = 20;
yabahiro 23:694ecfa97839 851 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 852 mtc=true;
yabahiro 23:694ecfa97839 853 break;
yabahiro 23:694ecfa97839 854 case 254:
yabahiro 23:694ecfa97839 855 motor[TIRE_FR].pwm = 30;
yabahiro 23:694ecfa97839 856 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 857 motor[TIRE_FL].pwm = 0;
yabahiro 23:694ecfa97839 858 motor[TIRE_FL].dir = FREE;
yabahiro 23:694ecfa97839 859 motor[TIRE_BR].pwm = 0;
yabahiro 23:694ecfa97839 860 motor[TIRE_BR].dir = FREE;
yabahiro 23:694ecfa97839 861 motor[TIRE_BL].pwm = 30;
yabahiro 23:694ecfa97839 862 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 863 mtc=true;
yabahiro 23:694ecfa97839 864 break;
yabahiro 23:694ecfa97839 865 case 1:
yabahiro 23:694ecfa97839 866 motor[TIRE_FR].pwm = 40;
yabahiro 23:694ecfa97839 867 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 868 motor[TIRE_FL].pwm = 60;
yabahiro 23:694ecfa97839 869 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 870 motor[TIRE_BR].pwm = 60;
yabahiro 23:694ecfa97839 871 motor[TIRE_BR].dir = BACK;
yabahiro 23:694ecfa97839 872 motor[TIRE_BL].pwm = 40;
yabahiro 23:694ecfa97839 873 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 874 mtc=true;
yabahiro 23:694ecfa97839 875 break;
yabahiro 23:694ecfa97839 876 case 3:
yabahiro 23:694ecfa97839 877 motor[TIRE_FR].pwm = 0;
yabahiro 23:694ecfa97839 878 motor[TIRE_FR].dir = FREE;
yabahiro 23:694ecfa97839 879 motor[TIRE_FL].pwm = 20;
yabahiro 23:694ecfa97839 880 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 881 motor[TIRE_BR].pwm = 20;
yabahiro 23:694ecfa97839 882 motor[TIRE_BR].dir = BACK;
yabahiro 23:694ecfa97839 883 motor[TIRE_BL].pwm = 0;
yabahiro 23:694ecfa97839 884 motor[TIRE_BL].dir = FREE;
yabahiro 23:694ecfa97839 885 mtc=true;
yabahiro 23:694ecfa97839 886 break;
yabahiro 23:694ecfa97839 887 case 2:
yabahiro 23:694ecfa97839 888 motor[TIRE_FR].pwm = 0;
yabahiro 23:694ecfa97839 889 motor[TIRE_FR].dir = FREE;
yabahiro 23:694ecfa97839 890 motor[TIRE_FL].pwm = 30;
yabahiro 23:694ecfa97839 891 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 892 motor[TIRE_BR].pwm = 30;
yabahiro 23:694ecfa97839 893 motor[TIRE_BR].dir = BACK;
yabahiro 23:694ecfa97839 894 motor[TIRE_BL].pwm = 0;
yabahiro 23:694ecfa97839 895 motor[TIRE_BL].dir = FREE;
yabahiro 23:694ecfa97839 896 mtc=true;
yabahiro 23:694ecfa97839 897 break;
yabahiro 23:694ecfa97839 898 }
yabahiro 23:694ecfa97839 899 if(g[0]!=98&&mtc==true) {
yabahiro 23:694ecfa97839 900 switch(g[1]) {
yabahiro 23:694ecfa97839 901 case 0:
yabahiro 23:694ecfa97839 902 mtc=false;
yabahiro 23:694ecfa97839 903 break;
yabahiro 23:694ecfa97839 904 case 255:
yabahiro 23:694ecfa97839 905 motor[TIRE_BR].pwm += 5;
yabahiro 23:694ecfa97839 906 mtc=false;
yabahiro 23:694ecfa97839 907 break;
yabahiro 23:694ecfa97839 908 case 253:
yabahiro 23:694ecfa97839 909 motor[TIRE_BR].pwm += 10;
yabahiro 23:694ecfa97839 910 mtc=false;
yabahiro 23:694ecfa97839 911 break;
yabahiro 23:694ecfa97839 912 case 254:
yabahiro 23:694ecfa97839 913 motor[TIRE_BR].pwm += 20;
yabahiro 23:694ecfa97839 914 motor[TIRE_BL].pwm = 0;
yabahiro 23:694ecfa97839 915 mtc=false;
yabahiro 23:694ecfa97839 916 break;
yabahiro 23:694ecfa97839 917 case 1:
yabahiro 23:694ecfa97839 918 motor[TIRE_BL].pwm += 5;
yabahiro 23:694ecfa97839 919 mtc=false;
yabahiro 23:694ecfa97839 920 break;
yabahiro 23:694ecfa97839 921 case 3:
yabahiro 23:694ecfa97839 922 motor[TIRE_BL].pwm += 10;
yabahiro 23:694ecfa97839 923 mtc=false;
yabahiro 23:694ecfa97839 924 break;
yabahiro 23:694ecfa97839 925 case 2:
yabahiro 23:694ecfa97839 926 motor[TIRE_BL].pwm += 20;
yabahiro 23:694ecfa97839 927 motor[TIRE_BR].pwm = 0;
yabahiro 23:694ecfa97839 928 mtc=false;
yabahiro 23:694ecfa97839 929 break;
yabahiro 23:694ecfa97839 930 }
yabahiro 23:694ecfa97839 931 }
yabahiro 23:694ecfa97839 932 } else if(mode==31) {
yabahiro 23:694ecfa97839 933 motor[TIRE_FR].pwm = 15;
yabahiro 23:694ecfa97839 934 motor[TIRE_FR].dir = BACK;
yabahiro 25:38d4964e8aad 935 motor[TIRE_FL].pwm = 0;
yabahiro 25:38d4964e8aad 936 motor[TIRE_FL].dir = FREE;
yabahiro 25:38d4964e8aad 937 motor[TIRE_BR].pwm = 0;
yabahiro 25:38d4964e8aad 938 motor[TIRE_BR].dir = FREE;
yabahiro 23:694ecfa97839 939 motor[TIRE_BL].pwm = 15;
yabahiro 23:694ecfa97839 940 motor[TIRE_BL].dir = FOR;
yabahiro 27:545148741493 941 if(count>5000&&g[3]==0) {
yabahiro 27:545148741493 942 count=0;
yabahiro 23:694ecfa97839 943 mode=32;
yabahiro 23:694ecfa97839 944 }
yabahiro 23:694ecfa97839 945 } else if(mode==32) {
yabahiro 23:694ecfa97839 946 motor[TIRE_FR].pwm = 15;
yabahiro 23:694ecfa97839 947 motor[TIRE_FR].dir = FOR;
yabahiro 23:694ecfa97839 948 motor[TIRE_FL].pwm = 15;
yabahiro 23:694ecfa97839 949 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 950 motor[TIRE_BR].pwm = 15;
yabahiro 23:694ecfa97839 951 motor[TIRE_BR].dir = FOR;
yabahiro 23:694ecfa97839 952 motor[TIRE_BL].pwm = 15;
yabahiro 23:694ecfa97839 953 motor[TIRE_BL].dir = BACK;
yabahiro 27:545148741493 954 if(count>5000&&g[3]==0) {
yabahiro 27:545148741493 955 count=0;
yabahiro 27:545148741493 956 cross=0;
yabahiro 23:694ecfa97839 957 mode=40;
yabahiro 23:694ecfa97839 958 }
yabahiro 23:694ecfa97839 959 } else if(mode==40) {
yabahiro 23:694ecfa97839 960 switch(g[3]) {
yabahiro 23:694ecfa97839 961 case 98:
yabahiro 23:694ecfa97839 962 motor[TIRE_FR].pwm = 30;
yabahiro 23:694ecfa97839 963 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 964 motor[TIRE_FL].pwm = 30;
yabahiro 23:694ecfa97839 965 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 966 motor[TIRE_BR].pwm = 30;
yabahiro 23:694ecfa97839 967 motor[TIRE_BR].dir = FOR;
yabahiro 23:694ecfa97839 968 motor[TIRE_BL].pwm = 30;
yabahiro 23:694ecfa97839 969 motor[TIRE_BL].dir = FOR;
yabahiro 27:545148741493 970 if(count>30000) {
yabahiro 27:545148741493 971 cross++;
yabahiro 27:545148741493 972 count=0;
yabahiro 23:694ecfa97839 973 }
yabahiro 23:694ecfa97839 974 mtc2=true;
yabahiro 27:545148741493 975 if(cross==1) {
yabahiro 23:694ecfa97839 976 mode=41;
yabahiro 27:545148741493 977 count=0;
yabahiro 27:545148741493 978 cross=0;
yabahiro 23:694ecfa97839 979 }
yabahiro 23:694ecfa97839 980 break;
yabahiro 23:694ecfa97839 981 case 0:
yabahiro 23:694ecfa97839 982 motor[TIRE_FR].pwm = 60;
yabahiro 23:694ecfa97839 983 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 984 motor[TIRE_FL].pwm = 60;
yabahiro 23:694ecfa97839 985 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 986 motor[TIRE_BR].pwm = 60;
yabahiro 23:694ecfa97839 987 motor[TIRE_BR].dir = FOR;
yabahiro 23:694ecfa97839 988 motor[TIRE_BL].pwm = 60;
yabahiro 23:694ecfa97839 989 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 990 mtc2=true;
yabahiro 23:694ecfa97839 991 break;
yabahiro 23:694ecfa97839 992 case 255:
yabahiro 23:694ecfa97839 993 motor[TIRE_FR].pwm = 40;
yabahiro 23:694ecfa97839 994 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 995 motor[TIRE_FL].pwm = 60;
yabahiro 23:694ecfa97839 996 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 997 motor[TIRE_BR].pwm = 60;
yabahiro 23:694ecfa97839 998 motor[TIRE_BR].dir = FOR;
yabahiro 23:694ecfa97839 999 motor[TIRE_BL].pwm = 40;
yabahiro 23:694ecfa97839 1000 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 1001 mtc2=true;
yabahiro 23:694ecfa97839 1002 break;
yabahiro 23:694ecfa97839 1003 case 253:
yabahiro 23:694ecfa97839 1004 motor[TIRE_FR].pwm = 0;
yabahiro 23:694ecfa97839 1005 motor[TIRE_FR].dir = FREE;
yabahiro 23:694ecfa97839 1006 motor[TIRE_FL].pwm = 20;
yabahiro 23:694ecfa97839 1007 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 1008 motor[TIRE_BR].pwm = 20;
yabahiro 23:694ecfa97839 1009 motor[TIRE_BR].dir = FOR;
yabahiro 23:694ecfa97839 1010 motor[TIRE_BL].pwm = 0;
yabahiro 23:694ecfa97839 1011 motor[TIRE_BL].dir = FREE;
yabahiro 23:694ecfa97839 1012 mtc2=true;
yabahiro 23:694ecfa97839 1013 break;
yabahiro 23:694ecfa97839 1014 case 254:
yabahiro 23:694ecfa97839 1015 motor[TIRE_FR].pwm = 0;
yabahiro 23:694ecfa97839 1016 motor[TIRE_FR].dir = FREE;
yabahiro 23:694ecfa97839 1017 motor[TIRE_FL].pwm = 30;
yabahiro 23:694ecfa97839 1018 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 1019 motor[TIRE_BR].pwm = 30;
yabahiro 23:694ecfa97839 1020 motor[TIRE_BR].dir = FOR;
yabahiro 23:694ecfa97839 1021 motor[TIRE_BL].pwm = 0;
yabahiro 23:694ecfa97839 1022 motor[TIRE_BL].dir = FREE;
yabahiro 23:694ecfa97839 1023 mtc2=true;
yabahiro 23:694ecfa97839 1024 break;
yabahiro 23:694ecfa97839 1025 case 1:
yabahiro 23:694ecfa97839 1026 motor[TIRE_FR].pwm = 60;
yabahiro 23:694ecfa97839 1027 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 1028 motor[TIRE_FL].pwm = 40;
yabahiro 23:694ecfa97839 1029 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 1030 motor[TIRE_BR].pwm = 40;
yabahiro 23:694ecfa97839 1031 motor[TIRE_BR].dir = FOR;
yabahiro 23:694ecfa97839 1032 motor[TIRE_BL].pwm = 60;
yabahiro 23:694ecfa97839 1033 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 1034 mtc2=true;
yabahiro 23:694ecfa97839 1035 break;
yabahiro 23:694ecfa97839 1036 case 3:
yabahiro 23:694ecfa97839 1037 motor[TIRE_FR].pwm = 20;
yabahiro 23:694ecfa97839 1038 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 1039 motor[TIRE_FL].pwm = 0;
yabahiro 23:694ecfa97839 1040 motor[TIRE_FL].dir = FREE;
yabahiro 23:694ecfa97839 1041 motor[TIRE_BR].pwm = 0;
yabahiro 23:694ecfa97839 1042 motor[TIRE_BR].dir = FREE;
yabahiro 23:694ecfa97839 1043 motor[TIRE_BL].pwm = 20;
yabahiro 23:694ecfa97839 1044 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 1045 mtc2=true;
yabahiro 23:694ecfa97839 1046 break;
yabahiro 23:694ecfa97839 1047 case 2:
yabahiro 23:694ecfa97839 1048 motor[TIRE_FR].pwm = 30;
yabahiro 23:694ecfa97839 1049 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 1050 motor[TIRE_FL].pwm = 0;
yabahiro 23:694ecfa97839 1051 motor[TIRE_FL].dir = FREE;
yabahiro 23:694ecfa97839 1052 motor[TIRE_BR].pwm = 0;
yabahiro 23:694ecfa97839 1053 motor[TIRE_BR].dir = FREE;
yabahiro 23:694ecfa97839 1054 motor[TIRE_BL].pwm = 30;
yabahiro 23:694ecfa97839 1055 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 1056 mtc2=true;
yabahiro 23:694ecfa97839 1057 break;
yabahiro 23:694ecfa97839 1058 }
yabahiro 23:694ecfa97839 1059 if(g[2]!=98&&mtc2==true) {
yabahiro 23:694ecfa97839 1060 switch(g[2]) {
yabahiro 23:694ecfa97839 1061 case 0:
yabahiro 23:694ecfa97839 1062 mtc2=false;
yabahiro 23:694ecfa97839 1063 break;
yabahiro 23:694ecfa97839 1064 case 255:
yabahiro 23:694ecfa97839 1065 motor[TIRE_FL].pwm += 5;
yabahiro 23:694ecfa97839 1066 mtc2=false;
yabahiro 23:694ecfa97839 1067 break;
yabahiro 23:694ecfa97839 1068 case 253:
yabahiro 23:694ecfa97839 1069 motor[TIRE_FL].pwm += 10;
yabahiro 23:694ecfa97839 1070 mtc2=false;
yabahiro 23:694ecfa97839 1071 break;
yabahiro 23:694ecfa97839 1072 case 254:
yabahiro 23:694ecfa97839 1073 motor[TIRE_FL].pwm += 20;
yabahiro 23:694ecfa97839 1074 motor[TIRE_BL].pwm = 0;
yabahiro 23:694ecfa97839 1075 mtc2=false;
yabahiro 23:694ecfa97839 1076 break;
yabahiro 23:694ecfa97839 1077 case 1:
yabahiro 23:694ecfa97839 1078 motor[TIRE_BL].pwm += 5;
yabahiro 23:694ecfa97839 1079 mtc2=false;
yabahiro 23:694ecfa97839 1080 break;
yabahiro 23:694ecfa97839 1081 case 3:
yabahiro 23:694ecfa97839 1082 motor[TIRE_BL].pwm += 10;
yabahiro 23:694ecfa97839 1083 mtc2=false;
yabahiro 23:694ecfa97839 1084 break;
yabahiro 23:694ecfa97839 1085 case 2:
yabahiro 23:694ecfa97839 1086 motor[TIRE_BL].pwm += 20;
yabahiro 23:694ecfa97839 1087 motor[TIRE_FL].pwm = 0;
yabahiro 23:694ecfa97839 1088 mtc2=false;
yabahiro 23:694ecfa97839 1089 break;
yabahiro 23:694ecfa97839 1090 }
yabahiro 23:694ecfa97839 1091 }
yabahiro 23:694ecfa97839 1092 } else if(mode==41) {
yabahiro 25:38d4964e8aad 1093 motor[TIRE_FR].pwm = 0;
yabahiro 25:38d4964e8aad 1094 motor[TIRE_FR].dir = FREE;
yabahiro 23:694ecfa97839 1095 motor[TIRE_FL].pwm = 15;
yabahiro 23:694ecfa97839 1096 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 1097 motor[TIRE_BR].pwm = 15;
yabahiro 23:694ecfa97839 1098 motor[TIRE_BR].dir = FOR;
yabahiro 25:38d4964e8aad 1099 motor[TIRE_BL].pwm = 0;
yabahiro 25:38d4964e8aad 1100 motor[TIRE_BL].dir = FREE;
yabahiro 27:545148741493 1101 if(count>5000&&g[1]==0) {
yabahiro 27:545148741493 1102 count=0;
yabahiro 23:694ecfa97839 1103 mode=42;
yabahiro 23:694ecfa97839 1104 }
yabahiro 23:694ecfa97839 1105 } else if(mode==42) {
yabahiro 23:694ecfa97839 1106 motor[TIRE_FR].pwm = 15;
yabahiro 23:694ecfa97839 1107 motor[TIRE_FR].dir = FOR;
yabahiro 23:694ecfa97839 1108 motor[TIRE_FL].pwm = 15;
yabahiro 23:694ecfa97839 1109 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 1110 motor[TIRE_BR].pwm = 15;
yabahiro 23:694ecfa97839 1111 motor[TIRE_BR].dir = BACK;
yabahiro 23:694ecfa97839 1112 motor[TIRE_BL].pwm = 15;
yabahiro 23:694ecfa97839 1113 motor[TIRE_BL].dir = BACK;
yabahiro 27:545148741493 1114 if(count>5000&&g[1]==0) {
yabahiro 27:545148741493 1115 count=0;
yabahiro 23:694ecfa97839 1116 mode=50;
yabahiro 24:41c23c9a5058 1117 }
yabahiro 24:41c23c9a5058 1118 } else if(mode==50) {
yabahiro 24:41c23c9a5058 1119 switch(g[1]) {
yabahiro 24:41c23c9a5058 1120 case 98:
yabahiro 24:41c23c9a5058 1121 motor[TIRE_FR].pwm = 30;
yabahiro 24:41c23c9a5058 1122 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1123 motor[TIRE_FL].pwm = 30;
yabahiro 24:41c23c9a5058 1124 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1125 motor[TIRE_BR].pwm = 30;
yabahiro 24:41c23c9a5058 1126 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1127 motor[TIRE_BL].pwm = 30;
yabahiro 24:41c23c9a5058 1128 motor[TIRE_BL].dir = BACK;
yabahiro 27:545148741493 1129 if(count>100000) {
yabahiro 27:545148741493 1130 cross++;
yabahiro 27:545148741493 1131 count=0;
yabahiro 24:41c23c9a5058 1132 }
yabahiro 24:41c23c9a5058 1133 mtc=true;
yabahiro 27:545148741493 1134 if(cross==1) {
yabahiro 24:41c23c9a5058 1135 mode=51;
yabahiro 27:545148741493 1136 count=0;
yabahiro 24:41c23c9a5058 1137 }
yabahiro 24:41c23c9a5058 1138 break;
yabahiro 24:41c23c9a5058 1139 case 0:
yabahiro 24:41c23c9a5058 1140 motor[TIRE_FR].pwm = 60;
yabahiro 24:41c23c9a5058 1141 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1142 motor[TIRE_FL].pwm = 60;
yabahiro 24:41c23c9a5058 1143 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1144 motor[TIRE_BR].pwm = 60;
yabahiro 24:41c23c9a5058 1145 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1146 motor[TIRE_BL].pwm = 60;
yabahiro 24:41c23c9a5058 1147 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1148 mtc=true;
yabahiro 24:41c23c9a5058 1149 break;
yabahiro 24:41c23c9a5058 1150 case 255:
yabahiro 24:41c23c9a5058 1151 motor[TIRE_FR].pwm = 60;
yabahiro 24:41c23c9a5058 1152 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1153 motor[TIRE_FL].pwm = 40;
yabahiro 24:41c23c9a5058 1154 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1155 motor[TIRE_BR].pwm = 40;
yabahiro 24:41c23c9a5058 1156 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1157 motor[TIRE_BL].pwm = 60;
yabahiro 24:41c23c9a5058 1158 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1159 mtc=true;
yabahiro 24:41c23c9a5058 1160 break;
yabahiro 24:41c23c9a5058 1161 case 253:
yabahiro 24:41c23c9a5058 1162 motor[TIRE_FR].pwm = 20;
yabahiro 24:41c23c9a5058 1163 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1164 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1165 motor[TIRE_FL].dir = FREE;
yabahiro 24:41c23c9a5058 1166 motor[TIRE_BR].pwm = 0;
yabahiro 24:41c23c9a5058 1167 motor[TIRE_BR].dir = FREE;
yabahiro 24:41c23c9a5058 1168 motor[TIRE_BL].pwm = 20;
yabahiro 24:41c23c9a5058 1169 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1170 mtc=true;
yabahiro 24:41c23c9a5058 1171 break;
yabahiro 24:41c23c9a5058 1172 case 254:
yabahiro 24:41c23c9a5058 1173 motor[TIRE_FR].pwm = 30;
yabahiro 24:41c23c9a5058 1174 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1175 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1176 motor[TIRE_FL].dir = FREE;
yabahiro 24:41c23c9a5058 1177 motor[TIRE_BR].pwm = 0;
yabahiro 24:41c23c9a5058 1178 motor[TIRE_BR].dir = FREE;
yabahiro 24:41c23c9a5058 1179 motor[TIRE_BL].pwm = 30;
yabahiro 24:41c23c9a5058 1180 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1181 mtc=true;
yabahiro 24:41c23c9a5058 1182 break;
yabahiro 24:41c23c9a5058 1183 case 1:
yabahiro 24:41c23c9a5058 1184 motor[TIRE_FR].pwm = 40;
yabahiro 24:41c23c9a5058 1185 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1186 motor[TIRE_FL].pwm = 60;
yabahiro 24:41c23c9a5058 1187 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1188 motor[TIRE_BR].pwm = 60;
yabahiro 24:41c23c9a5058 1189 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1190 motor[TIRE_BL].pwm = 40;
yabahiro 24:41c23c9a5058 1191 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1192 mtc=true;
yabahiro 24:41c23c9a5058 1193 break;
yabahiro 24:41c23c9a5058 1194 case 3:
yabahiro 24:41c23c9a5058 1195 motor[TIRE_FR].pwm = 0;
yabahiro 24:41c23c9a5058 1196 motor[TIRE_FR].dir = FREE;
yabahiro 24:41c23c9a5058 1197 motor[TIRE_FL].pwm = 20;
yabahiro 24:41c23c9a5058 1198 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1199 motor[TIRE_BR].pwm = 20;
yabahiro 24:41c23c9a5058 1200 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1201 motor[TIRE_BL].pwm = 0;
yabahiro 24:41c23c9a5058 1202 motor[TIRE_BL].dir = FREE;
yabahiro 24:41c23c9a5058 1203 mtc=true;
yabahiro 24:41c23c9a5058 1204 break;
yabahiro 24:41c23c9a5058 1205 case 2:
yabahiro 24:41c23c9a5058 1206 motor[TIRE_FR].pwm = 0;
yabahiro 24:41c23c9a5058 1207 motor[TIRE_FR].dir = FREE;
yabahiro 24:41c23c9a5058 1208 motor[TIRE_FL].pwm = 30;
yabahiro 24:41c23c9a5058 1209 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1210 motor[TIRE_BR].pwm = 30;
yabahiro 24:41c23c9a5058 1211 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1212 motor[TIRE_BL].pwm = 0;
yabahiro 24:41c23c9a5058 1213 motor[TIRE_BL].dir = FREE;
yabahiro 24:41c23c9a5058 1214 mtc=true;
yabahiro 24:41c23c9a5058 1215 break;
yabahiro 24:41c23c9a5058 1216 }
yabahiro 24:41c23c9a5058 1217 if(g[1]!=98&&mtc==true) {
yabahiro 24:41c23c9a5058 1218 switch(g[0]) {
yabahiro 23:694ecfa97839 1219 case 0:
yabahiro 24:41c23c9a5058 1220 mtc=false;
yabahiro 23:694ecfa97839 1221 break;
yabahiro 23:694ecfa97839 1222 case 255:
yabahiro 27:545148741493 1223 motor[TIRE_FL].pwm += 5;
yabahiro 24:41c23c9a5058 1224 mtc=false;
yabahiro 23:694ecfa97839 1225 break;
yabahiro 23:694ecfa97839 1226 case 253:
yabahiro 27:545148741493 1227 motor[TIRE_FL].pwm += 10;
yabahiro 24:41c23c9a5058 1228 mtc=false;
yabahiro 23:694ecfa97839 1229 break;
yabahiro 23:694ecfa97839 1230 case 254:
yabahiro 27:545148741493 1231 motor[TIRE_FL].pwm += 20;
yabahiro 27:545148741493 1232 motor[TIRE_FR].pwm = 0;
yabahiro 24:41c23c9a5058 1233 mtc=false;
yabahiro 23:694ecfa97839 1234 break;
yabahiro 23:694ecfa97839 1235 case 1:
yabahiro 27:545148741493 1236 motor[TIRE_FR].pwm += 5;
yabahiro 24:41c23c9a5058 1237 mtc=false;
yabahiro 23:694ecfa97839 1238 break;
yabahiro 23:694ecfa97839 1239 case 3:
yabahiro 27:545148741493 1240 motor[TIRE_FR].pwm += 10;
yabahiro 24:41c23c9a5058 1241 mtc=false;
yabahiro 23:694ecfa97839 1242 break;
yabahiro 23:694ecfa97839 1243 case 2:
yabahiro 27:545148741493 1244 motor[TIRE_FR].pwm += 20;
yabahiro 27:545148741493 1245 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1246 mtc=false;
yabahiro 23:694ecfa97839 1247 break;
yabahiro 23:694ecfa97839 1248 }
yabahiro 23:694ecfa97839 1249 }
yabahiro 23:694ecfa97839 1250 } else if(mode==51) {
yabahiro 25:38d4964e8aad 1251 motor[TIRE_FR].pwm = 0;
yabahiro 25:38d4964e8aad 1252 motor[TIRE_FR].dir = FREE;
yabahiro 24:41c23c9a5058 1253 motor[TIRE_FL].pwm = 15;
yabahiro 24:41c23c9a5058 1254 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1255 motor[TIRE_BR].pwm = 15;
yabahiro 24:41c23c9a5058 1256 motor[TIRE_BR].dir = FOR;
yabahiro 25:38d4964e8aad 1257 motor[TIRE_BL].pwm = 0;
yabahiro 25:38d4964e8aad 1258 motor[TIRE_BL].dir = FREE;
yabahiro 27:545148741493 1259 if(count>5000&&g[3]==0) {
yabahiro 27:545148741493 1260 count=0;
yabahiro 24:41c23c9a5058 1261 mode=52;
yabahiro 24:41c23c9a5058 1262 }
yabahiro 24:41c23c9a5058 1263 } else if(mode==52) {
yabahiro 24:41c23c9a5058 1264 motor[TIRE_FR].pwm = 15;
yabahiro 24:41c23c9a5058 1265 motor[TIRE_FR].dir = BACK;
yabahiro 24:41c23c9a5058 1266 motor[TIRE_FL].pwm = 15;
yabahiro 24:41c23c9a5058 1267 motor[TIRE_FL].dir = FOR;
yabahiro 24:41c23c9a5058 1268 motor[TIRE_BR].pwm = 15;
yabahiro 24:41c23c9a5058 1269 motor[TIRE_BR].dir = BACK;
yabahiro 24:41c23c9a5058 1270 motor[TIRE_BL].pwm = 15;
yabahiro 24:41c23c9a5058 1271 motor[TIRE_BL].dir = FOR;
yabahiro 27:545148741493 1272 if(count>5000&&g[3]==0) {
yabahiro 27:545148741493 1273 count=0;
yabahiro 27:545148741493 1274 cross=0;
yabahiro 24:41c23c9a5058 1275 mode=60;
yabahiro 24:41c23c9a5058 1276 }
yabahiro 24:41c23c9a5058 1277 } else if(mode==60) {
yabahiro 24:41c23c9a5058 1278 switch(g[3]) {
yabahiro 24:41c23c9a5058 1279 case 98:
yabahiro 24:41c23c9a5058 1280 motor[TIRE_FR].pwm = 30;
yabahiro 24:41c23c9a5058 1281 motor[TIRE_FR].dir = BACK;
yabahiro 24:41c23c9a5058 1282 motor[TIRE_FL].pwm = 30;
yabahiro 24:41c23c9a5058 1283 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1284 motor[TIRE_BR].pwm = 30;
yabahiro 24:41c23c9a5058 1285 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1286 motor[TIRE_BL].pwm = 30;
yabahiro 24:41c23c9a5058 1287 motor[TIRE_BL].dir = FOR;
yabahiro 27:545148741493 1288 if(count>50000) {
yabahiro 27:545148741493 1289 cross++;
yabahiro 27:545148741493 1290 count=0;
yabahiro 24:41c23c9a5058 1291 }
yabahiro 24:41c23c9a5058 1292 mtc2=true;
yabahiro 27:545148741493 1293 if(cross==2) {
yabahiro 24:41c23c9a5058 1294 mode=61;
yabahiro 27:545148741493 1295 count=0;
yabahiro 27:545148741493 1296 cross=0;
yabahiro 24:41c23c9a5058 1297 }
yabahiro 24:41c23c9a5058 1298 break;
yabahiro 24:41c23c9a5058 1299 case 0:
yabahiro 24:41c23c9a5058 1300 motor[TIRE_FR].pwm = 60;
yabahiro 24:41c23c9a5058 1301 motor[TIRE_FR].dir = BACK;
yabahiro 24:41c23c9a5058 1302 motor[TIRE_FL].pwm = 60;
yabahiro 24:41c23c9a5058 1303 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1304 motor[TIRE_BR].pwm = 60;
yabahiro 24:41c23c9a5058 1305 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1306 motor[TIRE_BL].pwm = 60;
yabahiro 24:41c23c9a5058 1307 motor[TIRE_BL].dir = FOR;
yabahiro 24:41c23c9a5058 1308 mtc2=true;
yabahiro 24:41c23c9a5058 1309 break;
yabahiro 24:41c23c9a5058 1310 case 255:
yabahiro 24:41c23c9a5058 1311 motor[TIRE_FR].pwm = 40;
yabahiro 24:41c23c9a5058 1312 motor[TIRE_FR].dir = BACK;
yabahiro 24:41c23c9a5058 1313 motor[TIRE_FL].pwm = 60;
yabahiro 24:41c23c9a5058 1314 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1315 motor[TIRE_BR].pwm = 60;
yabahiro 24:41c23c9a5058 1316 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1317 motor[TIRE_BL].pwm = 40;
yabahiro 24:41c23c9a5058 1318 motor[TIRE_BL].dir = FOR;
yabahiro 24:41c23c9a5058 1319 mtc2=true;
yabahiro 24:41c23c9a5058 1320 break;
yabahiro 24:41c23c9a5058 1321 case 253:
yabahiro 24:41c23c9a5058 1322 motor[TIRE_FR].pwm = 0;
yabahiro 24:41c23c9a5058 1323 motor[TIRE_FR].dir = FREE;
yabahiro 24:41c23c9a5058 1324 motor[TIRE_FL].pwm = 20;
yabahiro 24:41c23c9a5058 1325 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1326 motor[TIRE_BR].pwm = 20;
yabahiro 24:41c23c9a5058 1327 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1328 motor[TIRE_BL].pwm = 0;
yabahiro 24:41c23c9a5058 1329 motor[TIRE_BL].dir = FREE;
yabahiro 24:41c23c9a5058 1330 mtc2=true;
yabahiro 24:41c23c9a5058 1331 break;
yabahiro 24:41c23c9a5058 1332 case 254:
yabahiro 24:41c23c9a5058 1333 motor[TIRE_FR].pwm = 0;
yabahiro 24:41c23c9a5058 1334 motor[TIRE_FR].dir = FREE;
yabahiro 24:41c23c9a5058 1335 motor[TIRE_FL].pwm = 30;
yabahiro 24:41c23c9a5058 1336 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1337 motor[TIRE_BR].pwm = 30;
yabahiro 24:41c23c9a5058 1338 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1339 motor[TIRE_BL].pwm = 0;
yabahiro 24:41c23c9a5058 1340 motor[TIRE_BL].dir = FREE;
yabahiro 24:41c23c9a5058 1341 mtc2=true;
yabahiro 24:41c23c9a5058 1342 break;
yabahiro 24:41c23c9a5058 1343 case 1:
yabahiro 24:41c23c9a5058 1344 motor[TIRE_FR].pwm = 60;
yabahiro 24:41c23c9a5058 1345 motor[TIRE_FR].dir = BACK;
yabahiro 24:41c23c9a5058 1346 motor[TIRE_FL].pwm = 40;
yabahiro 24:41c23c9a5058 1347 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1348 motor[TIRE_BR].pwm = 40;
yabahiro 24:41c23c9a5058 1349 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1350 motor[TIRE_BL].pwm = 60;
yabahiro 24:41c23c9a5058 1351 motor[TIRE_BL].dir = FOR;
yabahiro 24:41c23c9a5058 1352 mtc2=true;
yabahiro 24:41c23c9a5058 1353 break;
yabahiro 24:41c23c9a5058 1354 case 3:
yabahiro 24:41c23c9a5058 1355 motor[TIRE_FR].pwm = 20;
yabahiro 24:41c23c9a5058 1356 motor[TIRE_FR].dir = BACK;
yabahiro 24:41c23c9a5058 1357 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1358 motor[TIRE_FL].dir = FREE;
yabahiro 24:41c23c9a5058 1359 motor[TIRE_BR].pwm = 0;
yabahiro 24:41c23c9a5058 1360 motor[TIRE_BR].dir = FREE;
yabahiro 24:41c23c9a5058 1361 motor[TIRE_BL].pwm = 20;
yabahiro 24:41c23c9a5058 1362 motor[TIRE_BL].dir = FOR;
yabahiro 24:41c23c9a5058 1363 mtc2=true;
yabahiro 24:41c23c9a5058 1364 break;
yabahiro 24:41c23c9a5058 1365 case 2:
yabahiro 24:41c23c9a5058 1366 motor[TIRE_FR].pwm = 30;
yabahiro 24:41c23c9a5058 1367 motor[TIRE_FR].dir = BACK;
yabahiro 24:41c23c9a5058 1368 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1369 motor[TIRE_FL].dir = FREE;
yabahiro 24:41c23c9a5058 1370 motor[TIRE_BR].pwm = 0;
yabahiro 24:41c23c9a5058 1371 motor[TIRE_BR].dir = FREE;
yabahiro 24:41c23c9a5058 1372 motor[TIRE_BL].pwm = 30;
yabahiro 24:41c23c9a5058 1373 motor[TIRE_BL].dir = FOR;
yabahiro 24:41c23c9a5058 1374 mtc2=true;
yabahiro 24:41c23c9a5058 1375 break;
yabahiro 24:41c23c9a5058 1376 }
yabahiro 24:41c23c9a5058 1377 if(g[2]!=98&&mtc2==true) {
yabahiro 24:41c23c9a5058 1378 switch(g[2]) {
yabahiro 24:41c23c9a5058 1379 case 0:
yabahiro 24:41c23c9a5058 1380 mtc2=false;
yabahiro 24:41c23c9a5058 1381 break;
yabahiro 24:41c23c9a5058 1382 case 255:
yabahiro 24:41c23c9a5058 1383 motor[TIRE_FL].pwm += 5;
yabahiro 24:41c23c9a5058 1384 mtc2=false;
yabahiro 24:41c23c9a5058 1385 break;
yabahiro 24:41c23c9a5058 1386 case 253:
yabahiro 24:41c23c9a5058 1387 motor[TIRE_FL].pwm += 10;
yabahiro 24:41c23c9a5058 1388 mtc2=false;
yabahiro 24:41c23c9a5058 1389 break;
yabahiro 24:41c23c9a5058 1390 case 254:
yabahiro 24:41c23c9a5058 1391 motor[TIRE_FL].pwm += 20;
yabahiro 24:41c23c9a5058 1392 motor[TIRE_BL].pwm = 0;
yabahiro 24:41c23c9a5058 1393 mtc2=false;
yabahiro 24:41c23c9a5058 1394 break;
yabahiro 24:41c23c9a5058 1395 case 1:
yabahiro 24:41c23c9a5058 1396 motor[TIRE_BL].pwm += 5;
yabahiro 24:41c23c9a5058 1397 mtc2=false;
yabahiro 24:41c23c9a5058 1398 break;
yabahiro 24:41c23c9a5058 1399 case 3:
yabahiro 24:41c23c9a5058 1400 motor[TIRE_BL].pwm += 10;
yabahiro 24:41c23c9a5058 1401 mtc2=false;
yabahiro 24:41c23c9a5058 1402 break;
yabahiro 24:41c23c9a5058 1403 case 2:
yabahiro 24:41c23c9a5058 1404 motor[TIRE_BL].pwm += 20;
yabahiro 24:41c23c9a5058 1405 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1406 mtc2=false;
yabahiro 24:41c23c9a5058 1407 break;
yabahiro 24:41c23c9a5058 1408 }
yabahiro 24:41c23c9a5058 1409 }
yabahiro 24:41c23c9a5058 1410 } else if(mode==61) {
yabahiro 25:38d4964e8aad 1411 motor[TIRE_FR].pwm = 0;
yabahiro 25:38d4964e8aad 1412 motor[TIRE_FR].dir = FREE;
yabahiro 24:41c23c9a5058 1413 motor[TIRE_FL].pwm = 15;
yabahiro 24:41c23c9a5058 1414 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1415 motor[TIRE_BR].pwm = 15;
yabahiro 24:41c23c9a5058 1416 motor[TIRE_BR].dir = FOR;
yabahiro 25:38d4964e8aad 1417 motor[TIRE_BL].pwm = 0;
yabahiro 25:38d4964e8aad 1418 motor[TIRE_BL].dir = FREE;
yabahiro 27:545148741493 1419 if(count>5000&&g[1]==0) {
yabahiro 27:545148741493 1420 count=0;
yabahiro 24:41c23c9a5058 1421 mode=62;
yabahiro 24:41c23c9a5058 1422 }
yabahiro 24:41c23c9a5058 1423 } else if(mode==62) {
yabahiro 24:41c23c9a5058 1424 motor[TIRE_FR].pwm = 15;
yabahiro 24:41c23c9a5058 1425 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1426 motor[TIRE_FL].pwm = 15;
yabahiro 24:41c23c9a5058 1427 motor[TIRE_FL].dir = FOR;
yabahiro 24:41c23c9a5058 1428 motor[TIRE_BR].pwm = 15;
yabahiro 24:41c23c9a5058 1429 motor[TIRE_BR].dir = BACK;
yabahiro 24:41c23c9a5058 1430 motor[TIRE_BL].pwm = 15;
yabahiro 24:41c23c9a5058 1431 motor[TIRE_BL].dir = BACK;
yabahiro 27:545148741493 1432 if(count>5000&&g[1]==0) {
yabahiro 27:545148741493 1433 count=0;
yabahiro 24:41c23c9a5058 1434 mode=70;
yabahiro 24:41c23c9a5058 1435 }
yabahiro 24:41c23c9a5058 1436 } else if(mode==70) {
yabahiro 24:41c23c9a5058 1437 switch(g[1]) {
yabahiro 28:9cd36721cf83 1438 case 99:
yabahiro 28:9cd36721cf83 1439 if(count>=100000) {
yabahiro 28:9cd36721cf83 1440 mode=100;
yabahiro 28:9cd36721cf83 1441 }
yabahiro 28:9cd36721cf83 1442 break;
yabahiro 24:41c23c9a5058 1443 case 98:
yabahiro 24:41c23c9a5058 1444 motor[TIRE_FR].pwm = 30;
yabahiro 24:41c23c9a5058 1445 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1446 motor[TIRE_FL].pwm = 30;
yabahiro 24:41c23c9a5058 1447 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1448 motor[TIRE_BR].pwm = 30;
yabahiro 24:41c23c9a5058 1449 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1450 motor[TIRE_BL].pwm = 30;
yabahiro 24:41c23c9a5058 1451 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1452 break;
yabahiro 24:41c23c9a5058 1453 case 0:
yabahiro 24:41c23c9a5058 1454 motor[TIRE_FR].pwm = 60;
yabahiro 24:41c23c9a5058 1455 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1456 motor[TIRE_FL].pwm = 60;
yabahiro 24:41c23c9a5058 1457 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1458 motor[TIRE_BR].pwm = 60;
yabahiro 24:41c23c9a5058 1459 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1460 motor[TIRE_BL].pwm = 60;
yabahiro 24:41c23c9a5058 1461 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1462 mtc=true;
yabahiro 24:41c23c9a5058 1463 break;
yabahiro 24:41c23c9a5058 1464 case 255:
yabahiro 24:41c23c9a5058 1465 motor[TIRE_FR].pwm = 60;
yabahiro 24:41c23c9a5058 1466 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1467 motor[TIRE_FL].pwm = 40;
yabahiro 24:41c23c9a5058 1468 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1469 motor[TIRE_BR].pwm = 40;
yabahiro 24:41c23c9a5058 1470 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1471 motor[TIRE_BL].pwm = 60;
yabahiro 24:41c23c9a5058 1472 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1473 mtc=true;
yabahiro 24:41c23c9a5058 1474 break;
yabahiro 24:41c23c9a5058 1475 case 253:
yabahiro 24:41c23c9a5058 1476 motor[TIRE_FR].pwm = 20;
yabahiro 24:41c23c9a5058 1477 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1478 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1479 motor[TIRE_FL].dir = FREE;
yabahiro 24:41c23c9a5058 1480 motor[TIRE_BR].pwm = 0;
yabahiro 24:41c23c9a5058 1481 motor[TIRE_BR].dir = FREE;
yabahiro 24:41c23c9a5058 1482 motor[TIRE_BL].pwm = 20;
yabahiro 24:41c23c9a5058 1483 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1484 mtc=true;
yabahiro 24:41c23c9a5058 1485 break;
yabahiro 24:41c23c9a5058 1486 case 254:
yabahiro 24:41c23c9a5058 1487 motor[TIRE_FR].pwm = 30;
yabahiro 24:41c23c9a5058 1488 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1489 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1490 motor[TIRE_FL].dir = FREE;
yabahiro 24:41c23c9a5058 1491 motor[TIRE_BR].pwm = 0;
yabahiro 24:41c23c9a5058 1492 motor[TIRE_BR].dir = FREE;
yabahiro 24:41c23c9a5058 1493 motor[TIRE_BL].pwm = 30;
yabahiro 24:41c23c9a5058 1494 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1495 mtc=true;
yabahiro 24:41c23c9a5058 1496 break;
yabahiro 24:41c23c9a5058 1497 case 1:
yabahiro 24:41c23c9a5058 1498 motor[TIRE_FR].pwm = 40;
yabahiro 24:41c23c9a5058 1499 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1500 motor[TIRE_FL].pwm = 60;
yabahiro 24:41c23c9a5058 1501 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1502 motor[TIRE_BR].pwm = 60;
yabahiro 24:41c23c9a5058 1503 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1504 motor[TIRE_BL].pwm = 40;
yabahiro 24:41c23c9a5058 1505 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1506 mtc=true;
yabahiro 24:41c23c9a5058 1507 break;
yabahiro 24:41c23c9a5058 1508 case 3:
yabahiro 24:41c23c9a5058 1509 motor[TIRE_FR].pwm = 0;
yabahiro 24:41c23c9a5058 1510 motor[TIRE_FR].dir = FREE;
yabahiro 24:41c23c9a5058 1511 motor[TIRE_FL].pwm = 20;
yabahiro 24:41c23c9a5058 1512 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1513 motor[TIRE_BR].pwm = 20;
yabahiro 24:41c23c9a5058 1514 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1515 motor[TIRE_BL].pwm = 0;
yabahiro 24:41c23c9a5058 1516 motor[TIRE_BL].dir = FREE;
yabahiro 24:41c23c9a5058 1517 mtc=true;
yabahiro 24:41c23c9a5058 1518 break;
yabahiro 24:41c23c9a5058 1519 case 2:
yabahiro 24:41c23c9a5058 1520 motor[TIRE_FR].pwm = 0;
yabahiro 24:41c23c9a5058 1521 motor[TIRE_FR].dir = FREE;
yabahiro 24:41c23c9a5058 1522 motor[TIRE_FL].pwm = 30;
yabahiro 24:41c23c9a5058 1523 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1524 motor[TIRE_BR].pwm = 30;
yabahiro 24:41c23c9a5058 1525 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1526 motor[TIRE_BL].pwm = 0;
yabahiro 24:41c23c9a5058 1527 motor[TIRE_BL].dir = FREE;
yabahiro 24:41c23c9a5058 1528 mtc=true;
yabahiro 24:41c23c9a5058 1529 break;
yabahiro 24:41c23c9a5058 1530 }
yabahiro 24:41c23c9a5058 1531 if(g[1]!=98&&mtc==true) {
yabahiro 24:41c23c9a5058 1532 switch(g[0]) {
yabahiro 24:41c23c9a5058 1533 case 0:
yabahiro 24:41c23c9a5058 1534 mtc=false;
yabahiro 24:41c23c9a5058 1535 break;
yabahiro 24:41c23c9a5058 1536 case 255:
yabahiro 27:545148741493 1537 motor[TIRE_FL].pwm += 5;
yabahiro 24:41c23c9a5058 1538 mtc=false;
yabahiro 24:41c23c9a5058 1539 break;
yabahiro 24:41c23c9a5058 1540 case 253:
yabahiro 27:545148741493 1541 motor[TIRE_FL].pwm += 10;
yabahiro 24:41c23c9a5058 1542 mtc=false;
yabahiro 24:41c23c9a5058 1543 break;
yabahiro 24:41c23c9a5058 1544 case 254:
yabahiro 27:545148741493 1545 motor[TIRE_FL].pwm += 20;
yabahiro 27:545148741493 1546 motor[TIRE_FR].pwm = 0;
yabahiro 24:41c23c9a5058 1547 mtc=false;
yabahiro 24:41c23c9a5058 1548 break;
yabahiro 24:41c23c9a5058 1549 case 1:
yabahiro 27:545148741493 1550 motor[TIRE_FR].pwm += 5;
yabahiro 24:41c23c9a5058 1551 mtc=false;
yabahiro 24:41c23c9a5058 1552 break;
yabahiro 24:41c23c9a5058 1553 case 3:
yabahiro 27:545148741493 1554 motor[TIRE_FR].pwm += 10;
yabahiro 24:41c23c9a5058 1555 mtc=false;
yabahiro 24:41c23c9a5058 1556 break;
yabahiro 24:41c23c9a5058 1557 case 2:
yabahiro 27:545148741493 1558 motor[TIRE_FR].pwm += 20;
yabahiro 27:545148741493 1559 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1560 mtc=false;
yabahiro 24:41c23c9a5058 1561 break;
yabahiro 24:41c23c9a5058 1562 }
yabahiro 24:41c23c9a5058 1563 }
yabahiro 28:9cd36721cf83 1564 } else if(mode==100) {
yabahiro 28:9cd36721cf83 1565 motor[TIRE_FR].pwm = 20;
yabahiro 24:41c23c9a5058 1566 motor[TIRE_FR].dir = FOR;
yabahiro 28:9cd36721cf83 1567 motor[TIRE_FL].pwm = 20;
yabahiro 24:41c23c9a5058 1568 motor[TIRE_FL].dir = BACK;
yabahiro 28:9cd36721cf83 1569 motor[TIRE_BR].pwm = 23;
yabahiro 24:41c23c9a5058 1570 motor[TIRE_BR].dir = FOR;
yabahiro 28:9cd36721cf83 1571 motor[TIRE_BL].pwm = 20;
yabahiro 24:41c23c9a5058 1572 motor[TIRE_BL].dir = BACK;
yabahiro 27:545148741493 1573 } else {
yabahiro 21:1f1e9c585da8 1574 motor[TIRE_FR].pwm = 0;
yabahiro 21:1f1e9c585da8 1575 motor[TIRE_FR].dir = BRAKE;
yabahiro 21:1f1e9c585da8 1576 motor[TIRE_FL].pwm = 0;
yabahiro 21:1f1e9c585da8 1577 motor[TIRE_FL].dir = BRAKE;
yabahiro 21:1f1e9c585da8 1578 motor[TIRE_BR].pwm = 0;
yabahiro 21:1f1e9c585da8 1579 motor[TIRE_BR].dir = BRAKE;
yabahiro 21:1f1e9c585da8 1580 motor[TIRE_BL].pwm = 0;
yabahiro 21:1f1e9c585da8 1581 motor[TIRE_BL].dir = BRAKE;
yabahiro 21:1f1e9c585da8 1582 }
yabahiro 21:1f1e9c585da8 1583
kishibekairohan 13:b6e02d6261d7 1584 }
yabahiro 23:694ecfa97839 1585
kishibekairohan 13:b6e02d6261d7 1586 #endif
kishibekairohan 13:b6e02d6261d7 1587
kishibekairohan 13:b6e02d6261d7 1588 #if USE_PROCESS_NUM>3
yabahiro 21:1f1e9c585da8 1589 static void Process3()
kishibekairohan 13:b6e02d6261d7 1590 {
yabahiro 23:694ecfa97839 1591
kishibekairohan 13:b6e02d6261d7 1592 }
kishibekairohan 13:b6e02d6261d7 1593 #endif
kishibekairohan 13:b6e02d6261d7 1594
kishibekairohan 13:b6e02d6261d7 1595 #if USE_PROCESS_NUM>4
yabahiro 21:1f1e9c585da8 1596 static void Process4()
yabahiro 21:1f1e9c585da8 1597 {
kishibekairohan 15:dfcec98f5aa9 1598
kishibekairohan 13:b6e02d6261d7 1599 }
kishibekairohan 13:b6e02d6261d7 1600 #endif
kishibekairohan 13:b6e02d6261d7 1601
kishibekairohan 13:b6e02d6261d7 1602 #if USE_PROCESS_NUM>5
yabahiro 21:1f1e9c585da8 1603 static void Process5()
yabahiro 21:1f1e9c585da8 1604 {
yabahiro 21:1f1e9c585da8 1605
kishibekairohan 13:b6e02d6261d7 1606 }
kishibekairohan 13:b6e02d6261d7 1607 #endif
kishibekairohan 13:b6e02d6261d7 1608
kishibekairohan 13:b6e02d6261d7 1609 #if USE_PROCESS_NUM>6
yabahiro 21:1f1e9c585da8 1610 static void Process6()
kishibekairohan 13:b6e02d6261d7 1611 {
yabahiro 21:1f1e9c585da8 1612
kishibekairohan 13:b6e02d6261d7 1613 }
kishibekairohan 13:b6e02d6261d7 1614 #endif
kishibekairohan 13:b6e02d6261d7 1615
kishibekairohan 13:b6e02d6261d7 1616 #if USE_PROCESS_NUM>7
kishibekairohan 13:b6e02d6261d7 1617 static void Process7()
kishibekairohan 13:b6e02d6261d7 1618 {
yabahiro 21:1f1e9c585da8 1619
kishibekairohan 12:c09b3e08a316 1620 }
kishibekairohan 12:c09b3e08a316 1621 #endif
kishibekairohan 12:c09b3e08a316 1622
yabahiro 21:1f1e9c585da8 1623 #if USE_PROCESS_NUM>8
kishibekairohan 13:b6e02d6261d7 1624 static void Process8()
kishibekairohan 12:c09b3e08a316 1625 {
yabahiro 21:1f1e9c585da8 1626
kishibekairohan 12:c09b3e08a316 1627 }
kishibekairohan 12:c09b3e08a316 1628 #endif
kishibekairohan 12:c09b3e08a316 1629
kishibekairohan 13:b6e02d6261d7 1630 #if USE_PROCESS_NUM>9
kishibekairohan 13:b6e02d6261d7 1631 static void Process9()
kishibekairohan 12:c09b3e08a316 1632 {
yabahiro 21:1f1e9c585da8 1633
t_yamamoto 0:669ef71cba68 1634 }
t_yamamoto 0:669ef71cba68 1635 #endif
t_yamamoto 0:669ef71cba68 1636 #endif
t_yamamoto 0:669ef71cba68 1637 #pragma endregion PROCESS
t_yamamoto 0:669ef71cba68 1638
t_yamamoto 0:669ef71cba68 1639 static void AllActuatorReset()
t_yamamoto 0:669ef71cba68 1640 {
t_yamamoto 0:669ef71cba68 1641
yabahiro 21:1f1e9c585da8 1642 #ifdef USE_SOLENOID
yabahiro 21:1f1e9c585da8 1643 solenoid.all = ALL_SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 1644 #endif
t_yamamoto 0:669ef71cba68 1645
yabahiro 21:1f1e9c585da8 1646 #ifdef USE_MOTOR
yabahiro 21:1f1e9c585da8 1647 for (uint8_t i = 0; i < MOUNTING_MOTOR_NUM; i++) {
yabahiro 21:1f1e9c585da8 1648 motor[i].dir = FREE;
yabahiro 21:1f1e9c585da8 1649 motor[i].pwm = 0;
yabahiro 21:1f1e9c585da8 1650 }
yabahiro 21:1f1e9c585da8 1651 #endif
t_yamamoto 0:669ef71cba68 1652 }
t_yamamoto 0:669ef71cba68 1653
yabahiro 21:1f1e9c585da8 1654 /*
yabahiro 21:1f1e9c585da8 1655 void BuzzerTimer_func()
yabahiro 21:1f1e9c585da8 1656 {
kishibekairohan 16:3f2c2d89372b 1657 buzzer = !buzzer;
kishibekairohan 17:50dc4b449e69 1658 //LED_DEBUG0 = !LED_DEBUG0;
kishibekairohan 11:028a150943b5 1659 }
yabahiro 21:1f1e9c585da8 1660 */
yabahiro 21:1f1e9c585da8 1661 void TapeLedEms_func()
yabahiro 21:1f1e9c585da8 1662 {
kishibekairohan 16:3f2c2d89372b 1663 sendLedData.code = sendLedData.code == (uint32_t)Red ? (uint32_t)Black : (uint32_t)Red;
kishibekairohan 9:f93fc79a49ea 1664 }
kishibekairohan 16:3f2c2d89372b 1665
kishibekairohan 16:3f2c2d89372b 1666 #pragma region USER-DEFINED-FUNCTIONS
kishibekairohan 16:3f2c2d89372b 1667
kishibekairohan 16:3f2c2d89372b 1668
t_yamamoto 0:669ef71cba68 1669 #pragma endregion