daad

Dependencies:   mbed TrapezoidControl QEI

Committer:
yabahiro
Date:
Mon Sep 16 00:03:18 2019 +0000
Revision:
24:41c23c9a5058
Parent:
23:694ecfa97839
ads

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
kishibekairohan 2:c015739085d3 268
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 21:1f1e9c585da8 273 static void Process0()
yabahiro 21:1f1e9c585da8 274 {
yabahiro 21:1f1e9c585da8 275
t_yamamoto 0:669ef71cba68 276 }
t_yamamoto 0:669ef71cba68 277 #endif
t_yamamoto 0:669ef71cba68 278
t_yamamoto 0:669ef71cba68 279 #if USE_PROCESS_NUM>1
yabahiro 21:1f1e9c585da8 280
yabahiro 21:1f1e9c585da8 281
yabahiro 21:1f1e9c585da8 282 bool dz1=true;
yabahiro 21:1f1e9c585da8 283 bool dz1i=false;
yabahiro 21:1f1e9c585da8 284 bool dz2=true;
yabahiro 21:1f1e9c585da8 285 bool dz2i=false;
yabahiro 21:1f1e9c585da8 286 bool dz3=true;
yabahiro 21:1f1e9c585da8 287 bool dz3i=false;
yabahiro 21:1f1e9c585da8 288 bool dz4=true;
yabahiro 21:1f1e9c585da8 289 bool dz4i=false;
yabahiro 21:1f1e9c585da8 290
yabahiro 23:694ecfa97839 291 int mode=10;
yabahiro 21:1f1e9c585da8 292 int mode1=0;
yabahiro 21:1f1e9c585da8 293 int mode1g0=100000;
yabahiro 21:1f1e9c585da8 294
kishibekairohan 22:c47f29caded6 295
kishibekairohan 16:3f2c2d89372b 296 static void Process1()
t_yamamoto 0:669ef71cba68 297 {
yabahiro 21:1f1e9c585da8 298 mode1g0=100000;
yabahiro 23:694ecfa97839 299 mode=10;
yabahiro 21:1f1e9c585da8 300 mode1=0;
yabahiro 21:1f1e9c585da8 301 motor[TIRE_FR].dir = SetStatus(-omni[controller->AnalogL.Y][14-controller->AnalogL.X] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 302 motor[TIRE_FL].dir = SetStatus(omni[controller->AnalogL.Y][controller->AnalogL.X] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 303 motor[TIRE_BR].dir = SetStatus(-omni[14-controller->AnalogL.X][14-controller->AnalogL.Y] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 304 motor[TIRE_BL].dir = SetStatus(omni[controller->AnalogL.X][14-controller->AnalogL.Y] + curve[controller->AnalogR.X]);
yabahiro 21:1f1e9c585da8 305
yabahiro 21:1f1e9c585da8 306 motor[TIRE_FR].pwm = Setpwm(omni[controller->AnalogL.Y][14-controller->AnalogL.X]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 307 motor[TIRE_FL].pwm = Setpwm(omni[controller->AnalogL.Y][controller->AnalogL.X]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 308 motor[TIRE_BR].pwm = Setpwm(omni[14-controller->AnalogL.X][14-controller->AnalogL.Y]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 309 motor[TIRE_BL].pwm = Setpwm(omni[controller->AnalogL.X][14-controller->AnalogL.Y]+ curve[controller->AnalogR.X])*0.2;
yabahiro 21:1f1e9c585da8 310
yabahiro 21:1f1e9c585da8 311 if(controller->Button.UP||controller->Button.DOWN) {
yabahiro 21:1f1e9c585da8 312
yabahiro 21:1f1e9c585da8 313 if(controller->Button.UP) {
yabahiro 21:1f1e9c585da8 314 motor[MOTOR_0].pwm = 110;
yabahiro 21:1f1e9c585da8 315 motor[MOTOR_0].dir = FOR;
yabahiro 21:1f1e9c585da8 316 }
yabahiro 21:1f1e9c585da8 317 if(controller->Button.DOWN) {
yabahiro 21:1f1e9c585da8 318 motor[MOTOR_0].pwm = 50;
yabahiro 21:1f1e9c585da8 319 motor[MOTOR_0].dir = BACK;
yabahiro 21:1f1e9c585da8 320 }
yabahiro 21:1f1e9c585da8 321 } else {
yabahiro 21:1f1e9c585da8 322 motor[MOTOR_0].pwm = 0;
yabahiro 21:1f1e9c585da8 323 motor[MOTOR_0].dir = BRAKE;
yabahiro 21:1f1e9c585da8 324 }
yabahiro 21:1f1e9c585da8 325 if(controller->Button.X) {
yabahiro 21:1f1e9c585da8 326 if(dz1==true) {
yabahiro 21:1f1e9c585da8 327 if(dz1i==false) {
yabahiro 21:1f1e9c585da8 328 solenoid.solenoid1 = SOLENOID_ON;
yabahiro 21:1f1e9c585da8 329 dz1i=true;
yabahiro 21:1f1e9c585da8 330 } else {
yabahiro 21:1f1e9c585da8 331 solenoid.solenoid1 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 332 dz1i=false;
yabahiro 21:1f1e9c585da8 333 }
yabahiro 21:1f1e9c585da8 334 dz1=false;
yabahiro 21:1f1e9c585da8 335 }
yabahiro 21:1f1e9c585da8 336 } else {
yabahiro 21:1f1e9c585da8 337 dz1=true;
yabahiro 21:1f1e9c585da8 338 }
yabahiro 21:1f1e9c585da8 339
yabahiro 21:1f1e9c585da8 340 if(controller->Button.Y) {
yabahiro 21:1f1e9c585da8 341 if(dz2==true) {
yabahiro 21:1f1e9c585da8 342 if(dz2i==false) {
yabahiro 21:1f1e9c585da8 343 solenoid.solenoid2 = SOLENOID_ON;
yabahiro 21:1f1e9c585da8 344 dz2i=true;
yabahiro 21:1f1e9c585da8 345 } else {
yabahiro 21:1f1e9c585da8 346 solenoid.solenoid2 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 347 dz2i=false;
yabahiro 21:1f1e9c585da8 348 }
yabahiro 21:1f1e9c585da8 349 dz2=false;
yabahiro 21:1f1e9c585da8 350 }
yabahiro 21:1f1e9c585da8 351 } else {
yabahiro 21:1f1e9c585da8 352 dz2=true;
yabahiro 21:1f1e9c585da8 353 }
yabahiro 21:1f1e9c585da8 354
yabahiro 21:1f1e9c585da8 355 if(controller->Button.A) {
yabahiro 21:1f1e9c585da8 356 if(dz3==true) {
yabahiro 21:1f1e9c585da8 357 if(dz3i==false) {
yabahiro 21:1f1e9c585da8 358 solenoid.solenoid3 = SOLENOID_ON;
yabahiro 21:1f1e9c585da8 359 dz3i=true;
yabahiro 21:1f1e9c585da8 360 } else {
yabahiro 21:1f1e9c585da8 361 solenoid.solenoid3 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 362 dz3i=false;
yabahiro 21:1f1e9c585da8 363 }
yabahiro 21:1f1e9c585da8 364 dz3=false;
yabahiro 21:1f1e9c585da8 365 }
yabahiro 21:1f1e9c585da8 366 } else {
yabahiro 21:1f1e9c585da8 367 dz3=true;
yabahiro 21:1f1e9c585da8 368 }
yabahiro 21:1f1e9c585da8 369
yabahiro 21:1f1e9c585da8 370 if(controller->Button.B) {
yabahiro 21:1f1e9c585da8 371 if(dz4==true) {
yabahiro 21:1f1e9c585da8 372 if(dz4i==false) {
yabahiro 21:1f1e9c585da8 373 solenoid.solenoid4 = SOLENOID_ON;
yabahiro 21:1f1e9c585da8 374 dz4i=true;
yabahiro 21:1f1e9c585da8 375 } else {
yabahiro 21:1f1e9c585da8 376 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 377 dz4i=false;
yabahiro 21:1f1e9c585da8 378 }
yabahiro 21:1f1e9c585da8 379 dz4=false;
yabahiro 21:1f1e9c585da8 380 }
yabahiro 21:1f1e9c585da8 381 } else {
yabahiro 21:1f1e9c585da8 382 dz4=true;
yabahiro 21:1f1e9c585da8 383 }
yabahiro 21:1f1e9c585da8 384 /*
yabahiro 21:1f1e9c585da8 385 if(controller->Button.RIGHT){
yabahiro 21:1f1e9c585da8 386 motor[MOTOR_1].dir = FOR;
yabahiro 21:1f1e9c585da8 387 motor[MOTOR_1].pwm = 60;
yabahiro 21:1f1e9c585da8 388 if (ARM_1){
yabahiro 21:1f1e9c585da8 389 motor[MOTOR_1].dir = BRAKE;
yabahiro 21:1f1e9c585da8 390 }
yabahiro 21:1f1e9c585da8 391 }
yabahiro 21:1f1e9c585da8 392 else if(controller->Button.LEFT){
yabahiro 21:1f1e9c585da8 393 motor[MOTOR_1].dir = BACK;
yabahiro 21:1f1e9c585da8 394 motor[MOTOR_1].pwm = 60;
yabahiro 21:1f1e9c585da8 395 if (ARM_0){
yabahiro 21:1f1e9c585da8 396 motor[MOTOR_1].dir = BRAKE;
yabahiro 21:1f1e9c585da8 397 }
yabahiro 21:1f1e9c585da8 398 }
yabahiro 21:1f1e9c585da8 399 */
t_yamamoto 0:669ef71cba68 400 }
t_yamamoto 0:669ef71cba68 401 #endif
t_yamamoto 0:669ef71cba68 402
t_yamamoto 0:669ef71cba68 403 #if USE_PROCESS_NUM>2
yabahiro 21:1f1e9c585da8 404 bool mtc=false;
kishibekairohan 22:c47f29caded6 405 //追加
kishibekairohan 22:c47f29caded6 406 bool mtc2 = false;
yabahiro 21:1f1e9c585da8 407
kishibekairohan 16:3f2c2d89372b 408 static void Process2()
yabahiro 21:1f1e9c585da8 409 {
yabahiro 21:1f1e9c585da8 410 // 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 21:1f1e9c585da8 411 mode1g0++;
yabahiro 23:694ecfa97839 412 if(g[0]!=99&&mode==10) {
yabahiro 21:1f1e9c585da8 413 switch(g[0]) {
yabahiro 21:1f1e9c585da8 414 case 98:
yabahiro 21:1f1e9c585da8 415 motor[TIRE_FR].pwm = 30;
yabahiro 21:1f1e9c585da8 416 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 417 motor[TIRE_FL].pwm = 30;
yabahiro 21:1f1e9c585da8 418 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 419 motor[TIRE_BR].pwm = 30;
yabahiro 21:1f1e9c585da8 420 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 421 motor[TIRE_BL].pwm = 30;
yabahiro 21:1f1e9c585da8 422 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 423 if(mode1g0>100000) {
yabahiro 21:1f1e9c585da8 424 mode1++;
yabahiro 21:1f1e9c585da8 425 mode1g0=0;
yabahiro 21:1f1e9c585da8 426 }
yabahiro 21:1f1e9c585da8 427 mtc=true;
yabahiro 21:1f1e9c585da8 428 if(mode1==2) {
yabahiro 23:694ecfa97839 429 mode=11;
yabahiro 23:694ecfa97839 430 mode1g0=0;
yabahiro 21:1f1e9c585da8 431 }
yabahiro 21:1f1e9c585da8 432 break;
yabahiro 21:1f1e9c585da8 433 case 0:
yabahiro 21:1f1e9c585da8 434 motor[TIRE_FR].pwm = 60;
yabahiro 21:1f1e9c585da8 435 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 436 motor[TIRE_FL].pwm = 60;
yabahiro 21:1f1e9c585da8 437 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 438 motor[TIRE_BR].pwm = 60;
yabahiro 21:1f1e9c585da8 439 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 440 motor[TIRE_BL].pwm = 60;
yabahiro 21:1f1e9c585da8 441 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 442 mtc=true;
yabahiro 21:1f1e9c585da8 443 break;
yabahiro 21:1f1e9c585da8 444 case 255:
yabahiro 21:1f1e9c585da8 445 motor[TIRE_FR].pwm = 60;
yabahiro 21:1f1e9c585da8 446 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 447 motor[TIRE_FL].pwm = 40;
yabahiro 21:1f1e9c585da8 448 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 449 motor[TIRE_BR].pwm = 40;
yabahiro 21:1f1e9c585da8 450 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 451 motor[TIRE_BL].pwm = 60;
yabahiro 21:1f1e9c585da8 452 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 453 mtc=true;
yabahiro 21:1f1e9c585da8 454 break;
yabahiro 21:1f1e9c585da8 455 case 253:
yabahiro 21:1f1e9c585da8 456 motor[TIRE_FR].pwm = 20;
yabahiro 21:1f1e9c585da8 457 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 458 motor[TIRE_FL].pwm = 0;
yabahiro 21:1f1e9c585da8 459 motor[TIRE_FL].dir = FREE;
yabahiro 21:1f1e9c585da8 460 motor[TIRE_BR].pwm = 0;
yabahiro 21:1f1e9c585da8 461 motor[TIRE_BR].dir = FREE;
yabahiro 21:1f1e9c585da8 462 motor[TIRE_BL].pwm = 20;
yabahiro 21:1f1e9c585da8 463 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 464 mtc=true;
yabahiro 21:1f1e9c585da8 465 break;
yabahiro 21:1f1e9c585da8 466 case 254:
yabahiro 21:1f1e9c585da8 467 motor[TIRE_FR].pwm = 30;
yabahiro 21:1f1e9c585da8 468 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 469 motor[TIRE_FL].pwm = 0;
yabahiro 21:1f1e9c585da8 470 motor[TIRE_FL].dir = FREE;
yabahiro 21:1f1e9c585da8 471 motor[TIRE_BR].pwm = 0;
yabahiro 21:1f1e9c585da8 472 motor[TIRE_BR].dir = FREE;
yabahiro 21:1f1e9c585da8 473 motor[TIRE_BL].pwm = 30;
yabahiro 21:1f1e9c585da8 474 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 475 mtc=true;
yabahiro 21:1f1e9c585da8 476 break;
yabahiro 21:1f1e9c585da8 477 case 1:
yabahiro 21:1f1e9c585da8 478 motor[TIRE_FR].pwm = 40;
yabahiro 21:1f1e9c585da8 479 motor[TIRE_FR].dir = BACK;
yabahiro 21:1f1e9c585da8 480 motor[TIRE_FL].pwm = 60;
yabahiro 21:1f1e9c585da8 481 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 482 motor[TIRE_BR].pwm = 60;
yabahiro 21:1f1e9c585da8 483 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 484 motor[TIRE_BL].pwm = 40;
yabahiro 21:1f1e9c585da8 485 motor[TIRE_BL].dir = FOR;
yabahiro 21:1f1e9c585da8 486 mtc=true;
yabahiro 21:1f1e9c585da8 487 break;
yabahiro 21:1f1e9c585da8 488 case 3:
yabahiro 21:1f1e9c585da8 489 motor[TIRE_FR].pwm = 0;
yabahiro 21:1f1e9c585da8 490 motor[TIRE_FR].dir = FREE;
yabahiro 21:1f1e9c585da8 491 motor[TIRE_FL].pwm = 20;
yabahiro 21:1f1e9c585da8 492 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 493 motor[TIRE_BR].pwm = 20;
yabahiro 21:1f1e9c585da8 494 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 495 motor[TIRE_BL].pwm = 0;
yabahiro 21:1f1e9c585da8 496 motor[TIRE_BL].dir = FREE;
yabahiro 21:1f1e9c585da8 497 mtc=true;
yabahiro 21:1f1e9c585da8 498 break;
yabahiro 21:1f1e9c585da8 499 case 2:
yabahiro 21:1f1e9c585da8 500 motor[TIRE_FR].pwm = 0;
yabahiro 21:1f1e9c585da8 501 motor[TIRE_FR].dir = FREE;
yabahiro 21:1f1e9c585da8 502 motor[TIRE_FL].pwm = 30;
yabahiro 21:1f1e9c585da8 503 motor[TIRE_FL].dir = FOR;
yabahiro 21:1f1e9c585da8 504 motor[TIRE_BR].pwm = 30;
yabahiro 21:1f1e9c585da8 505 motor[TIRE_BR].dir = BACK;
yabahiro 21:1f1e9c585da8 506 motor[TIRE_BL].pwm = 0;
yabahiro 21:1f1e9c585da8 507 motor[TIRE_BL].dir = FREE;
yabahiro 21:1f1e9c585da8 508 mtc=true;
yabahiro 21:1f1e9c585da8 509 break;
yabahiro 21:1f1e9c585da8 510 }
yabahiro 21:1f1e9c585da8 511 if(g[0]!=98&&mtc==true) {
yabahiro 21:1f1e9c585da8 512 switch(g[1]) {
yabahiro 21:1f1e9c585da8 513 case 0:
yabahiro 21:1f1e9c585da8 514 mtc=false;
yabahiro 21:1f1e9c585da8 515 break;
yabahiro 21:1f1e9c585da8 516 case 255:
yabahiro 21:1f1e9c585da8 517 motor[TIRE_BR].pwm += 5;
yabahiro 21:1f1e9c585da8 518 mtc=false;
yabahiro 21:1f1e9c585da8 519 break;
yabahiro 21:1f1e9c585da8 520 case 253:
yabahiro 21:1f1e9c585da8 521 motor[TIRE_BR].pwm += 10;
yabahiro 21:1f1e9c585da8 522 mtc=false;
yabahiro 21:1f1e9c585da8 523 break;
yabahiro 21:1f1e9c585da8 524 case 254:
yabahiro 21:1f1e9c585da8 525 motor[TIRE_BR].pwm += 20;
yabahiro 21:1f1e9c585da8 526 motor[TIRE_BL].pwm = 0;
yabahiro 21:1f1e9c585da8 527 mtc=false;
yabahiro 21:1f1e9c585da8 528 break;
yabahiro 21:1f1e9c585da8 529 case 1:
yabahiro 21:1f1e9c585da8 530 motor[TIRE_BL].pwm += 5;
yabahiro 21:1f1e9c585da8 531 mtc=false;
yabahiro 21:1f1e9c585da8 532 break;
yabahiro 21:1f1e9c585da8 533 case 3:
yabahiro 21:1f1e9c585da8 534 motor[TIRE_BL].pwm += 10;
yabahiro 21:1f1e9c585da8 535 mtc=false;
yabahiro 21:1f1e9c585da8 536 break;
yabahiro 21:1f1e9c585da8 537 case 2:
yabahiro 21:1f1e9c585da8 538 motor[TIRE_BL].pwm += 20;
yabahiro 21:1f1e9c585da8 539 motor[TIRE_BR].pwm = 0;
yabahiro 21:1f1e9c585da8 540 mtc=false;
yabahiro 21:1f1e9c585da8 541 break;
yabahiro 21:1f1e9c585da8 542 }
yabahiro 21:1f1e9c585da8 543 }
yabahiro 23:694ecfa97839 544 } else if(mode==11) {
yabahiro 23:694ecfa97839 545 motor[TIRE_FR].pwm = 15;
yabahiro 21:1f1e9c585da8 546 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 547 motor[TIRE_FL].pwm = 15;
yabahiro 21:1f1e9c585da8 548 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 549 motor[TIRE_BR].pwm = 15;
yabahiro 21:1f1e9c585da8 550 motor[TIRE_BR].dir = BACK;
yabahiro 23:694ecfa97839 551 motor[TIRE_BL].pwm = 15;
yabahiro 21:1f1e9c585da8 552 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 553 if(mode1g0>5000&&g[2]==0) {
yabahiro 23:694ecfa97839 554 mode1g0=0;
yabahiro 23:694ecfa97839 555 mode=12;
yabahiro 21:1f1e9c585da8 556 }
yabahiro 23:694ecfa97839 557 } else if(mode==12) {
yabahiro 21:1f1e9c585da8 558 motor[TIRE_FR].pwm = 15;
yabahiro 21:1f1e9c585da8 559 motor[TIRE_FR].dir = FOR;
yabahiro 21:1f1e9c585da8 560 motor[TIRE_FL].pwm = 15;
yabahiro 21:1f1e9c585da8 561 motor[TIRE_FL].dir = BACK;
yabahiro 21:1f1e9c585da8 562 motor[TIRE_BR].pwm = 15;
yabahiro 21:1f1e9c585da8 563 motor[TIRE_BR].dir = FOR;
yabahiro 21:1f1e9c585da8 564 motor[TIRE_BL].pwm = 15;
yabahiro 21:1f1e9c585da8 565 motor[TIRE_BL].dir = BACK;
yabahiro 21:1f1e9c585da8 566 mode1g0++;
yabahiro 21:1f1e9c585da8 567 if(mode1g0>10000&&g[2]==0) {
yabahiro 23:694ecfa97839 568 mode1g0=0;
yabahiro 23:694ecfa97839 569 mode1=0;
yabahiro 23:694ecfa97839 570 mode=20;
yabahiro 21:1f1e9c585da8 571 }
yabahiro 23:694ecfa97839 572 } else if(mode==20) {
yabahiro 23:694ecfa97839 573 switch(g[2]) {
kishibekairohan 22:c47f29caded6 574 case 98:
kishibekairohan 22:c47f29caded6 575 motor[TIRE_FR].pwm = 30;
kishibekairohan 22:c47f29caded6 576 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 577 motor[TIRE_FL].pwm = 30;
kishibekairohan 22:c47f29caded6 578 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 579 motor[TIRE_BR].pwm = 30;
kishibekairohan 22:c47f29caded6 580 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 581 motor[TIRE_BL].pwm = 30;
kishibekairohan 22:c47f29caded6 582 motor[TIRE_BL].dir = BACK;
kishibekairohan 22:c47f29caded6 583 if(mode1g0>100000) {
kishibekairohan 22:c47f29caded6 584 mode1++;
kishibekairohan 22:c47f29caded6 585 mode1g0=0;
kishibekairohan 22:c47f29caded6 586 }
kishibekairohan 22:c47f29caded6 587 mtc2=true;
yabahiro 23:694ecfa97839 588 if(mode1==3) {
yabahiro 23:694ecfa97839 589 mode=21;
yabahiro 23:694ecfa97839 590 mode1g0=0;
yabahiro 23:694ecfa97839 591 mode1=0;
kishibekairohan 22:c47f29caded6 592 }
kishibekairohan 22:c47f29caded6 593 break;
kishibekairohan 22:c47f29caded6 594 case 0:
kishibekairohan 22:c47f29caded6 595 motor[TIRE_FR].pwm = 60;
kishibekairohan 22:c47f29caded6 596 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 597 motor[TIRE_FL].pwm = 60;
kishibekairohan 22:c47f29caded6 598 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 599 motor[TIRE_BR].pwm = 60;
kishibekairohan 22:c47f29caded6 600 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 601 motor[TIRE_BL].pwm = 60;
kishibekairohan 22:c47f29caded6 602 motor[TIRE_BL].dir = BACK;
kishibekairohan 22:c47f29caded6 603 mtc2=true;
kishibekairohan 22:c47f29caded6 604 break;
kishibekairohan 22:c47f29caded6 605 case 255:
kishibekairohan 22:c47f29caded6 606 motor[TIRE_FR].pwm = 40;
kishibekairohan 22:c47f29caded6 607 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 608 motor[TIRE_FL].pwm = 60;
kishibekairohan 22:c47f29caded6 609 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 610 motor[TIRE_BR].pwm = 60;
kishibekairohan 22:c47f29caded6 611 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 612 motor[TIRE_BL].pwm = 40;
kishibekairohan 22:c47f29caded6 613 motor[TIRE_BL].dir = BACK;
kishibekairohan 22:c47f29caded6 614 mtc2=true;
kishibekairohan 22:c47f29caded6 615 break;
kishibekairohan 22:c47f29caded6 616 case 253:
kishibekairohan 22:c47f29caded6 617 motor[TIRE_FR].pwm = 0;
kishibekairohan 22:c47f29caded6 618 motor[TIRE_FR].dir = FREE;
kishibekairohan 22:c47f29caded6 619 motor[TIRE_FL].pwm = 20;
kishibekairohan 22:c47f29caded6 620 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 621 motor[TIRE_BR].pwm = 20;
kishibekairohan 22:c47f29caded6 622 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 623 motor[TIRE_BL].pwm = 0;
kishibekairohan 22:c47f29caded6 624 motor[TIRE_BL].dir = FREE;
kishibekairohan 22:c47f29caded6 625 mtc2=true;
kishibekairohan 22:c47f29caded6 626 break;
kishibekairohan 22:c47f29caded6 627 case 254:
kishibekairohan 22:c47f29caded6 628 motor[TIRE_FR].pwm = 0;
kishibekairohan 22:c47f29caded6 629 motor[TIRE_FR].dir = FREE;
kishibekairohan 22:c47f29caded6 630 motor[TIRE_FL].pwm = 30;
kishibekairohan 22:c47f29caded6 631 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 632 motor[TIRE_BR].pwm = 30;
kishibekairohan 22:c47f29caded6 633 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 634 motor[TIRE_BL].pwm = 0;
kishibekairohan 22:c47f29caded6 635 motor[TIRE_BL].dir = FREE;
kishibekairohan 22:c47f29caded6 636 mtc2=true;
kishibekairohan 22:c47f29caded6 637 break;
kishibekairohan 22:c47f29caded6 638 case 1:
kishibekairohan 22:c47f29caded6 639 motor[TIRE_FR].pwm = 60;
kishibekairohan 22:c47f29caded6 640 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 641 motor[TIRE_FL].pwm = 40;
kishibekairohan 22:c47f29caded6 642 motor[TIRE_FL].dir = FOR;
kishibekairohan 22:c47f29caded6 643 motor[TIRE_BR].pwm = 40;
kishibekairohan 22:c47f29caded6 644 motor[TIRE_BR].dir = BACK;
kishibekairohan 22:c47f29caded6 645 motor[TIRE_BL].pwm = 60;
kishibekairohan 22:c47f29caded6 646 motor[TIRE_BL].dir = BACK;
kishibekairohan 22:c47f29caded6 647 mtc2=true;
kishibekairohan 22:c47f29caded6 648 break;
kishibekairohan 22:c47f29caded6 649 case 3:
kishibekairohan 22:c47f29caded6 650 motor[TIRE_FR].pwm = 20;
kishibekairohan 22:c47f29caded6 651 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 652 motor[TIRE_FL].pwm = 0;
kishibekairohan 22:c47f29caded6 653 motor[TIRE_FL].dir = FREE;
kishibekairohan 22:c47f29caded6 654 motor[TIRE_BR].pwm = 0;
kishibekairohan 22:c47f29caded6 655 motor[TIRE_BR].dir = FREE;
kishibekairohan 22:c47f29caded6 656 motor[TIRE_BL].pwm = 20;
kishibekairohan 22:c47f29caded6 657 motor[TIRE_BL].dir = BACK;
kishibekairohan 22:c47f29caded6 658 mtc2=true;
kishibekairohan 22:c47f29caded6 659 break;
kishibekairohan 22:c47f29caded6 660 case 2:
kishibekairohan 22:c47f29caded6 661 motor[TIRE_FR].pwm = 30;
kishibekairohan 22:c47f29caded6 662 motor[TIRE_FR].dir = FOR;
kishibekairohan 22:c47f29caded6 663 motor[TIRE_FL].pwm = 0;
kishibekairohan 22:c47f29caded6 664 motor[TIRE_FL].dir = FREE;
kishibekairohan 22:c47f29caded6 665 motor[TIRE_BR].pwm = 0;
kishibekairohan 22:c47f29caded6 666 motor[TIRE_BR].dir = FREE;
kishibekairohan 22:c47f29caded6 667 motor[TIRE_BL].pwm = 30;
kishibekairohan 22:c47f29caded6 668 motor[TIRE_BL].dir = BACK;
kishibekairohan 22:c47f29caded6 669 mtc2=true;
kishibekairohan 22:c47f29caded6 670 break;
kishibekairohan 22:c47f29caded6 671 }
kishibekairohan 22:c47f29caded6 672 if(g[2]!=98&&mtc2==true) {
kishibekairohan 22:c47f29caded6 673 switch(g[3]) {
kishibekairohan 22:c47f29caded6 674 case 0:
kishibekairohan 22:c47f29caded6 675 mtc2=false;
kishibekairohan 22:c47f29caded6 676 break;
kishibekairohan 22:c47f29caded6 677 case 255:
kishibekairohan 22:c47f29caded6 678 motor[TIRE_BL].pwm += 5;
kishibekairohan 22:c47f29caded6 679 mtc2=false;
kishibekairohan 22:c47f29caded6 680 break;
kishibekairohan 22:c47f29caded6 681 case 253:
kishibekairohan 22:c47f29caded6 682 motor[TIRE_BL].pwm += 10;
kishibekairohan 22:c47f29caded6 683 mtc2=false;
kishibekairohan 22:c47f29caded6 684 break;
kishibekairohan 22:c47f29caded6 685 case 254:
kishibekairohan 22:c47f29caded6 686 motor[TIRE_BL].pwm += 20;
kishibekairohan 22:c47f29caded6 687 motor[TIRE_FL].pwm = 0;
kishibekairohan 22:c47f29caded6 688 mtc2=false;
kishibekairohan 22:c47f29caded6 689 break;
kishibekairohan 22:c47f29caded6 690 case 1:
kishibekairohan 22:c47f29caded6 691 motor[TIRE_FL].pwm += 5;
kishibekairohan 22:c47f29caded6 692 mtc2=false;
kishibekairohan 22:c47f29caded6 693 break;
kishibekairohan 22:c47f29caded6 694 case 3:
kishibekairohan 22:c47f29caded6 695 motor[TIRE_FL].pwm += 10;
kishibekairohan 22:c47f29caded6 696 mtc2=false;
kishibekairohan 22:c47f29caded6 697 break;
kishibekairohan 22:c47f29caded6 698 case 2:
kishibekairohan 22:c47f29caded6 699 motor[TIRE_FL].pwm += 20;
kishibekairohan 22:c47f29caded6 700 motor[TIRE_BL].pwm = 0;
kishibekairohan 22:c47f29caded6 701 mtc2=false;
kishibekairohan 22:c47f29caded6 702 break;
kishibekairohan 22:c47f29caded6 703 }
kishibekairohan 22:c47f29caded6 704 }
yabahiro 23:694ecfa97839 705 } else if(mode==21) {
yabahiro 23:694ecfa97839 706 motor[TIRE_FR].pwm = 15;
yabahiro 23:694ecfa97839 707 motor[TIRE_FR].dir = FOR;
yabahiro 23:694ecfa97839 708 motor[TIRE_FL].pwm = 15;
yabahiro 23:694ecfa97839 709 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 710 motor[TIRE_BR].pwm = 15;
yabahiro 23:694ecfa97839 711 motor[TIRE_BR].dir = BACK;
yabahiro 23:694ecfa97839 712 motor[TIRE_BL].pwm = 15;
yabahiro 23:694ecfa97839 713 motor[TIRE_BL].dir = BACK;
yabahiro 23:694ecfa97839 714 if(mode1g0>5000&&g[0]==0) {
yabahiro 23:694ecfa97839 715 mode1g0=0;
yabahiro 23:694ecfa97839 716 mode=22;
yabahiro 23:694ecfa97839 717 }
yabahiro 23:694ecfa97839 718 } else if(mode==22) {
yabahiro 23:694ecfa97839 719 motor[TIRE_FR].pwm = 15;
yabahiro 23:694ecfa97839 720 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 721 motor[TIRE_FL].pwm = 15;
yabahiro 23:694ecfa97839 722 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 723 motor[TIRE_BR].pwm = 15;
yabahiro 23:694ecfa97839 724 motor[TIRE_BR].dir = FOR;
yabahiro 23:694ecfa97839 725 motor[TIRE_BL].pwm = 15;
yabahiro 23:694ecfa97839 726 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 727 if(mode1g0>10000&&g[0]==0) {
yabahiro 23:694ecfa97839 728 mode1g0=0;
yabahiro 23:694ecfa97839 729 mode1=0;
yabahiro 23:694ecfa97839 730 mode=30;
yabahiro 23:694ecfa97839 731 }
yabahiro 23:694ecfa97839 732 } else if(mode==30) {
yabahiro 23:694ecfa97839 733 switch(g[0]) {
yabahiro 23:694ecfa97839 734 case 98:
yabahiro 23:694ecfa97839 735 motor[TIRE_FR].pwm = 30;
yabahiro 23:694ecfa97839 736 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 737 motor[TIRE_FL].pwm = 30;
yabahiro 23:694ecfa97839 738 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 739 motor[TIRE_BR].pwm = 30;
yabahiro 23:694ecfa97839 740 motor[TIRE_BR].dir = BACK;
yabahiro 23:694ecfa97839 741 motor[TIRE_BL].pwm = 30;
yabahiro 23:694ecfa97839 742 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 743 if(mode1g0>100000) {
yabahiro 23:694ecfa97839 744 mode1++;
yabahiro 23:694ecfa97839 745 mode1g0=0;
yabahiro 23:694ecfa97839 746 }
yabahiro 23:694ecfa97839 747 mtc=true;
yabahiro 23:694ecfa97839 748 if(mode1==1) {
yabahiro 23:694ecfa97839 749 mode=31;
yabahiro 23:694ecfa97839 750 mode1g0=0;
yabahiro 23:694ecfa97839 751 }
yabahiro 23:694ecfa97839 752 break;
yabahiro 23:694ecfa97839 753 case 0:
yabahiro 23:694ecfa97839 754 motor[TIRE_FR].pwm = 60;
yabahiro 23:694ecfa97839 755 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 756 motor[TIRE_FL].pwm = 60;
yabahiro 23:694ecfa97839 757 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 758 motor[TIRE_BR].pwm = 60;
yabahiro 23:694ecfa97839 759 motor[TIRE_BR].dir = BACK;
yabahiro 23:694ecfa97839 760 motor[TIRE_BL].pwm = 60;
yabahiro 23:694ecfa97839 761 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 762 mtc=true;
yabahiro 23:694ecfa97839 763 break;
yabahiro 23:694ecfa97839 764 case 255:
yabahiro 23:694ecfa97839 765 motor[TIRE_FR].pwm = 60;
yabahiro 23:694ecfa97839 766 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 767 motor[TIRE_FL].pwm = 40;
yabahiro 23:694ecfa97839 768 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 769 motor[TIRE_BR].pwm = 40;
yabahiro 23:694ecfa97839 770 motor[TIRE_BR].dir = BACK;
yabahiro 23:694ecfa97839 771 motor[TIRE_BL].pwm = 60;
yabahiro 23:694ecfa97839 772 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 773 mtc=true;
yabahiro 23:694ecfa97839 774 break;
yabahiro 23:694ecfa97839 775 case 253:
yabahiro 23:694ecfa97839 776 motor[TIRE_FR].pwm = 20;
yabahiro 23:694ecfa97839 777 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 778 motor[TIRE_FL].pwm = 0;
yabahiro 23:694ecfa97839 779 motor[TIRE_FL].dir = FREE;
yabahiro 23:694ecfa97839 780 motor[TIRE_BR].pwm = 0;
yabahiro 23:694ecfa97839 781 motor[TIRE_BR].dir = FREE;
yabahiro 23:694ecfa97839 782 motor[TIRE_BL].pwm = 20;
yabahiro 23:694ecfa97839 783 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 784 mtc=true;
yabahiro 23:694ecfa97839 785 break;
yabahiro 23:694ecfa97839 786 case 254:
yabahiro 23:694ecfa97839 787 motor[TIRE_FR].pwm = 30;
yabahiro 23:694ecfa97839 788 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 789 motor[TIRE_FL].pwm = 0;
yabahiro 23:694ecfa97839 790 motor[TIRE_FL].dir = FREE;
yabahiro 23:694ecfa97839 791 motor[TIRE_BR].pwm = 0;
yabahiro 23:694ecfa97839 792 motor[TIRE_BR].dir = FREE;
yabahiro 23:694ecfa97839 793 motor[TIRE_BL].pwm = 30;
yabahiro 23:694ecfa97839 794 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 795 mtc=true;
yabahiro 23:694ecfa97839 796 break;
yabahiro 23:694ecfa97839 797 case 1:
yabahiro 23:694ecfa97839 798 motor[TIRE_FR].pwm = 40;
yabahiro 23:694ecfa97839 799 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 800 motor[TIRE_FL].pwm = 60;
yabahiro 23:694ecfa97839 801 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 802 motor[TIRE_BR].pwm = 60;
yabahiro 23:694ecfa97839 803 motor[TIRE_BR].dir = BACK;
yabahiro 23:694ecfa97839 804 motor[TIRE_BL].pwm = 40;
yabahiro 23:694ecfa97839 805 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 806 mtc=true;
yabahiro 23:694ecfa97839 807 break;
yabahiro 23:694ecfa97839 808 case 3:
yabahiro 23:694ecfa97839 809 motor[TIRE_FR].pwm = 0;
yabahiro 23:694ecfa97839 810 motor[TIRE_FR].dir = FREE;
yabahiro 23:694ecfa97839 811 motor[TIRE_FL].pwm = 20;
yabahiro 23:694ecfa97839 812 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 813 motor[TIRE_BR].pwm = 20;
yabahiro 23:694ecfa97839 814 motor[TIRE_BR].dir = BACK;
yabahiro 23:694ecfa97839 815 motor[TIRE_BL].pwm = 0;
yabahiro 23:694ecfa97839 816 motor[TIRE_BL].dir = FREE;
yabahiro 23:694ecfa97839 817 mtc=true;
yabahiro 23:694ecfa97839 818 break;
yabahiro 23:694ecfa97839 819 case 2:
yabahiro 23:694ecfa97839 820 motor[TIRE_FR].pwm = 0;
yabahiro 23:694ecfa97839 821 motor[TIRE_FR].dir = FREE;
yabahiro 23:694ecfa97839 822 motor[TIRE_FL].pwm = 30;
yabahiro 23:694ecfa97839 823 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 824 motor[TIRE_BR].pwm = 30;
yabahiro 23:694ecfa97839 825 motor[TIRE_BR].dir = BACK;
yabahiro 23:694ecfa97839 826 motor[TIRE_BL].pwm = 0;
yabahiro 23:694ecfa97839 827 motor[TIRE_BL].dir = FREE;
yabahiro 23:694ecfa97839 828 mtc=true;
yabahiro 23:694ecfa97839 829 break;
yabahiro 23:694ecfa97839 830 }
yabahiro 23:694ecfa97839 831 if(g[0]!=98&&mtc==true) {
yabahiro 23:694ecfa97839 832 switch(g[1]) {
yabahiro 23:694ecfa97839 833 case 0:
yabahiro 23:694ecfa97839 834 mtc=false;
yabahiro 23:694ecfa97839 835 break;
yabahiro 23:694ecfa97839 836 case 255:
yabahiro 23:694ecfa97839 837 motor[TIRE_BR].pwm += 5;
yabahiro 23:694ecfa97839 838 mtc=false;
yabahiro 23:694ecfa97839 839 break;
yabahiro 23:694ecfa97839 840 case 253:
yabahiro 23:694ecfa97839 841 motor[TIRE_BR].pwm += 10;
yabahiro 23:694ecfa97839 842 mtc=false;
yabahiro 23:694ecfa97839 843 break;
yabahiro 23:694ecfa97839 844 case 254:
yabahiro 23:694ecfa97839 845 motor[TIRE_BR].pwm += 20;
yabahiro 23:694ecfa97839 846 motor[TIRE_BL].pwm = 0;
yabahiro 23:694ecfa97839 847 mtc=false;
yabahiro 23:694ecfa97839 848 break;
yabahiro 23:694ecfa97839 849 case 1:
yabahiro 23:694ecfa97839 850 motor[TIRE_BL].pwm += 5;
yabahiro 23:694ecfa97839 851 mtc=false;
yabahiro 23:694ecfa97839 852 break;
yabahiro 23:694ecfa97839 853 case 3:
yabahiro 23:694ecfa97839 854 motor[TIRE_BL].pwm += 10;
yabahiro 23:694ecfa97839 855 mtc=false;
yabahiro 23:694ecfa97839 856 break;
yabahiro 23:694ecfa97839 857 case 2:
yabahiro 23:694ecfa97839 858 motor[TIRE_BL].pwm += 20;
yabahiro 23:694ecfa97839 859 motor[TIRE_BR].pwm = 0;
yabahiro 23:694ecfa97839 860 mtc=false;
yabahiro 23:694ecfa97839 861 break;
yabahiro 23:694ecfa97839 862 }
yabahiro 23:694ecfa97839 863 }
yabahiro 23:694ecfa97839 864 } else if(mode==31) {
yabahiro 23:694ecfa97839 865 motor[TIRE_FR].pwm = 15;
yabahiro 23:694ecfa97839 866 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 867 motor[TIRE_FL].pwm = 15;
yabahiro 23:694ecfa97839 868 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 869 motor[TIRE_BR].pwm = 15;
yabahiro 23:694ecfa97839 870 motor[TIRE_BR].dir = BACK;
yabahiro 23:694ecfa97839 871 motor[TIRE_BL].pwm = 15;
yabahiro 23:694ecfa97839 872 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 873 mode1g0++;
yabahiro 23:694ecfa97839 874 if(mode1g0>5000&&g[3]==0) {
yabahiro 23:694ecfa97839 875 mode1g0=0;
yabahiro 23:694ecfa97839 876 mode=32;
yabahiro 23:694ecfa97839 877 }
yabahiro 23:694ecfa97839 878 } else if(mode==32) {
yabahiro 23:694ecfa97839 879 motor[TIRE_FR].pwm = 15;
yabahiro 23:694ecfa97839 880 motor[TIRE_FR].dir = FOR;
yabahiro 23:694ecfa97839 881 motor[TIRE_FL].pwm = 15;
yabahiro 23:694ecfa97839 882 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 883 motor[TIRE_BR].pwm = 15;
yabahiro 23:694ecfa97839 884 motor[TIRE_BR].dir = FOR;
yabahiro 23:694ecfa97839 885 motor[TIRE_BL].pwm = 15;
yabahiro 23:694ecfa97839 886 motor[TIRE_BL].dir = BACK;
yabahiro 23:694ecfa97839 887 mode1g0++;
yabahiro 23:694ecfa97839 888 if(mode1g0>5000&&g[3]==0) {
yabahiro 23:694ecfa97839 889 mode1g0=0;
yabahiro 23:694ecfa97839 890 mode1=0;
yabahiro 23:694ecfa97839 891 mode=40;
yabahiro 23:694ecfa97839 892 }
yabahiro 23:694ecfa97839 893 } else if(mode==40) {
yabahiro 23:694ecfa97839 894 switch(g[3]) {
yabahiro 23:694ecfa97839 895 case 98:
yabahiro 23:694ecfa97839 896 motor[TIRE_FR].pwm = 30;
yabahiro 23:694ecfa97839 897 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 898 motor[TIRE_FL].pwm = 30;
yabahiro 23:694ecfa97839 899 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 900 motor[TIRE_BR].pwm = 30;
yabahiro 23:694ecfa97839 901 motor[TIRE_BR].dir = FOR;
yabahiro 23:694ecfa97839 902 motor[TIRE_BL].pwm = 30;
yabahiro 23:694ecfa97839 903 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 904 if(mode1g0>100000) {
yabahiro 23:694ecfa97839 905 mode1++;
yabahiro 23:694ecfa97839 906 mode1g0=0;
yabahiro 23:694ecfa97839 907 }
yabahiro 23:694ecfa97839 908 mtc2=true;
yabahiro 23:694ecfa97839 909 if(mode1==1) {
yabahiro 23:694ecfa97839 910 mode=41;
yabahiro 23:694ecfa97839 911 mode1g0=0;
yabahiro 23:694ecfa97839 912 mode1=0;
yabahiro 23:694ecfa97839 913 }
yabahiro 23:694ecfa97839 914 break;
yabahiro 23:694ecfa97839 915 case 0:
yabahiro 23:694ecfa97839 916 motor[TIRE_FR].pwm = 60;
yabahiro 23:694ecfa97839 917 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 918 motor[TIRE_FL].pwm = 60;
yabahiro 23:694ecfa97839 919 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 920 motor[TIRE_BR].pwm = 60;
yabahiro 23:694ecfa97839 921 motor[TIRE_BR].dir = FOR;
yabahiro 23:694ecfa97839 922 motor[TIRE_BL].pwm = 60;
yabahiro 23:694ecfa97839 923 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 924 mtc2=true;
yabahiro 23:694ecfa97839 925 break;
yabahiro 23:694ecfa97839 926 case 255:
yabahiro 23:694ecfa97839 927 motor[TIRE_FR].pwm = 40;
yabahiro 23:694ecfa97839 928 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 929 motor[TIRE_FL].pwm = 60;
yabahiro 23:694ecfa97839 930 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 931 motor[TIRE_BR].pwm = 60;
yabahiro 23:694ecfa97839 932 motor[TIRE_BR].dir = FOR;
yabahiro 23:694ecfa97839 933 motor[TIRE_BL].pwm = 40;
yabahiro 23:694ecfa97839 934 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 935 mtc2=true;
yabahiro 23:694ecfa97839 936 break;
yabahiro 23:694ecfa97839 937 case 253:
yabahiro 23:694ecfa97839 938 motor[TIRE_FR].pwm = 0;
yabahiro 23:694ecfa97839 939 motor[TIRE_FR].dir = FREE;
yabahiro 23:694ecfa97839 940 motor[TIRE_FL].pwm = 20;
yabahiro 23:694ecfa97839 941 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 942 motor[TIRE_BR].pwm = 20;
yabahiro 23:694ecfa97839 943 motor[TIRE_BR].dir = FOR;
yabahiro 23:694ecfa97839 944 motor[TIRE_BL].pwm = 0;
yabahiro 23:694ecfa97839 945 motor[TIRE_BL].dir = FREE;
yabahiro 23:694ecfa97839 946 mtc2=true;
yabahiro 23:694ecfa97839 947 break;
yabahiro 23:694ecfa97839 948 case 254:
yabahiro 23:694ecfa97839 949 motor[TIRE_FR].pwm = 0;
yabahiro 23:694ecfa97839 950 motor[TIRE_FR].dir = FREE;
yabahiro 23:694ecfa97839 951 motor[TIRE_FL].pwm = 30;
yabahiro 23:694ecfa97839 952 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 953 motor[TIRE_BR].pwm = 30;
yabahiro 23:694ecfa97839 954 motor[TIRE_BR].dir = FOR;
yabahiro 23:694ecfa97839 955 motor[TIRE_BL].pwm = 0;
yabahiro 23:694ecfa97839 956 motor[TIRE_BL].dir = FREE;
yabahiro 23:694ecfa97839 957 mtc2=true;
yabahiro 23:694ecfa97839 958 break;
yabahiro 23:694ecfa97839 959 case 1:
yabahiro 23:694ecfa97839 960 motor[TIRE_FR].pwm = 60;
yabahiro 23:694ecfa97839 961 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 962 motor[TIRE_FL].pwm = 40;
yabahiro 23:694ecfa97839 963 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 964 motor[TIRE_BR].pwm = 40;
yabahiro 23:694ecfa97839 965 motor[TIRE_BR].dir = FOR;
yabahiro 23:694ecfa97839 966 motor[TIRE_BL].pwm = 60;
yabahiro 23:694ecfa97839 967 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 968 mtc2=true;
yabahiro 23:694ecfa97839 969 break;
yabahiro 23:694ecfa97839 970 case 3:
yabahiro 23:694ecfa97839 971 motor[TIRE_FR].pwm = 20;
yabahiro 23:694ecfa97839 972 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 973 motor[TIRE_FL].pwm = 0;
yabahiro 23:694ecfa97839 974 motor[TIRE_FL].dir = FREE;
yabahiro 23:694ecfa97839 975 motor[TIRE_BR].pwm = 0;
yabahiro 23:694ecfa97839 976 motor[TIRE_BR].dir = FREE;
yabahiro 23:694ecfa97839 977 motor[TIRE_BL].pwm = 20;
yabahiro 23:694ecfa97839 978 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 979 mtc2=true;
yabahiro 23:694ecfa97839 980 break;
yabahiro 23:694ecfa97839 981 case 2:
yabahiro 23:694ecfa97839 982 motor[TIRE_FR].pwm = 30;
yabahiro 23:694ecfa97839 983 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 984 motor[TIRE_FL].pwm = 0;
yabahiro 23:694ecfa97839 985 motor[TIRE_FL].dir = FREE;
yabahiro 23:694ecfa97839 986 motor[TIRE_BR].pwm = 0;
yabahiro 23:694ecfa97839 987 motor[TIRE_BR].dir = FREE;
yabahiro 23:694ecfa97839 988 motor[TIRE_BL].pwm = 30;
yabahiro 23:694ecfa97839 989 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 990 mtc2=true;
yabahiro 23:694ecfa97839 991 break;
yabahiro 23:694ecfa97839 992 }
yabahiro 23:694ecfa97839 993 if(g[2]!=98&&mtc2==true) {
yabahiro 23:694ecfa97839 994 switch(g[2]) {
yabahiro 23:694ecfa97839 995 case 0:
yabahiro 23:694ecfa97839 996 mtc2=false;
yabahiro 23:694ecfa97839 997 break;
yabahiro 23:694ecfa97839 998 case 255:
yabahiro 23:694ecfa97839 999 motor[TIRE_FL].pwm += 5;
yabahiro 23:694ecfa97839 1000 mtc2=false;
yabahiro 23:694ecfa97839 1001 break;
yabahiro 23:694ecfa97839 1002 case 253:
yabahiro 23:694ecfa97839 1003 motor[TIRE_FL].pwm += 10;
yabahiro 23:694ecfa97839 1004 mtc2=false;
yabahiro 23:694ecfa97839 1005 break;
yabahiro 23:694ecfa97839 1006 case 254:
yabahiro 23:694ecfa97839 1007 motor[TIRE_FL].pwm += 20;
yabahiro 23:694ecfa97839 1008 motor[TIRE_BL].pwm = 0;
yabahiro 23:694ecfa97839 1009 mtc2=false;
yabahiro 23:694ecfa97839 1010 break;
yabahiro 23:694ecfa97839 1011 case 1:
yabahiro 23:694ecfa97839 1012 motor[TIRE_BL].pwm += 5;
yabahiro 23:694ecfa97839 1013 mtc2=false;
yabahiro 23:694ecfa97839 1014 break;
yabahiro 23:694ecfa97839 1015 case 3:
yabahiro 23:694ecfa97839 1016 motor[TIRE_BL].pwm += 10;
yabahiro 23:694ecfa97839 1017 mtc2=false;
yabahiro 23:694ecfa97839 1018 break;
yabahiro 23:694ecfa97839 1019 case 2:
yabahiro 23:694ecfa97839 1020 motor[TIRE_BL].pwm += 20;
yabahiro 23:694ecfa97839 1021 motor[TIRE_FL].pwm = 0;
yabahiro 23:694ecfa97839 1022 mtc2=false;
yabahiro 23:694ecfa97839 1023 break;
yabahiro 23:694ecfa97839 1024 }
yabahiro 23:694ecfa97839 1025 }
yabahiro 23:694ecfa97839 1026 } else if(mode==41) {
yabahiro 23:694ecfa97839 1027 motor[TIRE_FR].pwm = 15;
yabahiro 23:694ecfa97839 1028 motor[TIRE_FR].dir = BACK;
yabahiro 23:694ecfa97839 1029 motor[TIRE_FL].pwm = 15;
yabahiro 23:694ecfa97839 1030 motor[TIRE_FL].dir = BACK;
yabahiro 23:694ecfa97839 1031 motor[TIRE_BR].pwm = 15;
yabahiro 23:694ecfa97839 1032 motor[TIRE_BR].dir = FOR;
yabahiro 23:694ecfa97839 1033 motor[TIRE_BL].pwm = 15;
yabahiro 23:694ecfa97839 1034 motor[TIRE_BL].dir = FOR;
yabahiro 23:694ecfa97839 1035 if(mode1g0>5000&&g[1]==0) {
yabahiro 23:694ecfa97839 1036 mode1g0=0;
yabahiro 23:694ecfa97839 1037 mode=42;
yabahiro 23:694ecfa97839 1038 }
yabahiro 23:694ecfa97839 1039 } else if(mode==42) {
yabahiro 23:694ecfa97839 1040 motor[TIRE_FR].pwm = 15;
yabahiro 23:694ecfa97839 1041 motor[TIRE_FR].dir = FOR;
yabahiro 23:694ecfa97839 1042 motor[TIRE_FL].pwm = 15;
yabahiro 23:694ecfa97839 1043 motor[TIRE_FL].dir = FOR;
yabahiro 23:694ecfa97839 1044 motor[TIRE_BR].pwm = 15;
yabahiro 23:694ecfa97839 1045 motor[TIRE_BR].dir = BACK;
yabahiro 23:694ecfa97839 1046 motor[TIRE_BL].pwm = 15;
yabahiro 23:694ecfa97839 1047 motor[TIRE_BL].dir = BACK;
yabahiro 23:694ecfa97839 1048 if(mode1g0>5000&&g[1]==0) {
yabahiro 23:694ecfa97839 1049 mode1g0=0;
yabahiro 23:694ecfa97839 1050 mode=50;
yabahiro 24:41c23c9a5058 1051 }
yabahiro 24:41c23c9a5058 1052 } else if(mode==50) {
yabahiro 24:41c23c9a5058 1053 switch(g[1]) {
yabahiro 24:41c23c9a5058 1054 case 98:
yabahiro 24:41c23c9a5058 1055 motor[TIRE_FR].pwm = 30;
yabahiro 24:41c23c9a5058 1056 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1057 motor[TIRE_FL].pwm = 30;
yabahiro 24:41c23c9a5058 1058 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1059 motor[TIRE_BR].pwm = 30;
yabahiro 24:41c23c9a5058 1060 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1061 motor[TIRE_BL].pwm = 30;
yabahiro 24:41c23c9a5058 1062 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1063 if(mode1g0>100000) {
yabahiro 24:41c23c9a5058 1064 mode1++;
yabahiro 24:41c23c9a5058 1065 mode1g0=0;
yabahiro 24:41c23c9a5058 1066 }
yabahiro 24:41c23c9a5058 1067 mtc=true;
yabahiro 24:41c23c9a5058 1068 if(mode1==1) {
yabahiro 24:41c23c9a5058 1069 mode=51;
yabahiro 24:41c23c9a5058 1070 mode1g0=0;
yabahiro 24:41c23c9a5058 1071 }
yabahiro 24:41c23c9a5058 1072 break;
yabahiro 24:41c23c9a5058 1073 case 0:
yabahiro 24:41c23c9a5058 1074 motor[TIRE_FR].pwm = 60;
yabahiro 24:41c23c9a5058 1075 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1076 motor[TIRE_FL].pwm = 60;
yabahiro 24:41c23c9a5058 1077 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1078 motor[TIRE_BR].pwm = 60;
yabahiro 24:41c23c9a5058 1079 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1080 motor[TIRE_BL].pwm = 60;
yabahiro 24:41c23c9a5058 1081 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1082 mtc=true;
yabahiro 24:41c23c9a5058 1083 break;
yabahiro 24:41c23c9a5058 1084 case 255:
yabahiro 24:41c23c9a5058 1085 motor[TIRE_FR].pwm = 60;
yabahiro 24:41c23c9a5058 1086 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1087 motor[TIRE_FL].pwm = 40;
yabahiro 24:41c23c9a5058 1088 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1089 motor[TIRE_BR].pwm = 40;
yabahiro 24:41c23c9a5058 1090 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1091 motor[TIRE_BL].pwm = 60;
yabahiro 24:41c23c9a5058 1092 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1093 mtc=true;
yabahiro 24:41c23c9a5058 1094 break;
yabahiro 24:41c23c9a5058 1095 case 253:
yabahiro 24:41c23c9a5058 1096 motor[TIRE_FR].pwm = 20;
yabahiro 24:41c23c9a5058 1097 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1098 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1099 motor[TIRE_FL].dir = FREE;
yabahiro 24:41c23c9a5058 1100 motor[TIRE_BR].pwm = 0;
yabahiro 24:41c23c9a5058 1101 motor[TIRE_BR].dir = FREE;
yabahiro 24:41c23c9a5058 1102 motor[TIRE_BL].pwm = 20;
yabahiro 24:41c23c9a5058 1103 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1104 mtc=true;
yabahiro 24:41c23c9a5058 1105 break;
yabahiro 24:41c23c9a5058 1106 case 254:
yabahiro 24:41c23c9a5058 1107 motor[TIRE_FR].pwm = 30;
yabahiro 24:41c23c9a5058 1108 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1109 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1110 motor[TIRE_FL].dir = FREE;
yabahiro 24:41c23c9a5058 1111 motor[TIRE_BR].pwm = 0;
yabahiro 24:41c23c9a5058 1112 motor[TIRE_BR].dir = FREE;
yabahiro 24:41c23c9a5058 1113 motor[TIRE_BL].pwm = 30;
yabahiro 24:41c23c9a5058 1114 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1115 mtc=true;
yabahiro 24:41c23c9a5058 1116 break;
yabahiro 24:41c23c9a5058 1117 case 1:
yabahiro 24:41c23c9a5058 1118 motor[TIRE_FR].pwm = 40;
yabahiro 24:41c23c9a5058 1119 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1120 motor[TIRE_FL].pwm = 60;
yabahiro 24:41c23c9a5058 1121 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1122 motor[TIRE_BR].pwm = 60;
yabahiro 24:41c23c9a5058 1123 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1124 motor[TIRE_BL].pwm = 40;
yabahiro 24:41c23c9a5058 1125 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1126 mtc=true;
yabahiro 24:41c23c9a5058 1127 break;
yabahiro 24:41c23c9a5058 1128 case 3:
yabahiro 24:41c23c9a5058 1129 motor[TIRE_FR].pwm = 0;
yabahiro 24:41c23c9a5058 1130 motor[TIRE_FR].dir = FREE;
yabahiro 24:41c23c9a5058 1131 motor[TIRE_FL].pwm = 20;
yabahiro 24:41c23c9a5058 1132 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1133 motor[TIRE_BR].pwm = 20;
yabahiro 24:41c23c9a5058 1134 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1135 motor[TIRE_BL].pwm = 0;
yabahiro 24:41c23c9a5058 1136 motor[TIRE_BL].dir = FREE;
yabahiro 24:41c23c9a5058 1137 mtc=true;
yabahiro 24:41c23c9a5058 1138 break;
yabahiro 24:41c23c9a5058 1139 case 2:
yabahiro 24:41c23c9a5058 1140 motor[TIRE_FR].pwm = 0;
yabahiro 24:41c23c9a5058 1141 motor[TIRE_FR].dir = FREE;
yabahiro 24:41c23c9a5058 1142 motor[TIRE_FL].pwm = 30;
yabahiro 24:41c23c9a5058 1143 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1144 motor[TIRE_BR].pwm = 30;
yabahiro 24:41c23c9a5058 1145 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1146 motor[TIRE_BL].pwm = 0;
yabahiro 24:41c23c9a5058 1147 motor[TIRE_BL].dir = FREE;
yabahiro 24:41c23c9a5058 1148 mtc=true;
yabahiro 24:41c23c9a5058 1149 break;
yabahiro 24:41c23c9a5058 1150 }
yabahiro 24:41c23c9a5058 1151 if(g[1]!=98&&mtc==true) {
yabahiro 24:41c23c9a5058 1152 switch(g[0]) {
yabahiro 23:694ecfa97839 1153 case 0:
yabahiro 24:41c23c9a5058 1154 mtc=false;
yabahiro 23:694ecfa97839 1155 break;
yabahiro 23:694ecfa97839 1156 case 255:
yabahiro 24:41c23c9a5058 1157 motor[TIRE_FR].pwm += 5;
yabahiro 24:41c23c9a5058 1158 mtc=false;
yabahiro 23:694ecfa97839 1159 break;
yabahiro 23:694ecfa97839 1160 case 253:
yabahiro 24:41c23c9a5058 1161 motor[TIRE_FR].pwm += 10;
yabahiro 24:41c23c9a5058 1162 mtc=false;
yabahiro 23:694ecfa97839 1163 break;
yabahiro 23:694ecfa97839 1164 case 254:
yabahiro 24:41c23c9a5058 1165 motor[TIRE_FR].pwm += 20;
yabahiro 23:694ecfa97839 1166 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1167 mtc=false;
yabahiro 23:694ecfa97839 1168 break;
yabahiro 23:694ecfa97839 1169 case 1:
yabahiro 24:41c23c9a5058 1170 motor[TIRE_FL].pwm += 5;
yabahiro 24:41c23c9a5058 1171 mtc=false;
yabahiro 23:694ecfa97839 1172 break;
yabahiro 23:694ecfa97839 1173 case 3:
yabahiro 24:41c23c9a5058 1174 motor[TIRE_FL].pwm += 10;
yabahiro 24:41c23c9a5058 1175 mtc=false;
yabahiro 23:694ecfa97839 1176 break;
yabahiro 23:694ecfa97839 1177 case 2:
yabahiro 24:41c23c9a5058 1178 motor[TIRE_FL].pwm += 20;
yabahiro 23:694ecfa97839 1179 motor[TIRE_FR].pwm = 0;
yabahiro 24:41c23c9a5058 1180 mtc=false;
yabahiro 23:694ecfa97839 1181 break;
yabahiro 23:694ecfa97839 1182 }
yabahiro 23:694ecfa97839 1183 }
yabahiro 23:694ecfa97839 1184 } else if(mode==51) {
yabahiro 24:41c23c9a5058 1185 motor[TIRE_FR].pwm = 15;
yabahiro 24:41c23c9a5058 1186 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1187 motor[TIRE_FL].pwm = 15;
yabahiro 24:41c23c9a5058 1188 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1189 motor[TIRE_BR].pwm = 15;
yabahiro 24:41c23c9a5058 1190 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1191 motor[TIRE_BL].pwm = 15;
yabahiro 24:41c23c9a5058 1192 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1193 mode1g0++;
yabahiro 24:41c23c9a5058 1194 if(mode1g0>5000&&g[3]==0) {
yabahiro 24:41c23c9a5058 1195 mode1g0=0;
yabahiro 24:41c23c9a5058 1196 mode=52;
yabahiro 24:41c23c9a5058 1197 }
yabahiro 24:41c23c9a5058 1198 } else if(mode==52) {
yabahiro 24:41c23c9a5058 1199 motor[TIRE_FR].pwm = 15;
yabahiro 24:41c23c9a5058 1200 motor[TIRE_FR].dir = BACK;
yabahiro 24:41c23c9a5058 1201 motor[TIRE_FL].pwm = 15;
yabahiro 24:41c23c9a5058 1202 motor[TIRE_FL].dir = FOR;
yabahiro 24:41c23c9a5058 1203 motor[TIRE_BR].pwm = 15;
yabahiro 24:41c23c9a5058 1204 motor[TIRE_BR].dir = BACK;
yabahiro 24:41c23c9a5058 1205 motor[TIRE_BL].pwm = 15;
yabahiro 24:41c23c9a5058 1206 motor[TIRE_BL].dir = FOR;
yabahiro 24:41c23c9a5058 1207 mode1g0++;
yabahiro 24:41c23c9a5058 1208 if(mode1g0>5000&&g[3]==0) {
yabahiro 24:41c23c9a5058 1209 mode1g0=0;
yabahiro 24:41c23c9a5058 1210 mode1=0;
yabahiro 24:41c23c9a5058 1211 mode=60;
yabahiro 24:41c23c9a5058 1212 }
yabahiro 24:41c23c9a5058 1213 } else if(mode==60) {
yabahiro 24:41c23c9a5058 1214 switch(g[3]) {
yabahiro 24:41c23c9a5058 1215 case 98:
yabahiro 24:41c23c9a5058 1216 motor[TIRE_FR].pwm = 30;
yabahiro 24:41c23c9a5058 1217 motor[TIRE_FR].dir = BACK;
yabahiro 24:41c23c9a5058 1218 motor[TIRE_FL].pwm = 30;
yabahiro 24:41c23c9a5058 1219 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1220 motor[TIRE_BR].pwm = 30;
yabahiro 24:41c23c9a5058 1221 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1222 motor[TIRE_BL].pwm = 30;
yabahiro 24:41c23c9a5058 1223 motor[TIRE_BL].dir = FOR;
yabahiro 24:41c23c9a5058 1224 if(mode1g0>100000) {
yabahiro 24:41c23c9a5058 1225 mode1++;
yabahiro 24:41c23c9a5058 1226 mode1g0=0;
yabahiro 24:41c23c9a5058 1227 }
yabahiro 24:41c23c9a5058 1228 mtc2=true;
yabahiro 24:41c23c9a5058 1229 if(mode1==1) {
yabahiro 24:41c23c9a5058 1230 mode=61;
yabahiro 24:41c23c9a5058 1231 mode1g0=0;
yabahiro 24:41c23c9a5058 1232 mode1=0;
yabahiro 24:41c23c9a5058 1233 }
yabahiro 24:41c23c9a5058 1234 break;
yabahiro 24:41c23c9a5058 1235 case 0:
yabahiro 24:41c23c9a5058 1236 motor[TIRE_FR].pwm = 60;
yabahiro 24:41c23c9a5058 1237 motor[TIRE_FR].dir = BACK;
yabahiro 24:41c23c9a5058 1238 motor[TIRE_FL].pwm = 60;
yabahiro 24:41c23c9a5058 1239 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1240 motor[TIRE_BR].pwm = 60;
yabahiro 24:41c23c9a5058 1241 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1242 motor[TIRE_BL].pwm = 60;
yabahiro 24:41c23c9a5058 1243 motor[TIRE_BL].dir = FOR;
yabahiro 24:41c23c9a5058 1244 mtc2=true;
yabahiro 24:41c23c9a5058 1245 break;
yabahiro 24:41c23c9a5058 1246 case 255:
yabahiro 24:41c23c9a5058 1247 motor[TIRE_FR].pwm = 40;
yabahiro 24:41c23c9a5058 1248 motor[TIRE_FR].dir = BACK;
yabahiro 24:41c23c9a5058 1249 motor[TIRE_FL].pwm = 60;
yabahiro 24:41c23c9a5058 1250 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1251 motor[TIRE_BR].pwm = 60;
yabahiro 24:41c23c9a5058 1252 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1253 motor[TIRE_BL].pwm = 40;
yabahiro 24:41c23c9a5058 1254 motor[TIRE_BL].dir = FOR;
yabahiro 24:41c23c9a5058 1255 mtc2=true;
yabahiro 24:41c23c9a5058 1256 break;
yabahiro 24:41c23c9a5058 1257 case 253:
yabahiro 24:41c23c9a5058 1258 motor[TIRE_FR].pwm = 0;
yabahiro 24:41c23c9a5058 1259 motor[TIRE_FR].dir = FREE;
yabahiro 24:41c23c9a5058 1260 motor[TIRE_FL].pwm = 20;
yabahiro 24:41c23c9a5058 1261 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1262 motor[TIRE_BR].pwm = 20;
yabahiro 24:41c23c9a5058 1263 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1264 motor[TIRE_BL].pwm = 0;
yabahiro 24:41c23c9a5058 1265 motor[TIRE_BL].dir = FREE;
yabahiro 24:41c23c9a5058 1266 mtc2=true;
yabahiro 24:41c23c9a5058 1267 break;
yabahiro 24:41c23c9a5058 1268 case 254:
yabahiro 24:41c23c9a5058 1269 motor[TIRE_FR].pwm = 0;
yabahiro 24:41c23c9a5058 1270 motor[TIRE_FR].dir = FREE;
yabahiro 24:41c23c9a5058 1271 motor[TIRE_FL].pwm = 30;
yabahiro 24:41c23c9a5058 1272 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1273 motor[TIRE_BR].pwm = 30;
yabahiro 24:41c23c9a5058 1274 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1275 motor[TIRE_BL].pwm = 0;
yabahiro 24:41c23c9a5058 1276 motor[TIRE_BL].dir = FREE;
yabahiro 24:41c23c9a5058 1277 mtc2=true;
yabahiro 24:41c23c9a5058 1278 break;
yabahiro 24:41c23c9a5058 1279 case 1:
yabahiro 24:41c23c9a5058 1280 motor[TIRE_FR].pwm = 60;
yabahiro 24:41c23c9a5058 1281 motor[TIRE_FR].dir = BACK;
yabahiro 24:41c23c9a5058 1282 motor[TIRE_FL].pwm = 40;
yabahiro 24:41c23c9a5058 1283 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1284 motor[TIRE_BR].pwm = 40;
yabahiro 24:41c23c9a5058 1285 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1286 motor[TIRE_BL].pwm = 60;
yabahiro 24:41c23c9a5058 1287 motor[TIRE_BL].dir = FOR;
yabahiro 24:41c23c9a5058 1288 mtc2=true;
yabahiro 24:41c23c9a5058 1289 break;
yabahiro 24:41c23c9a5058 1290 case 3:
yabahiro 24:41c23c9a5058 1291 motor[TIRE_FR].pwm = 20;
yabahiro 24:41c23c9a5058 1292 motor[TIRE_FR].dir = BACK;
yabahiro 24:41c23c9a5058 1293 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1294 motor[TIRE_FL].dir = FREE;
yabahiro 24:41c23c9a5058 1295 motor[TIRE_BR].pwm = 0;
yabahiro 24:41c23c9a5058 1296 motor[TIRE_BR].dir = FREE;
yabahiro 24:41c23c9a5058 1297 motor[TIRE_BL].pwm = 20;
yabahiro 24:41c23c9a5058 1298 motor[TIRE_BL].dir = FOR;
yabahiro 24:41c23c9a5058 1299 mtc2=true;
yabahiro 24:41c23c9a5058 1300 break;
yabahiro 24:41c23c9a5058 1301 case 2:
yabahiro 24:41c23c9a5058 1302 motor[TIRE_FR].pwm = 30;
yabahiro 24:41c23c9a5058 1303 motor[TIRE_FR].dir = BACK;
yabahiro 24:41c23c9a5058 1304 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1305 motor[TIRE_FL].dir = FREE;
yabahiro 24:41c23c9a5058 1306 motor[TIRE_BR].pwm = 0;
yabahiro 24:41c23c9a5058 1307 motor[TIRE_BR].dir = FREE;
yabahiro 24:41c23c9a5058 1308 motor[TIRE_BL].pwm = 30;
yabahiro 24:41c23c9a5058 1309 motor[TIRE_BL].dir = FOR;
yabahiro 24:41c23c9a5058 1310 mtc2=true;
yabahiro 24:41c23c9a5058 1311 break;
yabahiro 24:41c23c9a5058 1312 }
yabahiro 24:41c23c9a5058 1313 if(g[2]!=98&&mtc2==true) {
yabahiro 24:41c23c9a5058 1314 switch(g[2]) {
yabahiro 24:41c23c9a5058 1315 case 0:
yabahiro 24:41c23c9a5058 1316 mtc2=false;
yabahiro 24:41c23c9a5058 1317 break;
yabahiro 24:41c23c9a5058 1318 case 255:
yabahiro 24:41c23c9a5058 1319 motor[TIRE_FL].pwm += 5;
yabahiro 24:41c23c9a5058 1320 mtc2=false;
yabahiro 24:41c23c9a5058 1321 break;
yabahiro 24:41c23c9a5058 1322 case 253:
yabahiro 24:41c23c9a5058 1323 motor[TIRE_FL].pwm += 10;
yabahiro 24:41c23c9a5058 1324 mtc2=false;
yabahiro 24:41c23c9a5058 1325 break;
yabahiro 24:41c23c9a5058 1326 case 254:
yabahiro 24:41c23c9a5058 1327 motor[TIRE_FL].pwm += 20;
yabahiro 24:41c23c9a5058 1328 motor[TIRE_BL].pwm = 0;
yabahiro 24:41c23c9a5058 1329 mtc2=false;
yabahiro 24:41c23c9a5058 1330 break;
yabahiro 24:41c23c9a5058 1331 case 1:
yabahiro 24:41c23c9a5058 1332 motor[TIRE_BL].pwm += 5;
yabahiro 24:41c23c9a5058 1333 mtc2=false;
yabahiro 24:41c23c9a5058 1334 break;
yabahiro 24:41c23c9a5058 1335 case 3:
yabahiro 24:41c23c9a5058 1336 motor[TIRE_BL].pwm += 10;
yabahiro 24:41c23c9a5058 1337 mtc2=false;
yabahiro 24:41c23c9a5058 1338 break;
yabahiro 24:41c23c9a5058 1339 case 2:
yabahiro 24:41c23c9a5058 1340 motor[TIRE_BL].pwm += 20;
yabahiro 24:41c23c9a5058 1341 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1342 mtc2=false;
yabahiro 24:41c23c9a5058 1343 break;
yabahiro 24:41c23c9a5058 1344 }
yabahiro 24:41c23c9a5058 1345 }
yabahiro 24:41c23c9a5058 1346 } else if(mode==61) {
yabahiro 24:41c23c9a5058 1347 motor[TIRE_FR].pwm = 15;
yabahiro 24:41c23c9a5058 1348 motor[TIRE_FR].dir = BACK;
yabahiro 24:41c23c9a5058 1349 motor[TIRE_FL].pwm = 15;
yabahiro 24:41c23c9a5058 1350 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1351 motor[TIRE_BR].pwm = 15;
yabahiro 24:41c23c9a5058 1352 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1353 motor[TIRE_BL].pwm = 15;
yabahiro 24:41c23c9a5058 1354 motor[TIRE_BL].dir = FOR;
yabahiro 24:41c23c9a5058 1355 if(mode1g0>5000&&g[1]==0) {
yabahiro 24:41c23c9a5058 1356 mode1g0=0;
yabahiro 24:41c23c9a5058 1357 mode=62;
yabahiro 24:41c23c9a5058 1358 }
yabahiro 24:41c23c9a5058 1359 } else if(mode==62) {
yabahiro 24:41c23c9a5058 1360 motor[TIRE_FR].pwm = 15;
yabahiro 24:41c23c9a5058 1361 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1362 motor[TIRE_FL].pwm = 15;
yabahiro 24:41c23c9a5058 1363 motor[TIRE_FL].dir = FOR;
yabahiro 24:41c23c9a5058 1364 motor[TIRE_BR].pwm = 15;
yabahiro 24:41c23c9a5058 1365 motor[TIRE_BR].dir = BACK;
yabahiro 24:41c23c9a5058 1366 motor[TIRE_BL].pwm = 15;
yabahiro 24:41c23c9a5058 1367 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1368 if(mode1g0>5000&&g[1]==0) {
yabahiro 24:41c23c9a5058 1369 mode1g0=0;
yabahiro 24:41c23c9a5058 1370 mode=70;
yabahiro 24:41c23c9a5058 1371 }
yabahiro 24:41c23c9a5058 1372 } else if(mode==70) {
yabahiro 24:41c23c9a5058 1373 switch(g[1]) {
yabahiro 24:41c23c9a5058 1374 case 98:
yabahiro 24:41c23c9a5058 1375 motor[TIRE_FR].pwm = 30;
yabahiro 24:41c23c9a5058 1376 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1377 motor[TIRE_FL].pwm = 30;
yabahiro 24:41c23c9a5058 1378 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1379 motor[TIRE_BR].pwm = 30;
yabahiro 24:41c23c9a5058 1380 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1381 motor[TIRE_BL].pwm = 30;
yabahiro 24:41c23c9a5058 1382 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1383 if(mode1g0>100000) {
yabahiro 24:41c23c9a5058 1384 mode1++;
yabahiro 24:41c23c9a5058 1385 mode1g0=0;
yabahiro 24:41c23c9a5058 1386 }
yabahiro 24:41c23c9a5058 1387 mtc=true;
yabahiro 24:41c23c9a5058 1388 if(mode1==1) {
yabahiro 24:41c23c9a5058 1389 mode=71;
yabahiro 24:41c23c9a5058 1390 mode1g0=0;
yabahiro 24:41c23c9a5058 1391 }
yabahiro 24:41c23c9a5058 1392 break;
yabahiro 24:41c23c9a5058 1393 case 0:
yabahiro 24:41c23c9a5058 1394 motor[TIRE_FR].pwm = 60;
yabahiro 24:41c23c9a5058 1395 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1396 motor[TIRE_FL].pwm = 60;
yabahiro 24:41c23c9a5058 1397 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1398 motor[TIRE_BR].pwm = 60;
yabahiro 24:41c23c9a5058 1399 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1400 motor[TIRE_BL].pwm = 60;
yabahiro 24:41c23c9a5058 1401 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1402 mtc=true;
yabahiro 24:41c23c9a5058 1403 break;
yabahiro 24:41c23c9a5058 1404 case 255:
yabahiro 24:41c23c9a5058 1405 motor[TIRE_FR].pwm = 60;
yabahiro 24:41c23c9a5058 1406 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1407 motor[TIRE_FL].pwm = 40;
yabahiro 24:41c23c9a5058 1408 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1409 motor[TIRE_BR].pwm = 40;
yabahiro 24:41c23c9a5058 1410 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1411 motor[TIRE_BL].pwm = 60;
yabahiro 24:41c23c9a5058 1412 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1413 mtc=true;
yabahiro 24:41c23c9a5058 1414 break;
yabahiro 24:41c23c9a5058 1415 case 253:
yabahiro 24:41c23c9a5058 1416 motor[TIRE_FR].pwm = 20;
yabahiro 24:41c23c9a5058 1417 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1418 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1419 motor[TIRE_FL].dir = FREE;
yabahiro 24:41c23c9a5058 1420 motor[TIRE_BR].pwm = 0;
yabahiro 24:41c23c9a5058 1421 motor[TIRE_BR].dir = FREE;
yabahiro 24:41c23c9a5058 1422 motor[TIRE_BL].pwm = 20;
yabahiro 24:41c23c9a5058 1423 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1424 mtc=true;
yabahiro 24:41c23c9a5058 1425 break;
yabahiro 24:41c23c9a5058 1426 case 254:
yabahiro 24:41c23c9a5058 1427 motor[TIRE_FR].pwm = 30;
yabahiro 24:41c23c9a5058 1428 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1429 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1430 motor[TIRE_FL].dir = FREE;
yabahiro 24:41c23c9a5058 1431 motor[TIRE_BR].pwm = 0;
yabahiro 24:41c23c9a5058 1432 motor[TIRE_BR].dir = FREE;
yabahiro 24:41c23c9a5058 1433 motor[TIRE_BL].pwm = 30;
yabahiro 24:41c23c9a5058 1434 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1435 mtc=true;
yabahiro 24:41c23c9a5058 1436 break;
yabahiro 24:41c23c9a5058 1437 case 1:
yabahiro 24:41c23c9a5058 1438 motor[TIRE_FR].pwm = 40;
yabahiro 24:41c23c9a5058 1439 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1440 motor[TIRE_FL].pwm = 60;
yabahiro 24:41c23c9a5058 1441 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1442 motor[TIRE_BR].pwm = 60;
yabahiro 24:41c23c9a5058 1443 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1444 motor[TIRE_BL].pwm = 40;
yabahiro 24:41c23c9a5058 1445 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1446 mtc=true;
yabahiro 24:41c23c9a5058 1447 break;
yabahiro 24:41c23c9a5058 1448 case 3:
yabahiro 24:41c23c9a5058 1449 motor[TIRE_FR].pwm = 0;
yabahiro 24:41c23c9a5058 1450 motor[TIRE_FR].dir = FREE;
yabahiro 24:41c23c9a5058 1451 motor[TIRE_FL].pwm = 20;
yabahiro 24:41c23c9a5058 1452 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1453 motor[TIRE_BR].pwm = 20;
yabahiro 24:41c23c9a5058 1454 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1455 motor[TIRE_BL].pwm = 0;
yabahiro 24:41c23c9a5058 1456 motor[TIRE_BL].dir = FREE;
yabahiro 24:41c23c9a5058 1457 mtc=true;
yabahiro 24:41c23c9a5058 1458 break;
yabahiro 24:41c23c9a5058 1459 case 2:
yabahiro 24:41c23c9a5058 1460 motor[TIRE_FR].pwm = 0;
yabahiro 24:41c23c9a5058 1461 motor[TIRE_FR].dir = FREE;
yabahiro 24:41c23c9a5058 1462 motor[TIRE_FL].pwm = 30;
yabahiro 24:41c23c9a5058 1463 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1464 motor[TIRE_BR].pwm = 30;
yabahiro 24:41c23c9a5058 1465 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1466 motor[TIRE_BL].pwm = 0;
yabahiro 24:41c23c9a5058 1467 motor[TIRE_BL].dir = FREE;
yabahiro 24:41c23c9a5058 1468 mtc=true;
yabahiro 24:41c23c9a5058 1469 break;
yabahiro 24:41c23c9a5058 1470 }
yabahiro 24:41c23c9a5058 1471 if(g[1]!=98&&mtc==true) {
yabahiro 24:41c23c9a5058 1472 switch(g[0]) {
yabahiro 24:41c23c9a5058 1473 case 0:
yabahiro 24:41c23c9a5058 1474 mtc=false;
yabahiro 24:41c23c9a5058 1475 break;
yabahiro 24:41c23c9a5058 1476 case 255:
yabahiro 24:41c23c9a5058 1477 motor[TIRE_FR].pwm += 5;
yabahiro 24:41c23c9a5058 1478 mtc=false;
yabahiro 24:41c23c9a5058 1479 break;
yabahiro 24:41c23c9a5058 1480 case 253:
yabahiro 24:41c23c9a5058 1481 motor[TIRE_FR].pwm += 10;
yabahiro 24:41c23c9a5058 1482 mtc=false;
yabahiro 24:41c23c9a5058 1483 break;
yabahiro 24:41c23c9a5058 1484 case 254:
yabahiro 24:41c23c9a5058 1485 motor[TIRE_FR].pwm += 20;
yabahiro 24:41c23c9a5058 1486 motor[TIRE_FL].pwm = 0;
yabahiro 24:41c23c9a5058 1487 mtc=false;
yabahiro 24:41c23c9a5058 1488 break;
yabahiro 24:41c23c9a5058 1489 case 1:
yabahiro 24:41c23c9a5058 1490 motor[TIRE_FL].pwm += 5;
yabahiro 24:41c23c9a5058 1491 mtc=false;
yabahiro 24:41c23c9a5058 1492 break;
yabahiro 24:41c23c9a5058 1493 case 3:
yabahiro 24:41c23c9a5058 1494 motor[TIRE_FL].pwm += 10;
yabahiro 24:41c23c9a5058 1495 mtc=false;
yabahiro 24:41c23c9a5058 1496 break;
yabahiro 24:41c23c9a5058 1497 case 2:
yabahiro 24:41c23c9a5058 1498 motor[TIRE_FL].pwm += 20;
yabahiro 24:41c23c9a5058 1499 motor[TIRE_FR].pwm = 0;
yabahiro 24:41c23c9a5058 1500 mtc=false;
yabahiro 24:41c23c9a5058 1501 break;
yabahiro 24:41c23c9a5058 1502 }
yabahiro 24:41c23c9a5058 1503 }
yabahiro 24:41c23c9a5058 1504 } else if(mode==71) {
yabahiro 24:41c23c9a5058 1505 motor[TIRE_FR].pwm = 15;
yabahiro 24:41c23c9a5058 1506 motor[TIRE_FR].dir = FOR;
yabahiro 24:41c23c9a5058 1507 motor[TIRE_FL].pwm = 15;
yabahiro 24:41c23c9a5058 1508 motor[TIRE_FL].dir = BACK;
yabahiro 24:41c23c9a5058 1509 motor[TIRE_BR].pwm = 15;
yabahiro 24:41c23c9a5058 1510 motor[TIRE_BR].dir = FOR;
yabahiro 24:41c23c9a5058 1511 motor[TIRE_BL].pwm = 15;
yabahiro 24:41c23c9a5058 1512 motor[TIRE_BL].dir = BACK;
yabahiro 24:41c23c9a5058 1513 mode1g0++;
yabahiro 24:41c23c9a5058 1514 if(mode1g0>5000&&g[3]==0) {
yabahiro 24:41c23c9a5058 1515 mode1g0=0;
yabahiro 24:41c23c9a5058 1516 mode=72;
yabahiro 24:41c23c9a5058 1517 }
yabahiro 24:41c23c9a5058 1518 } else if(mode==72) {
yabahiro 24:41c23c9a5058 1519 motor[TIRE_FR].pwm = 15;
yabahiro 24:41c23c9a5058 1520 motor[TIRE_FR].dir = BACK;
yabahiro 24:41c23c9a5058 1521 motor[TIRE_FL].pwm = 15;
yabahiro 24:41c23c9a5058 1522 motor[TIRE_FL].dir = FOR;
yabahiro 24:41c23c9a5058 1523 motor[TIRE_BR].pwm = 15;
yabahiro 24:41c23c9a5058 1524 motor[TIRE_BR].dir = BACK;
yabahiro 24:41c23c9a5058 1525 motor[TIRE_BL].pwm = 15;
yabahiro 24:41c23c9a5058 1526 motor[TIRE_BL].dir = FOR;
yabahiro 24:41c23c9a5058 1527 mode1g0++;
yabahiro 24:41c23c9a5058 1528 if(mode1g0>5000&&g[3]==0) {
yabahiro 24:41c23c9a5058 1529 mode1g0=0;
yabahiro 24:41c23c9a5058 1530 mode1=0;
yabahiro 24:41c23c9a5058 1531 mode=80;
yabahiro 24:41c23c9a5058 1532 }
yabahiro 24:41c23c9a5058 1533 } else if(mode==80) {
yabahiro 23:694ecfa97839 1534 motor[TIRE_FR].pwm = 0;
yabahiro 23:694ecfa97839 1535 motor[TIRE_FR].dir = BRAKE;
yabahiro 23:694ecfa97839 1536 motor[TIRE_FL].pwm = 0;
yabahiro 23:694ecfa97839 1537 motor[TIRE_FL].dir = BRAKE;
yabahiro 23:694ecfa97839 1538 motor[TIRE_BR].pwm = 0;
yabahiro 23:694ecfa97839 1539 motor[TIRE_BR].dir = BRAKE;
yabahiro 23:694ecfa97839 1540 motor[TIRE_BL].pwm = 0;
yabahiro 23:694ecfa97839 1541 motor[TIRE_BL].dir = BRAKE;
yabahiro 23:694ecfa97839 1542 } else {
yabahiro 21:1f1e9c585da8 1543 motor[TIRE_FR].pwm = 0;
yabahiro 21:1f1e9c585da8 1544 motor[TIRE_FR].dir = BRAKE;
yabahiro 21:1f1e9c585da8 1545 motor[TIRE_FL].pwm = 0;
yabahiro 21:1f1e9c585da8 1546 motor[TIRE_FL].dir = BRAKE;
yabahiro 21:1f1e9c585da8 1547 motor[TIRE_BR].pwm = 0;
yabahiro 21:1f1e9c585da8 1548 motor[TIRE_BR].dir = BRAKE;
yabahiro 21:1f1e9c585da8 1549 motor[TIRE_BL].pwm = 0;
yabahiro 21:1f1e9c585da8 1550 motor[TIRE_BL].dir = BRAKE;
yabahiro 21:1f1e9c585da8 1551 }
yabahiro 21:1f1e9c585da8 1552
kishibekairohan 13:b6e02d6261d7 1553 }
yabahiro 23:694ecfa97839 1554
kishibekairohan 13:b6e02d6261d7 1555 #endif
kishibekairohan 13:b6e02d6261d7 1556
kishibekairohan 13:b6e02d6261d7 1557 #if USE_PROCESS_NUM>3
yabahiro 21:1f1e9c585da8 1558 static void Process3()
kishibekairohan 13:b6e02d6261d7 1559 {
yabahiro 23:694ecfa97839 1560
kishibekairohan 13:b6e02d6261d7 1561 }
kishibekairohan 13:b6e02d6261d7 1562 #endif
kishibekairohan 13:b6e02d6261d7 1563
kishibekairohan 13:b6e02d6261d7 1564 #if USE_PROCESS_NUM>4
yabahiro 21:1f1e9c585da8 1565 static void Process4()
yabahiro 21:1f1e9c585da8 1566 {
kishibekairohan 15:dfcec98f5aa9 1567
kishibekairohan 13:b6e02d6261d7 1568 }
kishibekairohan 13:b6e02d6261d7 1569 #endif
kishibekairohan 13:b6e02d6261d7 1570
kishibekairohan 13:b6e02d6261d7 1571 #if USE_PROCESS_NUM>5
yabahiro 21:1f1e9c585da8 1572 static void Process5()
yabahiro 21:1f1e9c585da8 1573 {
yabahiro 21:1f1e9c585da8 1574
kishibekairohan 13:b6e02d6261d7 1575 }
kishibekairohan 13:b6e02d6261d7 1576 #endif
kishibekairohan 13:b6e02d6261d7 1577
kishibekairohan 13:b6e02d6261d7 1578 #if USE_PROCESS_NUM>6
yabahiro 21:1f1e9c585da8 1579 static void Process6()
kishibekairohan 13:b6e02d6261d7 1580 {
yabahiro 21:1f1e9c585da8 1581
kishibekairohan 13:b6e02d6261d7 1582 }
kishibekairohan 13:b6e02d6261d7 1583 #endif
kishibekairohan 13:b6e02d6261d7 1584
kishibekairohan 13:b6e02d6261d7 1585 #if USE_PROCESS_NUM>7
kishibekairohan 13:b6e02d6261d7 1586 static void Process7()
kishibekairohan 13:b6e02d6261d7 1587 {
yabahiro 21:1f1e9c585da8 1588
kishibekairohan 12:c09b3e08a316 1589 }
kishibekairohan 12:c09b3e08a316 1590 #endif
kishibekairohan 12:c09b3e08a316 1591
yabahiro 21:1f1e9c585da8 1592 #if USE_PROCESS_NUM>8
kishibekairohan 13:b6e02d6261d7 1593 static void Process8()
kishibekairohan 12:c09b3e08a316 1594 {
yabahiro 21:1f1e9c585da8 1595
kishibekairohan 12:c09b3e08a316 1596 }
kishibekairohan 12:c09b3e08a316 1597 #endif
kishibekairohan 12:c09b3e08a316 1598
kishibekairohan 13:b6e02d6261d7 1599 #if USE_PROCESS_NUM>9
kishibekairohan 13:b6e02d6261d7 1600 static void Process9()
kishibekairohan 12:c09b3e08a316 1601 {
yabahiro 21:1f1e9c585da8 1602
t_yamamoto 0:669ef71cba68 1603 }
t_yamamoto 0:669ef71cba68 1604 #endif
t_yamamoto 0:669ef71cba68 1605 #endif
t_yamamoto 0:669ef71cba68 1606 #pragma endregion PROCESS
t_yamamoto 0:669ef71cba68 1607
t_yamamoto 0:669ef71cba68 1608 static void AllActuatorReset()
t_yamamoto 0:669ef71cba68 1609 {
t_yamamoto 0:669ef71cba68 1610
yabahiro 21:1f1e9c585da8 1611 #ifdef USE_SOLENOID
yabahiro 21:1f1e9c585da8 1612 solenoid.all = ALL_SOLENOID_OFF;
yabahiro 21:1f1e9c585da8 1613 #endif
t_yamamoto 0:669ef71cba68 1614
yabahiro 21:1f1e9c585da8 1615 #ifdef USE_MOTOR
yabahiro 21:1f1e9c585da8 1616 for (uint8_t i = 0; i < MOUNTING_MOTOR_NUM; i++) {
yabahiro 21:1f1e9c585da8 1617 motor[i].dir = FREE;
yabahiro 21:1f1e9c585da8 1618 motor[i].pwm = 0;
yabahiro 21:1f1e9c585da8 1619 }
yabahiro 21:1f1e9c585da8 1620 #endif
t_yamamoto 0:669ef71cba68 1621 }
t_yamamoto 0:669ef71cba68 1622
yabahiro 21:1f1e9c585da8 1623 /*
yabahiro 21:1f1e9c585da8 1624 void BuzzerTimer_func()
yabahiro 21:1f1e9c585da8 1625 {
kishibekairohan 16:3f2c2d89372b 1626 buzzer = !buzzer;
kishibekairohan 17:50dc4b449e69 1627 //LED_DEBUG0 = !LED_DEBUG0;
kishibekairohan 11:028a150943b5 1628 }
yabahiro 21:1f1e9c585da8 1629 */
yabahiro 21:1f1e9c585da8 1630 void TapeLedEms_func()
yabahiro 21:1f1e9c585da8 1631 {
kishibekairohan 16:3f2c2d89372b 1632 sendLedData.code = sendLedData.code == (uint32_t)Red ? (uint32_t)Black : (uint32_t)Red;
kishibekairohan 9:f93fc79a49ea 1633 }
kishibekairohan 16:3f2c2d89372b 1634
kishibekairohan 16:3f2c2d89372b 1635 #pragma region USER-DEFINED-FUNCTIONS
kishibekairohan 16:3f2c2d89372b 1636
kishibekairohan 16:3f2c2d89372b 1637
t_yamamoto 0:669ef71cba68 1638 #pragma endregion