大季 矢花
/
MB2019_main_alltimes_1123
aa
System/Process/Process.cpp@58:bfc38c43dadb, 2019-11-23 (annotated)
- Committer:
- yabahiro
- Date:
- Sat Nov 23 08:59:26 2019 +0000
- Revision:
- 58:bfc38c43dadb
- Parent:
- 57:ccfd26b94d8a
- Child:
- 59:5cd3875fa96a
aa
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
t_yamamoto | 0:669ef71cba68 | 1 | #include "mbed.h" |
t_yamamoto | 0:669ef71cba68 | 2 | #include "Process.h" |
Ryosei | 27:dd9f27fce7d1 | 3 | #include <stdlib.h> |
7ka884 | 4:ba9df71868df | 4 | #include "../../CommonLibraries/PID/PID.h" |
t_yamamoto | 0:669ef71cba68 | 5 | #include "../../Communication/RS485/ActuatorHub/ActuatorHub.h" |
M_souta | 21:e3b58d675c1c | 6 | #include "../../Communication/RS485/LineHub/LineHub.h" |
t_yamamoto | 0:669ef71cba68 | 7 | #include "../../Communication/Controller/Controller.h" |
M_souta | 30:8f092276b2ba | 8 | #include "../../Switch/Switch.h" |
Ryosei | 27:dd9f27fce7d1 | 9 | |
t_yamamoto | 0:669ef71cba68 | 10 | #include "../../LED/LED.h" |
t_yamamoto | 0:669ef71cba68 | 11 | #include "../../Safty/Safty.h" |
t_yamamoto | 0:669ef71cba68 | 12 | #include "../Using.h" |
t_yamamoto | 0:669ef71cba68 | 13 | |
t_yamamoto | 0:669ef71cba68 | 14 | using namespace SWITCH; |
7ka884 | 4:ba9df71868df | 15 | using namespace PID_SPACE; |
Ryosei | 27:dd9f27fce7d1 | 16 | |
M_souta | 21:e3b58d675c1c | 17 | using namespace LINEHUB; |
t_yamamoto | 0:669ef71cba68 | 18 | |
t_yamamoto | 0:669ef71cba68 | 19 | static CONTROLLER::ControllerData *controller; |
t_yamamoto | 0:669ef71cba68 | 20 | ACTUATORHUB::MOTOR::MotorStatus motor[MOUNTING_MOTOR_NUM]; |
t_yamamoto | 0:669ef71cba68 | 21 | ACTUATORHUB::SOLENOID::SolenoidStatus solenoid; |
t_yamamoto | 0:669ef71cba68 | 22 | |
t_yamamoto | 0:669ef71cba68 | 23 | static bool lock; |
t_yamamoto | 0:669ef71cba68 | 24 | static bool processChangeComp; |
t_yamamoto | 0:669ef71cba68 | 25 | static int current; |
t_yamamoto | 0:669ef71cba68 | 26 | |
t_yamamoto | 0:669ef71cba68 | 27 | static void AllActuatorReset(); |
t_yamamoto | 0:669ef71cba68 | 28 | |
t_yamamoto | 0:669ef71cba68 | 29 | #ifdef USE_SUBPROCESS |
t_yamamoto | 0:669ef71cba68 | 30 | static void (*Process[USE_PROCESS_NUM])(void); |
t_yamamoto | 0:669ef71cba68 | 31 | #endif |
t_yamamoto | 0:669ef71cba68 | 32 | |
t_yamamoto | 0:669ef71cba68 | 33 | #pragma region USER-DEFINED_VARIABLES_AND_PROTOTYPE |
t_yamamoto | 0:669ef71cba68 | 34 | |
t_yamamoto | 0:669ef71cba68 | 35 | /*Replace here with the definition code of your variables.*/ |
t_yamamoto | 0:669ef71cba68 | 36 | |
kishibekairohan | 2:c015739085d3 | 37 | |
M_souta | 30:8f092276b2ba | 38 | //Serial pc(USBTX, USBRX); |
kishibekairohan | 16:3f2c2d89372b | 39 | |
Ryosei | 27:dd9f27fce7d1 | 40 | const int omni[15][15] = { |
Ryosei | 27:dd9f27fce7d1 | 41 | { 0, 5, 21, 47, 83, 130, 187, 255, 255, 255, 255, 255, 255, 255, 255 }, |
Ryosei | 27:dd9f27fce7d1 | 42 | { -5, 0, 5, 21, 47, 83, 130, 187, 193, 208, 234, 255, 255, 255, 255 }, |
Ryosei | 27:dd9f27fce7d1 | 43 | { -21, -5, 0, 5, 21, 47, 83, 130, 135, 151, 177, 213, 255, 255, 255 }, |
Ryosei | 27:dd9f27fce7d1 | 44 | { -47, -21, 5, 0, 5, 21, 47, 83, 88, 104, 130, 167, 213, 255, 255 }, |
Ryosei | 27:dd9f27fce7d1 | 45 | { -83, -47, -21, 5, 0, 5, 21, 47, 52, 68, 94, 130, 177, 234, 255 }, |
Ryosei | 27:dd9f27fce7d1 | 46 | { -130, -83, -47, -21, 5, 0, 5, 21, 26, 42, 68, 104, 151, 208, 255 }, |
Ryosei | 27:dd9f27fce7d1 | 47 | { -187, -130, -83, -47, -21, -5, 0, 5, 10, 26, 52, 88, 135, 193, 255 }, |
Ryosei | 27:dd9f27fce7d1 | 48 | { -255, -187, -130, -83, -47, -21, -5, 0, 5, 21, 47, 83, 130, 187, 255 }, |
Ryosei | 27:dd9f27fce7d1 | 49 | { -255, -193, -135, -88, -52, -26, -10, -5, 0, 5, 21, 47, 83, 130, 187 }, |
Ryosei | 27:dd9f27fce7d1 | 50 | { -255, -208, -151, -104, -68, -42, -26, -21, -5, 0, 5, 21, 47, 83, 130 }, |
Ryosei | 27:dd9f27fce7d1 | 51 | { -255, -234, -177, -130, -94, -68, -52, -47, -21, -7, 0, 7, 21, 47, 83 }, |
Ryosei | 27:dd9f27fce7d1 | 52 | { -255, -255, -213, -167, -130, -104, -88, -83, -47, -21, -5, 0, 5, 21, 47 }, |
Ryosei | 27:dd9f27fce7d1 | 53 | { -255, -255, -255, -213, -177, -151, -135, -130, -83, -47, -21, -5, 0, 5, 21 }, |
Ryosei | 27:dd9f27fce7d1 | 54 | { -255, -255, -255, -255, -234, -208, -193, -187, -130, -83, -47, -21, -5, 0, 5 }, |
Ryosei | 27:dd9f27fce7d1 | 55 | { -255, -255, -255, -255, -255, -255, -255, -255, -187, -130, -83, -47, -21, -5, 0 } |
M_souta | 21:e3b58d675c1c | 56 | }; |
M_souta | 21:e3b58d675c1c | 57 | |
M_souta | 21:e3b58d675c1c | 58 | const int curve[15] = { -204, -150, -104, -66, -38, -17, -4, 0, 4, 17, 38, 66, 104, 150, 204 }; |
M_souta | 21:e3b58d675c1c | 59 | |
kishibekairohan | 42:980af34f6fe3 | 60 | uint8_t SetStatus(int pwmVal); |
kishibekairohan | 42:980af34f6fe3 | 61 | uint8_t SetPWM(int pwmVal); |
yabahiro | 33:dd598bb23ad1 | 62 | |
kishibekairohan | 35:33c6cdba5630 | 63 | DigitalIn EMC(PC_13); //非常停止確認用 |
yabahiro | 33:dd598bb23ad1 | 64 | |
yabahiro | 33:dd598bb23ad1 | 65 | bool start_flag = true; |
yabahiro | 33:dd598bb23ad1 | 66 | bool UP_flag = false; |
yabahiro | 33:dd598bb23ad1 | 67 | bool SW_flag = false; |
yabahiro | 33:dd598bb23ad1 | 68 | bool Air_flag = false; |
yabahiro | 33:dd598bb23ad1 | 69 | bool zyouge; |
yabahiro | 33:dd598bb23ad1 | 70 | bool zyougedo; |
yabahiro | 33:dd598bb23ad1 | 71 | bool dz2=true; |
yabahiro | 33:dd598bb23ad1 | 72 | bool dz2i=false; |
yabahiro | 33:dd598bb23ad1 | 73 | bool dz3=true; |
yabahiro | 33:dd598bb23ad1 | 74 | bool dz3i=false; |
yabahiro | 33:dd598bb23ad1 | 75 | bool dz4=true; |
yabahiro | 33:dd598bb23ad1 | 76 | bool dz4i=false; |
yabahiro | 33:dd598bb23ad1 | 77 | bool zone; |
yabahiro | 33:dd598bb23ad1 | 78 | bool through=false; |
yabahiro | 33:dd598bb23ad1 | 79 | bool counts=false; |
yabahiro | 33:dd598bb23ad1 | 80 | bool mtc=false; |
yabahiro | 33:dd598bb23ad1 | 81 | bool mtc2 = false; |
yabahiro | 33:dd598bb23ad1 | 82 | bool emcs=false; |
yabahiro | 33:dd598bb23ad1 | 83 | bool kiri; |
yabahiro | 33:dd598bb23ad1 | 84 | |
yabahiro | 33:dd598bb23ad1 | 85 | int g[8]; |
yabahiro | 33:dd598bb23ad1 | 86 | int Twsh; |
yabahiro | 38:40e7fdf3c694 | 87 | int testmode =0; |
yabahiro | 33:dd598bb23ad1 | 88 | int mode =0; |
yabahiro | 33:dd598bb23ad1 | 89 | int cross=0;//十字数える用 |
yabahiro | 33:dd598bb23ad1 | 90 | int cros=0; |
yabahiro | 33:dd598bb23ad1 | 91 | int countss=100000;//wait代替え |
yabahiro | 55:844ac0974740 | 92 | int num=0; |
yabahiro | 33:dd598bb23ad1 | 93 | |
yabahiro | 33:dd598bb23ad1 | 94 | ///*********PWM調整用*********/// |
kishibekairohan | 41:99a1158f3eca | 95 | |
kishibekairohan | 42:980af34f6fe3 | 96 | int fast = 60; |
yabahiro | 33:dd598bb23ad1 | 97 | int normal = 40; |
yabahiro | 46:68296caae1af | 98 | int slow = 25; |
yabahiro | 33:dd598bb23ad1 | 99 | |
yabahiro | 55:844ac0974740 | 100 | /* |
yabahiro | 55:844ac0974740 | 101 | void Count(); |
yabahiro | 55:844ac0974740 | 102 | Ticker bunzin; |
yabahiro | 55:844ac0974740 | 103 | */ |
yabahiro | 55:844ac0974740 | 104 | |
yabahiro | 56:61ebd4b759b4 | 105 | Timer aime; |
yabahiro | 56:61ebd4b759b4 | 106 | int value; |
yabahiro | 55:844ac0974740 | 107 | |
t_yamamoto | 0:669ef71cba68 | 108 | #pragma endregion USER-DEFINED_VARIABLES_AND_PROTOTYPE |
t_yamamoto | 0:669ef71cba68 | 109 | |
t_yamamoto | 0:669ef71cba68 | 110 | #ifdef USE_SUBPROCESS |
t_yamamoto | 0:669ef71cba68 | 111 | #if USE_PROCESS_NUM>0 |
t_yamamoto | 0:669ef71cba68 | 112 | static void Process0(void); |
t_yamamoto | 0:669ef71cba68 | 113 | #endif |
t_yamamoto | 0:669ef71cba68 | 114 | #if USE_PROCESS_NUM>1 |
t_yamamoto | 0:669ef71cba68 | 115 | static void Process1(void); |
t_yamamoto | 0:669ef71cba68 | 116 | #endif |
t_yamamoto | 0:669ef71cba68 | 117 | #if USE_PROCESS_NUM>2 |
t_yamamoto | 0:669ef71cba68 | 118 | static void Process2(void); |
t_yamamoto | 0:669ef71cba68 | 119 | #endif |
t_yamamoto | 0:669ef71cba68 | 120 | #if USE_PROCESS_NUM>3 |
t_yamamoto | 0:669ef71cba68 | 121 | static void Process3(void); |
t_yamamoto | 0:669ef71cba68 | 122 | #endif |
t_yamamoto | 0:669ef71cba68 | 123 | #if USE_PROCESS_NUM>4 |
t_yamamoto | 0:669ef71cba68 | 124 | static void Process4(void); |
t_yamamoto | 0:669ef71cba68 | 125 | #endif |
t_yamamoto | 0:669ef71cba68 | 126 | #if USE_PROCESS_NUM>5 |
t_yamamoto | 0:669ef71cba68 | 127 | static void Process5(void); |
t_yamamoto | 0:669ef71cba68 | 128 | #endif |
t_yamamoto | 0:669ef71cba68 | 129 | #if USE_PROCESS_NUM>6 |
t_yamamoto | 0:669ef71cba68 | 130 | static void Process6(void); |
t_yamamoto | 0:669ef71cba68 | 131 | #endif |
t_yamamoto | 0:669ef71cba68 | 132 | #if USE_PROCESS_NUM>7 |
t_yamamoto | 0:669ef71cba68 | 133 | static void Process7(void); |
t_yamamoto | 0:669ef71cba68 | 134 | #endif |
t_yamamoto | 0:669ef71cba68 | 135 | #if USE_PROCESS_NUM>8 |
t_yamamoto | 0:669ef71cba68 | 136 | static void Process8(void); |
t_yamamoto | 0:669ef71cba68 | 137 | #endif |
t_yamamoto | 0:669ef71cba68 | 138 | #if USE_PROCESS_NUM>9 |
t_yamamoto | 0:669ef71cba68 | 139 | static void Process9(void); |
t_yamamoto | 0:669ef71cba68 | 140 | #endif |
t_yamamoto | 0:669ef71cba68 | 141 | #endif |
t_yamamoto | 0:669ef71cba68 | 142 | |
t_yamamoto | 0:669ef71cba68 | 143 | void SystemProcessInitialize() |
t_yamamoto | 0:669ef71cba68 | 144 | { |
Ryosei | 27:dd9f27fce7d1 | 145 | #pragma region USER-DEFINED_VARIABLE_INIT |
Ryosei | 27:dd9f27fce7d1 | 146 | /*Replace here with the initialization code of your variables.*/ |
yabahiro | 55:844ac0974740 | 147 | //bunzin.attach(Count,0.001); |
Ryosei | 27:dd9f27fce7d1 | 148 | |
Ryosei | 27:dd9f27fce7d1 | 149 | #pragma endregion USER-DEFINED_VARIABLE_INIT |
Ryosei | 27:dd9f27fce7d1 | 150 | |
Ryosei | 27:dd9f27fce7d1 | 151 | lock = true; |
Ryosei | 27:dd9f27fce7d1 | 152 | processChangeComp = true; |
Ryosei | 27:dd9f27fce7d1 | 153 | current = DEFAULT_PROCESS; |
t_yamamoto | 0:669ef71cba68 | 154 | |
Ryosei | 27:dd9f27fce7d1 | 155 | #ifdef USE_SUBPROCESS |
Ryosei | 27:dd9f27fce7d1 | 156 | #if USE_PROCESS_NUM>0 |
Ryosei | 27:dd9f27fce7d1 | 157 | Process[0] = Process0; |
Ryosei | 27:dd9f27fce7d1 | 158 | #endif |
Ryosei | 27:dd9f27fce7d1 | 159 | #if USE_PROCESS_NUM>1 |
Ryosei | 27:dd9f27fce7d1 | 160 | Process[1] = Process1; |
Ryosei | 27:dd9f27fce7d1 | 161 | #endif |
Ryosei | 27:dd9f27fce7d1 | 162 | #if USE_PROCESS_NUM>2 |
Ryosei | 27:dd9f27fce7d1 | 163 | Process[2] = Process2; |
Ryosei | 27:dd9f27fce7d1 | 164 | #endif |
Ryosei | 27:dd9f27fce7d1 | 165 | #if USE_PROCESS_NUM>3 |
Ryosei | 27:dd9f27fce7d1 | 166 | Process[3] = Process3; |
Ryosei | 27:dd9f27fce7d1 | 167 | #endif |
Ryosei | 27:dd9f27fce7d1 | 168 | #if USE_PROCESS_NUM>4 |
Ryosei | 27:dd9f27fce7d1 | 169 | Process[4] = Process4; |
Ryosei | 27:dd9f27fce7d1 | 170 | #endif |
Ryosei | 27:dd9f27fce7d1 | 171 | #if USE_PROCESS_NUM>5 |
Ryosei | 27:dd9f27fce7d1 | 172 | Process[5] = Process5; |
Ryosei | 27:dd9f27fce7d1 | 173 | #endif |
Ryosei | 27:dd9f27fce7d1 | 174 | #if USE_PROCESS_NUM>6 |
Ryosei | 27:dd9f27fce7d1 | 175 | Process[6] = Process6; |
Ryosei | 27:dd9f27fce7d1 | 176 | #endif |
Ryosei | 27:dd9f27fce7d1 | 177 | #if USE_PROCESS_NUM>7 |
Ryosei | 27:dd9f27fce7d1 | 178 | Process[7] = Process7; |
Ryosei | 27:dd9f27fce7d1 | 179 | #endif |
Ryosei | 27:dd9f27fce7d1 | 180 | #if USE_PROCESS_NUM>8 |
Ryosei | 27:dd9f27fce7d1 | 181 | Process[8] = Process8; |
Ryosei | 27:dd9f27fce7d1 | 182 | #endif |
Ryosei | 27:dd9f27fce7d1 | 183 | #if USE_PROCESS_NUM>9 |
Ryosei | 27:dd9f27fce7d1 | 184 | Process[9] = Process9; |
Ryosei | 27:dd9f27fce7d1 | 185 | #endif |
Ryosei | 27:dd9f27fce7d1 | 186 | #endif |
t_yamamoto | 0:669ef71cba68 | 187 | } |
t_yamamoto | 0:669ef71cba68 | 188 | |
t_yamamoto | 0:669ef71cba68 | 189 | static void SystemProcessUpdate() |
t_yamamoto | 0:669ef71cba68 | 190 | { |
Ryosei | 27:dd9f27fce7d1 | 191 | #ifdef USE_SUBPROCESS |
Ryosei | 27:dd9f27fce7d1 | 192 | if(controller->Button.HOME) lock = false; |
Ryosei | 27:dd9f27fce7d1 | 193 | |
Ryosei | 27:dd9f27fce7d1 | 194 | if(controller->Button.START && processChangeComp) { |
Ryosei | 27:dd9f27fce7d1 | 195 | current++; |
Ryosei | 27:dd9f27fce7d1 | 196 | if (USE_PROCESS_NUM < current) current = USE_PROCESS_NUM; |
Ryosei | 27:dd9f27fce7d1 | 197 | processChangeComp = false; |
Ryosei | 27:dd9f27fce7d1 | 198 | } else if(controller->Button.SELECT && processChangeComp) { |
Ryosei | 27:dd9f27fce7d1 | 199 | current--; |
Ryosei | 27:dd9f27fce7d1 | 200 | if (current < 0) current = 0; |
Ryosei | 27:dd9f27fce7d1 | 201 | processChangeComp = false; |
Ryosei | 27:dd9f27fce7d1 | 202 | } else if(!controller->Button.SELECT && !controller->Button.START) processChangeComp = true; |
Ryosei | 27:dd9f27fce7d1 | 203 | #endif |
Ryosei | 27:dd9f27fce7d1 | 204 | |
Ryosei | 27:dd9f27fce7d1 | 205 | #ifdef USE_MOTOR |
Ryosei | 27:dd9f27fce7d1 | 206 | ACTUATORHUB::MOTOR::Motor::Update(motor); |
Ryosei | 27:dd9f27fce7d1 | 207 | #endif |
Ryosei | 27:dd9f27fce7d1 | 208 | |
Ryosei | 27:dd9f27fce7d1 | 209 | #ifdef USE_SOLENOID |
Ryosei | 27:dd9f27fce7d1 | 210 | ACTUATORHUB::SOLENOID::Solenoid::Update(solenoid); |
Ryosei | 27:dd9f27fce7d1 | 211 | #endif |
Ryosei | 27:dd9f27fce7d1 | 212 | |
Ryosei | 27:dd9f27fce7d1 | 213 | #ifdef USE_RS485 |
Ryosei | 27:dd9f27fce7d1 | 214 | ACTUATORHUB::ActuatorHub::Update(); |
Ryosei | 27:dd9f27fce7d1 | 215 | //LINEHUB::LineHub::Update(); |
Ryosei | 27:dd9f27fce7d1 | 216 | #endif |
Ryosei | 27:dd9f27fce7d1 | 217 | |
Ryosei | 27:dd9f27fce7d1 | 218 | } |
Ryosei | 27:dd9f27fce7d1 | 219 | |
yabahiro | 39:784552c26163 | 220 | int point1; |
Ryosei | 27:dd9f27fce7d1 | 221 | void SystemProcess() |
Ryosei | 27:dd9f27fce7d1 | 222 | { |
yabahiro | 56:61ebd4b759b4 | 223 | |
Ryosei | 27:dd9f27fce7d1 | 224 | SystemProcessInitialize(); |
yabahiro | 33:dd598bb23ad1 | 225 | |
Ryosei | 27:dd9f27fce7d1 | 226 | while(1) { |
yabahiro | 53:694dbd7dfa0e | 227 | //pc.printf("3:%d\n\r",g[3]); |
yabahiro | 46:68296caae1af | 228 | |
yabahiro | 33:dd598bb23ad1 | 229 | if(EMC==0) { |
yabahiro | 33:dd598bb23ad1 | 230 | fast=40; |
yabahiro | 33:dd598bb23ad1 | 231 | normal=30; |
yabahiro | 33:dd598bb23ad1 | 232 | slow=20; |
yabahiro | 33:dd598bb23ad1 | 233 | cross=0;//十字数える用 |
yabahiro | 33:dd598bb23ad1 | 234 | cros=0; |
yabahiro | 33:dd598bb23ad1 | 235 | countss=0;//wait代替え |
yabahiro | 33:dd598bb23ad1 | 236 | UP_flag = false; |
yabahiro | 33:dd598bb23ad1 | 237 | SW_flag = false; |
yabahiro | 33:dd598bb23ad1 | 238 | Air_flag = false; |
yabahiro | 33:dd598bb23ad1 | 239 | zyouge=false; |
yabahiro | 33:dd598bb23ad1 | 240 | zyougedo=false; |
yabahiro | 33:dd598bb23ad1 | 241 | dz2=true; |
yabahiro | 33:dd598bb23ad1 | 242 | dz2i=false; |
yabahiro | 33:dd598bb23ad1 | 243 | dz3=true; |
yabahiro | 33:dd598bb23ad1 | 244 | dz3i=false; |
yabahiro | 33:dd598bb23ad1 | 245 | dz4=true; |
yabahiro | 33:dd598bb23ad1 | 246 | dz4i=false; |
yabahiro | 33:dd598bb23ad1 | 247 | through=false; |
yabahiro | 33:dd598bb23ad1 | 248 | counts=false; |
yabahiro | 33:dd598bb23ad1 | 249 | mtc=false; |
yabahiro | 33:dd598bb23ad1 | 250 | mtc2 = false; |
yabahiro | 33:dd598bb23ad1 | 251 | current = 0; |
yabahiro | 33:dd598bb23ad1 | 252 | SystemProcessInitialize(); |
yabahiro | 33:dd598bb23ad1 | 253 | if(emcs==false) { |
yabahiro | 33:dd598bb23ad1 | 254 | AllActuatorReset(); |
yabahiro | 33:dd598bb23ad1 | 255 | emcs=true; |
yabahiro | 33:dd598bb23ad1 | 256 | } |
yabahiro | 33:dd598bb23ad1 | 257 | } else { |
yabahiro | 33:dd598bb23ad1 | 258 | emcs=false; |
yabahiro | 33:dd598bb23ad1 | 259 | } |
Ryosei | 27:dd9f27fce7d1 | 260 | |
yabahiro | 33:dd598bb23ad1 | 261 | if(mode==0) { |
yabahiro | 33:dd598bb23ad1 | 262 | if(ZoneSW) { |
kishibekairohan | 35:33c6cdba5630 | 263 | LED::LED::TapeledMode(1); |
yabahiro | 33:dd598bb23ad1 | 264 | } else { |
kishibekairohan | 35:33c6cdba5630 | 265 | LED::LED::TapeledMode(2); |
yabahiro | 33:dd598bb23ad1 | 266 | } |
yabahiro | 33:dd598bb23ad1 | 267 | } |
yabahiro | 33:dd598bb23ad1 | 268 | for(int i = 0; i < 8; i++) { |
yabahiro | 33:dd598bb23ad1 | 269 | g[i] = LineHub::GetPara(i); |
yabahiro | 33:dd598bb23ad1 | 270 | } |
yabahiro | 33:dd598bb23ad1 | 271 | if(ThSW) { |
yabahiro | 33:dd598bb23ad1 | 272 | Twsh=1; |
yabahiro | 33:dd598bb23ad1 | 273 | } else { |
yabahiro | 33:dd598bb23ad1 | 274 | Twsh=2; |
yabahiro | 33:dd598bb23ad1 | 275 | } |
yabahiro | 33:dd598bb23ad1 | 276 | |
yabahiro | 33:dd598bb23ad1 | 277 | if(StertSW && start_flag == true) { |
yabahiro | 33:dd598bb23ad1 | 278 | start_flag = false; |
yabahiro | 33:dd598bb23ad1 | 279 | lock = false; |
yabahiro | 33:dd598bb23ad1 | 280 | if(ZoneSW) { |
yabahiro | 33:dd598bb23ad1 | 281 | countss=0; |
yabahiro | 33:dd598bb23ad1 | 282 | mode=1; |
yabahiro | 58:bfc38c43dadb | 283 | aime.start(); |
yabahiro | 57:ccfd26b94d8a | 284 | current = 3;//1119変更した |
yabahiro | 33:dd598bb23ad1 | 285 | |
yabahiro | 33:dd598bb23ad1 | 286 | } else { |
kishibekairohan | 34:2fce61e3ebc4 | 287 | countss = 0; |
yabahiro | 33:dd598bb23ad1 | 288 | mode=1; |
yabahiro | 58:bfc38c43dadb | 289 | aime.start(); |
yabahiro | 56:61ebd4b759b4 | 290 | current = 2; |
yabahiro | 33:dd598bb23ad1 | 291 | } |
yabahiro | 33:dd598bb23ad1 | 292 | } |
yabahiro | 33:dd598bb23ad1 | 293 | if(DWSW||DOSW) { |
yabahiro | 33:dd598bb23ad1 | 294 | if(DWSW) { |
yabahiro | 33:dd598bb23ad1 | 295 | zyouge=true; |
yabahiro | 33:dd598bb23ad1 | 296 | } |
yabahiro | 33:dd598bb23ad1 | 297 | if(DOSW) { |
yabahiro | 33:dd598bb23ad1 | 298 | if(DOLS) { |
yabahiro | 33:dd598bb23ad1 | 299 | motor[MOTOR_0].pwm = 100; |
yabahiro | 33:dd598bb23ad1 | 300 | motor[MOTOR_0].dir = BRAKE; |
yabahiro | 33:dd598bb23ad1 | 301 | } else { |
yabahiro | 38:40e7fdf3c694 | 302 | motor[MOTOR_0].pwm = 200; |
yabahiro | 33:dd598bb23ad1 | 303 | motor[MOTOR_0].dir = BACK; |
yabahiro | 33:dd598bb23ad1 | 304 | } |
yabahiro | 33:dd598bb23ad1 | 305 | } |
yabahiro | 33:dd598bb23ad1 | 306 | } else if(zyouge==false) { |
yabahiro | 33:dd598bb23ad1 | 307 | motor[MOTOR_0].pwm = 100; |
yabahiro | 33:dd598bb23ad1 | 308 | motor[MOTOR_0].dir = BRAKE; |
yabahiro | 33:dd598bb23ad1 | 309 | } |
yabahiro | 33:dd598bb23ad1 | 310 | if(zyouge) { |
yabahiro | 33:dd598bb23ad1 | 311 | if(Twsh==1) { |
yabahiro | 38:40e7fdf3c694 | 312 | motor[MOTOR_0].pwm = 255; |
yabahiro | 33:dd598bb23ad1 | 313 | motor[MOTOR_0].dir = FOR; |
yabahiro | 33:dd598bb23ad1 | 314 | if(UPLS) { |
yabahiro | 33:dd598bb23ad1 | 315 | motor[MOTOR_0].pwm = 100; |
yabahiro | 33:dd598bb23ad1 | 316 | motor[MOTOR_0].dir = BRAKE; |
yabahiro | 33:dd598bb23ad1 | 317 | zyouge=false; |
yabahiro | 33:dd598bb23ad1 | 318 | } |
yabahiro | 33:dd598bb23ad1 | 319 | } |
yabahiro | 33:dd598bb23ad1 | 320 | if(Twsh==2) { |
yabahiro | 33:dd598bb23ad1 | 321 | motor[MOTOR_0].pwm = 245; |
yabahiro | 33:dd598bb23ad1 | 322 | motor[MOTOR_0].dir = FOR; |
yabahiro | 33:dd598bb23ad1 | 323 | if(UPLS2) { |
yabahiro | 33:dd598bb23ad1 | 324 | motor[MOTOR_0].pwm = 100; |
yabahiro | 33:dd598bb23ad1 | 325 | motor[MOTOR_0].dir = BRAKE; |
yabahiro | 33:dd598bb23ad1 | 326 | zyouge=false; |
yabahiro | 33:dd598bb23ad1 | 327 | } |
yabahiro | 33:dd598bb23ad1 | 328 | } |
yabahiro | 33:dd598bb23ad1 | 329 | } |
yabahiro | 33:dd598bb23ad1 | 330 | if(AIRSW) { |
yabahiro | 33:dd598bb23ad1 | 331 | if(SW_flag==false) { |
yabahiro | 33:dd598bb23ad1 | 332 | if(Air_flag==false) { |
yabahiro | 33:dd598bb23ad1 | 333 | solenoid.solenoid3 = SOLENOID_ON; |
yabahiro | 33:dd598bb23ad1 | 334 | Air_flag=true; |
yabahiro | 33:dd598bb23ad1 | 335 | SW_flag=true; |
yabahiro | 33:dd598bb23ad1 | 336 | } else { |
yabahiro | 33:dd598bb23ad1 | 337 | solenoid.solenoid3 = SOLENOID_OFF; |
yabahiro | 33:dd598bb23ad1 | 338 | Air_flag=false; |
yabahiro | 33:dd598bb23ad1 | 339 | SW_flag=true; |
yabahiro | 33:dd598bb23ad1 | 340 | } |
yabahiro | 33:dd598bb23ad1 | 341 | } |
yabahiro | 33:dd598bb23ad1 | 342 | } else { |
yabahiro | 33:dd598bb23ad1 | 343 | if(SW_flag==true) { |
yabahiro | 33:dd598bb23ad1 | 344 | countss++; |
yabahiro | 33:dd598bb23ad1 | 345 | if(countss>=2000) { |
yabahiro | 33:dd598bb23ad1 | 346 | SW_flag=false; |
yabahiro | 33:dd598bb23ad1 | 347 | countss=0; |
yabahiro | 33:dd598bb23ad1 | 348 | } |
yabahiro | 33:dd598bb23ad1 | 349 | } |
yabahiro | 33:dd598bb23ad1 | 350 | } |
yabahiro | 33:dd598bb23ad1 | 351 | |
yabahiro | 33:dd598bb23ad1 | 352 | |
yabahiro | 33:dd598bb23ad1 | 353 | #ifdef USE_MU |
Ryosei | 27:dd9f27fce7d1 | 354 | controller = CONTROLLER::Controller::GetData(); |
yabahiro | 33:dd598bb23ad1 | 355 | #endif |
yabahiro | 33:dd598bb23ad1 | 356 | |
Ryosei | 27:dd9f27fce7d1 | 357 | |
yabahiro | 33:dd598bb23ad1 | 358 | #ifdef USE_ERRORCHECK |
yabahiro | 38:40e7fdf3c694 | 359 | if(SAFTY::ErrorCheck::Check() & SAFTY::Error::ControllerLost & start_flag) { |
Ryosei | 27:dd9f27fce7d1 | 360 | CONTROLLER::Controller::DataReset(); |
Ryosei | 27:dd9f27fce7d1 | 361 | AllActuatorReset(); |
Ryosei | 27:dd9f27fce7d1 | 362 | lock = true; |
Ryosei | 27:dd9f27fce7d1 | 363 | } else |
yabahiro | 38:40e7fdf3c694 | 364 | |
yabahiro | 33:dd598bb23ad1 | 365 | #endif |
Ryosei | 27:dd9f27fce7d1 | 366 | { |
Ryosei | 27:dd9f27fce7d1 | 367 | |
yabahiro | 33:dd598bb23ad1 | 368 | #ifdef USE_SUBPROCESS |
Ryosei | 27:dd9f27fce7d1 | 369 | if(!lock) { |
Ryosei | 27:dd9f27fce7d1 | 370 | Process[current](); |
Ryosei | 27:dd9f27fce7d1 | 371 | } else |
yabahiro | 33:dd598bb23ad1 | 372 | #endif |
Ryosei | 27:dd9f27fce7d1 | 373 | { |
Ryosei | 27:dd9f27fce7d1 | 374 | //ロック時の処理 |
Ryosei | 27:dd9f27fce7d1 | 375 | } |
Ryosei | 27:dd9f27fce7d1 | 376 | } |
yabahiro | 33:dd598bb23ad1 | 377 | |
Ryosei | 27:dd9f27fce7d1 | 378 | SystemProcessUpdate(); |
Ryosei | 27:dd9f27fce7d1 | 379 | } |
t_yamamoto | 0:669ef71cba68 | 380 | } |
t_yamamoto | 0:669ef71cba68 | 381 | |
kishibekairohan | 2:c015739085d3 | 382 | |
kishibekairohan | 2:c015739085d3 | 383 | |
kishibekairohan | 2:c015739085d3 | 384 | |
t_yamamoto | 0:669ef71cba68 | 385 | #pragma region PROCESS |
t_yamamoto | 0:669ef71cba68 | 386 | #ifdef USE_SUBPROCESS |
t_yamamoto | 0:669ef71cba68 | 387 | #if USE_PROCESS_NUM>0 |
Ryosei | 27:dd9f27fce7d1 | 388 | static void Process0() |
Ryosei | 27:dd9f27fce7d1 | 389 | { |
yabahiro | 33:dd598bb23ad1 | 390 | |
yabahiro | 33:dd598bb23ad1 | 391 | //AllActuatorReset(); |
t_yamamoto | 0:669ef71cba68 | 392 | } |
t_yamamoto | 0:669ef71cba68 | 393 | #endif |
t_yamamoto | 0:669ef71cba68 | 394 | |
t_yamamoto | 0:669ef71cba68 | 395 | #if USE_PROCESS_NUM>1 |
kishibekairohan | 16:3f2c2d89372b | 396 | static void Process1() |
t_yamamoto | 0:669ef71cba68 | 397 | { |
kishibekairohan | 35:33c6cdba5630 | 398 | LED::LED::TapeledMode(6); |
yabahiro | 33:dd598bb23ad1 | 399 | start_flag = true; |
yabahiro | 33:dd598bb23ad1 | 400 | mtc=false; |
yabahiro | 33:dd598bb23ad1 | 401 | mtc2 = false; |
yabahiro | 33:dd598bb23ad1 | 402 | mode=1; |
yabahiro | 33:dd598bb23ad1 | 403 | cross=0; |
yabahiro | 33:dd598bb23ad1 | 404 | Twsh=1; |
yabahiro | 33:dd598bb23ad1 | 405 | motor[TIRE_FR].dir = SetStatus(-omni[controller->AnalogL.Y][14-controller->AnalogL.X] + curve[controller->AnalogR.X]); |
yabahiro | 33:dd598bb23ad1 | 406 | motor[TIRE_FL].dir = SetStatus(omni[controller->AnalogL.Y][controller->AnalogL.X] + curve[controller->AnalogR.X]); |
yabahiro | 33:dd598bb23ad1 | 407 | motor[TIRE_BR].dir = SetStatus(-omni[14-controller->AnalogL.X][14-controller->AnalogL.Y] + curve[controller->AnalogR.X]); |
yabahiro | 33:dd598bb23ad1 | 408 | motor[TIRE_BL].dir = SetStatus(omni[controller->AnalogL.X][14-controller->AnalogL.Y] + curve[controller->AnalogR.X]); |
Ryosei | 27:dd9f27fce7d1 | 409 | |
kishibekairohan | 42:980af34f6fe3 | 410 | motor[TIRE_FR].pwm = SetPWM(omni[controller->AnalogL.Y][14-controller->AnalogL.X]+ curve[controller->AnalogR.X])*0.2; |
kishibekairohan | 42:980af34f6fe3 | 411 | motor[TIRE_FL].pwm = SetPWM(omni[controller->AnalogL.Y][controller->AnalogL.X]+ curve[controller->AnalogR.X])*0.2; |
kishibekairohan | 42:980af34f6fe3 | 412 | motor[TIRE_BR].pwm = SetPWM(omni[14-controller->AnalogL.X][14-controller->AnalogL.Y]+ curve[controller->AnalogR.X])*0.2; |
kishibekairohan | 42:980af34f6fe3 | 413 | motor[TIRE_BL].pwm = SetPWM(omni[controller->AnalogL.X][14-controller->AnalogL.Y]+ curve[controller->AnalogR.X])*0.2; |
yabahiro | 33:dd598bb23ad1 | 414 | |
yabahiro | 33:dd598bb23ad1 | 415 | if(controller->Button.UP||controller->Button.DOWN) { |
yabahiro | 33:dd598bb23ad1 | 416 | |
yabahiro | 33:dd598bb23ad1 | 417 | if(controller->Button.UP) { |
yabahiro | 33:dd598bb23ad1 | 418 | motor[MOTOR_0].pwm =200; |
yabahiro | 33:dd598bb23ad1 | 419 | motor[MOTOR_0].dir = FOR; |
yabahiro | 33:dd598bb23ad1 | 420 | if(UPLS) { |
yabahiro | 33:dd598bb23ad1 | 421 | motor[MOTOR_0].pwm = 0; |
yabahiro | 33:dd598bb23ad1 | 422 | motor[MOTOR_0].dir = BRAKE; |
yabahiro | 33:dd598bb23ad1 | 423 | } |
yabahiro | 33:dd598bb23ad1 | 424 | } |
yabahiro | 33:dd598bb23ad1 | 425 | if(controller->Button.DOWN) { |
yabahiro | 33:dd598bb23ad1 | 426 | motor[MOTOR_0].pwm = 50; |
yabahiro | 33:dd598bb23ad1 | 427 | motor[MOTOR_0].dir = BACK; |
yabahiro | 33:dd598bb23ad1 | 428 | } |
yabahiro | 33:dd598bb23ad1 | 429 | } else { |
yabahiro | 33:dd598bb23ad1 | 430 | motor[MOTOR_0].pwm = 0; |
yabahiro | 33:dd598bb23ad1 | 431 | motor[MOTOR_0].dir = BRAKE; |
yabahiro | 33:dd598bb23ad1 | 432 | } |
yabahiro | 33:dd598bb23ad1 | 433 | |
yabahiro | 33:dd598bb23ad1 | 434 | if(controller->Button.Y) { |
yabahiro | 33:dd598bb23ad1 | 435 | if(dz2==true) { |
yabahiro | 33:dd598bb23ad1 | 436 | if(dz2i==false) { |
yabahiro | 33:dd598bb23ad1 | 437 | solenoid.solenoid2 = SOLENOID_ON; |
yabahiro | 33:dd598bb23ad1 | 438 | dz2i=true; |
yabahiro | 33:dd598bb23ad1 | 439 | } else { |
yabahiro | 33:dd598bb23ad1 | 440 | solenoid.solenoid2 = SOLENOID_OFF; |
yabahiro | 33:dd598bb23ad1 | 441 | dz2i=false; |
yabahiro | 33:dd598bb23ad1 | 442 | } |
yabahiro | 33:dd598bb23ad1 | 443 | dz2=false; |
yabahiro | 33:dd598bb23ad1 | 444 | } |
yabahiro | 33:dd598bb23ad1 | 445 | } else { |
yabahiro | 33:dd598bb23ad1 | 446 | dz2=true; |
yabahiro | 33:dd598bb23ad1 | 447 | } |
yabahiro | 33:dd598bb23ad1 | 448 | |
yabahiro | 33:dd598bb23ad1 | 449 | if(controller->Button.A) { |
yabahiro | 33:dd598bb23ad1 | 450 | if(dz3==true) { |
yabahiro | 33:dd598bb23ad1 | 451 | if(dz3i==false) { |
kishibekairohan | 37:e77816810627 | 452 | solenoid.solenoid3 = SOLENOID_ON; |
yabahiro | 33:dd598bb23ad1 | 453 | dz3i=true; |
yabahiro | 33:dd598bb23ad1 | 454 | } else { |
yabahiro | 33:dd598bb23ad1 | 455 | solenoid.solenoid3 = SOLENOID_OFF; |
yabahiro | 33:dd598bb23ad1 | 456 | dz3i=false; |
yabahiro | 33:dd598bb23ad1 | 457 | } |
yabahiro | 33:dd598bb23ad1 | 458 | dz3=false; |
yabahiro | 33:dd598bb23ad1 | 459 | } |
yabahiro | 33:dd598bb23ad1 | 460 | } else { |
yabahiro | 33:dd598bb23ad1 | 461 | dz3=true; |
yabahiro | 33:dd598bb23ad1 | 462 | } |
yabahiro | 33:dd598bb23ad1 | 463 | |
yabahiro | 33:dd598bb23ad1 | 464 | if(controller->Button.B) { |
yabahiro | 33:dd598bb23ad1 | 465 | if(dz4==true) { |
yabahiro | 33:dd598bb23ad1 | 466 | if(dz4i==false) { |
yabahiro | 38:40e7fdf3c694 | 467 | solenoid.solenoid4 = SOLENOID_ON; |
yabahiro | 33:dd598bb23ad1 | 468 | dz4i=true; |
yabahiro | 33:dd598bb23ad1 | 469 | } else { |
yabahiro | 38:40e7fdf3c694 | 470 | solenoid.solenoid4 = SOLENOID_OFF; |
yabahiro | 33:dd598bb23ad1 | 471 | dz4i=false; |
yabahiro | 33:dd598bb23ad1 | 472 | } |
yabahiro | 33:dd598bb23ad1 | 473 | dz4=false; |
yabahiro | 33:dd598bb23ad1 | 474 | } |
yabahiro | 33:dd598bb23ad1 | 475 | } else { |
yabahiro | 33:dd598bb23ad1 | 476 | dz4=true; |
yabahiro | 33:dd598bb23ad1 | 477 | } |
t_yamamoto | 0:669ef71cba68 | 478 | } |
t_yamamoto | 0:669ef71cba68 | 479 | #endif |
t_yamamoto | 0:669ef71cba68 | 480 | |
t_yamamoto | 0:669ef71cba68 | 481 | #if USE_PROCESS_NUM>2 |
kishibekairohan | 16:3f2c2d89372b | 482 | static void Process2() |
Ryosei | 27:dd9f27fce7d1 | 483 | { |
yabahiro | 33:dd598bb23ad1 | 484 | //Oh So 青ゾーン |
yabahiro | 58:bfc38c43dadb | 485 | value=aime.read_ms(); |
yabahiro | 53:694dbd7dfa0e | 486 | LED::LED::TapeledMode(4); |
yabahiro | 33:dd598bb23ad1 | 487 | countss++; |
yabahiro | 50:87f5fa1bc460 | 488 | switch(mode) { |
yabahiro | 50:87f5fa1bc460 | 489 | case 1: |
yabahiro | 51:a0bdbddd08f7 | 490 | fast=40; |
yabahiro | 51:a0bdbddd08f7 | 491 | normal=30; |
yabahiro | 51:a0bdbddd08f7 | 492 | slow=20; |
yabahiro | 51:a0bdbddd08f7 | 493 | motor[TIRE_FR].pwm = normal+20; |
yabahiro | 51:a0bdbddd08f7 | 494 | motor[TIRE_FR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 495 | motor[TIRE_FL].pwm = normal+20; |
yabahiro | 51:a0bdbddd08f7 | 496 | motor[TIRE_FL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 497 | motor[TIRE_BR].pwm = normal+20; |
yabahiro | 51:a0bdbddd08f7 | 498 | motor[TIRE_BR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 499 | motor[TIRE_BL].pwm = normal+20; |
yabahiro | 51:a0bdbddd08f7 | 500 | motor[TIRE_BL].dir = BACK; |
yabahiro | 58:bfc38c43dadb | 501 | if(g[2]==0&&value>=1500) { |
yabahiro | 51:a0bdbddd08f7 | 502 | countss=100000; |
yabahiro | 58:bfc38c43dadb | 503 | aime.reset(); |
yabahiro | 51:a0bdbddd08f7 | 504 | cross=0; |
yabahiro | 51:a0bdbddd08f7 | 505 | mode=3; |
yabahiro | 51:a0bdbddd08f7 | 506 | } |
yabahiro | 50:87f5fa1bc460 | 507 | break; |
yabahiro | 51:a0bdbddd08f7 | 508 | case 3: |
yabahiro | 51:a0bdbddd08f7 | 509 | motor[TIRE_FR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 510 | motor[TIRE_FR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 511 | motor[TIRE_FL].pwm = 255; |
yabahiro | 51:a0bdbddd08f7 | 512 | motor[TIRE_FL].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 513 | motor[TIRE_BR].pwm = 255; |
yabahiro | 51:a0bdbddd08f7 | 514 | motor[TIRE_BR].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 515 | motor[TIRE_BL].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 516 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 517 | if(g[1]==0) { |
yabahiro | 51:a0bdbddd08f7 | 518 | mode=10; |
yabahiro | 58:bfc38c43dadb | 519 | aime.reset(); |
yabahiro | 51:a0bdbddd08f7 | 520 | countss=100000; |
yabahiro | 55:844ac0974740 | 521 | fast=80; |
yabahiro | 55:844ac0974740 | 522 | normal=60; |
yabahiro | 55:844ac0974740 | 523 | slow=40; |
yabahiro | 51:a0bdbddd08f7 | 524 | } |
yabahiro | 50:87f5fa1bc460 | 525 | break; |
yabahiro | 50:87f5fa1bc460 | 526 | case 10: |
yabahiro | 51:a0bdbddd08f7 | 527 | switch(g[1]) { |
yabahiro | 51:a0bdbddd08f7 | 528 | case 98: |
yabahiro | 51:a0bdbddd08f7 | 529 | motor[TIRE_FR].pwm = normal+55; |
yabahiro | 51:a0bdbddd08f7 | 530 | motor[TIRE_FR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 531 | motor[TIRE_FL].pwm = normal+50; |
yabahiro | 51:a0bdbddd08f7 | 532 | motor[TIRE_FL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 533 | motor[TIRE_BR].pwm = normal+50; |
yabahiro | 51:a0bdbddd08f7 | 534 | motor[TIRE_BR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 535 | motor[TIRE_BL].pwm = normal+45; |
yabahiro | 51:a0bdbddd08f7 | 536 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 537 | mtc=true; |
yabahiro | 58:bfc38c43dadb | 538 | if(value>=1200) { |
yabahiro | 51:a0bdbddd08f7 | 539 | cross++; |
yabahiro | 51:a0bdbddd08f7 | 540 | countss=0; |
yabahiro | 58:bfc38c43dadb | 541 | value=0; |
yabahiro | 58:bfc38c43dadb | 542 | aime.reset(); |
yabahiro | 51:a0bdbddd08f7 | 543 | } |
yabahiro | 46:68296caae1af | 544 | |
yabahiro | 51:a0bdbddd08f7 | 545 | if(cross==2) { |
yabahiro | 51:a0bdbddd08f7 | 546 | fast = 10; |
yabahiro | 51:a0bdbddd08f7 | 547 | normal = 10; |
yabahiro | 51:a0bdbddd08f7 | 548 | slow = 5; |
yabahiro | 51:a0bdbddd08f7 | 549 | } |
yabahiro | 46:68296caae1af | 550 | |
kishibekairohan | 45:0cf48a0605cd | 551 | if(cross==3) { |
yabahiro | 51:a0bdbddd08f7 | 552 | fast=40; |
yabahiro | 51:a0bdbddd08f7 | 553 | normal=30; |
yabahiro | 51:a0bdbddd08f7 | 554 | slow=20; |
yabahiro | 51:a0bdbddd08f7 | 555 | mode=11; |
yabahiro | 58:bfc38c43dadb | 556 | aime.reset(); |
yabahiro | 39:784552c26163 | 557 | countss=0; |
yabahiro | 39:784552c26163 | 558 | cross=0; |
yabahiro | 39:784552c26163 | 559 | } |
yabahiro | 39:784552c26163 | 560 | break; |
yabahiro | 39:784552c26163 | 561 | case 0: |
yabahiro | 51:a0bdbddd08f7 | 562 | motor[TIRE_FR].pwm = fast+55; |
yabahiro | 51:a0bdbddd08f7 | 563 | motor[TIRE_FR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 564 | motor[TIRE_FL].pwm = fast+50; |
yabahiro | 51:a0bdbddd08f7 | 565 | motor[TIRE_FL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 566 | motor[TIRE_BR].pwm = fast+50; |
yabahiro | 51:a0bdbddd08f7 | 567 | motor[TIRE_BR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 568 | motor[TIRE_BL].pwm = fast+45; |
yabahiro | 51:a0bdbddd08f7 | 569 | motor[TIRE_BL].dir = BACK; |
yabahiro | 39:784552c26163 | 570 | mtc=true; |
yabahiro | 39:784552c26163 | 571 | break; |
yabahiro | 39:784552c26163 | 572 | case 255: |
yabahiro | 51:a0bdbddd08f7 | 573 | motor[TIRE_FR].pwm = fast+55; |
yabahiro | 51:a0bdbddd08f7 | 574 | motor[TIRE_FR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 575 | motor[TIRE_FL].pwm = slow+50; |
yabahiro | 51:a0bdbddd08f7 | 576 | motor[TIRE_FL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 577 | motor[TIRE_BR].pwm = slow+50; |
yabahiro | 51:a0bdbddd08f7 | 578 | motor[TIRE_BR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 579 | motor[TIRE_BL].pwm = fast+45; |
yabahiro | 51:a0bdbddd08f7 | 580 | motor[TIRE_BL].dir = BACK; |
yabahiro | 39:784552c26163 | 581 | mtc=true; |
yabahiro | 39:784552c26163 | 582 | break; |
yabahiro | 39:784552c26163 | 583 | case 253: |
yabahiro | 51:a0bdbddd08f7 | 584 | motor[TIRE_FR].pwm = slow+55; |
yabahiro | 51:a0bdbddd08f7 | 585 | motor[TIRE_FR].dir = FOR; |
yabahiro | 39:784552c26163 | 586 | motor[TIRE_FL].pwm = 0; |
yabahiro | 39:784552c26163 | 587 | motor[TIRE_FL].dir = FREE; |
yabahiro | 39:784552c26163 | 588 | motor[TIRE_BR].pwm = 0; |
yabahiro | 39:784552c26163 | 589 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 590 | motor[TIRE_BL].pwm = slow+45; |
yabahiro | 51:a0bdbddd08f7 | 591 | motor[TIRE_BL].dir = BACK; |
yabahiro | 39:784552c26163 | 592 | mtc=true; |
yabahiro | 39:784552c26163 | 593 | break; |
yabahiro | 39:784552c26163 | 594 | case 254: |
yabahiro | 51:a0bdbddd08f7 | 595 | motor[TIRE_FR].pwm = normal+55; |
yabahiro | 51:a0bdbddd08f7 | 596 | motor[TIRE_FR].dir = FOR; |
yabahiro | 39:784552c26163 | 597 | motor[TIRE_FL].pwm = 0; |
yabahiro | 39:784552c26163 | 598 | motor[TIRE_FL].dir = FREE; |
yabahiro | 39:784552c26163 | 599 | motor[TIRE_BR].pwm = 0; |
yabahiro | 39:784552c26163 | 600 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 601 | motor[TIRE_BL].pwm = normal+45; |
yabahiro | 51:a0bdbddd08f7 | 602 | motor[TIRE_BL].dir = BACK; |
yabahiro | 39:784552c26163 | 603 | mtc=true; |
yabahiro | 39:784552c26163 | 604 | break; |
yabahiro | 39:784552c26163 | 605 | case 1: |
yabahiro | 51:a0bdbddd08f7 | 606 | motor[TIRE_FR].pwm = slow+55; |
yabahiro | 51:a0bdbddd08f7 | 607 | motor[TIRE_FR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 608 | motor[TIRE_FL].pwm = fast+50; |
yabahiro | 51:a0bdbddd08f7 | 609 | motor[TIRE_FL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 610 | motor[TIRE_BR].pwm = fast+50; |
yabahiro | 51:a0bdbddd08f7 | 611 | motor[TIRE_BR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 612 | motor[TIRE_BL].pwm = slow+45; |
yabahiro | 51:a0bdbddd08f7 | 613 | motor[TIRE_BL].dir = BACK; |
yabahiro | 39:784552c26163 | 614 | mtc=true; |
yabahiro | 39:784552c26163 | 615 | break; |
yabahiro | 39:784552c26163 | 616 | case 3: |
yabahiro | 39:784552c26163 | 617 | motor[TIRE_FR].pwm = 0; |
yabahiro | 39:784552c26163 | 618 | motor[TIRE_FR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 619 | motor[TIRE_FL].pwm = slow+50; |
yabahiro | 51:a0bdbddd08f7 | 620 | motor[TIRE_FL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 621 | motor[TIRE_BR].pwm = slow+50; |
yabahiro | 51:a0bdbddd08f7 | 622 | motor[TIRE_BR].dir = FOR; |
yabahiro | 39:784552c26163 | 623 | motor[TIRE_BL].pwm = 0; |
yabahiro | 39:784552c26163 | 624 | motor[TIRE_BL].dir = FREE; |
yabahiro | 39:784552c26163 | 625 | mtc=true; |
yabahiro | 39:784552c26163 | 626 | break; |
yabahiro | 39:784552c26163 | 627 | case 2: |
yabahiro | 39:784552c26163 | 628 | motor[TIRE_FR].pwm = 0; |
yabahiro | 39:784552c26163 | 629 | motor[TIRE_FR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 630 | motor[TIRE_FL].pwm = normal+50; |
yabahiro | 51:a0bdbddd08f7 | 631 | motor[TIRE_FL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 632 | motor[TIRE_BR].pwm = normal+50; |
yabahiro | 51:a0bdbddd08f7 | 633 | motor[TIRE_BR].dir = FOR; |
yabahiro | 39:784552c26163 | 634 | motor[TIRE_BL].pwm = 0; |
yabahiro | 39:784552c26163 | 635 | motor[TIRE_BL].dir = FREE; |
yabahiro | 39:784552c26163 | 636 | mtc=true; |
yabahiro | 39:784552c26163 | 637 | break; |
yabahiro | 39:784552c26163 | 638 | } |
yabahiro | 51:a0bdbddd08f7 | 639 | if(g[1]!=98&&mtc==true) { |
yabahiro | 39:784552c26163 | 640 | switch(g[0]) { |
yabahiro | 39:784552c26163 | 641 | case 0: |
yabahiro | 39:784552c26163 | 642 | mtc=false; |
yabahiro | 39:784552c26163 | 643 | break; |
yabahiro | 39:784552c26163 | 644 | case 255: |
yabahiro | 51:a0bdbddd08f7 | 645 | motor[TIRE_FL].pwm += 3; |
yabahiro | 39:784552c26163 | 646 | mtc=false; |
yabahiro | 39:784552c26163 | 647 | break; |
yabahiro | 39:784552c26163 | 648 | case 253: |
yabahiro | 51:a0bdbddd08f7 | 649 | motor[TIRE_FL].pwm += 6; |
yabahiro | 39:784552c26163 | 650 | mtc=false; |
yabahiro | 39:784552c26163 | 651 | break; |
yabahiro | 39:784552c26163 | 652 | case 254: |
yabahiro | 51:a0bdbddd08f7 | 653 | motor[TIRE_FL].pwm += 9; |
yabahiro | 51:a0bdbddd08f7 | 654 | motor[TIRE_FR].pwm = 0; |
yabahiro | 39:784552c26163 | 655 | mtc=false; |
yabahiro | 39:784552c26163 | 656 | break; |
yabahiro | 39:784552c26163 | 657 | case 1: |
yabahiro | 51:a0bdbddd08f7 | 658 | motor[TIRE_FR].pwm += 3; |
yabahiro | 39:784552c26163 | 659 | mtc=false; |
yabahiro | 39:784552c26163 | 660 | break; |
yabahiro | 39:784552c26163 | 661 | case 3: |
yabahiro | 51:a0bdbddd08f7 | 662 | motor[TIRE_FR].pwm += 6; |
yabahiro | 39:784552c26163 | 663 | mtc=false; |
yabahiro | 39:784552c26163 | 664 | break; |
yabahiro | 39:784552c26163 | 665 | case 2: |
yabahiro | 51:a0bdbddd08f7 | 666 | motor[TIRE_FR].pwm += 9; |
yabahiro | 51:a0bdbddd08f7 | 667 | motor[TIRE_FL].pwm = 0; |
yabahiro | 39:784552c26163 | 668 | mtc=false; |
yabahiro | 39:784552c26163 | 669 | break; |
yabahiro | 39:784552c26163 | 670 | } |
yabahiro | 39:784552c26163 | 671 | } |
yabahiro | 51:a0bdbddd08f7 | 672 | break; |
yabahiro | 51:a0bdbddd08f7 | 673 | case 11: |
yabahiro | 53:694dbd7dfa0e | 674 | motor[TIRE_FR].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 675 | motor[TIRE_FR].dir = FOR; |
yabahiro | 53:694dbd7dfa0e | 676 | motor[TIRE_FL].pwm = 15; |
yabahiro | 53:694dbd7dfa0e | 677 | motor[TIRE_FL].dir = FOR; |
yabahiro | 53:694dbd7dfa0e | 678 | motor[TIRE_BR].pwm = 15; |
yabahiro | 53:694dbd7dfa0e | 679 | motor[TIRE_BR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 680 | motor[TIRE_BL].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 681 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 682 | if(g[2]==0 || g[2]==255 || g[2]==254 || g[2]==253) { |
yabahiro | 51:a0bdbddd08f7 | 683 | countss=0; |
yabahiro | 51:a0bdbddd08f7 | 684 | cross=0; |
yabahiro | 51:a0bdbddd08f7 | 685 | mode=20; |
yabahiro | 51:a0bdbddd08f7 | 686 | } |
yabahiro | 51:a0bdbddd08f7 | 687 | break; |
yabahiro | 51:a0bdbddd08f7 | 688 | case 20: |
yabahiro | 51:a0bdbddd08f7 | 689 | solenoid.solenoid2= SOLENOID_ON; |
yabahiro | 51:a0bdbddd08f7 | 690 | switch(g[2]) { |
yabahiro | 51:a0bdbddd08f7 | 691 | case 98: |
yabahiro | 51:a0bdbddd08f7 | 692 | motor[TIRE_FR].pwm = normal+20; |
yabahiro | 51:a0bdbddd08f7 | 693 | motor[TIRE_FR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 694 | motor[TIRE_FL].pwm = normal+20; |
yabahiro | 51:a0bdbddd08f7 | 695 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 696 | motor[TIRE_BR].pwm = normal+20; |
yabahiro | 51:a0bdbddd08f7 | 697 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 698 | motor[TIRE_BL].pwm = normal+20; |
yabahiro | 51:a0bdbddd08f7 | 699 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 700 | if(countss>30000) { |
yabahiro | 51:a0bdbddd08f7 | 701 | cross++; |
yabahiro | 51:a0bdbddd08f7 | 702 | countss=0; |
yabahiro | 51:a0bdbddd08f7 | 703 | } |
yabahiro | 51:a0bdbddd08f7 | 704 | mtc2=true; |
yabahiro | 51:a0bdbddd08f7 | 705 | if(YELLOW) { |
yabahiro | 51:a0bdbddd08f7 | 706 | if(cross==1) { |
yabahiro | 51:a0bdbddd08f7 | 707 | fast=20; |
yabahiro | 51:a0bdbddd08f7 | 708 | normal=15; |
yabahiro | 51:a0bdbddd08f7 | 709 | slow=15; |
yabahiro | 51:a0bdbddd08f7 | 710 | } |
yabahiro | 51:a0bdbddd08f7 | 711 | if(cross==2) { |
yabahiro | 51:a0bdbddd08f7 | 712 | mode=21; |
yabahiro | 51:a0bdbddd08f7 | 713 | countss=0; |
yabahiro | 51:a0bdbddd08f7 | 714 | cross=0; |
yabahiro | 51:a0bdbddd08f7 | 715 | } |
yabahiro | 51:a0bdbddd08f7 | 716 | } else { |
yabahiro | 51:a0bdbddd08f7 | 717 | if(cross==3) { |
yabahiro | 51:a0bdbddd08f7 | 718 | mode=21; |
yabahiro | 51:a0bdbddd08f7 | 719 | countss=0; |
yabahiro | 51:a0bdbddd08f7 | 720 | cross=0; |
yabahiro | 51:a0bdbddd08f7 | 721 | } |
yabahiro | 51:a0bdbddd08f7 | 722 | } |
yabahiro | 51:a0bdbddd08f7 | 723 | break; |
yabahiro | 51:a0bdbddd08f7 | 724 | case 0: |
yabahiro | 51:a0bdbddd08f7 | 725 | motor[TIRE_FR].pwm = fast+20; |
yabahiro | 51:a0bdbddd08f7 | 726 | motor[TIRE_FR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 727 | motor[TIRE_FL].pwm = fast+20; |
yabahiro | 51:a0bdbddd08f7 | 728 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 729 | motor[TIRE_BR].pwm = fast+20; |
yabahiro | 51:a0bdbddd08f7 | 730 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 731 | motor[TIRE_BL].pwm = fast+20; |
yabahiro | 51:a0bdbddd08f7 | 732 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 733 | mtc2=true; |
yabahiro | 51:a0bdbddd08f7 | 734 | break; |
yabahiro | 51:a0bdbddd08f7 | 735 | case 255: |
yabahiro | 51:a0bdbddd08f7 | 736 | motor[TIRE_FR].pwm = normal+20; |
yabahiro | 51:a0bdbddd08f7 | 737 | motor[TIRE_FR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 738 | motor[TIRE_FL].pwm = fast+20; |
yabahiro | 51:a0bdbddd08f7 | 739 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 740 | motor[TIRE_BR].pwm = fast+20; |
yabahiro | 51:a0bdbddd08f7 | 741 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 742 | motor[TIRE_BL].pwm = normal+20; |
yabahiro | 51:a0bdbddd08f7 | 743 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 744 | mtc2=true; |
yabahiro | 51:a0bdbddd08f7 | 745 | break; |
yabahiro | 51:a0bdbddd08f7 | 746 | case 253: |
yabahiro | 51:a0bdbddd08f7 | 747 | motor[TIRE_FR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 748 | motor[TIRE_FR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 749 | motor[TIRE_FL].pwm = slow+20; |
yabahiro | 51:a0bdbddd08f7 | 750 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 751 | motor[TIRE_BR].pwm = slow+20; |
yabahiro | 51:a0bdbddd08f7 | 752 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 753 | motor[TIRE_BL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 754 | motor[TIRE_BL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 755 | mtc2=true; |
yabahiro | 51:a0bdbddd08f7 | 756 | break; |
yabahiro | 51:a0bdbddd08f7 | 757 | case 254: |
yabahiro | 51:a0bdbddd08f7 | 758 | motor[TIRE_FR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 759 | motor[TIRE_FR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 760 | motor[TIRE_FL].pwm = normal+20; |
yabahiro | 51:a0bdbddd08f7 | 761 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 762 | motor[TIRE_BR].pwm = normal+20; |
yabahiro | 51:a0bdbddd08f7 | 763 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 764 | motor[TIRE_BL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 765 | motor[TIRE_BL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 766 | mtc2=true; |
yabahiro | 51:a0bdbddd08f7 | 767 | break; |
yabahiro | 51:a0bdbddd08f7 | 768 | case 1: |
yabahiro | 51:a0bdbddd08f7 | 769 | motor[TIRE_FR].pwm = fast+20; |
yabahiro | 51:a0bdbddd08f7 | 770 | motor[TIRE_FR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 771 | motor[TIRE_FL].pwm = slow+20; |
yabahiro | 51:a0bdbddd08f7 | 772 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 773 | motor[TIRE_BR].pwm = slow+20; |
yabahiro | 51:a0bdbddd08f7 | 774 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 775 | motor[TIRE_BL].pwm = fast+20; |
yabahiro | 51:a0bdbddd08f7 | 776 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 777 | mtc2=true; |
yabahiro | 51:a0bdbddd08f7 | 778 | break; |
yabahiro | 51:a0bdbddd08f7 | 779 | case 3: |
yabahiro | 51:a0bdbddd08f7 | 780 | motor[TIRE_FR].pwm = slow+20; |
yabahiro | 51:a0bdbddd08f7 | 781 | motor[TIRE_FR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 782 | motor[TIRE_FL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 783 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 784 | motor[TIRE_BR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 785 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 786 | motor[TIRE_BL].pwm = slow+20; |
yabahiro | 51:a0bdbddd08f7 | 787 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 788 | mtc2=true; |
yabahiro | 51:a0bdbddd08f7 | 789 | break; |
yabahiro | 51:a0bdbddd08f7 | 790 | case 2: |
yabahiro | 51:a0bdbddd08f7 | 791 | motor[TIRE_FR].pwm = normal+20; |
yabahiro | 51:a0bdbddd08f7 | 792 | motor[TIRE_FR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 793 | motor[TIRE_FL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 794 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 795 | motor[TIRE_BR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 796 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 797 | motor[TIRE_BL].pwm = normal+20; |
yabahiro | 51:a0bdbddd08f7 | 798 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 799 | mtc2=true; |
yabahiro | 51:a0bdbddd08f7 | 800 | break; |
yabahiro | 51:a0bdbddd08f7 | 801 | } |
yabahiro | 51:a0bdbddd08f7 | 802 | if(g[2]!=98&&mtc2==true) { |
yabahiro | 51:a0bdbddd08f7 | 803 | switch(g[3]) { |
yabahiro | 51:a0bdbddd08f7 | 804 | case 0: |
yabahiro | 51:a0bdbddd08f7 | 805 | mtc2=false; |
yabahiro | 51:a0bdbddd08f7 | 806 | break; |
yabahiro | 51:a0bdbddd08f7 | 807 | case 255: |
yabahiro | 51:a0bdbddd08f7 | 808 | motor[TIRE_BL].pwm += 5; |
yabahiro | 51:a0bdbddd08f7 | 809 | mtc2=false; |
yabahiro | 51:a0bdbddd08f7 | 810 | break; |
yabahiro | 51:a0bdbddd08f7 | 811 | case 253: |
yabahiro | 51:a0bdbddd08f7 | 812 | motor[TIRE_BL].pwm += 10; |
yabahiro | 51:a0bdbddd08f7 | 813 | mtc2=false; |
yabahiro | 51:a0bdbddd08f7 | 814 | break; |
yabahiro | 51:a0bdbddd08f7 | 815 | case 254: |
yabahiro | 51:a0bdbddd08f7 | 816 | motor[TIRE_BL].pwm += 15; |
yabahiro | 51:a0bdbddd08f7 | 817 | motor[TIRE_FL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 818 | mtc2=false; |
yabahiro | 51:a0bdbddd08f7 | 819 | break; |
yabahiro | 51:a0bdbddd08f7 | 820 | case 1: |
yabahiro | 51:a0bdbddd08f7 | 821 | motor[TIRE_FL].pwm += 5; |
yabahiro | 51:a0bdbddd08f7 | 822 | mtc2=false; |
yabahiro | 51:a0bdbddd08f7 | 823 | break; |
yabahiro | 51:a0bdbddd08f7 | 824 | case 3: |
yabahiro | 51:a0bdbddd08f7 | 825 | motor[TIRE_FL].pwm += 10; |
yabahiro | 51:a0bdbddd08f7 | 826 | mtc2=false; |
yabahiro | 51:a0bdbddd08f7 | 827 | break; |
yabahiro | 51:a0bdbddd08f7 | 828 | case 2: |
yabahiro | 51:a0bdbddd08f7 | 829 | motor[TIRE_FL].pwm += 15; |
yabahiro | 51:a0bdbddd08f7 | 830 | motor[TIRE_BL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 831 | mtc2=false; |
yabahiro | 51:a0bdbddd08f7 | 832 | break; |
yabahiro | 51:a0bdbddd08f7 | 833 | } |
yabahiro | 51:a0bdbddd08f7 | 834 | } |
yabahiro | 51:a0bdbddd08f7 | 835 | break; |
yabahiro | 51:a0bdbddd08f7 | 836 | case 21: |
yabahiro | 51:a0bdbddd08f7 | 837 | if(YELLOW) { |
yabahiro | 51:a0bdbddd08f7 | 838 | motor[TIRE_FR].pwm = 20; |
yabahiro | 51:a0bdbddd08f7 | 839 | motor[TIRE_FR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 840 | motor[TIRE_FL].pwm = 20; |
yabahiro | 51:a0bdbddd08f7 | 841 | motor[TIRE_FL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 842 | motor[TIRE_BR].pwm = 20; |
yabahiro | 51:a0bdbddd08f7 | 843 | motor[TIRE_BR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 844 | motor[TIRE_BL].pwm = 20; |
yabahiro | 51:a0bdbddd08f7 | 845 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 846 | if(g[3]==98&&countss>=10000) { |
yabahiro | 51:a0bdbddd08f7 | 847 | mode=22; |
yabahiro | 51:a0bdbddd08f7 | 848 | countss=0; |
yabahiro | 51:a0bdbddd08f7 | 849 | fast=60; |
yabahiro | 51:a0bdbddd08f7 | 850 | normal=40; |
yabahiro | 51:a0bdbddd08f7 | 851 | slow=20; |
yabahiro | 51:a0bdbddd08f7 | 852 | } |
yabahiro | 51:a0bdbddd08f7 | 853 | } else { |
yabahiro | 51:a0bdbddd08f7 | 854 | motor[TIRE_FR].pwm = 255; |
yabahiro | 51:a0bdbddd08f7 | 855 | motor[TIRE_FR].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 856 | motor[TIRE_FL].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 857 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 858 | motor[TIRE_BR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 859 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 860 | motor[TIRE_BL].pwm = 255; |
yabahiro | 51:a0bdbddd08f7 | 861 | motor[TIRE_BL].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 862 | if(g[0]==0) { |
yabahiro | 51:a0bdbddd08f7 | 863 | mode=22; |
yabahiro | 51:a0bdbddd08f7 | 864 | fast=60; |
yabahiro | 51:a0bdbddd08f7 | 865 | normal=40; |
yabahiro | 51:a0bdbddd08f7 | 866 | slow=25; |
yabahiro | 58:bfc38c43dadb | 867 | value=0; |
yabahiro | 58:bfc38c43dadb | 868 | aime.reset(); |
yabahiro | 51:a0bdbddd08f7 | 869 | } |
yabahiro | 51:a0bdbddd08f7 | 870 | } |
yabahiro | 51:a0bdbddd08f7 | 871 | break; |
yabahiro | 51:a0bdbddd08f7 | 872 | case 22: |
yabahiro | 51:a0bdbddd08f7 | 873 | if(YELLOW) { |
yabahiro | 51:a0bdbddd08f7 | 874 | if(g[4]==3||g[4]==2) { |
yabahiro | 51:a0bdbddd08f7 | 875 | motor[TIRE_FR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 876 | motor[TIRE_FR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 877 | motor[TIRE_FL].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 878 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 879 | motor[TIRE_BR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 880 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 881 | motor[TIRE_BL].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 882 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 883 | } |
yabahiro | 51:a0bdbddd08f7 | 884 | if(g[4]==253||g[4]==254) { |
yabahiro | 51:a0bdbddd08f7 | 885 | motor[TIRE_FR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 886 | motor[TIRE_FR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 887 | motor[TIRE_FL].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 888 | motor[TIRE_FL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 889 | motor[TIRE_BR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 890 | motor[TIRE_BR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 891 | motor[TIRE_BL].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 892 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 893 | } |
yabahiro | 51:a0bdbddd08f7 | 894 | switch(g[2]) { |
yabahiro | 51:a0bdbddd08f7 | 895 | case 0: |
yabahiro | 51:a0bdbddd08f7 | 896 | motor[TIRE_FR].pwm = 20; |
yabahiro | 51:a0bdbddd08f7 | 897 | motor[TIRE_FR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 898 | motor[TIRE_BR].pwm = 20; |
yabahiro | 51:a0bdbddd08f7 | 899 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 900 | break; |
yabahiro | 51:a0bdbddd08f7 | 901 | case 255: |
yabahiro | 51:a0bdbddd08f7 | 902 | motor[TIRE_FR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 903 | motor[TIRE_FR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 904 | motor[TIRE_BR].pwm = 20; |
yabahiro | 51:a0bdbddd08f7 | 905 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 906 | break; |
yabahiro | 51:a0bdbddd08f7 | 907 | case 253: |
yabahiro | 51:a0bdbddd08f7 | 908 | motor[TIRE_FR].pwm = 40; |
yabahiro | 51:a0bdbddd08f7 | 909 | motor[TIRE_FR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 910 | motor[TIRE_BR].pwm = 20; |
yabahiro | 51:a0bdbddd08f7 | 911 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 912 | break; |
yabahiro | 51:a0bdbddd08f7 | 913 | case 254: |
yabahiro | 51:a0bdbddd08f7 | 914 | motor[TIRE_FR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 915 | motor[TIRE_FR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 916 | motor[TIRE_BR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 917 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 918 | break; |
yabahiro | 51:a0bdbddd08f7 | 919 | case 1: |
yabahiro | 51:a0bdbddd08f7 | 920 | motor[TIRE_FR].pwm = 20; |
yabahiro | 51:a0bdbddd08f7 | 921 | motor[TIRE_FR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 922 | motor[TIRE_BR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 923 | motor[TIRE_BR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 924 | break; |
yabahiro | 51:a0bdbddd08f7 | 925 | case 3: |
yabahiro | 51:a0bdbddd08f7 | 926 | motor[TIRE_FR].pwm = 20; |
yabahiro | 51:a0bdbddd08f7 | 927 | motor[TIRE_FR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 928 | motor[TIRE_BR].pwm = 40; |
yabahiro | 51:a0bdbddd08f7 | 929 | motor[TIRE_BR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 930 | break; |
yabahiro | 51:a0bdbddd08f7 | 931 | case 2: |
yabahiro | 51:a0bdbddd08f7 | 932 | motor[TIRE_FR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 933 | motor[TIRE_FR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 934 | motor[TIRE_BR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 935 | motor[TIRE_BR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 936 | break; |
yabahiro | 51:a0bdbddd08f7 | 937 | } |
yabahiro | 51:a0bdbddd08f7 | 938 | switch(g[3]) { |
yabahiro | 51:a0bdbddd08f7 | 939 | case 0: |
yabahiro | 53:694dbd7dfa0e | 940 | motor[TIRE_FL].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 941 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 942 | motor[TIRE_BL].pwm = 20; |
yabahiro | 51:a0bdbddd08f7 | 943 | motor[TIRE_BL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 944 | break; |
yabahiro | 51:a0bdbddd08f7 | 945 | case 255: |
yabahiro | 53:694dbd7dfa0e | 946 | motor[TIRE_FL].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 947 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 948 | motor[TIRE_BL].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 949 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 950 | case 253: |
yabahiro | 53:694dbd7dfa0e | 951 | motor[TIRE_FL].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 952 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 953 | motor[TIRE_BL].pwm = 40; |
yabahiro | 51:a0bdbddd08f7 | 954 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 955 | break; |
yabahiro | 51:a0bdbddd08f7 | 956 | case 254: |
yabahiro | 53:694dbd7dfa0e | 957 | motor[TIRE_FL].pwm = 35; |
yabahiro | 51:a0bdbddd08f7 | 958 | motor[TIRE_FL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 959 | motor[TIRE_BL].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 960 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 961 | break; |
yabahiro | 51:a0bdbddd08f7 | 962 | case 1: |
yabahiro | 53:694dbd7dfa0e | 963 | motor[TIRE_FL].pwm = 35; |
yabahiro | 51:a0bdbddd08f7 | 964 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 965 | motor[TIRE_BL].pwm = 20; |
yabahiro | 51:a0bdbddd08f7 | 966 | motor[TIRE_BL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 967 | break; |
yabahiro | 51:a0bdbddd08f7 | 968 | case 3: |
yabahiro | 53:694dbd7dfa0e | 969 | motor[TIRE_FL].pwm = 45; |
yabahiro | 51:a0bdbddd08f7 | 970 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 971 | motor[TIRE_BL].pwm = 20; |
yabahiro | 51:a0bdbddd08f7 | 972 | motor[TIRE_BL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 973 | break; |
yabahiro | 51:a0bdbddd08f7 | 974 | case 2: |
yabahiro | 53:694dbd7dfa0e | 975 | motor[TIRE_FL].pwm = 35; |
yabahiro | 51:a0bdbddd08f7 | 976 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 977 | motor[TIRE_BL].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 978 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 979 | break; |
yabahiro | 51:a0bdbddd08f7 | 980 | } |
yabahiro | 51:a0bdbddd08f7 | 981 | if(g[3]==0&&g[2]==0) { |
yabahiro | 58:bfc38c43dadb | 982 | aime.reset(); |
yabahiro | 51:a0bdbddd08f7 | 983 | mode=23; |
yabahiro | 51:a0bdbddd08f7 | 984 | countss=0; |
yabahiro | 54:4167f10ecad0 | 985 | fast=80; |
yabahiro | 54:4167f10ecad0 | 986 | normal=60; |
yabahiro | 54:4167f10ecad0 | 987 | slow=30; |
yabahiro | 51:a0bdbddd08f7 | 988 | } |
yabahiro | 51:a0bdbddd08f7 | 989 | } else { |
yabahiro | 58:bfc38c43dadb | 990 | if(g[3]==0&&value>=2000) { |
yabahiro | 58:bfc38c43dadb | 991 | solenoid.solenoid2 = SOLENOID_OFF; |
yabahiro | 51:a0bdbddd08f7 | 992 | slow=25; |
yabahiro | 51:a0bdbddd08f7 | 993 | normal=40; |
yabahiro | 51:a0bdbddd08f7 | 994 | fast=60; |
yabahiro | 58:bfc38c43dadb | 995 | aime.reset(); |
yabahiro | 51:a0bdbddd08f7 | 996 | mode=23; |
yabahiro | 51:a0bdbddd08f7 | 997 | } |
yabahiro | 51:a0bdbddd08f7 | 998 | switch(g[0]) { |
yabahiro | 51:a0bdbddd08f7 | 999 | case 98: |
yabahiro | 58:bfc38c43dadb | 1000 | if(value>=1500) { |
yabahiro | 58:bfc38c43dadb | 1001 | solenoid.solenoid2 = SOLENOID_OFF; |
yabahiro | 58:bfc38c43dadb | 1002 | slow=25; |
yabahiro | 58:bfc38c43dadb | 1003 | normal=30; |
yabahiro | 58:bfc38c43dadb | 1004 | fast=30; |
yabahiro | 58:bfc38c43dadb | 1005 | } |
yabahiro | 51:a0bdbddd08f7 | 1006 | motor[TIRE_FR].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1007 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1008 | motor[TIRE_FL].pwm = normal+5; |
yabahiro | 51:a0bdbddd08f7 | 1009 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1010 | motor[TIRE_BR].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1011 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1012 | motor[TIRE_BL].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1013 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1014 | break; |
yabahiro | 51:a0bdbddd08f7 | 1015 | case 0: |
yabahiro | 51:a0bdbddd08f7 | 1016 | motor[TIRE_FR].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1017 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1018 | motor[TIRE_FL].pwm = fast+5; |
yabahiro | 51:a0bdbddd08f7 | 1019 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1020 | motor[TIRE_BR].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1021 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1022 | motor[TIRE_BL].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1023 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1024 | mtc=true; |
yabahiro | 51:a0bdbddd08f7 | 1025 | break; |
yabahiro | 51:a0bdbddd08f7 | 1026 | case 255: |
yabahiro | 51:a0bdbddd08f7 | 1027 | motor[TIRE_FR].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1028 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1029 | motor[TIRE_FL].pwm = slow+5; |
yabahiro | 51:a0bdbddd08f7 | 1030 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1031 | motor[TIRE_BR].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1032 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1033 | motor[TIRE_BL].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1034 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1035 | mtc=true; |
yabahiro | 51:a0bdbddd08f7 | 1036 | break; |
yabahiro | 51:a0bdbddd08f7 | 1037 | case 253: |
yabahiro | 51:a0bdbddd08f7 | 1038 | motor[TIRE_FR].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1039 | motor[TIRE_FR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1040 | motor[TIRE_FL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1041 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1042 | motor[TIRE_BR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1043 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1044 | motor[TIRE_BL].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1045 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1046 | mtc=true; |
yabahiro | 51:a0bdbddd08f7 | 1047 | break; |
yabahiro | 51:a0bdbddd08f7 | 1048 | case 254: |
yabahiro | 51:a0bdbddd08f7 | 1049 | motor[TIRE_FR].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1050 | motor[TIRE_FR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1051 | motor[TIRE_FL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1052 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1053 | motor[TIRE_BR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1054 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1055 | motor[TIRE_BL].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1056 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1057 | mtc=true; |
yabahiro | 51:a0bdbddd08f7 | 1058 | break; |
yabahiro | 51:a0bdbddd08f7 | 1059 | case 1: |
yabahiro | 51:a0bdbddd08f7 | 1060 | motor[TIRE_FR].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1061 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1062 | motor[TIRE_FL].pwm = fast+5; |
yabahiro | 51:a0bdbddd08f7 | 1063 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1064 | motor[TIRE_BR].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1065 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1066 | motor[TIRE_BL].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1067 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1068 | mtc=true; |
yabahiro | 51:a0bdbddd08f7 | 1069 | break; |
yabahiro | 51:a0bdbddd08f7 | 1070 | case 3: |
yabahiro | 51:a0bdbddd08f7 | 1071 | motor[TIRE_FR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1072 | motor[TIRE_FR].dir = FREE; |
yabahiro | 53:694dbd7dfa0e | 1073 | motor[TIRE_FL].pwm = slow+5; |
yabahiro | 51:a0bdbddd08f7 | 1074 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1075 | motor[TIRE_BR].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1076 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1077 | motor[TIRE_BL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1078 | motor[TIRE_BL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1079 | mtc=true; |
yabahiro | 51:a0bdbddd08f7 | 1080 | break; |
yabahiro | 51:a0bdbddd08f7 | 1081 | case 2: |
yabahiro | 51:a0bdbddd08f7 | 1082 | motor[TIRE_FR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1083 | motor[TIRE_FR].dir = FREE; |
yabahiro | 53:694dbd7dfa0e | 1084 | motor[TIRE_FL].pwm = normal+5; |
yabahiro | 51:a0bdbddd08f7 | 1085 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1086 | motor[TIRE_BR].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1087 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1088 | motor[TIRE_BL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1089 | motor[TIRE_BL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1090 | mtc=true; |
yabahiro | 51:a0bdbddd08f7 | 1091 | break; |
yabahiro | 51:a0bdbddd08f7 | 1092 | } |
yabahiro | 51:a0bdbddd08f7 | 1093 | if(g[0]!=98&&mtc==true) { |
yabahiro | 51:a0bdbddd08f7 | 1094 | switch(g[0]) { |
yabahiro | 51:a0bdbddd08f7 | 1095 | case 0: |
yabahiro | 51:a0bdbddd08f7 | 1096 | mtc=false; |
yabahiro | 51:a0bdbddd08f7 | 1097 | break; |
yabahiro | 51:a0bdbddd08f7 | 1098 | case 255: |
yabahiro | 51:a0bdbddd08f7 | 1099 | motor[TIRE_BR].pwm += 5; |
yabahiro | 51:a0bdbddd08f7 | 1100 | mtc=false; |
yabahiro | 51:a0bdbddd08f7 | 1101 | break; |
yabahiro | 51:a0bdbddd08f7 | 1102 | case 253: |
yabahiro | 51:a0bdbddd08f7 | 1103 | motor[TIRE_BR].pwm += 10; |
yabahiro | 51:a0bdbddd08f7 | 1104 | mtc=false; |
yabahiro | 51:a0bdbddd08f7 | 1105 | break; |
yabahiro | 51:a0bdbddd08f7 | 1106 | case 254: |
yabahiro | 51:a0bdbddd08f7 | 1107 | motor[TIRE_BR].pwm += 20; |
yabahiro | 51:a0bdbddd08f7 | 1108 | motor[TIRE_BL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1109 | mtc=false; |
yabahiro | 51:a0bdbddd08f7 | 1110 | break; |
yabahiro | 51:a0bdbddd08f7 | 1111 | case 1: |
yabahiro | 51:a0bdbddd08f7 | 1112 | motor[TIRE_BL].pwm += 5; |
yabahiro | 51:a0bdbddd08f7 | 1113 | mtc=false; |
yabahiro | 51:a0bdbddd08f7 | 1114 | break; |
yabahiro | 51:a0bdbddd08f7 | 1115 | case 3: |
yabahiro | 51:a0bdbddd08f7 | 1116 | motor[TIRE_BL].pwm += 10; |
yabahiro | 51:a0bdbddd08f7 | 1117 | mtc=false; |
yabahiro | 51:a0bdbddd08f7 | 1118 | break; |
yabahiro | 51:a0bdbddd08f7 | 1119 | case 2: |
yabahiro | 51:a0bdbddd08f7 | 1120 | motor[TIRE_BL].pwm += 20; |
yabahiro | 51:a0bdbddd08f7 | 1121 | motor[TIRE_BR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1122 | mtc=false; |
yabahiro | 51:a0bdbddd08f7 | 1123 | break; |
yabahiro | 51:a0bdbddd08f7 | 1124 | } |
yabahiro | 51:a0bdbddd08f7 | 1125 | } |
yabahiro | 51:a0bdbddd08f7 | 1126 | } |
yabahiro | 51:a0bdbddd08f7 | 1127 | break; |
yabahiro | 51:a0bdbddd08f7 | 1128 | case 23: |
yabahiro | 51:a0bdbddd08f7 | 1129 | if(YELLOW) { |
yabahiro | 51:a0bdbddd08f7 | 1130 | switch(g[4]) { |
yabahiro | 51:a0bdbddd08f7 | 1131 | case 98: |
yabahiro | 51:a0bdbddd08f7 | 1132 | motor[TIRE_FR].pwm = fast-5; |
yabahiro | 51:a0bdbddd08f7 | 1133 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1134 | motor[TIRE_FL].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1135 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1136 | motor[TIRE_BR].pwm = fast-5; |
yabahiro | 51:a0bdbddd08f7 | 1137 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1138 | motor[TIRE_BL].pwm = fast-5; |
yabahiro | 51:a0bdbddd08f7 | 1139 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1140 | break; |
yabahiro | 51:a0bdbddd08f7 | 1141 | case 99: |
yabahiro | 51:a0bdbddd08f7 | 1142 | motor[TIRE_FR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1143 | motor[TIRE_FR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1144 | motor[TIRE_FL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1145 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1146 | motor[TIRE_BR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1147 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1148 | motor[TIRE_BL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1149 | motor[TIRE_BL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1150 | break; |
yabahiro | 51:a0bdbddd08f7 | 1151 | case 0: |
yabahiro | 51:a0bdbddd08f7 | 1152 | motor[TIRE_FR].pwm = fast-5; |
yabahiro | 51:a0bdbddd08f7 | 1153 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1154 | motor[TIRE_FL].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1155 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1156 | motor[TIRE_BR].pwm = fast-5; |
yabahiro | 51:a0bdbddd08f7 | 1157 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1158 | motor[TIRE_BL].pwm = fast-5; |
yabahiro | 51:a0bdbddd08f7 | 1159 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1160 | break; |
yabahiro | 51:a0bdbddd08f7 | 1161 | case 255: |
yabahiro | 51:a0bdbddd08f7 | 1162 | motor[TIRE_FR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1163 | motor[TIRE_FR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1164 | motor[TIRE_FL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1165 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1166 | motor[TIRE_BR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1167 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1168 | motor[TIRE_BL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1169 | motor[TIRE_BL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1170 | break; |
yabahiro | 51:a0bdbddd08f7 | 1171 | case 253: |
yabahiro | 51:a0bdbddd08f7 | 1172 | motor[TIRE_FR].pwm = fast-5; |
yabahiro | 51:a0bdbddd08f7 | 1173 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1174 | motor[TIRE_FL].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1175 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1176 | motor[TIRE_BR].pwm = slow-5; |
yabahiro | 51:a0bdbddd08f7 | 1177 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1178 | motor[TIRE_BL].pwm = fast-5; |
yabahiro | 51:a0bdbddd08f7 | 1179 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1180 | break; |
yabahiro | 51:a0bdbddd08f7 | 1181 | case 254: |
yabahiro | 51:a0bdbddd08f7 | 1182 | motor[TIRE_FR].pwm = fast-5; |
yabahiro | 51:a0bdbddd08f7 | 1183 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1184 | motor[TIRE_FL].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1185 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1186 | motor[TIRE_BR].pwm = normal-5; |
yabahiro | 51:a0bdbddd08f7 | 1187 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1188 | motor[TIRE_BL].pwm = fast-5; |
yabahiro | 51:a0bdbddd08f7 | 1189 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1190 | break; |
yabahiro | 51:a0bdbddd08f7 | 1191 | case 1: |
yabahiro | 51:a0bdbddd08f7 | 1192 | motor[TIRE_FR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1193 | motor[TIRE_FR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1194 | motor[TIRE_FL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1195 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1196 | motor[TIRE_BR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1197 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1198 | motor[TIRE_BL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1199 | motor[TIRE_BL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1200 | break; |
yabahiro | 51:a0bdbddd08f7 | 1201 | case 3: |
yabahiro | 51:a0bdbddd08f7 | 1202 | motor[TIRE_FR].pwm = slow-5; |
yabahiro | 51:a0bdbddd08f7 | 1203 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1204 | motor[TIRE_FL].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1205 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1206 | motor[TIRE_BR].pwm = fast-5; |
yabahiro | 51:a0bdbddd08f7 | 1207 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1208 | motor[TIRE_BL].pwm = slow-5; |
yabahiro | 51:a0bdbddd08f7 | 1209 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1210 | break; |
yabahiro | 51:a0bdbddd08f7 | 1211 | case 2: |
yabahiro | 51:a0bdbddd08f7 | 1212 | motor[TIRE_FR].pwm = normal-5; |
yabahiro | 51:a0bdbddd08f7 | 1213 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1214 | motor[TIRE_FL].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1215 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1216 | motor[TIRE_BR].pwm = fast-5; |
yabahiro | 51:a0bdbddd08f7 | 1217 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1218 | motor[TIRE_BL].pwm = normal-5; |
yabahiro | 51:a0bdbddd08f7 | 1219 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1220 | break; |
yabahiro | 51:a0bdbddd08f7 | 1221 | } |
yabahiro | 58:bfc38c43dadb | 1222 | |
yabahiro | 58:bfc38c43dadb | 1223 | |
yabahiro | 58:bfc38c43dadb | 1224 | /* |
yabahiro | 58:bfc38c43dadb | 1225 | if(value>=3000) { |
yabahiro | 58:bfc38c43dadb | 1226 | mode=24; |
yabahiro | 58:bfc38c43dadb | 1227 | aime.reset(); |
yabahiro | 58:bfc38c43dadb | 1228 | value=0; |
yabahiro | 58:bfc38c43dadb | 1229 | solenoid.solenoid2 = SOLENOID_OFF; |
yabahiro | 58:bfc38c43dadb | 1230 | countss=0; |
yabahiro | 58:bfc38c43dadb | 1231 | fast=80; |
yabahiro | 58:bfc38c43dadb | 1232 | normal=60; |
yabahiro | 58:bfc38c43dadb | 1233 | slow=30; |
yabahiro | 58:bfc38c43dadb | 1234 | } |
yabahiro | 51:a0bdbddd08f7 | 1235 | if(g[0]==98) { |
yabahiro | 51:a0bdbddd08f7 | 1236 | fast=20; |
yabahiro | 51:a0bdbddd08f7 | 1237 | normal=15; |
yabahiro | 51:a0bdbddd08f7 | 1238 | slow=10; |
yabahiro | 51:a0bdbddd08f7 | 1239 | } |
yabahiro | 58:bfc38c43dadb | 1240 | */ |
yabahiro | 58:bfc38c43dadb | 1241 | if(value>=2000) { |
yabahiro | 58:bfc38c43dadb | 1242 | fast=20; |
yabahiro | 58:bfc38c43dadb | 1243 | normal=15; |
yabahiro | 58:bfc38c43dadb | 1244 | slow=10; |
yabahiro | 58:bfc38c43dadb | 1245 | } |
yabahiro | 58:bfc38c43dadb | 1246 | if(g[2]==254&&value>=2700) { |
yabahiro | 51:a0bdbddd08f7 | 1247 | mode=24; |
yabahiro | 51:a0bdbddd08f7 | 1248 | solenoid.solenoid2 = SOLENOID_OFF; |
yabahiro | 51:a0bdbddd08f7 | 1249 | countss=0; |
yabahiro | 58:bfc38c43dadb | 1250 | value=0; |
yabahiro | 58:bfc38c43dadb | 1251 | aime.reset(); |
yabahiro | 54:4167f10ecad0 | 1252 | fast=80; |
yabahiro | 54:4167f10ecad0 | 1253 | normal=60; |
yabahiro | 54:4167f10ecad0 | 1254 | slow=30; |
yabahiro | 51:a0bdbddd08f7 | 1255 | } |
yabahiro | 51:a0bdbddd08f7 | 1256 | } else { |
yabahiro | 51:a0bdbddd08f7 | 1257 | if(UPLS==true||DOLS==true) { |
yabahiro | 51:a0bdbddd08f7 | 1258 | if(UPLS==true||DOLS==true) { |
yabahiro | 51:a0bdbddd08f7 | 1259 | motor[MOTOR_0].pwm = 200; |
yabahiro | 51:a0bdbddd08f7 | 1260 | motor[MOTOR_0].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 1261 | fast=60; |
yabahiro | 51:a0bdbddd08f7 | 1262 | normal=40; |
yabahiro | 53:694dbd7dfa0e | 1263 | slow=30; |
yabahiro | 51:a0bdbddd08f7 | 1264 | countss=0; |
yabahiro | 58:bfc38c43dadb | 1265 | value=0; |
yabahiro | 58:bfc38c43dadb | 1266 | aime.reset(); |
yabahiro | 51:a0bdbddd08f7 | 1267 | mode=24; |
yabahiro | 51:a0bdbddd08f7 | 1268 | } |
yabahiro | 51:a0bdbddd08f7 | 1269 | } else { |
yabahiro | 51:a0bdbddd08f7 | 1270 | motor[MOTOR_0].pwm = 100; |
yabahiro | 51:a0bdbddd08f7 | 1271 | motor[MOTOR_0].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1272 | } |
yabahiro | 51:a0bdbddd08f7 | 1273 | motor[TIRE_FR].pwm = 100; |
yabahiro | 51:a0bdbddd08f7 | 1274 | motor[TIRE_FR].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 1275 | motor[TIRE_FL].pwm = 100; |
yabahiro | 51:a0bdbddd08f7 | 1276 | motor[TIRE_FL].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 1277 | motor[TIRE_BR].pwm = 100; |
yabahiro | 51:a0bdbddd08f7 | 1278 | motor[TIRE_BR].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 1279 | motor[TIRE_BL].pwm = 100; |
yabahiro | 51:a0bdbddd08f7 | 1280 | motor[TIRE_BL].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 1281 | } |
yabahiro | 51:a0bdbddd08f7 | 1282 | break; |
yabahiro | 51:a0bdbddd08f7 | 1283 | case 24: |
yabahiro | 51:a0bdbddd08f7 | 1284 | if(YELLOW) { |
yabahiro | 58:bfc38c43dadb | 1285 | /* |
yabahiro | 51:a0bdbddd08f7 | 1286 | if(g[4]==3||g[4]==2) { |
yabahiro | 51:a0bdbddd08f7 | 1287 | motor[TIRE_FR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 1288 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 1289 | motor[TIRE_FL].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 1290 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 1291 | motor[TIRE_BR].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 1292 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1293 | motor[TIRE_BL].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 1294 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1295 | } |
yabahiro | 51:a0bdbddd08f7 | 1296 | if(g[4]==253||g[4]==254) { |
yabahiro | 54:4167f10ecad0 | 1297 | motor[TIRE_FR].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 1298 | motor[TIRE_FR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1299 | motor[TIRE_FL].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 1300 | motor[TIRE_FL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1301 | motor[TIRE_BR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 1302 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 1303 | motor[TIRE_BL].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 1304 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1305 | } |
yabahiro | 51:a0bdbddd08f7 | 1306 | switch(g[2]) { |
yabahiro | 51:a0bdbddd08f7 | 1307 | case 0: |
yabahiro | 51:a0bdbddd08f7 | 1308 | motor[TIRE_FR].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 1309 | motor[TIRE_FR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1310 | motor[TIRE_BR].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 1311 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1312 | break; |
yabahiro | 51:a0bdbddd08f7 | 1313 | case 255: |
yabahiro | 51:a0bdbddd08f7 | 1314 | motor[TIRE_FR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 1315 | motor[TIRE_FR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1316 | motor[TIRE_BR].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 1317 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1318 | break; |
yabahiro | 51:a0bdbddd08f7 | 1319 | case 253: |
yabahiro | 51:a0bdbddd08f7 | 1320 | motor[TIRE_FR].pwm = 40; |
yabahiro | 51:a0bdbddd08f7 | 1321 | motor[TIRE_FR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1322 | motor[TIRE_BR].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 1323 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1324 | break; |
yabahiro | 51:a0bdbddd08f7 | 1325 | case 254: |
yabahiro | 51:a0bdbddd08f7 | 1326 | motor[TIRE_FR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 1327 | motor[TIRE_FR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1328 | motor[TIRE_BR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 1329 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1330 | break; |
yabahiro | 51:a0bdbddd08f7 | 1331 | case 1: |
yabahiro | 51:a0bdbddd08f7 | 1332 | motor[TIRE_FR].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 1333 | motor[TIRE_FR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1334 | motor[TIRE_BR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 1335 | motor[TIRE_BR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1336 | break; |
yabahiro | 51:a0bdbddd08f7 | 1337 | case 3: |
yabahiro | 51:a0bdbddd08f7 | 1338 | motor[TIRE_FR].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 1339 | motor[TIRE_FR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1340 | motor[TIRE_BR].pwm = 40; |
yabahiro | 51:a0bdbddd08f7 | 1341 | motor[TIRE_BR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1342 | break; |
yabahiro | 51:a0bdbddd08f7 | 1343 | case 2: |
yabahiro | 51:a0bdbddd08f7 | 1344 | motor[TIRE_FR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 1345 | motor[TIRE_FR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1346 | motor[TIRE_BR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 1347 | motor[TIRE_BR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1348 | break; |
yabahiro | 51:a0bdbddd08f7 | 1349 | } |
yabahiro | 51:a0bdbddd08f7 | 1350 | switch(g[3]) { |
yabahiro | 51:a0bdbddd08f7 | 1351 | case 0: |
yabahiro | 51:a0bdbddd08f7 | 1352 | motor[TIRE_FL].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 1353 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1354 | motor[TIRE_BL].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 1355 | motor[TIRE_BL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1356 | break; |
yabahiro | 51:a0bdbddd08f7 | 1357 | case 255: |
yabahiro | 51:a0bdbddd08f7 | 1358 | motor[TIRE_FL].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 1359 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1360 | motor[TIRE_BL].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 1361 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1362 | case 253: |
yabahiro | 51:a0bdbddd08f7 | 1363 | motor[TIRE_FL].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 1364 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1365 | motor[TIRE_BL].pwm = 40; |
yabahiro | 51:a0bdbddd08f7 | 1366 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1367 | break; |
yabahiro | 51:a0bdbddd08f7 | 1368 | case 254: |
yabahiro | 53:694dbd7dfa0e | 1369 | motor[TIRE_FL].pwm = 35; |
yabahiro | 51:a0bdbddd08f7 | 1370 | motor[TIRE_FL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1371 | motor[TIRE_BL].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 1372 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1373 | break; |
yabahiro | 51:a0bdbddd08f7 | 1374 | case 1: |
yabahiro | 53:694dbd7dfa0e | 1375 | motor[TIRE_FL].pwm = 35; |
yabahiro | 51:a0bdbddd08f7 | 1376 | motor[TIRE_FL].dir = FOR; |
yabahiro | 53:694dbd7dfa0e | 1377 | motor[TIRE_BL].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 1378 | motor[TIRE_BL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1379 | break; |
yabahiro | 51:a0bdbddd08f7 | 1380 | case 3: |
yabahiro | 53:694dbd7dfa0e | 1381 | motor[TIRE_FL].pwm = 45; |
yabahiro | 51:a0bdbddd08f7 | 1382 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1383 | motor[TIRE_BL].pwm = 25; |
yabahiro | 51:a0bdbddd08f7 | 1384 | motor[TIRE_BL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1385 | break; |
yabahiro | 51:a0bdbddd08f7 | 1386 | case 2: |
yabahiro | 53:694dbd7dfa0e | 1387 | motor[TIRE_FL].pwm = 35; |
yabahiro | 51:a0bdbddd08f7 | 1388 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1389 | motor[TIRE_BL].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 1390 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1391 | break; |
yabahiro | 51:a0bdbddd08f7 | 1392 | } |
yabahiro | 58:bfc38c43dadb | 1393 | |
yabahiro | 51:a0bdbddd08f7 | 1394 | if(g[3]==0&&g[2]==0) { |
yabahiro | 51:a0bdbddd08f7 | 1395 | mode=25; |
yabahiro | 51:a0bdbddd08f7 | 1396 | } |
yabahiro | 58:bfc38c43dadb | 1397 | */ |
yabahiro | 58:bfc38c43dadb | 1398 | mode=25; |
yabahiro | 51:a0bdbddd08f7 | 1399 | } else { |
yabahiro | 58:bfc38c43dadb | 1400 | if(g[0]==98&&value>=2000) { |
yabahiro | 51:a0bdbddd08f7 | 1401 | mode=31; |
yabahiro | 53:694dbd7dfa0e | 1402 | fast=60; |
yabahiro | 53:694dbd7dfa0e | 1403 | normal=40; |
yabahiro | 53:694dbd7dfa0e | 1404 | slow=30; |
yabahiro | 51:a0bdbddd08f7 | 1405 | countss=0; |
yabahiro | 51:a0bdbddd08f7 | 1406 | } |
yabahiro | 51:a0bdbddd08f7 | 1407 | switch(g[0]) { |
yabahiro | 51:a0bdbddd08f7 | 1408 | case 98: |
yabahiro | 51:a0bdbddd08f7 | 1409 | motor[TIRE_FR].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1410 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1411 | motor[TIRE_FL].pwm = normal+5; |
yabahiro | 51:a0bdbddd08f7 | 1412 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1413 | motor[TIRE_BR].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1414 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1415 | motor[TIRE_BL].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1416 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1417 | break; |
yabahiro | 51:a0bdbddd08f7 | 1418 | case 0: |
yabahiro | 51:a0bdbddd08f7 | 1419 | motor[TIRE_FR].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1420 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1421 | motor[TIRE_FL].pwm = fast+5; |
yabahiro | 51:a0bdbddd08f7 | 1422 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1423 | motor[TIRE_BR].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1424 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1425 | motor[TIRE_BL].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1426 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1427 | mtc=true; |
yabahiro | 51:a0bdbddd08f7 | 1428 | break; |
yabahiro | 51:a0bdbddd08f7 | 1429 | case 255: |
yabahiro | 51:a0bdbddd08f7 | 1430 | motor[TIRE_FR].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1431 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1432 | motor[TIRE_FL].pwm = slow+5; |
yabahiro | 51:a0bdbddd08f7 | 1433 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1434 | motor[TIRE_BR].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1435 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1436 | motor[TIRE_BL].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1437 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1438 | mtc=true; |
yabahiro | 51:a0bdbddd08f7 | 1439 | break; |
yabahiro | 51:a0bdbddd08f7 | 1440 | case 253: |
yabahiro | 51:a0bdbddd08f7 | 1441 | motor[TIRE_FR].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1442 | motor[TIRE_FR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1443 | motor[TIRE_FL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1444 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1445 | motor[TIRE_BR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1446 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1447 | motor[TIRE_BL].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1448 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1449 | mtc=true; |
yabahiro | 51:a0bdbddd08f7 | 1450 | break; |
yabahiro | 51:a0bdbddd08f7 | 1451 | case 254: |
yabahiro | 51:a0bdbddd08f7 | 1452 | motor[TIRE_FR].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1453 | motor[TIRE_FR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1454 | motor[TIRE_FL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1455 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1456 | motor[TIRE_BR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1457 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1458 | motor[TIRE_BL].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1459 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1460 | mtc=true; |
yabahiro | 51:a0bdbddd08f7 | 1461 | break; |
yabahiro | 51:a0bdbddd08f7 | 1462 | case 1: |
yabahiro | 51:a0bdbddd08f7 | 1463 | motor[TIRE_FR].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1464 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1465 | motor[TIRE_FL].pwm = fast+5; |
yabahiro | 51:a0bdbddd08f7 | 1466 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1467 | motor[TIRE_BR].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1468 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1469 | motor[TIRE_BL].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1470 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1471 | mtc=true; |
yabahiro | 51:a0bdbddd08f7 | 1472 | break; |
yabahiro | 51:a0bdbddd08f7 | 1473 | case 3: |
yabahiro | 51:a0bdbddd08f7 | 1474 | motor[TIRE_FR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1475 | motor[TIRE_FR].dir = FREE; |
yabahiro | 53:694dbd7dfa0e | 1476 | motor[TIRE_FL].pwm = slow+5; |
yabahiro | 51:a0bdbddd08f7 | 1477 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1478 | motor[TIRE_BR].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1479 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1480 | motor[TIRE_BL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1481 | motor[TIRE_BL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1482 | mtc=true; |
yabahiro | 51:a0bdbddd08f7 | 1483 | break; |
yabahiro | 51:a0bdbddd08f7 | 1484 | case 2: |
yabahiro | 51:a0bdbddd08f7 | 1485 | motor[TIRE_FR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1486 | motor[TIRE_FR].dir = FREE; |
yabahiro | 53:694dbd7dfa0e | 1487 | motor[TIRE_FL].pwm = normal+5; |
yabahiro | 51:a0bdbddd08f7 | 1488 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1489 | motor[TIRE_BR].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1490 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1491 | motor[TIRE_BL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1492 | motor[TIRE_BL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1493 | mtc=true; |
yabahiro | 51:a0bdbddd08f7 | 1494 | break; |
yabahiro | 51:a0bdbddd08f7 | 1495 | } |
yabahiro | 51:a0bdbddd08f7 | 1496 | if(g[1]!=98&&mtc==true) { |
yabahiro | 51:a0bdbddd08f7 | 1497 | switch(g[1]) { |
yabahiro | 51:a0bdbddd08f7 | 1498 | case 0: |
yabahiro | 51:a0bdbddd08f7 | 1499 | mtc=false; |
yabahiro | 51:a0bdbddd08f7 | 1500 | break; |
yabahiro | 51:a0bdbddd08f7 | 1501 | case 255: |
yabahiro | 51:a0bdbddd08f7 | 1502 | motor[TIRE_BR].pwm += 5; |
yabahiro | 51:a0bdbddd08f7 | 1503 | mtc=false; |
yabahiro | 51:a0bdbddd08f7 | 1504 | break; |
yabahiro | 51:a0bdbddd08f7 | 1505 | case 253: |
yabahiro | 51:a0bdbddd08f7 | 1506 | motor[TIRE_BR].pwm += 10; |
yabahiro | 51:a0bdbddd08f7 | 1507 | mtc=false; |
yabahiro | 51:a0bdbddd08f7 | 1508 | break; |
yabahiro | 51:a0bdbddd08f7 | 1509 | case 254: |
yabahiro | 51:a0bdbddd08f7 | 1510 | motor[TIRE_BR].pwm += 20; |
yabahiro | 51:a0bdbddd08f7 | 1511 | motor[TIRE_BL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1512 | mtc=false; |
yabahiro | 51:a0bdbddd08f7 | 1513 | break; |
yabahiro | 51:a0bdbddd08f7 | 1514 | case 1: |
yabahiro | 51:a0bdbddd08f7 | 1515 | motor[TIRE_BL].pwm += 5; |
yabahiro | 51:a0bdbddd08f7 | 1516 | mtc=false; |
yabahiro | 51:a0bdbddd08f7 | 1517 | break; |
yabahiro | 51:a0bdbddd08f7 | 1518 | case 3: |
yabahiro | 51:a0bdbddd08f7 | 1519 | motor[TIRE_BL].pwm += 10; |
yabahiro | 51:a0bdbddd08f7 | 1520 | mtc=false; |
yabahiro | 51:a0bdbddd08f7 | 1521 | break; |
yabahiro | 51:a0bdbddd08f7 | 1522 | case 2: |
yabahiro | 51:a0bdbddd08f7 | 1523 | motor[TIRE_BL].pwm += 20; |
yabahiro | 51:a0bdbddd08f7 | 1524 | motor[TIRE_BR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1525 | mtc=false; |
yabahiro | 51:a0bdbddd08f7 | 1526 | break; |
yabahiro | 51:a0bdbddd08f7 | 1527 | } |
yabahiro | 51:a0bdbddd08f7 | 1528 | } |
yabahiro | 51:a0bdbddd08f7 | 1529 | } |
yabahiro | 51:a0bdbddd08f7 | 1530 | break; |
yabahiro | 51:a0bdbddd08f7 | 1531 | case 25: |
yabahiro | 51:a0bdbddd08f7 | 1532 | motor[TIRE_FR].pwm = 100; |
yabahiro | 51:a0bdbddd08f7 | 1533 | motor[TIRE_FR].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 1534 | motor[TIRE_FL].pwm = 100; |
yabahiro | 51:a0bdbddd08f7 | 1535 | motor[TIRE_FL].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 1536 | motor[TIRE_BR].pwm = 100; |
yabahiro | 51:a0bdbddd08f7 | 1537 | motor[TIRE_BR].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 1538 | motor[TIRE_BL].pwm = 100; |
yabahiro | 51:a0bdbddd08f7 | 1539 | motor[TIRE_BL].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 1540 | if(DOLS==true||UPLS==true) { |
yabahiro | 51:a0bdbddd08f7 | 1541 | if(DOLS==true||UPLS==true) { |
yabahiro | 51:a0bdbddd08f7 | 1542 | motor[MOTOR_0].pwm = 200; |
yabahiro | 51:a0bdbddd08f7 | 1543 | motor[MOTOR_0].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 1544 | countss=0; |
yabahiro | 51:a0bdbddd08f7 | 1545 | mode=26; |
yabahiro | 58:bfc38c43dadb | 1546 | value=0; |
yabahiro | 58:bfc38c43dadb | 1547 | aime.reset(); |
yabahiro | 51:a0bdbddd08f7 | 1548 | } |
yabahiro | 51:a0bdbddd08f7 | 1549 | } else { |
yabahiro | 51:a0bdbddd08f7 | 1550 | motor[MOTOR_0].pwm = 100; |
yabahiro | 51:a0bdbddd08f7 | 1551 | motor[MOTOR_0].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1552 | } |
yabahiro | 51:a0bdbddd08f7 | 1553 | break; |
yabahiro | 51:a0bdbddd08f7 | 1554 | case 26: |
yabahiro | 58:bfc38c43dadb | 1555 | if(g[0]==98&&value>=2500) { |
yabahiro | 53:694dbd7dfa0e | 1556 | mode=31; |
yabahiro | 53:694dbd7dfa0e | 1557 | } |
yabahiro | 50:87f5fa1bc460 | 1558 | switch(g[4]) { |
yabahiro | 50:87f5fa1bc460 | 1559 | case 98: |
yabahiro | 51:a0bdbddd08f7 | 1560 | motor[TIRE_FR].pwm = 60; |
yabahiro | 50:87f5fa1bc460 | 1561 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1562 | motor[TIRE_FL].pwm = 65; |
yabahiro | 50:87f5fa1bc460 | 1563 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1564 | motor[TIRE_BR].pwm = 60; |
yabahiro | 50:87f5fa1bc460 | 1565 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1566 | motor[TIRE_BL].pwm = 60; |
yabahiro | 50:87f5fa1bc460 | 1567 | motor[TIRE_BL].dir = FOR; |
yabahiro | 50:87f5fa1bc460 | 1568 | break; |
yabahiro | 50:87f5fa1bc460 | 1569 | case 99: |
yabahiro | 50:87f5fa1bc460 | 1570 | motor[TIRE_FR].pwm = 0; |
yabahiro | 50:87f5fa1bc460 | 1571 | motor[TIRE_FR].dir = FREE; |
yabahiro | 50:87f5fa1bc460 | 1572 | motor[TIRE_FL].pwm = 0; |
yabahiro | 50:87f5fa1bc460 | 1573 | motor[TIRE_FL].dir = FREE; |
yabahiro | 50:87f5fa1bc460 | 1574 | motor[TIRE_BR].pwm = 0; |
yabahiro | 50:87f5fa1bc460 | 1575 | motor[TIRE_BR].dir = FREE; |
yabahiro | 50:87f5fa1bc460 | 1576 | motor[TIRE_BL].pwm = 0; |
yabahiro | 50:87f5fa1bc460 | 1577 | motor[TIRE_BL].dir = FREE; |
yabahiro | 50:87f5fa1bc460 | 1578 | break; |
yabahiro | 50:87f5fa1bc460 | 1579 | case 0: |
yabahiro | 51:a0bdbddd08f7 | 1580 | motor[TIRE_FR].pwm = 60; |
yabahiro | 50:87f5fa1bc460 | 1581 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1582 | motor[TIRE_FL].pwm = 65; |
yabahiro | 50:87f5fa1bc460 | 1583 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1584 | motor[TIRE_BR].pwm = 60; |
yabahiro | 50:87f5fa1bc460 | 1585 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1586 | motor[TIRE_BL].pwm = 60; |
yabahiro | 50:87f5fa1bc460 | 1587 | motor[TIRE_BL].dir = FOR; |
yabahiro | 50:87f5fa1bc460 | 1588 | break; |
yabahiro | 50:87f5fa1bc460 | 1589 | case 255: |
yabahiro | 50:87f5fa1bc460 | 1590 | motor[TIRE_FR].pwm = 0; |
yabahiro | 50:87f5fa1bc460 | 1591 | motor[TIRE_FR].dir = FREE; |
yabahiro | 50:87f5fa1bc460 | 1592 | motor[TIRE_FL].pwm = 0; |
yabahiro | 50:87f5fa1bc460 | 1593 | motor[TIRE_FL].dir = FREE; |
yabahiro | 50:87f5fa1bc460 | 1594 | motor[TIRE_BR].pwm = 0; |
yabahiro | 50:87f5fa1bc460 | 1595 | motor[TIRE_BR].dir = FREE; |
yabahiro | 50:87f5fa1bc460 | 1596 | motor[TIRE_BL].pwm = 0; |
yabahiro | 50:87f5fa1bc460 | 1597 | motor[TIRE_BL].dir = FREE; |
yabahiro | 50:87f5fa1bc460 | 1598 | break; |
yabahiro | 50:87f5fa1bc460 | 1599 | case 253: |
yabahiro | 51:a0bdbddd08f7 | 1600 | motor[TIRE_FR].pwm = 60; |
yabahiro | 50:87f5fa1bc460 | 1601 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1602 | motor[TIRE_FL].pwm = 30; |
yabahiro | 50:87f5fa1bc460 | 1603 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1604 | motor[TIRE_BR].pwm = 25; |
yabahiro | 50:87f5fa1bc460 | 1605 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1606 | motor[TIRE_BL].pwm = 60; |
yabahiro | 50:87f5fa1bc460 | 1607 | motor[TIRE_BL].dir = FOR; |
yabahiro | 50:87f5fa1bc460 | 1608 | break; |
yabahiro | 50:87f5fa1bc460 | 1609 | case 254: |
yabahiro | 51:a0bdbddd08f7 | 1610 | motor[TIRE_FR].pwm = 60; |
yabahiro | 50:87f5fa1bc460 | 1611 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1612 | motor[TIRE_FL].pwm = 45; |
yabahiro | 50:87f5fa1bc460 | 1613 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1614 | motor[TIRE_BR].pwm = 40; |
yabahiro | 50:87f5fa1bc460 | 1615 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1616 | motor[TIRE_BL].pwm = 60; |
yabahiro | 50:87f5fa1bc460 | 1617 | motor[TIRE_BL].dir = FOR; |
yabahiro | 50:87f5fa1bc460 | 1618 | break; |
yabahiro | 50:87f5fa1bc460 | 1619 | case 1: |
yabahiro | 50:87f5fa1bc460 | 1620 | motor[TIRE_FR].pwm = 0; |
yabahiro | 50:87f5fa1bc460 | 1621 | motor[TIRE_FR].dir = FREE; |
yabahiro | 50:87f5fa1bc460 | 1622 | motor[TIRE_FL].pwm = 0; |
yabahiro | 50:87f5fa1bc460 | 1623 | motor[TIRE_FL].dir = FREE; |
yabahiro | 50:87f5fa1bc460 | 1624 | motor[TIRE_BR].pwm = 0; |
yabahiro | 50:87f5fa1bc460 | 1625 | motor[TIRE_BR].dir = FREE; |
yabahiro | 50:87f5fa1bc460 | 1626 | motor[TIRE_BL].pwm = 0; |
yabahiro | 50:87f5fa1bc460 | 1627 | motor[TIRE_BL].dir = FREE; |
yabahiro | 50:87f5fa1bc460 | 1628 | break; |
yabahiro | 50:87f5fa1bc460 | 1629 | case 3: |
yabahiro | 51:a0bdbddd08f7 | 1630 | motor[TIRE_FR].pwm = 25; |
yabahiro | 50:87f5fa1bc460 | 1631 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1632 | motor[TIRE_FL].pwm = 65; |
yabahiro | 50:87f5fa1bc460 | 1633 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1634 | motor[TIRE_BR].pwm = 60; |
yabahiro | 50:87f5fa1bc460 | 1635 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1636 | motor[TIRE_BL].pwm = 25; |
yabahiro | 50:87f5fa1bc460 | 1637 | motor[TIRE_BL].dir = FOR; |
yabahiro | 50:87f5fa1bc460 | 1638 | break; |
yabahiro | 50:87f5fa1bc460 | 1639 | case 2: |
yabahiro | 51:a0bdbddd08f7 | 1640 | motor[TIRE_FR].pwm = 40; |
yabahiro | 50:87f5fa1bc460 | 1641 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1642 | motor[TIRE_FL].pwm = 65; |
yabahiro | 50:87f5fa1bc460 | 1643 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1644 | motor[TIRE_BR].pwm = 60; |
yabahiro | 50:87f5fa1bc460 | 1645 | motor[TIRE_BR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1646 | motor[TIRE_BL].pwm = 40; |
yabahiro | 50:87f5fa1bc460 | 1647 | motor[TIRE_BL].dir = FOR; |
yabahiro | 50:87f5fa1bc460 | 1648 | break; |
yabahiro | 50:87f5fa1bc460 | 1649 | } |
yabahiro | 51:a0bdbddd08f7 | 1650 | break; |
yabahiro | 51:a0bdbddd08f7 | 1651 | case 31: |
yabahiro | 53:694dbd7dfa0e | 1652 | motor[TIRE_FR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 1653 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1654 | motor[TIRE_FL].pwm = 5; |
yabahiro | 53:694dbd7dfa0e | 1655 | motor[TIRE_FL].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1656 | motor[TIRE_BR].pwm = 5; |
yabahiro | 53:694dbd7dfa0e | 1657 | motor[TIRE_BR].dir = FOR; |
yabahiro | 53:694dbd7dfa0e | 1658 | motor[TIRE_BL].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 1659 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1660 | if(g[2]==0) { |
yabahiro | 51:a0bdbddd08f7 | 1661 | cross=0; |
yabahiro | 51:a0bdbddd08f7 | 1662 | countss=0; |
yabahiro | 51:a0bdbddd08f7 | 1663 | mode=40; |
yabahiro | 55:844ac0974740 | 1664 | fast=70; |
yabahiro | 55:844ac0974740 | 1665 | normal=50; |
yabahiro | 55:844ac0974740 | 1666 | slow=40; |
yabahiro | 51:a0bdbddd08f7 | 1667 | } |
yabahiro | 51:a0bdbddd08f7 | 1668 | break; |
yabahiro | 51:a0bdbddd08f7 | 1669 | case 40: |
yabahiro | 51:a0bdbddd08f7 | 1670 | switch(g[3]) { |
yabahiro | 51:a0bdbddd08f7 | 1671 | case 98: |
yabahiro | 53:694dbd7dfa0e | 1672 | motor[TIRE_FR].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1673 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1674 | motor[TIRE_FL].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1675 | motor[TIRE_FL].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1676 | motor[TIRE_BR].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1677 | motor[TIRE_BR].dir = FOR; |
yabahiro | 53:694dbd7dfa0e | 1678 | motor[TIRE_BL].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1679 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1680 | if(countss>30000) { |
yabahiro | 51:a0bdbddd08f7 | 1681 | cross++; |
yabahiro | 51:a0bdbddd08f7 | 1682 | countss=0; |
yabahiro | 51:a0bdbddd08f7 | 1683 | } |
yabahiro | 51:a0bdbddd08f7 | 1684 | mtc2=true; |
yabahiro | 51:a0bdbddd08f7 | 1685 | if(YELLOW) { |
yabahiro | 51:a0bdbddd08f7 | 1686 | if(cross==1) { |
yabahiro | 51:a0bdbddd08f7 | 1687 | mode=41; |
yabahiro | 51:a0bdbddd08f7 | 1688 | countss=0; |
yabahiro | 51:a0bdbddd08f7 | 1689 | cross=0; |
yabahiro | 51:a0bdbddd08f7 | 1690 | } |
yabahiro | 51:a0bdbddd08f7 | 1691 | } else { |
yabahiro | 51:a0bdbddd08f7 | 1692 | if(cross==3) { |
yabahiro | 53:694dbd7dfa0e | 1693 | fast=60; |
yabahiro | 53:694dbd7dfa0e | 1694 | normal=40; |
yabahiro | 53:694dbd7dfa0e | 1695 | slow=30; |
yabahiro | 51:a0bdbddd08f7 | 1696 | mode=41; |
yabahiro | 51:a0bdbddd08f7 | 1697 | countss=0; |
yabahiro | 51:a0bdbddd08f7 | 1698 | cross=0; |
yabahiro | 51:a0bdbddd08f7 | 1699 | } |
yabahiro | 51:a0bdbddd08f7 | 1700 | } |
yabahiro | 51:a0bdbddd08f7 | 1701 | break; |
yabahiro | 50:87f5fa1bc460 | 1702 | case 0: |
yabahiro | 53:694dbd7dfa0e | 1703 | motor[TIRE_FR].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1704 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1705 | motor[TIRE_FL].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1706 | motor[TIRE_FL].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1707 | motor[TIRE_BR].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1708 | motor[TIRE_BR].dir = FOR; |
yabahiro | 53:694dbd7dfa0e | 1709 | motor[TIRE_BL].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1710 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1711 | mtc2=true; |
yabahiro | 50:87f5fa1bc460 | 1712 | break; |
yabahiro | 50:87f5fa1bc460 | 1713 | case 255: |
yabahiro | 53:694dbd7dfa0e | 1714 | motor[TIRE_FR].pwm = slow; |
yabahiro | 50:87f5fa1bc460 | 1715 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1716 | motor[TIRE_FL].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1717 | motor[TIRE_FL].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1718 | motor[TIRE_BR].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1719 | motor[TIRE_BR].dir = FOR; |
yabahiro | 53:694dbd7dfa0e | 1720 | motor[TIRE_BL].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1721 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1722 | mtc2=true; |
yabahiro | 50:87f5fa1bc460 | 1723 | break; |
yabahiro | 50:87f5fa1bc460 | 1724 | case 253: |
yabahiro | 51:a0bdbddd08f7 | 1725 | motor[TIRE_FR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1726 | motor[TIRE_FR].dir = FREE; |
yabahiro | 53:694dbd7dfa0e | 1727 | motor[TIRE_FL].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1728 | motor[TIRE_FL].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1729 | motor[TIRE_BR].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1730 | motor[TIRE_BR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1731 | motor[TIRE_BL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1732 | motor[TIRE_BL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1733 | mtc2=true; |
yabahiro | 50:87f5fa1bc460 | 1734 | break; |
yabahiro | 50:87f5fa1bc460 | 1735 | case 254: |
yabahiro | 51:a0bdbddd08f7 | 1736 | motor[TIRE_FR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1737 | motor[TIRE_FR].dir = FREE; |
yabahiro | 53:694dbd7dfa0e | 1738 | motor[TIRE_FL].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1739 | motor[TIRE_FL].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1740 | motor[TIRE_BR].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1741 | motor[TIRE_BR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1742 | motor[TIRE_BL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1743 | motor[TIRE_BL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1744 | mtc2=true; |
yabahiro | 50:87f5fa1bc460 | 1745 | break; |
yabahiro | 50:87f5fa1bc460 | 1746 | case 1: |
yabahiro | 53:694dbd7dfa0e | 1747 | motor[TIRE_FR].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1748 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1749 | motor[TIRE_FL].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1750 | motor[TIRE_FL].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1751 | motor[TIRE_BR].pwm = slow; |
yabahiro | 50:87f5fa1bc460 | 1752 | motor[TIRE_BR].dir = FOR; |
yabahiro | 53:694dbd7dfa0e | 1753 | motor[TIRE_BL].pwm = fast; |
yabahiro | 51:a0bdbddd08f7 | 1754 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1755 | mtc2=true; |
yabahiro | 50:87f5fa1bc460 | 1756 | break; |
yabahiro | 50:87f5fa1bc460 | 1757 | case 3: |
yabahiro | 53:694dbd7dfa0e | 1758 | motor[TIRE_FR].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1759 | motor[TIRE_FR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1760 | motor[TIRE_FL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1761 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1762 | motor[TIRE_BR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1763 | motor[TIRE_BR].dir = FREE; |
yabahiro | 53:694dbd7dfa0e | 1764 | motor[TIRE_BL].pwm = slow; |
yabahiro | 51:a0bdbddd08f7 | 1765 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1766 | mtc2=true; |
yabahiro | 50:87f5fa1bc460 | 1767 | break; |
yabahiro | 50:87f5fa1bc460 | 1768 | case 2: |
yabahiro | 53:694dbd7dfa0e | 1769 | motor[TIRE_FR].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1770 | motor[TIRE_FR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1771 | motor[TIRE_FL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1772 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1773 | motor[TIRE_BR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1774 | motor[TIRE_BR].dir = FREE; |
yabahiro | 53:694dbd7dfa0e | 1775 | motor[TIRE_BL].pwm = normal; |
yabahiro | 51:a0bdbddd08f7 | 1776 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1777 | mtc2=true; |
yabahiro | 50:87f5fa1bc460 | 1778 | break; |
yabahiro | 50:87f5fa1bc460 | 1779 | } |
yabahiro | 51:a0bdbddd08f7 | 1780 | if(g[2]!=98&&mtc2==true) { |
yabahiro | 51:a0bdbddd08f7 | 1781 | switch(g[2]) { |
yabahiro | 51:a0bdbddd08f7 | 1782 | case 0: |
yabahiro | 51:a0bdbddd08f7 | 1783 | mtc2=false; |
yabahiro | 51:a0bdbddd08f7 | 1784 | break; |
yabahiro | 51:a0bdbddd08f7 | 1785 | case 255: |
yabahiro | 51:a0bdbddd08f7 | 1786 | motor[TIRE_FL].pwm += 5; |
yabahiro | 51:a0bdbddd08f7 | 1787 | mtc2=false; |
yabahiro | 51:a0bdbddd08f7 | 1788 | break; |
yabahiro | 51:a0bdbddd08f7 | 1789 | case 253: |
yabahiro | 51:a0bdbddd08f7 | 1790 | motor[TIRE_FL].pwm += 10; |
yabahiro | 51:a0bdbddd08f7 | 1791 | mtc2=false; |
yabahiro | 51:a0bdbddd08f7 | 1792 | break; |
yabahiro | 51:a0bdbddd08f7 | 1793 | case 254: |
yabahiro | 51:a0bdbddd08f7 | 1794 | motor[TIRE_FL].pwm += 20; |
yabahiro | 51:a0bdbddd08f7 | 1795 | motor[TIRE_BL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1796 | mtc2=false; |
yabahiro | 51:a0bdbddd08f7 | 1797 | break; |
yabahiro | 51:a0bdbddd08f7 | 1798 | case 1: |
yabahiro | 51:a0bdbddd08f7 | 1799 | motor[TIRE_BL].pwm += 5; |
yabahiro | 51:a0bdbddd08f7 | 1800 | mtc2=false; |
yabahiro | 51:a0bdbddd08f7 | 1801 | break; |
yabahiro | 51:a0bdbddd08f7 | 1802 | case 3: |
yabahiro | 51:a0bdbddd08f7 | 1803 | motor[TIRE_BL].pwm += 10; |
yabahiro | 51:a0bdbddd08f7 | 1804 | mtc2=false; |
yabahiro | 51:a0bdbddd08f7 | 1805 | break; |
yabahiro | 51:a0bdbddd08f7 | 1806 | case 2: |
yabahiro | 51:a0bdbddd08f7 | 1807 | motor[TIRE_BL].pwm += 20; |
yabahiro | 51:a0bdbddd08f7 | 1808 | motor[TIRE_FL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1809 | mtc2=false; |
yabahiro | 51:a0bdbddd08f7 | 1810 | break; |
yabahiro | 51:a0bdbddd08f7 | 1811 | } |
yabahiro | 51:a0bdbddd08f7 | 1812 | } |
yabahiro | 51:a0bdbddd08f7 | 1813 | break; |
yabahiro | 51:a0bdbddd08f7 | 1814 | case 41: |
yabahiro | 53:694dbd7dfa0e | 1815 | /* |
yabahiro | 53:694dbd7dfa0e | 1816 | if(LIF||LIB) { |
yabahiro | 53:694dbd7dfa0e | 1817 | mode=42; |
yabahiro | 53:694dbd7dfa0e | 1818 | } |
yabahiro | 53:694dbd7dfa0e | 1819 | */ |
yabahiro | 53:694dbd7dfa0e | 1820 | motor[TIRE_FR].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 1821 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1822 | motor[TIRE_FL].pwm = 0; |
yabahiro | 53:694dbd7dfa0e | 1823 | motor[TIRE_FL].dir = FREE; |
yabahiro | 53:694dbd7dfa0e | 1824 | motor[TIRE_BR].pwm = 0; |
yabahiro | 53:694dbd7dfa0e | 1825 | motor[TIRE_BR].dir = FREE; |
yabahiro | 53:694dbd7dfa0e | 1826 | motor[TIRE_BL].pwm = 30; |
yabahiro | 51:a0bdbddd08f7 | 1827 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1828 | if(g[1]==0) { |
yabahiro | 51:a0bdbddd08f7 | 1829 | countss=0; |
yabahiro | 51:a0bdbddd08f7 | 1830 | mode=70; |
yabahiro | 55:844ac0974740 | 1831 | normal=120; |
yabahiro | 55:844ac0974740 | 1832 | fast=140; |
yabahiro | 55:844ac0974740 | 1833 | slow=100; |
yabahiro | 51:a0bdbddd08f7 | 1834 | } |
yabahiro | 51:a0bdbddd08f7 | 1835 | break; |
yabahiro | 51:a0bdbddd08f7 | 1836 | case 42: |
yabahiro | 51:a0bdbddd08f7 | 1837 | motor[TIRE_FR].pwm = 40; |
yabahiro | 51:a0bdbddd08f7 | 1838 | motor[TIRE_FR].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1839 | motor[TIRE_FL].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1840 | motor[TIRE_FL].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1841 | motor[TIRE_BR].pwm = 0; |
yabahiro | 51:a0bdbddd08f7 | 1842 | motor[TIRE_BR].dir = FREE; |
yabahiro | 51:a0bdbddd08f7 | 1843 | motor[TIRE_BL].pwm = 40; |
yabahiro | 51:a0bdbddd08f7 | 1844 | motor[TIRE_BL].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1845 | if(g[1]==0) { |
yabahiro | 51:a0bdbddd08f7 | 1846 | countss=0; |
yabahiro | 51:a0bdbddd08f7 | 1847 | mode=70; |
yabahiro | 51:a0bdbddd08f7 | 1848 | } |
yabahiro | 51:a0bdbddd08f7 | 1849 | break; |
yabahiro | 51:a0bdbddd08f7 | 1850 | case 70: |
yabahiro | 51:a0bdbddd08f7 | 1851 | switch(g[0]) { |
yabahiro | 51:a0bdbddd08f7 | 1852 | case 99: |
yabahiro | 51:a0bdbddd08f7 | 1853 | if(countss>=100000) { |
yabahiro | 51:a0bdbddd08f7 | 1854 | mode=100; |
yabahiro | 51:a0bdbddd08f7 | 1855 | } |
yabahiro | 50:87f5fa1bc460 | 1856 | break; |
yabahiro | 39:784552c26163 | 1857 | case 98: |
yabahiro | 39:784552c26163 | 1858 | motor[TIRE_FR].pwm = normal; |
yabahiro | 39:784552c26163 | 1859 | motor[TIRE_FR].dir = BACK; |
yabahiro | 39:784552c26163 | 1860 | motor[TIRE_FL].pwm = normal; |
yabahiro | 39:784552c26163 | 1861 | motor[TIRE_FL].dir = FOR; |
yabahiro | 39:784552c26163 | 1862 | motor[TIRE_BR].pwm = normal; |
yabahiro | 39:784552c26163 | 1863 | motor[TIRE_BR].dir = BACK; |
yabahiro | 39:784552c26163 | 1864 | motor[TIRE_BL].pwm = normal; |
yabahiro | 39:784552c26163 | 1865 | motor[TIRE_BL].dir = FOR; |
yabahiro | 39:784552c26163 | 1866 | break; |
yabahiro | 39:784552c26163 | 1867 | case 0: |
yabahiro | 53:694dbd7dfa0e | 1868 | motor[TIRE_FR].pwm = 80; |
yabahiro | 39:784552c26163 | 1869 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1870 | motor[TIRE_FL].pwm = 80; |
yabahiro | 39:784552c26163 | 1871 | motor[TIRE_FL].dir = FOR; |
yabahiro | 53:694dbd7dfa0e | 1872 | motor[TIRE_BR].pwm = 80; |
yabahiro | 39:784552c26163 | 1873 | motor[TIRE_BR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 1874 | motor[TIRE_BL].pwm = 80; |
yabahiro | 39:784552c26163 | 1875 | motor[TIRE_BL].dir = FOR; |
yabahiro | 39:784552c26163 | 1876 | mtc=true; |
yabahiro | 39:784552c26163 | 1877 | break; |
yabahiro | 39:784552c26163 | 1878 | case 255: |
yabahiro | 39:784552c26163 | 1879 | motor[TIRE_FR].pwm = fast; |
yabahiro | 39:784552c26163 | 1880 | motor[TIRE_FR].dir = BACK; |
yabahiro | 39:784552c26163 | 1881 | motor[TIRE_FL].pwm = slow; |
yabahiro | 39:784552c26163 | 1882 | motor[TIRE_FL].dir = FOR; |
yabahiro | 39:784552c26163 | 1883 | motor[TIRE_BR].pwm = slow; |
yabahiro | 39:784552c26163 | 1884 | motor[TIRE_BR].dir = BACK; |
yabahiro | 39:784552c26163 | 1885 | motor[TIRE_BL].pwm = fast; |
yabahiro | 39:784552c26163 | 1886 | motor[TIRE_BL].dir = FOR; |
yabahiro | 39:784552c26163 | 1887 | mtc=true; |
yabahiro | 39:784552c26163 | 1888 | break; |
yabahiro | 39:784552c26163 | 1889 | case 253: |
yabahiro | 39:784552c26163 | 1890 | motor[TIRE_FR].pwm = slow; |
yabahiro | 39:784552c26163 | 1891 | motor[TIRE_FR].dir = BACK; |
yabahiro | 39:784552c26163 | 1892 | motor[TIRE_FL].pwm = 0; |
yabahiro | 39:784552c26163 | 1893 | motor[TIRE_FL].dir = FREE; |
yabahiro | 39:784552c26163 | 1894 | motor[TIRE_BR].pwm = 0; |
yabahiro | 39:784552c26163 | 1895 | motor[TIRE_BR].dir = FREE; |
yabahiro | 39:784552c26163 | 1896 | motor[TIRE_BL].pwm = slow; |
yabahiro | 39:784552c26163 | 1897 | motor[TIRE_BL].dir = FOR; |
yabahiro | 39:784552c26163 | 1898 | mtc=true; |
yabahiro | 39:784552c26163 | 1899 | break; |
yabahiro | 39:784552c26163 | 1900 | case 254: |
yabahiro | 39:784552c26163 | 1901 | motor[TIRE_FR].pwm = normal; |
yabahiro | 39:784552c26163 | 1902 | motor[TIRE_FR].dir = BACK; |
yabahiro | 39:784552c26163 | 1903 | motor[TIRE_FL].pwm = 0; |
yabahiro | 39:784552c26163 | 1904 | motor[TIRE_FL].dir = FREE; |
yabahiro | 39:784552c26163 | 1905 | motor[TIRE_BR].pwm = 0; |
yabahiro | 39:784552c26163 | 1906 | motor[TIRE_BR].dir = FREE; |
yabahiro | 39:784552c26163 | 1907 | motor[TIRE_BL].pwm = normal; |
yabahiro | 39:784552c26163 | 1908 | motor[TIRE_BL].dir = FOR; |
yabahiro | 39:784552c26163 | 1909 | mtc=true; |
yabahiro | 39:784552c26163 | 1910 | break; |
yabahiro | 39:784552c26163 | 1911 | case 1: |
yabahiro | 39:784552c26163 | 1912 | motor[TIRE_FR].pwm = slow; |
yabahiro | 39:784552c26163 | 1913 | motor[TIRE_FR].dir = BACK; |
yabahiro | 39:784552c26163 | 1914 | motor[TIRE_FL].pwm = fast; |
yabahiro | 39:784552c26163 | 1915 | motor[TIRE_FL].dir = FOR; |
yabahiro | 39:784552c26163 | 1916 | motor[TIRE_BR].pwm = fast; |
yabahiro | 39:784552c26163 | 1917 | motor[TIRE_BR].dir = BACK; |
yabahiro | 39:784552c26163 | 1918 | motor[TIRE_BL].pwm = slow; |
yabahiro | 39:784552c26163 | 1919 | motor[TIRE_BL].dir = FOR; |
yabahiro | 39:784552c26163 | 1920 | mtc=true; |
yabahiro | 39:784552c26163 | 1921 | break; |
yabahiro | 39:784552c26163 | 1922 | case 3: |
yabahiro | 39:784552c26163 | 1923 | motor[TIRE_FR].pwm = 0; |
yabahiro | 39:784552c26163 | 1924 | motor[TIRE_FR].dir = FREE; |
yabahiro | 39:784552c26163 | 1925 | motor[TIRE_FL].pwm = slow; |
yabahiro | 39:784552c26163 | 1926 | motor[TIRE_FL].dir = FOR; |
yabahiro | 39:784552c26163 | 1927 | motor[TIRE_BR].pwm = slow; |
yabahiro | 39:784552c26163 | 1928 | motor[TIRE_BR].dir = BACK; |
yabahiro | 39:784552c26163 | 1929 | motor[TIRE_BL].pwm = 0; |
yabahiro | 39:784552c26163 | 1930 | motor[TIRE_BL].dir = FREE; |
yabahiro | 39:784552c26163 | 1931 | mtc=true; |
yabahiro | 39:784552c26163 | 1932 | break; |
yabahiro | 39:784552c26163 | 1933 | case 2: |
yabahiro | 39:784552c26163 | 1934 | motor[TIRE_FR].pwm = 0; |
yabahiro | 39:784552c26163 | 1935 | motor[TIRE_FR].dir = FREE; |
yabahiro | 39:784552c26163 | 1936 | motor[TIRE_FL].pwm = normal; |
yabahiro | 39:784552c26163 | 1937 | motor[TIRE_FL].dir = FOR; |
yabahiro | 39:784552c26163 | 1938 | motor[TIRE_BR].pwm = normal; |
yabahiro | 39:784552c26163 | 1939 | motor[TIRE_BR].dir = BACK; |
yabahiro | 39:784552c26163 | 1940 | motor[TIRE_BL].pwm = 0; |
yabahiro | 39:784552c26163 | 1941 | motor[TIRE_BL].dir = FREE; |
yabahiro | 39:784552c26163 | 1942 | mtc=true; |
yabahiro | 39:784552c26163 | 1943 | break; |
yabahiro | 39:784552c26163 | 1944 | } |
yabahiro | 39:784552c26163 | 1945 | if(g[1]!=98&&mtc==true) { |
yabahiro | 39:784552c26163 | 1946 | switch(g[1]) { |
yabahiro | 39:784552c26163 | 1947 | case 0: |
yabahiro | 39:784552c26163 | 1948 | mtc=false; |
yabahiro | 39:784552c26163 | 1949 | break; |
yabahiro | 39:784552c26163 | 1950 | case 255: |
yabahiro | 39:784552c26163 | 1951 | motor[TIRE_BR].pwm += 5; |
yabahiro | 39:784552c26163 | 1952 | mtc=false; |
yabahiro | 39:784552c26163 | 1953 | break; |
yabahiro | 39:784552c26163 | 1954 | case 253: |
yabahiro | 39:784552c26163 | 1955 | motor[TIRE_BR].pwm += 10; |
yabahiro | 39:784552c26163 | 1956 | mtc=false; |
yabahiro | 39:784552c26163 | 1957 | break; |
yabahiro | 39:784552c26163 | 1958 | case 254: |
yabahiro | 39:784552c26163 | 1959 | motor[TIRE_BR].pwm += 20; |
yabahiro | 39:784552c26163 | 1960 | motor[TIRE_BL].pwm = 0; |
yabahiro | 39:784552c26163 | 1961 | mtc=false; |
yabahiro | 39:784552c26163 | 1962 | break; |
yabahiro | 39:784552c26163 | 1963 | case 1: |
yabahiro | 39:784552c26163 | 1964 | motor[TIRE_BL].pwm += 5; |
yabahiro | 39:784552c26163 | 1965 | mtc=false; |
yabahiro | 39:784552c26163 | 1966 | break; |
yabahiro | 39:784552c26163 | 1967 | case 3: |
yabahiro | 39:784552c26163 | 1968 | motor[TIRE_BL].pwm += 10; |
yabahiro | 39:784552c26163 | 1969 | mtc=false; |
yabahiro | 39:784552c26163 | 1970 | break; |
yabahiro | 39:784552c26163 | 1971 | case 2: |
yabahiro | 39:784552c26163 | 1972 | motor[TIRE_BL].pwm += 20; |
yabahiro | 39:784552c26163 | 1973 | motor[TIRE_BR].pwm = 0; |
yabahiro | 39:784552c26163 | 1974 | mtc=false; |
yabahiro | 39:784552c26163 | 1975 | break; |
yabahiro | 39:784552c26163 | 1976 | } |
yabahiro | 33:dd598bb23ad1 | 1977 | } |
yabahiro | 51:a0bdbddd08f7 | 1978 | break; |
yabahiro | 51:a0bdbddd08f7 | 1979 | case 100: |
yabahiro | 54:4167f10ecad0 | 1980 | motor[TIRE_FR].pwm = 47; |
yabahiro | 51:a0bdbddd08f7 | 1981 | motor[TIRE_FR].dir = BACK; |
yabahiro | 51:a0bdbddd08f7 | 1982 | motor[TIRE_FL].pwm = 50; |
yabahiro | 51:a0bdbddd08f7 | 1983 | motor[TIRE_FL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1984 | motor[TIRE_BR].pwm = 50; |
yabahiro | 51:a0bdbddd08f7 | 1985 | motor[TIRE_BR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 1986 | motor[TIRE_BL].pwm = 55; |
yabahiro | 51:a0bdbddd08f7 | 1987 | motor[TIRE_BL].dir = FOR; |
yabahiro | 51:a0bdbddd08f7 | 1988 | break; |
yabahiro | 51:a0bdbddd08f7 | 1989 | default: |
yabahiro | 51:a0bdbddd08f7 | 1990 | motor[TIRE_FR].pwm = 50; |
yabahiro | 51:a0bdbddd08f7 | 1991 | motor[TIRE_FR].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 1992 | motor[TIRE_FL].pwm = 50; |
yabahiro | 51:a0bdbddd08f7 | 1993 | motor[TIRE_FL].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 1994 | motor[TIRE_BR].pwm = 50; |
yabahiro | 51:a0bdbddd08f7 | 1995 | motor[TIRE_BR].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 1996 | motor[TIRE_BL].pwm = 50; |
yabahiro | 51:a0bdbddd08f7 | 1997 | motor[TIRE_BL].dir = BRAKE; |
yabahiro | 51:a0bdbddd08f7 | 1998 | break; |
yabahiro | 33:dd598bb23ad1 | 1999 | } |
kishibekairohan | 13:b6e02d6261d7 | 2000 | } |
kishibekairohan | 13:b6e02d6261d7 | 2001 | #endif |
kishibekairohan | 13:b6e02d6261d7 | 2002 | |
kishibekairohan | 13:b6e02d6261d7 | 2003 | #if USE_PROCESS_NUM>3 |
Ryosei | 27:dd9f27fce7d1 | 2004 | static void Process3() |
kishibekairohan | 13:b6e02d6261d7 | 2005 | { |
yabahiro | 33:dd598bb23ad1 | 2006 | //Clearly 赤ゾーン |
kishibekairohan | 35:33c6cdba5630 | 2007 | LED::LED::TapeledMode(3); |
yabahiro | 58:bfc38c43dadb | 2008 | value=aime.read_ms(); |
yabahiro | 33:dd598bb23ad1 | 2009 | countss++; |
yabahiro | 54:4167f10ecad0 | 2010 | switch(mode) { |
yabahiro | 54:4167f10ecad0 | 2011 | case 1: |
yabahiro | 54:4167f10ecad0 | 2012 | fast=40; |
yabahiro | 54:4167f10ecad0 | 2013 | normal=30; |
yabahiro | 54:4167f10ecad0 | 2014 | slow=20; |
yabahiro | 54:4167f10ecad0 | 2015 | motor[TIRE_FR].pwm = normal+20; |
yabahiro | 54:4167f10ecad0 | 2016 | motor[TIRE_FR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2017 | motor[TIRE_FL].pwm = normal+20; |
yabahiro | 54:4167f10ecad0 | 2018 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2019 | motor[TIRE_BR].pwm = normal+20; |
yabahiro | 54:4167f10ecad0 | 2020 | motor[TIRE_BR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2021 | motor[TIRE_BL].pwm = normal+20; |
yabahiro | 54:4167f10ecad0 | 2022 | motor[TIRE_BL].dir = FOR; |
yabahiro | 58:bfc38c43dadb | 2023 | if(g[2]==0&&value>=1500) { |
yabahiro | 54:4167f10ecad0 | 2024 | countss=100000; |
yabahiro | 54:4167f10ecad0 | 2025 | cross=0; |
yabahiro | 54:4167f10ecad0 | 2026 | mode=3; |
yabahiro | 54:4167f10ecad0 | 2027 | } |
yabahiro | 54:4167f10ecad0 | 2028 | break; |
yabahiro | 54:4167f10ecad0 | 2029 | case 3: |
yabahiro | 54:4167f10ecad0 | 2030 | motor[TIRE_FR].pwm = 255; |
yabahiro | 54:4167f10ecad0 | 2031 | motor[TIRE_FR].dir = BRAKE; |
yabahiro | 54:4167f10ecad0 | 2032 | motor[TIRE_FL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2033 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2034 | motor[TIRE_BR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2035 | motor[TIRE_BR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2036 | motor[TIRE_BL].pwm = 255; |
yabahiro | 54:4167f10ecad0 | 2037 | motor[TIRE_BL].dir = BRAKE; |
yabahiro | 54:4167f10ecad0 | 2038 | if(g[0]==0) { |
yabahiro | 54:4167f10ecad0 | 2039 | mode=10; |
yabahiro | 58:bfc38c43dadb | 2040 | aime.reset(); |
yabahiro | 54:4167f10ecad0 | 2041 | countss=100000; |
yabahiro | 56:61ebd4b759b4 | 2042 | fast = 80; |
yabahiro | 56:61ebd4b759b4 | 2043 | normal = 60; |
yabahiro | 56:61ebd4b759b4 | 2044 | slow = 40; |
yabahiro | 54:4167f10ecad0 | 2045 | } |
yabahiro | 54:4167f10ecad0 | 2046 | break; |
yabahiro | 54:4167f10ecad0 | 2047 | case 10: |
yabahiro | 54:4167f10ecad0 | 2048 | switch(g[0]) { |
yabahiro | 54:4167f10ecad0 | 2049 | case 98: |
yabahiro | 54:4167f10ecad0 | 2050 | motor[TIRE_FR].pwm = normal+50; |
yabahiro | 54:4167f10ecad0 | 2051 | motor[TIRE_FR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2052 | motor[TIRE_FL].pwm = normal+50; |
yabahiro | 54:4167f10ecad0 | 2053 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2054 | motor[TIRE_BR].pwm = normal+50; |
yabahiro | 54:4167f10ecad0 | 2055 | motor[TIRE_BR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2056 | motor[TIRE_BL].pwm = normal+50; |
yabahiro | 54:4167f10ecad0 | 2057 | motor[TIRE_BL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2058 | mtc=true; |
yabahiro | 58:bfc38c43dadb | 2059 | if(value>=1200) { |
yabahiro | 58:bfc38c43dadb | 2060 | cross++; |
yabahiro | 58:bfc38c43dadb | 2061 | countss=0; |
yabahiro | 58:bfc38c43dadb | 2062 | value=0; |
yabahiro | 58:bfc38c43dadb | 2063 | aime.reset(); |
yabahiro | 58:bfc38c43dadb | 2064 | } |
yabahiro | 58:bfc38c43dadb | 2065 | /* |
yabahiro | 54:4167f10ecad0 | 2066 | if(countss>80000) { |
yabahiro | 54:4167f10ecad0 | 2067 | cross++; |
yabahiro | 54:4167f10ecad0 | 2068 | countss=0; |
yabahiro | 54:4167f10ecad0 | 2069 | } |
yabahiro | 58:bfc38c43dadb | 2070 | */ |
yabahiro | 54:4167f10ecad0 | 2071 | if(cross==2) { |
yabahiro | 54:4167f10ecad0 | 2072 | fast = 10; |
yabahiro | 54:4167f10ecad0 | 2073 | normal = 10; |
yabahiro | 54:4167f10ecad0 | 2074 | slow = 5; |
yabahiro | 54:4167f10ecad0 | 2075 | } |
yabahiro | 46:68296caae1af | 2076 | |
yabahiro | 53:694dbd7dfa0e | 2077 | if(cross==3) { |
yabahiro | 54:4167f10ecad0 | 2078 | fast=40; |
yabahiro | 54:4167f10ecad0 | 2079 | normal=30; |
yabahiro | 54:4167f10ecad0 | 2080 | slow=20; |
yabahiro | 54:4167f10ecad0 | 2081 | mode=11; |
yabahiro | 58:bfc38c43dadb | 2082 | aime.reset(); |
yabahiro | 53:694dbd7dfa0e | 2083 | countss=0; |
yabahiro | 53:694dbd7dfa0e | 2084 | cross=0; |
yabahiro | 54:4167f10ecad0 | 2085 | |
yabahiro | 53:694dbd7dfa0e | 2086 | } |
yabahiro | 54:4167f10ecad0 | 2087 | break; |
yabahiro | 38:40e7fdf3c694 | 2088 | case 0: |
yabahiro | 54:4167f10ecad0 | 2089 | motor[TIRE_FR].pwm = fast+50; |
yabahiro | 54:4167f10ecad0 | 2090 | motor[TIRE_FR].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 2091 | motor[TIRE_FL].pwm = fast+60; |
yabahiro | 54:4167f10ecad0 | 2092 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2093 | motor[TIRE_BR].pwm = fast+50; |
yabahiro | 54:4167f10ecad0 | 2094 | motor[TIRE_BR].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 2095 | motor[TIRE_BL].pwm = fast+45; |
yabahiro | 54:4167f10ecad0 | 2096 | motor[TIRE_BL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2097 | mtc=true; |
yabahiro | 38:40e7fdf3c694 | 2098 | break; |
yabahiro | 38:40e7fdf3c694 | 2099 | case 255: |
yabahiro | 54:4167f10ecad0 | 2100 | motor[TIRE_FR].pwm = fast+50; |
yabahiro | 54:4167f10ecad0 | 2101 | motor[TIRE_FR].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 2102 | motor[TIRE_FL].pwm = slow+60; |
yabahiro | 54:4167f10ecad0 | 2103 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2104 | motor[TIRE_BR].pwm = slow+50; |
yabahiro | 54:4167f10ecad0 | 2105 | motor[TIRE_BR].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 2106 | motor[TIRE_BL].pwm = fast+45; |
yabahiro | 54:4167f10ecad0 | 2107 | motor[TIRE_BL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2108 | mtc=true; |
yabahiro | 53:694dbd7dfa0e | 2109 | break; |
yabahiro | 53:694dbd7dfa0e | 2110 | case 253: |
yabahiro | 54:4167f10ecad0 | 2111 | motor[TIRE_FR].pwm = slow+50; |
yabahiro | 54:4167f10ecad0 | 2112 | motor[TIRE_FR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2113 | motor[TIRE_FL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2114 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2115 | motor[TIRE_BR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2116 | motor[TIRE_BR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 2117 | motor[TIRE_BL].pwm = slow+45; |
yabahiro | 54:4167f10ecad0 | 2118 | motor[TIRE_BL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2119 | mtc=true; |
yabahiro | 53:694dbd7dfa0e | 2120 | break; |
yabahiro | 53:694dbd7dfa0e | 2121 | case 254: |
yabahiro | 54:4167f10ecad0 | 2122 | motor[TIRE_FR].pwm = normal+50; |
yabahiro | 54:4167f10ecad0 | 2123 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 2124 | motor[TIRE_FL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2125 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2126 | motor[TIRE_BR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2127 | motor[TIRE_BR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 2128 | motor[TIRE_BL].pwm = normal+45; |
yabahiro | 54:4167f10ecad0 | 2129 | motor[TIRE_BL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2130 | mtc=true; |
yabahiro | 53:694dbd7dfa0e | 2131 | break; |
yabahiro | 53:694dbd7dfa0e | 2132 | case 1: |
yabahiro | 54:4167f10ecad0 | 2133 | motor[TIRE_FR].pwm = slow+50; |
yabahiro | 54:4167f10ecad0 | 2134 | motor[TIRE_FR].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 2135 | motor[TIRE_FL].pwm = fast+60; |
yabahiro | 54:4167f10ecad0 | 2136 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2137 | motor[TIRE_BR].pwm = fast+50; |
yabahiro | 54:4167f10ecad0 | 2138 | motor[TIRE_BR].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 2139 | motor[TIRE_BL].pwm = slow+45; |
yabahiro | 54:4167f10ecad0 | 2140 | motor[TIRE_BL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2141 | mtc=true; |
yabahiro | 53:694dbd7dfa0e | 2142 | break; |
yabahiro | 53:694dbd7dfa0e | 2143 | case 3: |
yabahiro | 54:4167f10ecad0 | 2144 | motor[TIRE_FR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2145 | motor[TIRE_FR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 2146 | motor[TIRE_FL].pwm = slow+60; |
yabahiro | 54:4167f10ecad0 | 2147 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2148 | motor[TIRE_BR].pwm = slow+50; |
yabahiro | 54:4167f10ecad0 | 2149 | motor[TIRE_BR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2150 | motor[TIRE_BL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2151 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2152 | mtc=true; |
yabahiro | 53:694dbd7dfa0e | 2153 | break; |
yabahiro | 53:694dbd7dfa0e | 2154 | case 2: |
yabahiro | 54:4167f10ecad0 | 2155 | motor[TIRE_FR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2156 | motor[TIRE_FR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 2157 | motor[TIRE_FL].pwm = normal+60; |
yabahiro | 54:4167f10ecad0 | 2158 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2159 | motor[TIRE_BR].pwm = normal+50; |
yabahiro | 54:4167f10ecad0 | 2160 | motor[TIRE_BR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 2161 | motor[TIRE_BL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2162 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2163 | mtc=true; |
yabahiro | 53:694dbd7dfa0e | 2164 | break; |
yabahiro | 53:694dbd7dfa0e | 2165 | } |
yabahiro | 54:4167f10ecad0 | 2166 | if(g[0]!=98&&mtc==true) { |
yabahiro | 54:4167f10ecad0 | 2167 | switch(g[1]) { |
yabahiro | 54:4167f10ecad0 | 2168 | case 0: |
yabahiro | 54:4167f10ecad0 | 2169 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 2170 | break; |
yabahiro | 54:4167f10ecad0 | 2171 | case 255: |
yabahiro | 54:4167f10ecad0 | 2172 | motor[TIRE_BR].pwm += 3; |
yabahiro | 54:4167f10ecad0 | 2173 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 2174 | break; |
yabahiro | 54:4167f10ecad0 | 2175 | case 253: |
yabahiro | 54:4167f10ecad0 | 2176 | motor[TIRE_BR].pwm += 6; |
yabahiro | 54:4167f10ecad0 | 2177 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 2178 | break; |
yabahiro | 54:4167f10ecad0 | 2179 | case 254: |
yabahiro | 54:4167f10ecad0 | 2180 | motor[TIRE_BR].pwm += 9; |
yabahiro | 54:4167f10ecad0 | 2181 | motor[TIRE_BL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2182 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 2183 | break; |
yabahiro | 54:4167f10ecad0 | 2184 | case 1: |
yabahiro | 54:4167f10ecad0 | 2185 | motor[TIRE_BL].pwm += 3; |
yabahiro | 54:4167f10ecad0 | 2186 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 2187 | break; |
yabahiro | 54:4167f10ecad0 | 2188 | case 3: |
yabahiro | 54:4167f10ecad0 | 2189 | motor[TIRE_BL].pwm += 6; |
yabahiro | 54:4167f10ecad0 | 2190 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 2191 | break; |
yabahiro | 54:4167f10ecad0 | 2192 | case 2: |
yabahiro | 54:4167f10ecad0 | 2193 | motor[TIRE_BL].pwm += 9; |
yabahiro | 54:4167f10ecad0 | 2194 | motor[TIRE_BR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2195 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 2196 | break; |
yabahiro | 54:4167f10ecad0 | 2197 | } |
yabahiro | 54:4167f10ecad0 | 2198 | } |
yabahiro | 54:4167f10ecad0 | 2199 | break; |
yabahiro | 54:4167f10ecad0 | 2200 | case 11: |
yabahiro | 54:4167f10ecad0 | 2201 | motor[TIRE_FR].pwm = 15; |
yabahiro | 54:4167f10ecad0 | 2202 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2203 | motor[TIRE_FL].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 2204 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2205 | motor[TIRE_BR].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 2206 | motor[TIRE_BR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2207 | motor[TIRE_BL].pwm = 15; |
yabahiro | 54:4167f10ecad0 | 2208 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2209 | if(g[2]==0 || g[2]==255 || g[2]==254 || g[2]==253) { |
yabahiro | 53:694dbd7dfa0e | 2210 | countss=0; |
yabahiro | 54:4167f10ecad0 | 2211 | cross=0; |
yabahiro | 54:4167f10ecad0 | 2212 | mode=20; |
yabahiro | 53:694dbd7dfa0e | 2213 | } |
yabahiro | 54:4167f10ecad0 | 2214 | break; |
yabahiro | 54:4167f10ecad0 | 2215 | case 20: |
yabahiro | 54:4167f10ecad0 | 2216 | solenoid.solenoid4= SOLENOID_ON; |
yabahiro | 53:694dbd7dfa0e | 2217 | switch(g[2]) { |
yabahiro | 54:4167f10ecad0 | 2218 | case 98: |
yabahiro | 54:4167f10ecad0 | 2219 | motor[TIRE_FR].pwm = normal+20; |
yabahiro | 54:4167f10ecad0 | 2220 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2221 | motor[TIRE_FL].pwm = normal+20; |
yabahiro | 54:4167f10ecad0 | 2222 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2223 | motor[TIRE_BR].pwm = normal+20; |
yabahiro | 54:4167f10ecad0 | 2224 | motor[TIRE_BR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2225 | motor[TIRE_BL].pwm = normal+20; |
yabahiro | 54:4167f10ecad0 | 2226 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2227 | if(countss>30000) { |
yabahiro | 54:4167f10ecad0 | 2228 | cross++; |
yabahiro | 54:4167f10ecad0 | 2229 | countss=0; |
yabahiro | 54:4167f10ecad0 | 2230 | } |
yabahiro | 54:4167f10ecad0 | 2231 | mtc2=true; |
yabahiro | 54:4167f10ecad0 | 2232 | |
yabahiro | 54:4167f10ecad0 | 2233 | if(YELLOW) { |
yabahiro | 54:4167f10ecad0 | 2234 | if(cross==1) { |
yabahiro | 54:4167f10ecad0 | 2235 | fast=20; |
yabahiro | 54:4167f10ecad0 | 2236 | normal=15; |
yabahiro | 54:4167f10ecad0 | 2237 | slow=15; |
yabahiro | 54:4167f10ecad0 | 2238 | } else if(cross==2) { |
yabahiro | 54:4167f10ecad0 | 2239 | mode=21; |
yabahiro | 54:4167f10ecad0 | 2240 | countss=0; |
yabahiro | 54:4167f10ecad0 | 2241 | cross=0; |
yabahiro | 54:4167f10ecad0 | 2242 | } |
yabahiro | 54:4167f10ecad0 | 2243 | } else { |
yabahiro | 54:4167f10ecad0 | 2244 | if(cross==3) { |
yabahiro | 54:4167f10ecad0 | 2245 | mode=21; |
yabahiro | 54:4167f10ecad0 | 2246 | countss=0; |
yabahiro | 54:4167f10ecad0 | 2247 | cross=0; |
yabahiro | 54:4167f10ecad0 | 2248 | } |
yabahiro | 54:4167f10ecad0 | 2249 | } |
yabahiro | 54:4167f10ecad0 | 2250 | break; |
yabahiro | 53:694dbd7dfa0e | 2251 | case 0: |
yabahiro | 54:4167f10ecad0 | 2252 | motor[TIRE_FR].pwm = fast+20; |
yabahiro | 54:4167f10ecad0 | 2253 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2254 | motor[TIRE_FL].pwm = fast+20; |
yabahiro | 54:4167f10ecad0 | 2255 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2256 | motor[TIRE_BR].pwm = fast+20; |
yabahiro | 54:4167f10ecad0 | 2257 | motor[TIRE_BR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2258 | motor[TIRE_BL].pwm = fast+20; |
yabahiro | 54:4167f10ecad0 | 2259 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2260 | mtc2=true; |
yabahiro | 53:694dbd7dfa0e | 2261 | break; |
yabahiro | 53:694dbd7dfa0e | 2262 | case 255: |
yabahiro | 54:4167f10ecad0 | 2263 | motor[TIRE_FR].pwm = normal+20; |
yabahiro | 54:4167f10ecad0 | 2264 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2265 | motor[TIRE_FL].pwm = fast+20; |
yabahiro | 54:4167f10ecad0 | 2266 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2267 | motor[TIRE_BR].pwm = fast+20; |
yabahiro | 54:4167f10ecad0 | 2268 | motor[TIRE_BR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2269 | motor[TIRE_BL].pwm = normal+20; |
yabahiro | 54:4167f10ecad0 | 2270 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2271 | mtc2=true; |
yabahiro | 38:40e7fdf3c694 | 2272 | break; |
yabahiro | 38:40e7fdf3c694 | 2273 | case 253: |
yabahiro | 54:4167f10ecad0 | 2274 | motor[TIRE_FR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2275 | motor[TIRE_FR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2276 | motor[TIRE_FL].pwm = slow+20; |
yabahiro | 54:4167f10ecad0 | 2277 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2278 | motor[TIRE_BR].pwm = slow+20; |
yabahiro | 54:4167f10ecad0 | 2279 | motor[TIRE_BR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2280 | motor[TIRE_BL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2281 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2282 | mtc2=true; |
yabahiro | 38:40e7fdf3c694 | 2283 | break; |
yabahiro | 38:40e7fdf3c694 | 2284 | case 254: |
yabahiro | 54:4167f10ecad0 | 2285 | motor[TIRE_FR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2286 | motor[TIRE_FR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2287 | motor[TIRE_FL].pwm = normal+20; |
yabahiro | 54:4167f10ecad0 | 2288 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2289 | motor[TIRE_BR].pwm = normal+20; |
yabahiro | 53:694dbd7dfa0e | 2290 | motor[TIRE_BR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2291 | motor[TIRE_BL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2292 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2293 | mtc2=true; |
yabahiro | 53:694dbd7dfa0e | 2294 | break; |
yabahiro | 53:694dbd7dfa0e | 2295 | case 1: |
yabahiro | 54:4167f10ecad0 | 2296 | motor[TIRE_FR].pwm = fast+20; |
yabahiro | 54:4167f10ecad0 | 2297 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2298 | motor[TIRE_FL].pwm = slow+20; |
yabahiro | 54:4167f10ecad0 | 2299 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2300 | motor[TIRE_BR].pwm = slow+20; |
yabahiro | 54:4167f10ecad0 | 2301 | motor[TIRE_BR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2302 | motor[TIRE_BL].pwm = fast+20; |
yabahiro | 54:4167f10ecad0 | 2303 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2304 | mtc2=true; |
yabahiro | 53:694dbd7dfa0e | 2305 | break; |
yabahiro | 53:694dbd7dfa0e | 2306 | case 3: |
yabahiro | 54:4167f10ecad0 | 2307 | motor[TIRE_FR].pwm = slow+20; |
yabahiro | 54:4167f10ecad0 | 2308 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2309 | motor[TIRE_FL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2310 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2311 | motor[TIRE_BR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2312 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2313 | motor[TIRE_BL].pwm = slow+20; |
yabahiro | 54:4167f10ecad0 | 2314 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2315 | mtc2=true; |
yabahiro | 53:694dbd7dfa0e | 2316 | break; |
yabahiro | 53:694dbd7dfa0e | 2317 | case 2: |
yabahiro | 54:4167f10ecad0 | 2318 | motor[TIRE_FR].pwm = normal+20; |
yabahiro | 53:694dbd7dfa0e | 2319 | motor[TIRE_FR].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 2320 | motor[TIRE_FL].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 2321 | motor[TIRE_FL].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 2322 | motor[TIRE_BR].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 2323 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2324 | motor[TIRE_BL].pwm = normal+20; |
yabahiro | 38:40e7fdf3c694 | 2325 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2326 | mtc2=true; |
yabahiro | 38:40e7fdf3c694 | 2327 | break; |
yabahiro | 33:dd598bb23ad1 | 2328 | } |
yabahiro | 54:4167f10ecad0 | 2329 | if(g[2]!=98&&mtc2==true) { |
yabahiro | 54:4167f10ecad0 | 2330 | switch(g[3]) { |
yabahiro | 54:4167f10ecad0 | 2331 | case 0: |
yabahiro | 54:4167f10ecad0 | 2332 | mtc2=false; |
yabahiro | 54:4167f10ecad0 | 2333 | break; |
yabahiro | 54:4167f10ecad0 | 2334 | case 255: |
yabahiro | 54:4167f10ecad0 | 2335 | motor[TIRE_BL].pwm += 5; |
yabahiro | 54:4167f10ecad0 | 2336 | mtc2=false; |
yabahiro | 54:4167f10ecad0 | 2337 | break; |
yabahiro | 54:4167f10ecad0 | 2338 | case 253: |
yabahiro | 54:4167f10ecad0 | 2339 | motor[TIRE_BL].pwm += 10; |
yabahiro | 54:4167f10ecad0 | 2340 | mtc2=false; |
yabahiro | 54:4167f10ecad0 | 2341 | break; |
yabahiro | 54:4167f10ecad0 | 2342 | case 254: |
yabahiro | 54:4167f10ecad0 | 2343 | motor[TIRE_BL].pwm += 15; |
yabahiro | 54:4167f10ecad0 | 2344 | motor[TIRE_FL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2345 | mtc2=false; |
yabahiro | 54:4167f10ecad0 | 2346 | break; |
yabahiro | 54:4167f10ecad0 | 2347 | case 1: |
yabahiro | 54:4167f10ecad0 | 2348 | motor[TIRE_FL].pwm += 5; |
yabahiro | 54:4167f10ecad0 | 2349 | mtc2=false; |
yabahiro | 54:4167f10ecad0 | 2350 | break; |
yabahiro | 54:4167f10ecad0 | 2351 | case 3: |
yabahiro | 54:4167f10ecad0 | 2352 | motor[TIRE_FL].pwm += 10; |
yabahiro | 54:4167f10ecad0 | 2353 | mtc2=false; |
yabahiro | 54:4167f10ecad0 | 2354 | break; |
yabahiro | 54:4167f10ecad0 | 2355 | case 2: |
yabahiro | 54:4167f10ecad0 | 2356 | motor[TIRE_FL].pwm += 15; |
yabahiro | 54:4167f10ecad0 | 2357 | motor[TIRE_BL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2358 | mtc2=false; |
yabahiro | 54:4167f10ecad0 | 2359 | break; |
yabahiro | 54:4167f10ecad0 | 2360 | } |
yabahiro | 38:40e7fdf3c694 | 2361 | } |
yabahiro | 54:4167f10ecad0 | 2362 | break; |
yabahiro | 54:4167f10ecad0 | 2363 | case 21: |
yabahiro | 54:4167f10ecad0 | 2364 | if(YELLOW) { |
yabahiro | 54:4167f10ecad0 | 2365 | motor[TIRE_FR].pwm = 20; |
yabahiro | 54:4167f10ecad0 | 2366 | motor[TIRE_FR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2367 | motor[TIRE_FL].pwm = 20; |
yabahiro | 54:4167f10ecad0 | 2368 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2369 | motor[TIRE_BR].pwm = 20; |
yabahiro | 54:4167f10ecad0 | 2370 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2371 | motor[TIRE_BL].pwm = 20; |
yabahiro | 54:4167f10ecad0 | 2372 | motor[TIRE_BL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2373 | if(g[3]==98&&countss>=10000) { |
yabahiro | 54:4167f10ecad0 | 2374 | mode=22; |
yabahiro | 58:bfc38c43dadb | 2375 | aime.reset(); |
yabahiro | 54:4167f10ecad0 | 2376 | countss=0; |
yabahiro | 54:4167f10ecad0 | 2377 | fast=60; |
yabahiro | 54:4167f10ecad0 | 2378 | normal=40; |
yabahiro | 54:4167f10ecad0 | 2379 | slow=20; |
yabahiro | 54:4167f10ecad0 | 2380 | } |
yabahiro | 54:4167f10ecad0 | 2381 | } else { |
yabahiro | 38:40e7fdf3c694 | 2382 | motor[TIRE_FR].pwm = 30; |
yabahiro | 38:40e7fdf3c694 | 2383 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2384 | motor[TIRE_FL].pwm = 255; |
yabahiro | 54:4167f10ecad0 | 2385 | motor[TIRE_FL].dir = BRAKE; |
yabahiro | 54:4167f10ecad0 | 2386 | motor[TIRE_BR].pwm = 255; |
yabahiro | 54:4167f10ecad0 | 2387 | motor[TIRE_BR].dir = BRAKE; |
yabahiro | 38:40e7fdf3c694 | 2388 | motor[TIRE_BL].pwm = 30; |
yabahiro | 38:40e7fdf3c694 | 2389 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2390 | if(g[1]==0) { |
yabahiro | 54:4167f10ecad0 | 2391 | mode=22; |
yabahiro | 58:bfc38c43dadb | 2392 | aime.reset(); |
yabahiro | 54:4167f10ecad0 | 2393 | fast=60; |
yabahiro | 54:4167f10ecad0 | 2394 | normal=40; |
yabahiro | 54:4167f10ecad0 | 2395 | slow=25; |
yabahiro | 54:4167f10ecad0 | 2396 | } |
yabahiro | 38:40e7fdf3c694 | 2397 | } |
yabahiro | 54:4167f10ecad0 | 2398 | break; |
yabahiro | 54:4167f10ecad0 | 2399 | case 22: |
yabahiro | 54:4167f10ecad0 | 2400 | if(YELLOW) { |
yabahiro | 54:4167f10ecad0 | 2401 | if(g[4]==3||g[4]==2) { |
yabahiro | 38:40e7fdf3c694 | 2402 | motor[TIRE_FR].pwm = 30; |
yabahiro | 38:40e7fdf3c694 | 2403 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2404 | motor[TIRE_FL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2405 | motor[TIRE_FL].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 2406 | motor[TIRE_BR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2407 | motor[TIRE_BR].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 2408 | motor[TIRE_BL].pwm = 30; |
yabahiro | 38:40e7fdf3c694 | 2409 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2410 | } |
yabahiro | 54:4167f10ecad0 | 2411 | if(g[4]==253||g[4]==254) { |
yabahiro | 54:4167f10ecad0 | 2412 | motor[TIRE_FR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2413 | motor[TIRE_FR].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 2414 | motor[TIRE_FL].pwm = 30; |
yabahiro | 38:40e7fdf3c694 | 2415 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2416 | motor[TIRE_BR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2417 | motor[TIRE_BR].dir = FOR; |
yabahiro | 53:694dbd7dfa0e | 2418 | motor[TIRE_BL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2419 | motor[TIRE_BL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2420 | } |
yabahiro | 54:4167f10ecad0 | 2421 | switch(g[2]) { |
yabahiro | 54:4167f10ecad0 | 2422 | case 0: |
yabahiro | 54:4167f10ecad0 | 2423 | motor[TIRE_FR].pwm = 20; |
yabahiro | 54:4167f10ecad0 | 2424 | motor[TIRE_FR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2425 | motor[TIRE_BR].pwm = 20; |
yabahiro | 54:4167f10ecad0 | 2426 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2427 | break; |
yabahiro | 54:4167f10ecad0 | 2428 | case 255: |
yabahiro | 54:4167f10ecad0 | 2429 | motor[TIRE_FR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2430 | motor[TIRE_FR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2431 | motor[TIRE_BR].pwm = 20; |
yabahiro | 54:4167f10ecad0 | 2432 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2433 | break; |
yabahiro | 54:4167f10ecad0 | 2434 | case 253: |
yabahiro | 54:4167f10ecad0 | 2435 | motor[TIRE_FR].pwm = 40; |
yabahiro | 54:4167f10ecad0 | 2436 | motor[TIRE_FR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2437 | motor[TIRE_BR].pwm = 20; |
yabahiro | 54:4167f10ecad0 | 2438 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2439 | break; |
yabahiro | 54:4167f10ecad0 | 2440 | case 254: |
yabahiro | 54:4167f10ecad0 | 2441 | motor[TIRE_FR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2442 | motor[TIRE_FR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2443 | motor[TIRE_BR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2444 | motor[TIRE_BR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2445 | break; |
yabahiro | 54:4167f10ecad0 | 2446 | case 1: |
yabahiro | 54:4167f10ecad0 | 2447 | motor[TIRE_FR].pwm = 20; |
yabahiro | 54:4167f10ecad0 | 2448 | motor[TIRE_FR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2449 | motor[TIRE_BR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2450 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2451 | break; |
yabahiro | 54:4167f10ecad0 | 2452 | case 3: |
yabahiro | 54:4167f10ecad0 | 2453 | motor[TIRE_FR].pwm = 20; |
yabahiro | 54:4167f10ecad0 | 2454 | motor[TIRE_FR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2455 | motor[TIRE_BR].pwm = 40; |
yabahiro | 54:4167f10ecad0 | 2456 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2457 | break; |
yabahiro | 54:4167f10ecad0 | 2458 | case 2: |
yabahiro | 54:4167f10ecad0 | 2459 | motor[TIRE_FR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2460 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2461 | motor[TIRE_BR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2462 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2463 | break; |
yabahiro | 54:4167f10ecad0 | 2464 | } |
yabahiro | 54:4167f10ecad0 | 2465 | switch(g[3]) { |
yabahiro | 54:4167f10ecad0 | 2466 | case 0: |
yabahiro | 54:4167f10ecad0 | 2467 | motor[TIRE_FL].pwm = 20; |
yabahiro | 54:4167f10ecad0 | 2468 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2469 | motor[TIRE_BL].pwm = 20; |
yabahiro | 54:4167f10ecad0 | 2470 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2471 | break; |
yabahiro | 54:4167f10ecad0 | 2472 | case 255: |
yabahiro | 54:4167f10ecad0 | 2473 | motor[TIRE_FL].pwm = 20; |
yabahiro | 54:4167f10ecad0 | 2474 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2475 | motor[TIRE_BL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2476 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2477 | case 253: |
yabahiro | 54:4167f10ecad0 | 2478 | motor[TIRE_FL].pwm = 20; |
yabahiro | 54:4167f10ecad0 | 2479 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2480 | motor[TIRE_BL].pwm = 40; |
yabahiro | 54:4167f10ecad0 | 2481 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2482 | break; |
yabahiro | 54:4167f10ecad0 | 2483 | case 254: |
yabahiro | 54:4167f10ecad0 | 2484 | motor[TIRE_FL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2485 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2486 | motor[TIRE_BL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2487 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2488 | break; |
yabahiro | 54:4167f10ecad0 | 2489 | case 1: |
yabahiro | 54:4167f10ecad0 | 2490 | motor[TIRE_FL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2491 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2492 | motor[TIRE_BL].pwm = 20; |
yabahiro | 54:4167f10ecad0 | 2493 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2494 | break; |
yabahiro | 54:4167f10ecad0 | 2495 | case 3: |
yabahiro | 54:4167f10ecad0 | 2496 | motor[TIRE_FL].pwm = 40; |
yabahiro | 54:4167f10ecad0 | 2497 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2498 | motor[TIRE_BL].pwm = 20; |
yabahiro | 54:4167f10ecad0 | 2499 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2500 | break; |
yabahiro | 54:4167f10ecad0 | 2501 | case 2: |
yabahiro | 54:4167f10ecad0 | 2502 | motor[TIRE_FL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2503 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2504 | motor[TIRE_BL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2505 | motor[TIRE_BL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2506 | break; |
yabahiro | 54:4167f10ecad0 | 2507 | } |
yabahiro | 54:4167f10ecad0 | 2508 | if(g[3]==0&&g[2]==0) { |
yabahiro | 54:4167f10ecad0 | 2509 | mode=23; |
yabahiro | 58:bfc38c43dadb | 2510 | aime.reset(); |
yabahiro | 54:4167f10ecad0 | 2511 | countss=0; |
yabahiro | 56:61ebd4b759b4 | 2512 | fast = 60; |
yabahiro | 56:61ebd4b759b4 | 2513 | normal = 40; |
yabahiro | 54:4167f10ecad0 | 2514 | slow = 30; |
yabahiro | 54:4167f10ecad0 | 2515 | } |
yabahiro | 54:4167f10ecad0 | 2516 | } else { |
yabahiro | 58:bfc38c43dadb | 2517 | if(value>=2200) { |
yabahiro | 58:bfc38c43dadb | 2518 | slow=25; |
yabahiro | 58:bfc38c43dadb | 2519 | normal=30; |
yabahiro | 58:bfc38c43dadb | 2520 | fast=40; |
yabahiro | 58:bfc38c43dadb | 2521 | } |
yabahiro | 58:bfc38c43dadb | 2522 | /* |
yabahiro | 54:4167f10ecad0 | 2523 | if(g[1]==98) { |
yabahiro | 54:4167f10ecad0 | 2524 | slow=25; |
yabahiro | 54:4167f10ecad0 | 2525 | normal=30; |
yabahiro | 54:4167f10ecad0 | 2526 | fast=40; |
yabahiro | 54:4167f10ecad0 | 2527 | } |
yabahiro | 58:bfc38c43dadb | 2528 | */ |
yabahiro | 58:bfc38c43dadb | 2529 | if(g[3]==0&&value>=2200) { |
yabahiro | 54:4167f10ecad0 | 2530 | slow=25; |
yabahiro | 54:4167f10ecad0 | 2531 | normal=40; |
yabahiro | 54:4167f10ecad0 | 2532 | fast=60; |
yabahiro | 54:4167f10ecad0 | 2533 | mode=23; |
yabahiro | 54:4167f10ecad0 | 2534 | } |
yabahiro | 54:4167f10ecad0 | 2535 | switch(g[1]) { |
yabahiro | 54:4167f10ecad0 | 2536 | case 98: |
yabahiro | 54:4167f10ecad0 | 2537 | solenoid.solenoid4 = SOLENOID_OFF; |
yabahiro | 54:4167f10ecad0 | 2538 | fast=40; |
yabahiro | 54:4167f10ecad0 | 2539 | normal=30; |
yabahiro | 54:4167f10ecad0 | 2540 | slow=25; |
yabahiro | 54:4167f10ecad0 | 2541 | motor[TIRE_FR].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 2542 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2543 | motor[TIRE_FL].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 2544 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2545 | motor[TIRE_BR].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 2546 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2547 | motor[TIRE_BL].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 2548 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2549 | break; |
yabahiro | 54:4167f10ecad0 | 2550 | case 0: |
yabahiro | 54:4167f10ecad0 | 2551 | motor[TIRE_FR].pwm = fast; |
yabahiro | 54:4167f10ecad0 | 2552 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2553 | motor[TIRE_FL].pwm = fast; |
yabahiro | 54:4167f10ecad0 | 2554 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2555 | motor[TIRE_BR].pwm = fast; |
yabahiro | 54:4167f10ecad0 | 2556 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2557 | motor[TIRE_BL].pwm = fast; |
yabahiro | 54:4167f10ecad0 | 2558 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2559 | mtc=true; |
yabahiro | 54:4167f10ecad0 | 2560 | break; |
yabahiro | 54:4167f10ecad0 | 2561 | case 255: |
yabahiro | 54:4167f10ecad0 | 2562 | motor[TIRE_FR].pwm = fast; |
yabahiro | 54:4167f10ecad0 | 2563 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2564 | motor[TIRE_FL].pwm = slow; |
yabahiro | 54:4167f10ecad0 | 2565 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2566 | motor[TIRE_BR].pwm = slow; |
yabahiro | 54:4167f10ecad0 | 2567 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2568 | motor[TIRE_BL].pwm = fast; |
yabahiro | 54:4167f10ecad0 | 2569 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2570 | mtc=true; |
yabahiro | 54:4167f10ecad0 | 2571 | break; |
yabahiro | 54:4167f10ecad0 | 2572 | case 253: |
yabahiro | 54:4167f10ecad0 | 2573 | motor[TIRE_FR].pwm = slow; |
yabahiro | 54:4167f10ecad0 | 2574 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2575 | motor[TIRE_FL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2576 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2577 | motor[TIRE_BR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2578 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2579 | motor[TIRE_BL].pwm = slow; |
yabahiro | 54:4167f10ecad0 | 2580 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2581 | mtc=true; |
yabahiro | 54:4167f10ecad0 | 2582 | break; |
yabahiro | 54:4167f10ecad0 | 2583 | case 254: |
yabahiro | 54:4167f10ecad0 | 2584 | motor[TIRE_FR].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 2585 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2586 | motor[TIRE_FL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2587 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2588 | motor[TIRE_BR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2589 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2590 | motor[TIRE_BL].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 2591 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2592 | mtc=true; |
yabahiro | 54:4167f10ecad0 | 2593 | break; |
yabahiro | 54:4167f10ecad0 | 2594 | case 1: |
yabahiro | 54:4167f10ecad0 | 2595 | motor[TIRE_FR].pwm = slow; |
yabahiro | 54:4167f10ecad0 | 2596 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2597 | motor[TIRE_FL].pwm = fast; |
yabahiro | 54:4167f10ecad0 | 2598 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2599 | motor[TIRE_BR].pwm = fast; |
yabahiro | 54:4167f10ecad0 | 2600 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2601 | motor[TIRE_BL].pwm = slow; |
yabahiro | 54:4167f10ecad0 | 2602 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2603 | mtc=true; |
yabahiro | 54:4167f10ecad0 | 2604 | break; |
yabahiro | 54:4167f10ecad0 | 2605 | case 3: |
yabahiro | 54:4167f10ecad0 | 2606 | motor[TIRE_FR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2607 | motor[TIRE_FR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2608 | motor[TIRE_FL].pwm = slow; |
yabahiro | 54:4167f10ecad0 | 2609 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2610 | motor[TIRE_BR].pwm = slow; |
yabahiro | 54:4167f10ecad0 | 2611 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2612 | motor[TIRE_BL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2613 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2614 | mtc=true; |
yabahiro | 54:4167f10ecad0 | 2615 | break; |
yabahiro | 54:4167f10ecad0 | 2616 | case 2: |
yabahiro | 54:4167f10ecad0 | 2617 | motor[TIRE_FR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2618 | motor[TIRE_FR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2619 | motor[TIRE_FL].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 2620 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2621 | motor[TIRE_BR].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 2622 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2623 | motor[TIRE_BL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2624 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2625 | mtc=true; |
yabahiro | 54:4167f10ecad0 | 2626 | break; |
yabahiro | 54:4167f10ecad0 | 2627 | } |
yabahiro | 54:4167f10ecad0 | 2628 | if(g[1]!=98&&mtc==true) { |
yabahiro | 54:4167f10ecad0 | 2629 | switch(g[0]) { |
yabahiro | 54:4167f10ecad0 | 2630 | case 0: |
yabahiro | 54:4167f10ecad0 | 2631 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 2632 | break; |
yabahiro | 54:4167f10ecad0 | 2633 | case 255: |
yabahiro | 54:4167f10ecad0 | 2634 | motor[TIRE_FL].pwm += 3; |
yabahiro | 54:4167f10ecad0 | 2635 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 2636 | break; |
yabahiro | 54:4167f10ecad0 | 2637 | case 253: |
yabahiro | 54:4167f10ecad0 | 2638 | motor[TIRE_FL].pwm += 6; |
yabahiro | 54:4167f10ecad0 | 2639 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 2640 | break; |
yabahiro | 54:4167f10ecad0 | 2641 | case 254: |
yabahiro | 54:4167f10ecad0 | 2642 | motor[TIRE_FL].pwm += 9; |
yabahiro | 54:4167f10ecad0 | 2643 | motor[TIRE_FR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2644 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 2645 | break; |
yabahiro | 54:4167f10ecad0 | 2646 | case 1: |
yabahiro | 54:4167f10ecad0 | 2647 | motor[TIRE_FR].pwm += 3; |
yabahiro | 54:4167f10ecad0 | 2648 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 2649 | break; |
yabahiro | 54:4167f10ecad0 | 2650 | case 3: |
yabahiro | 54:4167f10ecad0 | 2651 | motor[TIRE_FR].pwm += 6; |
yabahiro | 54:4167f10ecad0 | 2652 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 2653 | break; |
yabahiro | 54:4167f10ecad0 | 2654 | case 2: |
yabahiro | 54:4167f10ecad0 | 2655 | motor[TIRE_FR].pwm += 9; |
yabahiro | 54:4167f10ecad0 | 2656 | motor[TIRE_FL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2657 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 2658 | break; |
yabahiro | 54:4167f10ecad0 | 2659 | } |
yabahiro | 54:4167f10ecad0 | 2660 | } |
yabahiro | 54:4167f10ecad0 | 2661 | } |
yabahiro | 54:4167f10ecad0 | 2662 | break; |
yabahiro | 54:4167f10ecad0 | 2663 | case 23: |
yabahiro | 54:4167f10ecad0 | 2664 | if(YELLOW) { |
yabahiro | 54:4167f10ecad0 | 2665 | switch(g[4]) { |
yabahiro | 54:4167f10ecad0 | 2666 | case 98: |
yabahiro | 54:4167f10ecad0 | 2667 | motor[TIRE_FR].pwm = fast-5; |
yabahiro | 54:4167f10ecad0 | 2668 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2669 | motor[TIRE_FL].pwm = fast-5; |
yabahiro | 54:4167f10ecad0 | 2670 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2671 | motor[TIRE_BR].pwm = fast-5; |
yabahiro | 54:4167f10ecad0 | 2672 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2673 | motor[TIRE_BL].pwm = fast-5; |
yabahiro | 54:4167f10ecad0 | 2674 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2675 | break; |
yabahiro | 54:4167f10ecad0 | 2676 | case 99: |
yabahiro | 54:4167f10ecad0 | 2677 | motor[TIRE_FR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2678 | motor[TIRE_FR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2679 | motor[TIRE_FL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2680 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2681 | motor[TIRE_BR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2682 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2683 | motor[TIRE_BL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2684 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2685 | break; |
yabahiro | 54:4167f10ecad0 | 2686 | case 0: |
yabahiro | 54:4167f10ecad0 | 2687 | motor[TIRE_FR].pwm = fast-5; |
yabahiro | 54:4167f10ecad0 | 2688 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2689 | motor[TIRE_FL].pwm = fast-5; |
yabahiro | 54:4167f10ecad0 | 2690 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2691 | motor[TIRE_BR].pwm = fast-5; |
yabahiro | 54:4167f10ecad0 | 2692 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2693 | motor[TIRE_BL].pwm = fast-5; |
yabahiro | 54:4167f10ecad0 | 2694 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2695 | break; |
yabahiro | 54:4167f10ecad0 | 2696 | case 255: |
yabahiro | 54:4167f10ecad0 | 2697 | motor[TIRE_FR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2698 | motor[TIRE_FR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2699 | motor[TIRE_FL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2700 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2701 | motor[TIRE_BR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2702 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2703 | motor[TIRE_BL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2704 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2705 | break; |
yabahiro | 54:4167f10ecad0 | 2706 | case 253: |
yabahiro | 54:4167f10ecad0 | 2707 | motor[TIRE_FR].pwm = slow+5; |
yabahiro | 54:4167f10ecad0 | 2708 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2709 | motor[TIRE_FL].pwm = fast-5; |
yabahiro | 54:4167f10ecad0 | 2710 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2711 | motor[TIRE_BR].pwm = fast-5; |
yabahiro | 54:4167f10ecad0 | 2712 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2713 | motor[TIRE_BL].pwm = slow+5; |
yabahiro | 54:4167f10ecad0 | 2714 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2715 | break; |
yabahiro | 54:4167f10ecad0 | 2716 | case 254: |
yabahiro | 54:4167f10ecad0 | 2717 | motor[TIRE_FR].pwm = normal+5; |
yabahiro | 54:4167f10ecad0 | 2718 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2719 | motor[TIRE_FL].pwm = fast-5; |
yabahiro | 54:4167f10ecad0 | 2720 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2721 | motor[TIRE_BR].pwm = fast-5; |
yabahiro | 54:4167f10ecad0 | 2722 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2723 | motor[TIRE_BL].pwm = normal+5; |
yabahiro | 54:4167f10ecad0 | 2724 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2725 | break; |
yabahiro | 54:4167f10ecad0 | 2726 | case 1: |
yabahiro | 54:4167f10ecad0 | 2727 | motor[TIRE_FR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2728 | motor[TIRE_FR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2729 | motor[TIRE_FL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2730 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2731 | motor[TIRE_BR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2732 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2733 | motor[TIRE_BL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2734 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2735 | break; |
yabahiro | 54:4167f10ecad0 | 2736 | case 3: |
yabahiro | 54:4167f10ecad0 | 2737 | motor[TIRE_FR].pwm = fast-5; |
yabahiro | 54:4167f10ecad0 | 2738 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2739 | motor[TIRE_FL].pwm = slow+5; |
yabahiro | 54:4167f10ecad0 | 2740 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2741 | motor[TIRE_BR].pwm = slow+5; |
yabahiro | 54:4167f10ecad0 | 2742 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2743 | motor[TIRE_BL].pwm = fast-5; |
yabahiro | 54:4167f10ecad0 | 2744 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2745 | break; |
yabahiro | 54:4167f10ecad0 | 2746 | case 2: |
yabahiro | 54:4167f10ecad0 | 2747 | motor[TIRE_FR].pwm = fast-5; |
yabahiro | 54:4167f10ecad0 | 2748 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2749 | motor[TIRE_FL].pwm = normal+5; |
yabahiro | 54:4167f10ecad0 | 2750 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2751 | motor[TIRE_BR].pwm = normal+5; |
yabahiro | 54:4167f10ecad0 | 2752 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2753 | motor[TIRE_BL].pwm = fast-5; |
yabahiro | 54:4167f10ecad0 | 2754 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2755 | break; |
yabahiro | 54:4167f10ecad0 | 2756 | } |
yabahiro | 58:bfc38c43dadb | 2757 | if(value>=2400) { |
yabahiro | 58:bfc38c43dadb | 2758 | fast=20; |
yabahiro | 58:bfc38c43dadb | 2759 | normal=15; |
yabahiro | 54:4167f10ecad0 | 2760 | slow=10; |
yabahiro | 54:4167f10ecad0 | 2761 | } |
yabahiro | 58:bfc38c43dadb | 2762 | if(g[3]==254&&value>=2700) { |
yabahiro | 54:4167f10ecad0 | 2763 | mode=24; |
yabahiro | 54:4167f10ecad0 | 2764 | solenoid.solenoid4 = SOLENOID_OFF; |
yabahiro | 56:61ebd4b759b4 | 2765 | aime.reset(); |
yabahiro | 54:4167f10ecad0 | 2766 | countss=0; |
yabahiro | 54:4167f10ecad0 | 2767 | fast=80; |
yabahiro | 54:4167f10ecad0 | 2768 | normal=60; |
yabahiro | 54:4167f10ecad0 | 2769 | slow=30; |
yabahiro | 54:4167f10ecad0 | 2770 | } |
yabahiro | 58:bfc38c43dadb | 2771 | |
yabahiro | 58:bfc38c43dadb | 2772 | /* |
yabahiro | 58:bfc38c43dadb | 2773 | if(value>=2500) { |
yabahiro | 58:bfc38c43dadb | 2774 | mode=24; |
yabahiro | 58:bfc38c43dadb | 2775 | aime.reset(); |
yabahiro | 58:bfc38c43dadb | 2776 | solenoid.solenoid4 = SOLENOID_OFF; |
yabahiro | 58:bfc38c43dadb | 2777 | countss=0; |
yabahiro | 58:bfc38c43dadb | 2778 | fast=80; |
yabahiro | 58:bfc38c43dadb | 2779 | normal=60; |
yabahiro | 58:bfc38c43dadb | 2780 | slow=30; |
yabahiro | 58:bfc38c43dadb | 2781 | } |
yabahiro | 58:bfc38c43dadb | 2782 | if(g[1]==98) { |
yabahiro | 58:bfc38c43dadb | 2783 | fast=10; |
yabahiro | 58:bfc38c43dadb | 2784 | normal=10; |
yabahiro | 58:bfc38c43dadb | 2785 | slow=10; |
yabahiro | 58:bfc38c43dadb | 2786 | } |
yabahiro | 58:bfc38c43dadb | 2787 | */ |
yabahiro | 54:4167f10ecad0 | 2788 | } else { |
yabahiro | 54:4167f10ecad0 | 2789 | if(UPLS||DOLS) { |
yabahiro | 54:4167f10ecad0 | 2790 | if(UPLS||DOLS) { |
yabahiro | 54:4167f10ecad0 | 2791 | motor[MOTOR_0].pwm = 200; |
yabahiro | 54:4167f10ecad0 | 2792 | motor[MOTOR_0].dir = BRAKE; |
yabahiro | 54:4167f10ecad0 | 2793 | fast=60; |
yabahiro | 54:4167f10ecad0 | 2794 | normal=40; |
yabahiro | 54:4167f10ecad0 | 2795 | slow=30; |
yabahiro | 54:4167f10ecad0 | 2796 | countss=0; |
yabahiro | 54:4167f10ecad0 | 2797 | mode=24; |
yabahiro | 54:4167f10ecad0 | 2798 | } |
yabahiro | 54:4167f10ecad0 | 2799 | } else { |
yabahiro | 54:4167f10ecad0 | 2800 | motor[MOTOR_0].pwm = 100; |
yabahiro | 54:4167f10ecad0 | 2801 | motor[MOTOR_0].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2802 | } |
yabahiro | 54:4167f10ecad0 | 2803 | motor[TIRE_FR].pwm = 100; |
yabahiro | 54:4167f10ecad0 | 2804 | motor[TIRE_FR].dir = BRAKE; |
yabahiro | 54:4167f10ecad0 | 2805 | motor[TIRE_FL].pwm = 100; |
yabahiro | 54:4167f10ecad0 | 2806 | motor[TIRE_FL].dir = BRAKE; |
yabahiro | 54:4167f10ecad0 | 2807 | motor[TIRE_BR].pwm = 100; |
yabahiro | 54:4167f10ecad0 | 2808 | motor[TIRE_BR].dir = BRAKE; |
yabahiro | 54:4167f10ecad0 | 2809 | motor[TIRE_BL].pwm = 100; |
yabahiro | 54:4167f10ecad0 | 2810 | motor[TIRE_BL].dir = BRAKE; |
yabahiro | 54:4167f10ecad0 | 2811 | } |
yabahiro | 54:4167f10ecad0 | 2812 | break; |
yabahiro | 54:4167f10ecad0 | 2813 | case 24: |
yabahiro | 54:4167f10ecad0 | 2814 | if(YELLOW) { |
yabahiro | 56:61ebd4b759b4 | 2815 | value=aime.read_ms(); |
yabahiro | 56:61ebd4b759b4 | 2816 | if(value>=4000) { |
yabahiro | 56:61ebd4b759b4 | 2817 | mode=25; |
yabahiro | 56:61ebd4b759b4 | 2818 | } |
yabahiro | 54:4167f10ecad0 | 2819 | if(g[4]==3||g[4]==2) { |
yabahiro | 54:4167f10ecad0 | 2820 | motor[TIRE_FR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2821 | motor[TIRE_FR].dir = FOR; |
yabahiro | 53:694dbd7dfa0e | 2822 | motor[TIRE_FL].pwm = 30; |
yabahiro | 53:694dbd7dfa0e | 2823 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2824 | motor[TIRE_BR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2825 | motor[TIRE_BR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2826 | motor[TIRE_BL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2827 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2828 | } |
yabahiro | 54:4167f10ecad0 | 2829 | if(g[4]==253||g[4]==254) { |
yabahiro | 54:4167f10ecad0 | 2830 | motor[TIRE_FR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2831 | motor[TIRE_FR].dir = BACK; |
yabahiro | 53:694dbd7dfa0e | 2832 | motor[TIRE_FL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2833 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2834 | motor[TIRE_BR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2835 | motor[TIRE_BR].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 2836 | motor[TIRE_BL].pwm = 30; |
yabahiro | 52:4394a1debceb | 2837 | motor[TIRE_BL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2838 | } |
yabahiro | 54:4167f10ecad0 | 2839 | switch(g[2]) { |
yabahiro | 54:4167f10ecad0 | 2840 | case 0: |
yabahiro | 54:4167f10ecad0 | 2841 | motor[TIRE_FR].pwm = 25; |
yabahiro | 54:4167f10ecad0 | 2842 | motor[TIRE_FR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2843 | motor[TIRE_BR].pwm = 25; |
yabahiro | 54:4167f10ecad0 | 2844 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2845 | break; |
yabahiro | 54:4167f10ecad0 | 2846 | case 255: |
yabahiro | 54:4167f10ecad0 | 2847 | motor[TIRE_FR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2848 | motor[TIRE_FR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2849 | motor[TIRE_BR].pwm = 25; |
yabahiro | 54:4167f10ecad0 | 2850 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2851 | break; |
yabahiro | 54:4167f10ecad0 | 2852 | case 253: |
yabahiro | 54:4167f10ecad0 | 2853 | motor[TIRE_FR].pwm = 40; |
yabahiro | 54:4167f10ecad0 | 2854 | motor[TIRE_FR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2855 | motor[TIRE_BR].pwm = 25; |
yabahiro | 54:4167f10ecad0 | 2856 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2857 | break; |
yabahiro | 54:4167f10ecad0 | 2858 | case 254: |
yabahiro | 54:4167f10ecad0 | 2859 | motor[TIRE_FR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2860 | motor[TIRE_FR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2861 | motor[TIRE_BR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2862 | motor[TIRE_BR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2863 | break; |
yabahiro | 54:4167f10ecad0 | 2864 | case 1: |
yabahiro | 54:4167f10ecad0 | 2865 | motor[TIRE_FR].pwm = 25; |
yabahiro | 54:4167f10ecad0 | 2866 | motor[TIRE_FR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2867 | motor[TIRE_BR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2868 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2869 | break; |
yabahiro | 54:4167f10ecad0 | 2870 | case 3: |
yabahiro | 54:4167f10ecad0 | 2871 | motor[TIRE_FR].pwm = 25; |
yabahiro | 54:4167f10ecad0 | 2872 | motor[TIRE_FR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2873 | motor[TIRE_BR].pwm = 40; |
yabahiro | 54:4167f10ecad0 | 2874 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2875 | break; |
yabahiro | 54:4167f10ecad0 | 2876 | case 2: |
yabahiro | 54:4167f10ecad0 | 2877 | motor[TIRE_FR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2878 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2879 | motor[TIRE_BR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2880 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2881 | break; |
yabahiro | 54:4167f10ecad0 | 2882 | } |
yabahiro | 54:4167f10ecad0 | 2883 | switch(g[3]) { |
yabahiro | 54:4167f10ecad0 | 2884 | case 0: |
yabahiro | 54:4167f10ecad0 | 2885 | motor[TIRE_FL].pwm = 25; |
yabahiro | 54:4167f10ecad0 | 2886 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2887 | motor[TIRE_BL].pwm = 25; |
yabahiro | 54:4167f10ecad0 | 2888 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2889 | break; |
yabahiro | 54:4167f10ecad0 | 2890 | case 255: |
yabahiro | 54:4167f10ecad0 | 2891 | motor[TIRE_FL].pwm = 25; |
yabahiro | 54:4167f10ecad0 | 2892 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2893 | motor[TIRE_BL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2894 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2895 | case 253: |
yabahiro | 54:4167f10ecad0 | 2896 | motor[TIRE_FL].pwm = 25; |
yabahiro | 54:4167f10ecad0 | 2897 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2898 | motor[TIRE_BL].pwm = 40; |
yabahiro | 54:4167f10ecad0 | 2899 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2900 | break; |
yabahiro | 54:4167f10ecad0 | 2901 | case 254: |
yabahiro | 54:4167f10ecad0 | 2902 | motor[TIRE_FL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2903 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2904 | motor[TIRE_BL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2905 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2906 | break; |
yabahiro | 54:4167f10ecad0 | 2907 | case 1: |
yabahiro | 54:4167f10ecad0 | 2908 | motor[TIRE_FL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2909 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2910 | motor[TIRE_BL].pwm = 25; |
yabahiro | 54:4167f10ecad0 | 2911 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2912 | break; |
yabahiro | 54:4167f10ecad0 | 2913 | case 3: |
yabahiro | 54:4167f10ecad0 | 2914 | motor[TIRE_FL].pwm = 40; |
yabahiro | 54:4167f10ecad0 | 2915 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2916 | motor[TIRE_BL].pwm = 25; |
yabahiro | 54:4167f10ecad0 | 2917 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2918 | break; |
yabahiro | 54:4167f10ecad0 | 2919 | case 2: |
yabahiro | 54:4167f10ecad0 | 2920 | motor[TIRE_FL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2921 | motor[TIRE_FL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2922 | motor[TIRE_BL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 2923 | motor[TIRE_BL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2924 | break; |
yabahiro | 54:4167f10ecad0 | 2925 | } |
yabahiro | 54:4167f10ecad0 | 2926 | if(g[3]==0&&g[2]==0) { |
yabahiro | 54:4167f10ecad0 | 2927 | mode=25; |
yabahiro | 54:4167f10ecad0 | 2928 | } |
yabahiro | 54:4167f10ecad0 | 2929 | } else { |
yabahiro | 54:4167f10ecad0 | 2930 | if(g[1]==98&&countss>=40000) { |
yabahiro | 54:4167f10ecad0 | 2931 | mode=31; |
yabahiro | 54:4167f10ecad0 | 2932 | fast = 60; |
yabahiro | 54:4167f10ecad0 | 2933 | normal = 40; |
yabahiro | 54:4167f10ecad0 | 2934 | slow = 30; |
yabahiro | 54:4167f10ecad0 | 2935 | countss=0; |
yabahiro | 54:4167f10ecad0 | 2936 | } |
yabahiro | 54:4167f10ecad0 | 2937 | switch(g[1]) { |
yabahiro | 54:4167f10ecad0 | 2938 | case 98: |
yabahiro | 54:4167f10ecad0 | 2939 | fast=40; |
yabahiro | 54:4167f10ecad0 | 2940 | normal=30; |
yabahiro | 54:4167f10ecad0 | 2941 | slow=25; |
yabahiro | 54:4167f10ecad0 | 2942 | motor[TIRE_FR].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 2943 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2944 | motor[TIRE_FL].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 2945 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2946 | motor[TIRE_BR].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 2947 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2948 | motor[TIRE_BL].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 2949 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2950 | break; |
yabahiro | 54:4167f10ecad0 | 2951 | case 0: |
yabahiro | 54:4167f10ecad0 | 2952 | motor[TIRE_FR].pwm = fast; |
yabahiro | 54:4167f10ecad0 | 2953 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2954 | motor[TIRE_FL].pwm = fast; |
yabahiro | 54:4167f10ecad0 | 2955 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2956 | motor[TIRE_BR].pwm = fast; |
yabahiro | 54:4167f10ecad0 | 2957 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2958 | motor[TIRE_BL].pwm = fast; |
yabahiro | 54:4167f10ecad0 | 2959 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2960 | mtc=true; |
yabahiro | 54:4167f10ecad0 | 2961 | break; |
yabahiro | 54:4167f10ecad0 | 2962 | case 255: |
yabahiro | 54:4167f10ecad0 | 2963 | motor[TIRE_FR].pwm = fast; |
yabahiro | 54:4167f10ecad0 | 2964 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2965 | motor[TIRE_FL].pwm = slow; |
yabahiro | 54:4167f10ecad0 | 2966 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2967 | motor[TIRE_BR].pwm = slow; |
yabahiro | 54:4167f10ecad0 | 2968 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2969 | motor[TIRE_BL].pwm = fast; |
yabahiro | 54:4167f10ecad0 | 2970 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2971 | mtc=true; |
yabahiro | 54:4167f10ecad0 | 2972 | break; |
yabahiro | 54:4167f10ecad0 | 2973 | case 253: |
yabahiro | 54:4167f10ecad0 | 2974 | motor[TIRE_FR].pwm = slow; |
yabahiro | 54:4167f10ecad0 | 2975 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2976 | motor[TIRE_FL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2977 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2978 | motor[TIRE_BR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2979 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2980 | motor[TIRE_BL].pwm = slow; |
yabahiro | 54:4167f10ecad0 | 2981 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2982 | mtc=true; |
yabahiro | 54:4167f10ecad0 | 2983 | break; |
yabahiro | 54:4167f10ecad0 | 2984 | case 254: |
yabahiro | 54:4167f10ecad0 | 2985 | motor[TIRE_FR].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 2986 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2987 | motor[TIRE_FL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2988 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2989 | motor[TIRE_BR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 2990 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 2991 | motor[TIRE_BL].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 2992 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 2993 | mtc=true; |
yabahiro | 54:4167f10ecad0 | 2994 | break; |
yabahiro | 54:4167f10ecad0 | 2995 | case 1: |
yabahiro | 54:4167f10ecad0 | 2996 | motor[TIRE_FR].pwm = slow; |
yabahiro | 54:4167f10ecad0 | 2997 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 2998 | motor[TIRE_FL].pwm = fast; |
yabahiro | 54:4167f10ecad0 | 2999 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3000 | motor[TIRE_BR].pwm = fast; |
yabahiro | 54:4167f10ecad0 | 3001 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3002 | motor[TIRE_BL].pwm = slow; |
yabahiro | 54:4167f10ecad0 | 3003 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3004 | mtc=true; |
yabahiro | 54:4167f10ecad0 | 3005 | break; |
yabahiro | 54:4167f10ecad0 | 3006 | case 3: |
yabahiro | 54:4167f10ecad0 | 3007 | motor[TIRE_FR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3008 | motor[TIRE_FR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 3009 | motor[TIRE_FL].pwm = slow; |
yabahiro | 54:4167f10ecad0 | 3010 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3011 | motor[TIRE_BR].pwm = slow; |
yabahiro | 54:4167f10ecad0 | 3012 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3013 | motor[TIRE_BL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3014 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 3015 | mtc=true; |
yabahiro | 54:4167f10ecad0 | 3016 | break; |
yabahiro | 54:4167f10ecad0 | 3017 | case 2: |
yabahiro | 54:4167f10ecad0 | 3018 | motor[TIRE_FR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3019 | motor[TIRE_FR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 3020 | motor[TIRE_FL].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 3021 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3022 | motor[TIRE_BR].pwm = normal; |
yabahiro | 54:4167f10ecad0 | 3023 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3024 | motor[TIRE_BL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3025 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 3026 | mtc=true; |
yabahiro | 54:4167f10ecad0 | 3027 | break; |
yabahiro | 54:4167f10ecad0 | 3028 | } |
yabahiro | 54:4167f10ecad0 | 3029 | if(g[1]!=98&&mtc==true) { |
yabahiro | 54:4167f10ecad0 | 3030 | switch(g[0]) { |
yabahiro | 54:4167f10ecad0 | 3031 | case 0: |
yabahiro | 54:4167f10ecad0 | 3032 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 3033 | break; |
yabahiro | 54:4167f10ecad0 | 3034 | case 255: |
yabahiro | 54:4167f10ecad0 | 3035 | motor[TIRE_FL].pwm += 3; |
yabahiro | 54:4167f10ecad0 | 3036 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 3037 | break; |
yabahiro | 54:4167f10ecad0 | 3038 | case 253: |
yabahiro | 54:4167f10ecad0 | 3039 | motor[TIRE_FL].pwm += 6; |
yabahiro | 54:4167f10ecad0 | 3040 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 3041 | break; |
yabahiro | 54:4167f10ecad0 | 3042 | case 254: |
yabahiro | 54:4167f10ecad0 | 3043 | motor[TIRE_FL].pwm += 9; |
yabahiro | 54:4167f10ecad0 | 3044 | motor[TIRE_FR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3045 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 3046 | break; |
yabahiro | 54:4167f10ecad0 | 3047 | case 1: |
yabahiro | 54:4167f10ecad0 | 3048 | motor[TIRE_FR].pwm += 3; |
yabahiro | 54:4167f10ecad0 | 3049 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 3050 | break; |
yabahiro | 54:4167f10ecad0 | 3051 | case 3: |
yabahiro | 54:4167f10ecad0 | 3052 | motor[TIRE_FR].pwm += 6; |
yabahiro | 54:4167f10ecad0 | 3053 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 3054 | break; |
yabahiro | 54:4167f10ecad0 | 3055 | case 2: |
yabahiro | 54:4167f10ecad0 | 3056 | motor[TIRE_FR].pwm += 9; |
yabahiro | 54:4167f10ecad0 | 3057 | motor[TIRE_FL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3058 | mtc=false; |
yabahiro | 54:4167f10ecad0 | 3059 | break; |
yabahiro | 54:4167f10ecad0 | 3060 | } |
yabahiro | 54:4167f10ecad0 | 3061 | } |
yabahiro | 52:4394a1debceb | 3062 | } |
yabahiro | 54:4167f10ecad0 | 3063 | break; |
yabahiro | 54:4167f10ecad0 | 3064 | case 25: |
kishibekairohan | 47:a9cad8502999 | 3065 | motor[TIRE_FR].pwm = 100; |
kishibekairohan | 47:a9cad8502999 | 3066 | motor[TIRE_FR].dir = BRAKE; |
kishibekairohan | 47:a9cad8502999 | 3067 | motor[TIRE_FL].pwm = 100; |
kishibekairohan | 47:a9cad8502999 | 3068 | motor[TIRE_FL].dir = BRAKE; |
kishibekairohan | 47:a9cad8502999 | 3069 | motor[TIRE_BR].pwm = 100; |
kishibekairohan | 47:a9cad8502999 | 3070 | motor[TIRE_BR].dir = BRAKE; |
kishibekairohan | 47:a9cad8502999 | 3071 | motor[TIRE_BL].pwm = 100; |
kishibekairohan | 47:a9cad8502999 | 3072 | motor[TIRE_BL].dir = BRAKE; |
yabahiro | 46:68296caae1af | 3073 | if(UPLS==true||DOLS==true) { |
yabahiro | 54:4167f10ecad0 | 3074 | if(UPLS==true||DOLS==true) { |
yabahiro | 54:4167f10ecad0 | 3075 | motor[MOTOR_0].pwm = 200; |
yabahiro | 54:4167f10ecad0 | 3076 | motor[MOTOR_0].dir = BRAKE; |
yabahiro | 54:4167f10ecad0 | 3077 | countss = 0; |
yabahiro | 54:4167f10ecad0 | 3078 | mode=26; |
yabahiro | 54:4167f10ecad0 | 3079 | } |
yabahiro | 46:68296caae1af | 3080 | } else { |
yabahiro | 46:68296caae1af | 3081 | motor[MOTOR_0].pwm = 100; |
yabahiro | 46:68296caae1af | 3082 | motor[MOTOR_0].dir = BACK; |
yabahiro | 46:68296caae1af | 3083 | } |
yabahiro | 54:4167f10ecad0 | 3084 | break; |
yabahiro | 54:4167f10ecad0 | 3085 | case 26: |
yabahiro | 56:61ebd4b759b4 | 3086 | /* |
yabahiro | 56:61ebd4b759b4 | 3087 | if (g[3] == 0&&countss>=30000) { |
yabahiro | 56:61ebd4b759b4 | 3088 | mode = 40; |
yabahiro | 56:61ebd4b759b4 | 3089 | } |
yabahiro | 56:61ebd4b759b4 | 3090 | */ |
yabahiro | 56:61ebd4b759b4 | 3091 | if (g[1] != 99) { |
yabahiro | 54:4167f10ecad0 | 3092 | mode = 31; |
yabahiro | 54:4167f10ecad0 | 3093 | } |
yabahiro | 38:40e7fdf3c694 | 3094 | switch(g[4]) { |
yabahiro | 38:40e7fdf3c694 | 3095 | case 98: |
yabahiro | 38:40e7fdf3c694 | 3096 | motor[TIRE_FR].pwm = 60; |
yabahiro | 38:40e7fdf3c694 | 3097 | motor[TIRE_FR].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 3098 | motor[TIRE_FL].pwm = 60; |
yabahiro | 38:40e7fdf3c694 | 3099 | motor[TIRE_FL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3100 | motor[TIRE_BR].pwm = 60; |
yabahiro | 38:40e7fdf3c694 | 3101 | motor[TIRE_BR].dir = FOR; |
kishibekairohan | 41:99a1158f3eca | 3102 | motor[TIRE_BL].pwm = 60; |
yabahiro | 38:40e7fdf3c694 | 3103 | motor[TIRE_BL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3104 | break; |
yabahiro | 38:40e7fdf3c694 | 3105 | case 99: |
yabahiro | 38:40e7fdf3c694 | 3106 | motor[TIRE_FR].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3107 | motor[TIRE_FR].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3108 | motor[TIRE_FL].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3109 | motor[TIRE_FL].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3110 | motor[TIRE_BR].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3111 | motor[TIRE_BR].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3112 | motor[TIRE_BL].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3113 | motor[TIRE_BL].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3114 | break; |
yabahiro | 38:40e7fdf3c694 | 3115 | case 0: |
yabahiro | 38:40e7fdf3c694 | 3116 | motor[TIRE_FR].pwm = 60; |
yabahiro | 38:40e7fdf3c694 | 3117 | motor[TIRE_FR].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 3118 | motor[TIRE_FL].pwm = 60; |
yabahiro | 38:40e7fdf3c694 | 3119 | motor[TIRE_FL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3120 | motor[TIRE_BR].pwm = 60; |
yabahiro | 38:40e7fdf3c694 | 3121 | motor[TIRE_BR].dir = FOR; |
kishibekairohan | 41:99a1158f3eca | 3122 | motor[TIRE_BL].pwm = 60; |
yabahiro | 38:40e7fdf3c694 | 3123 | motor[TIRE_BL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3124 | break; |
yabahiro | 38:40e7fdf3c694 | 3125 | case 255: |
yabahiro | 38:40e7fdf3c694 | 3126 | motor[TIRE_FR].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3127 | motor[TIRE_FR].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3128 | motor[TIRE_FL].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3129 | motor[TIRE_FL].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3130 | motor[TIRE_BR].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3131 | motor[TIRE_BR].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3132 | motor[TIRE_BL].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3133 | motor[TIRE_BL].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3134 | break; |
yabahiro | 38:40e7fdf3c694 | 3135 | case 253: |
yabahiro | 46:68296caae1af | 3136 | motor[TIRE_FR].pwm = 25; |
yabahiro | 38:40e7fdf3c694 | 3137 | motor[TIRE_FR].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 3138 | motor[TIRE_FL].pwm = 60; |
yabahiro | 38:40e7fdf3c694 | 3139 | motor[TIRE_FL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3140 | motor[TIRE_BR].pwm = 60; |
yabahiro | 38:40e7fdf3c694 | 3141 | motor[TIRE_BR].dir = FOR; |
yabahiro | 46:68296caae1af | 3142 | motor[TIRE_BL].pwm = 25; |
yabahiro | 38:40e7fdf3c694 | 3143 | motor[TIRE_BL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3144 | break; |
yabahiro | 38:40e7fdf3c694 | 3145 | case 254: |
yabahiro | 38:40e7fdf3c694 | 3146 | motor[TIRE_FR].pwm = 40; |
yabahiro | 38:40e7fdf3c694 | 3147 | motor[TIRE_FR].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 3148 | motor[TIRE_FL].pwm = 60; |
yabahiro | 38:40e7fdf3c694 | 3149 | motor[TIRE_FL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3150 | motor[TIRE_BR].pwm = 60; |
yabahiro | 38:40e7fdf3c694 | 3151 | motor[TIRE_BR].dir = FOR; |
kishibekairohan | 41:99a1158f3eca | 3152 | motor[TIRE_BL].pwm = 40; |
yabahiro | 38:40e7fdf3c694 | 3153 | motor[TIRE_BL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3154 | break; |
yabahiro | 38:40e7fdf3c694 | 3155 | case 1: |
yabahiro | 38:40e7fdf3c694 | 3156 | motor[TIRE_FR].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3157 | motor[TIRE_FR].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3158 | motor[TIRE_FL].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3159 | motor[TIRE_FL].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3160 | motor[TIRE_BR].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3161 | motor[TIRE_BR].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3162 | motor[TIRE_BL].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3163 | motor[TIRE_BL].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3164 | break; |
yabahiro | 38:40e7fdf3c694 | 3165 | case 3: |
yabahiro | 38:40e7fdf3c694 | 3166 | motor[TIRE_FR].pwm = 60; |
yabahiro | 38:40e7fdf3c694 | 3167 | motor[TIRE_FR].dir = FOR; |
yabahiro | 46:68296caae1af | 3168 | motor[TIRE_FL].pwm = 25; |
yabahiro | 38:40e7fdf3c694 | 3169 | motor[TIRE_FL].dir = BACK; |
yabahiro | 46:68296caae1af | 3170 | motor[TIRE_BR].pwm = 25; |
yabahiro | 38:40e7fdf3c694 | 3171 | motor[TIRE_BR].dir = FOR; |
kishibekairohan | 41:99a1158f3eca | 3172 | motor[TIRE_BL].pwm = 60; |
yabahiro | 38:40e7fdf3c694 | 3173 | motor[TIRE_BL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3174 | break; |
yabahiro | 38:40e7fdf3c694 | 3175 | case 2: |
yabahiro | 38:40e7fdf3c694 | 3176 | motor[TIRE_FR].pwm = 60; |
yabahiro | 38:40e7fdf3c694 | 3177 | motor[TIRE_FR].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 3178 | motor[TIRE_FL].pwm = 40; |
yabahiro | 38:40e7fdf3c694 | 3179 | motor[TIRE_FL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3180 | motor[TIRE_BR].pwm = 40; |
yabahiro | 38:40e7fdf3c694 | 3181 | motor[TIRE_BR].dir = FOR; |
kishibekairohan | 41:99a1158f3eca | 3182 | motor[TIRE_BL].pwm = 60; |
yabahiro | 38:40e7fdf3c694 | 3183 | motor[TIRE_BL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3184 | break; |
yabahiro | 38:40e7fdf3c694 | 3185 | } |
yabahiro | 54:4167f10ecad0 | 3186 | break; |
yabahiro | 54:4167f10ecad0 | 3187 | case 31: |
yabahiro | 54:4167f10ecad0 | 3188 | motor[TIRE_FR].pwm = 255; |
yabahiro | 54:4167f10ecad0 | 3189 | motor[TIRE_FR].dir = BRAKE; |
yabahiro | 54:4167f10ecad0 | 3190 | motor[TIRE_FL].pwm = 45; |
yabahiro | 54:4167f10ecad0 | 3191 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3192 | motor[TIRE_BR].pwm = 45; |
yabahiro | 54:4167f10ecad0 | 3193 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3194 | motor[TIRE_BL].pwm = 255; |
yabahiro | 54:4167f10ecad0 | 3195 | motor[TIRE_BL].dir = BRAKE; |
yabahiro | 56:61ebd4b759b4 | 3196 | if(g[3]==0) { |
yabahiro | 54:4167f10ecad0 | 3197 | cross=0; |
yabahiro | 54:4167f10ecad0 | 3198 | countss=0; |
yabahiro | 54:4167f10ecad0 | 3199 | mode=40; |
yabahiro | 56:61ebd4b759b4 | 3200 | fast = 70; |
yabahiro | 56:61ebd4b759b4 | 3201 | normal = 50; |
yabahiro | 54:4167f10ecad0 | 3202 | slow = 30; |
yabahiro | 54:4167f10ecad0 | 3203 | } |
yabahiro | 54:4167f10ecad0 | 3204 | break; |
yabahiro | 54:4167f10ecad0 | 3205 | case 40: |
yabahiro | 54:4167f10ecad0 | 3206 | if(YELLOW) { |
yabahiro | 54:4167f10ecad0 | 3207 | if(cross==1) { |
yabahiro | 54:4167f10ecad0 | 3208 | mode=41; |
yabahiro | 54:4167f10ecad0 | 3209 | countss=0; |
yabahiro | 54:4167f10ecad0 | 3210 | cross=0; |
yabahiro | 54:4167f10ecad0 | 3211 | } |
yabahiro | 54:4167f10ecad0 | 3212 | } else { |
yabahiro | 54:4167f10ecad0 | 3213 | if(cross==3) { |
yabahiro | 54:4167f10ecad0 | 3214 | fast = 60; |
yabahiro | 54:4167f10ecad0 | 3215 | normal = 40; |
yabahiro | 54:4167f10ecad0 | 3216 | slow = 30; |
yabahiro | 54:4167f10ecad0 | 3217 | mode=41; |
yabahiro | 54:4167f10ecad0 | 3218 | countss=0; |
yabahiro | 54:4167f10ecad0 | 3219 | cross=0; |
yabahiro | 54:4167f10ecad0 | 3220 | } |
yabahiro | 54:4167f10ecad0 | 3221 | } |
yabahiro | 54:4167f10ecad0 | 3222 | /* |
yabahiro | 54:4167f10ecad0 | 3223 | if(LIF||LIB) { |
yabahiro | 54:4167f10ecad0 | 3224 | mode=42; |
yabahiro | 33:dd598bb23ad1 | 3225 | } |
yabahiro | 54:4167f10ecad0 | 3226 | */ |
yabahiro | 54:4167f10ecad0 | 3227 | switch(g[3]) { |
yabahiro | 54:4167f10ecad0 | 3228 | case 98: |
yabahiro | 54:4167f10ecad0 | 3229 | motor[TIRE_FR].pwm = normal+15; |
yabahiro | 54:4167f10ecad0 | 3230 | motor[TIRE_FR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3231 | motor[TIRE_FL].pwm = normal+15; |
yabahiro | 54:4167f10ecad0 | 3232 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3233 | motor[TIRE_BR].pwm = normal+15; |
yabahiro | 54:4167f10ecad0 | 3234 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3235 | motor[TIRE_BL].pwm = normal+15; |
yabahiro | 54:4167f10ecad0 | 3236 | motor[TIRE_BL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3237 | if(countss>30000) { |
yabahiro | 54:4167f10ecad0 | 3238 | cross++; |
yabahiro | 54:4167f10ecad0 | 3239 | countss=0; |
yabahiro | 54:4167f10ecad0 | 3240 | } |
yabahiro | 54:4167f10ecad0 | 3241 | mtc2=true; |
yabahiro | 54:4167f10ecad0 | 3242 | break; |
yabahiro | 54:4167f10ecad0 | 3243 | case 0: |
yabahiro | 54:4167f10ecad0 | 3244 | motor[TIRE_FR].pwm = fast+15; |
yabahiro | 54:4167f10ecad0 | 3245 | motor[TIRE_FR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3246 | motor[TIRE_FL].pwm = fast+15; |
yabahiro | 54:4167f10ecad0 | 3247 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3248 | motor[TIRE_BR].pwm = fast+15; |
yabahiro | 54:4167f10ecad0 | 3249 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3250 | motor[TIRE_BL].pwm = fast+15; |
yabahiro | 54:4167f10ecad0 | 3251 | motor[TIRE_BL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3252 | mtc2=true; |
yabahiro | 54:4167f10ecad0 | 3253 | break; |
yabahiro | 54:4167f10ecad0 | 3254 | case 255: |
yabahiro | 54:4167f10ecad0 | 3255 | motor[TIRE_FR].pwm = slow+15; |
yabahiro | 54:4167f10ecad0 | 3256 | motor[TIRE_FR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3257 | motor[TIRE_FL].pwm = fast+15; |
yabahiro | 54:4167f10ecad0 | 3258 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3259 | motor[TIRE_BR].pwm = fast+15; |
yabahiro | 54:4167f10ecad0 | 3260 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3261 | motor[TIRE_BL].pwm = slow+15; |
yabahiro | 54:4167f10ecad0 | 3262 | motor[TIRE_BL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3263 | mtc2=true; |
yabahiro | 54:4167f10ecad0 | 3264 | break; |
yabahiro | 54:4167f10ecad0 | 3265 | case 253: |
yabahiro | 54:4167f10ecad0 | 3266 | motor[TIRE_FR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3267 | motor[TIRE_FR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 3268 | motor[TIRE_FL].pwm = slow+15; |
yabahiro | 54:4167f10ecad0 | 3269 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3270 | motor[TIRE_BR].pwm = slow+15; |
yabahiro | 54:4167f10ecad0 | 3271 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3272 | motor[TIRE_BL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3273 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 3274 | mtc2=true; |
yabahiro | 54:4167f10ecad0 | 3275 | break; |
yabahiro | 54:4167f10ecad0 | 3276 | case 254: |
yabahiro | 54:4167f10ecad0 | 3277 | motor[TIRE_FR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3278 | motor[TIRE_FR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 3279 | motor[TIRE_FL].pwm = normal+15; |
yabahiro | 54:4167f10ecad0 | 3280 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3281 | motor[TIRE_BR].pwm = normal+15; |
yabahiro | 54:4167f10ecad0 | 3282 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3283 | motor[TIRE_BL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3284 | motor[TIRE_BL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 3285 | mtc2=true; |
yabahiro | 54:4167f10ecad0 | 3286 | break; |
yabahiro | 54:4167f10ecad0 | 3287 | case 1: |
yabahiro | 54:4167f10ecad0 | 3288 | motor[TIRE_FR].pwm = fast+15; |
yabahiro | 54:4167f10ecad0 | 3289 | motor[TIRE_FR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3290 | motor[TIRE_FL].pwm = slow+15; |
yabahiro | 54:4167f10ecad0 | 3291 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3292 | motor[TIRE_BR].pwm = slow+15; |
yabahiro | 54:4167f10ecad0 | 3293 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3294 | motor[TIRE_BL].pwm = fast+15; |
yabahiro | 54:4167f10ecad0 | 3295 | motor[TIRE_BL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3296 | mtc2=true; |
yabahiro | 54:4167f10ecad0 | 3297 | break; |
yabahiro | 54:4167f10ecad0 | 3298 | case 3: |
yabahiro | 54:4167f10ecad0 | 3299 | motor[TIRE_FR].pwm = slow+15; |
yabahiro | 54:4167f10ecad0 | 3300 | motor[TIRE_FR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3301 | motor[TIRE_FL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3302 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 3303 | motor[TIRE_BR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3304 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 3305 | motor[TIRE_BL].pwm = slow+15; |
yabahiro | 54:4167f10ecad0 | 3306 | motor[TIRE_BL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3307 | mtc2=true; |
yabahiro | 54:4167f10ecad0 | 3308 | break; |
yabahiro | 54:4167f10ecad0 | 3309 | case 2: |
yabahiro | 54:4167f10ecad0 | 3310 | motor[TIRE_FR].pwm = normal+15; |
yabahiro | 54:4167f10ecad0 | 3311 | motor[TIRE_FR].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3312 | motor[TIRE_FL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3313 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 3314 | motor[TIRE_BR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3315 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 3316 | motor[TIRE_BL].pwm = normal+15; |
yabahiro | 54:4167f10ecad0 | 3317 | motor[TIRE_BL].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3318 | mtc2=true; |
yabahiro | 54:4167f10ecad0 | 3319 | break; |
yabahiro | 54:4167f10ecad0 | 3320 | } |
yabahiro | 54:4167f10ecad0 | 3321 | if(g[2]!=98&&mtc2==true) { |
yabahiro | 54:4167f10ecad0 | 3322 | switch(g[2]) { |
yabahiro | 54:4167f10ecad0 | 3323 | case 0: |
yabahiro | 54:4167f10ecad0 | 3324 | mtc2=false; |
yabahiro | 54:4167f10ecad0 | 3325 | break; |
yabahiro | 54:4167f10ecad0 | 3326 | case 255: |
yabahiro | 54:4167f10ecad0 | 3327 | motor[TIRE_FR].pwm += 3; |
yabahiro | 54:4167f10ecad0 | 3328 | mtc2=false; |
yabahiro | 54:4167f10ecad0 | 3329 | break; |
yabahiro | 54:4167f10ecad0 | 3330 | case 253: |
yabahiro | 54:4167f10ecad0 | 3331 | motor[TIRE_FR].pwm += 6; |
yabahiro | 54:4167f10ecad0 | 3332 | mtc2=false; |
yabahiro | 54:4167f10ecad0 | 3333 | break; |
yabahiro | 54:4167f10ecad0 | 3334 | case 254: |
yabahiro | 54:4167f10ecad0 | 3335 | motor[TIRE_FR].pwm += 9; |
yabahiro | 54:4167f10ecad0 | 3336 | motor[TIRE_BR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3337 | mtc2=false; |
yabahiro | 54:4167f10ecad0 | 3338 | break; |
yabahiro | 54:4167f10ecad0 | 3339 | case 1: |
yabahiro | 54:4167f10ecad0 | 3340 | motor[TIRE_BR].pwm += 3; |
yabahiro | 54:4167f10ecad0 | 3341 | mtc2=false; |
yabahiro | 54:4167f10ecad0 | 3342 | break; |
yabahiro | 54:4167f10ecad0 | 3343 | case 3: |
yabahiro | 54:4167f10ecad0 | 3344 | motor[TIRE_BR].pwm += 6; |
yabahiro | 54:4167f10ecad0 | 3345 | mtc2=false; |
yabahiro | 54:4167f10ecad0 | 3346 | break; |
yabahiro | 54:4167f10ecad0 | 3347 | case 2: |
yabahiro | 54:4167f10ecad0 | 3348 | motor[TIRE_BR].pwm += 9; |
yabahiro | 54:4167f10ecad0 | 3349 | motor[TIRE_FR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3350 | mtc2=false; |
yabahiro | 54:4167f10ecad0 | 3351 | break; |
yabahiro | 54:4167f10ecad0 | 3352 | } |
yabahiro | 54:4167f10ecad0 | 3353 | } |
yabahiro | 54:4167f10ecad0 | 3354 | break; |
yabahiro | 54:4167f10ecad0 | 3355 | case 41: |
yabahiro | 54:4167f10ecad0 | 3356 | /* |
yabahiro | 54:4167f10ecad0 | 3357 | if(LIF||LIB) { |
yabahiro | 54:4167f10ecad0 | 3358 | mode=42; |
yabahiro | 54:4167f10ecad0 | 3359 | } |
yabahiro | 54:4167f10ecad0 | 3360 | */ |
yabahiro | 54:4167f10ecad0 | 3361 | motor[TIRE_FR].pwm = 255; |
yabahiro | 54:4167f10ecad0 | 3362 | motor[TIRE_FR].dir = BRAKE; |
yabahiro | 54:4167f10ecad0 | 3363 | motor[TIRE_FL].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 3364 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3365 | motor[TIRE_BR].pwm = 30; |
yabahiro | 54:4167f10ecad0 | 3366 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3367 | motor[TIRE_BL].pwm = 255; |
yabahiro | 54:4167f10ecad0 | 3368 | motor[TIRE_BL].dir = BRAKE; |
yabahiro | 54:4167f10ecad0 | 3369 | if(g[1]==0) { |
yabahiro | 54:4167f10ecad0 | 3370 | countss=0; |
yabahiro | 54:4167f10ecad0 | 3371 | mode=70; |
yabahiro | 56:61ebd4b759b4 | 3372 | normal = 120; |
yabahiro | 56:61ebd4b759b4 | 3373 | fast = 140; |
yabahiro | 56:61ebd4b759b4 | 3374 | slow = 100; |
yabahiro | 54:4167f10ecad0 | 3375 | } |
yabahiro | 54:4167f10ecad0 | 3376 | break; |
yabahiro | 54:4167f10ecad0 | 3377 | case 42: |
yabahiro | 54:4167f10ecad0 | 3378 | motor[TIRE_FR].pwm = 40; |
yabahiro | 38:40e7fdf3c694 | 3379 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3380 | motor[TIRE_FL].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3381 | motor[TIRE_FL].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 3382 | motor[TIRE_BR].pwm = 0; |
yabahiro | 54:4167f10ecad0 | 3383 | motor[TIRE_BR].dir = FREE; |
yabahiro | 54:4167f10ecad0 | 3384 | motor[TIRE_BL].pwm = 40; |
yabahiro | 38:40e7fdf3c694 | 3385 | motor[TIRE_BL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3386 | if(g[1]==0) { |
yabahiro | 54:4167f10ecad0 | 3387 | countss=0; |
yabahiro | 54:4167f10ecad0 | 3388 | mode=70; |
yabahiro | 53:694dbd7dfa0e | 3389 | } |
yabahiro | 54:4167f10ecad0 | 3390 | break; |
yabahiro | 54:4167f10ecad0 | 3391 | case 70: |
yabahiro | 38:40e7fdf3c694 | 3392 | switch(g[1]) { |
yabahiro | 54:4167f10ecad0 | 3393 | case 99: |
yabahiro | 54:4167f10ecad0 | 3394 | if(countss>=100000) { |
yabahiro | 54:4167f10ecad0 | 3395 | mode=100; |
yabahiro | 54:4167f10ecad0 | 3396 | } |
yabahiro | 54:4167f10ecad0 | 3397 | break; |
yabahiro | 38:40e7fdf3c694 | 3398 | case 98: |
yabahiro | 38:40e7fdf3c694 | 3399 | motor[TIRE_FR].pwm = normal; |
yabahiro | 38:40e7fdf3c694 | 3400 | motor[TIRE_FR].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 3401 | motor[TIRE_FL].pwm = normal; |
yabahiro | 38:40e7fdf3c694 | 3402 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3403 | motor[TIRE_BR].pwm = normal+5; |
yabahiro | 38:40e7fdf3c694 | 3404 | motor[TIRE_BR].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 3405 | motor[TIRE_BL].pwm = normal; |
yabahiro | 38:40e7fdf3c694 | 3406 | motor[TIRE_BL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3407 | break; |
yabahiro | 38:40e7fdf3c694 | 3408 | case 0: |
yabahiro | 54:4167f10ecad0 | 3409 | motor[TIRE_FR].pwm = 100; |
yabahiro | 38:40e7fdf3c694 | 3410 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3411 | motor[TIRE_FL].pwm = 100; |
yabahiro | 38:40e7fdf3c694 | 3412 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3413 | motor[TIRE_BR].pwm = 105; |
yabahiro | 38:40e7fdf3c694 | 3414 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3415 | motor[TIRE_BL].pwm = 100; |
yabahiro | 38:40e7fdf3c694 | 3416 | motor[TIRE_BL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3417 | mtc=true; |
yabahiro | 38:40e7fdf3c694 | 3418 | break; |
yabahiro | 38:40e7fdf3c694 | 3419 | case 255: |
yabahiro | 38:40e7fdf3c694 | 3420 | motor[TIRE_FR].pwm = fast; |
yabahiro | 38:40e7fdf3c694 | 3421 | motor[TIRE_FR].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 3422 | motor[TIRE_FL].pwm = slow; |
yabahiro | 38:40e7fdf3c694 | 3423 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3424 | motor[TIRE_BR].pwm = slow+5; |
yabahiro | 38:40e7fdf3c694 | 3425 | motor[TIRE_BR].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 3426 | motor[TIRE_BL].pwm = fast; |
yabahiro | 38:40e7fdf3c694 | 3427 | motor[TIRE_BL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3428 | mtc=true; |
yabahiro | 38:40e7fdf3c694 | 3429 | break; |
yabahiro | 38:40e7fdf3c694 | 3430 | case 253: |
yabahiro | 38:40e7fdf3c694 | 3431 | motor[TIRE_FR].pwm = slow; |
yabahiro | 38:40e7fdf3c694 | 3432 | motor[TIRE_FR].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 3433 | motor[TIRE_FL].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3434 | motor[TIRE_FL].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3435 | motor[TIRE_BR].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3436 | motor[TIRE_BR].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3437 | motor[TIRE_BL].pwm = slow; |
yabahiro | 38:40e7fdf3c694 | 3438 | motor[TIRE_BL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3439 | mtc=true; |
yabahiro | 38:40e7fdf3c694 | 3440 | break; |
yabahiro | 38:40e7fdf3c694 | 3441 | case 254: |
yabahiro | 38:40e7fdf3c694 | 3442 | motor[TIRE_FR].pwm = normal; |
yabahiro | 38:40e7fdf3c694 | 3443 | motor[TIRE_FR].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 3444 | motor[TIRE_FL].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3445 | motor[TIRE_FL].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3446 | motor[TIRE_BR].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3447 | motor[TIRE_BR].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3448 | motor[TIRE_BL].pwm = normal; |
yabahiro | 38:40e7fdf3c694 | 3449 | motor[TIRE_BL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3450 | mtc=true; |
yabahiro | 38:40e7fdf3c694 | 3451 | break; |
yabahiro | 38:40e7fdf3c694 | 3452 | case 1: |
yabahiro | 38:40e7fdf3c694 | 3453 | motor[TIRE_FR].pwm = slow; |
yabahiro | 38:40e7fdf3c694 | 3454 | motor[TIRE_FR].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 3455 | motor[TIRE_FL].pwm = fast; |
yabahiro | 38:40e7fdf3c694 | 3456 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3457 | motor[TIRE_BR].pwm = fast+5; |
yabahiro | 38:40e7fdf3c694 | 3458 | motor[TIRE_BR].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 3459 | motor[TIRE_BL].pwm = slow; |
yabahiro | 38:40e7fdf3c694 | 3460 | motor[TIRE_BL].dir = BACK; |
yabahiro | 38:40e7fdf3c694 | 3461 | mtc=true; |
yabahiro | 38:40e7fdf3c694 | 3462 | break; |
yabahiro | 38:40e7fdf3c694 | 3463 | case 3: |
yabahiro | 38:40e7fdf3c694 | 3464 | motor[TIRE_FR].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3465 | motor[TIRE_FR].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3466 | motor[TIRE_FL].pwm = slow; |
yabahiro | 38:40e7fdf3c694 | 3467 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3468 | motor[TIRE_BR].pwm = slow+5; |
yabahiro | 38:40e7fdf3c694 | 3469 | motor[TIRE_BR].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 3470 | motor[TIRE_BL].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3471 | motor[TIRE_BL].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3472 | mtc=true; |
yabahiro | 38:40e7fdf3c694 | 3473 | break; |
yabahiro | 38:40e7fdf3c694 | 3474 | case 2: |
yabahiro | 38:40e7fdf3c694 | 3475 | motor[TIRE_FR].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3476 | motor[TIRE_FR].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3477 | motor[TIRE_FL].pwm = normal; |
yabahiro | 38:40e7fdf3c694 | 3478 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3479 | motor[TIRE_BR].pwm = normal+5; |
yabahiro | 38:40e7fdf3c694 | 3480 | motor[TIRE_BR].dir = FOR; |
yabahiro | 38:40e7fdf3c694 | 3481 | motor[TIRE_BL].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3482 | motor[TIRE_BL].dir = FREE; |
yabahiro | 38:40e7fdf3c694 | 3483 | mtc=true; |
yabahiro | 38:40e7fdf3c694 | 3484 | break; |
yabahiro | 38:40e7fdf3c694 | 3485 | } |
yabahiro | 38:40e7fdf3c694 | 3486 | if(g[1]!=98&&mtc==true) { |
yabahiro | 38:40e7fdf3c694 | 3487 | switch(g[0]) { |
yabahiro | 38:40e7fdf3c694 | 3488 | case 0: |
yabahiro | 38:40e7fdf3c694 | 3489 | mtc=false; |
yabahiro | 38:40e7fdf3c694 | 3490 | break; |
yabahiro | 38:40e7fdf3c694 | 3491 | case 255: |
kishibekairohan | 44:2aff0da5ebdb | 3492 | motor[TIRE_FL].pwm += 3; |
yabahiro | 38:40e7fdf3c694 | 3493 | mtc=false; |
yabahiro | 38:40e7fdf3c694 | 3494 | break; |
yabahiro | 38:40e7fdf3c694 | 3495 | case 253: |
kishibekairohan | 44:2aff0da5ebdb | 3496 | motor[TIRE_FL].pwm += 6; |
yabahiro | 38:40e7fdf3c694 | 3497 | mtc=false; |
yabahiro | 38:40e7fdf3c694 | 3498 | break; |
yabahiro | 38:40e7fdf3c694 | 3499 | case 254: |
kishibekairohan | 44:2aff0da5ebdb | 3500 | motor[TIRE_FL].pwm += 9; |
yabahiro | 38:40e7fdf3c694 | 3501 | motor[TIRE_FR].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3502 | mtc=false; |
yabahiro | 38:40e7fdf3c694 | 3503 | break; |
yabahiro | 38:40e7fdf3c694 | 3504 | case 1: |
kishibekairohan | 44:2aff0da5ebdb | 3505 | motor[TIRE_FR].pwm += 3; |
yabahiro | 38:40e7fdf3c694 | 3506 | mtc=false; |
yabahiro | 38:40e7fdf3c694 | 3507 | break; |
yabahiro | 38:40e7fdf3c694 | 3508 | case 3: |
kishibekairohan | 44:2aff0da5ebdb | 3509 | motor[TIRE_FR].pwm += 6; |
yabahiro | 38:40e7fdf3c694 | 3510 | mtc=false; |
yabahiro | 38:40e7fdf3c694 | 3511 | break; |
yabahiro | 38:40e7fdf3c694 | 3512 | case 2: |
kishibekairohan | 44:2aff0da5ebdb | 3513 | motor[TIRE_FR].pwm += 9; |
yabahiro | 38:40e7fdf3c694 | 3514 | motor[TIRE_FL].pwm = 0; |
yabahiro | 38:40e7fdf3c694 | 3515 | mtc=false; |
yabahiro | 38:40e7fdf3c694 | 3516 | break; |
yabahiro | 38:40e7fdf3c694 | 3517 | } |
yabahiro | 33:dd598bb23ad1 | 3518 | } |
yabahiro | 54:4167f10ecad0 | 3519 | break; |
yabahiro | 54:4167f10ecad0 | 3520 | case 100: |
yabahiro | 54:4167f10ecad0 | 3521 | motor[TIRE_FR].pwm = 50; |
yabahiro | 54:4167f10ecad0 | 3522 | motor[TIRE_FR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3523 | motor[TIRE_FL].pwm = 55; |
yabahiro | 54:4167f10ecad0 | 3524 | motor[TIRE_FL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3525 | motor[TIRE_BR].pwm = 60; |
yabahiro | 54:4167f10ecad0 | 3526 | motor[TIRE_BR].dir = FOR; |
yabahiro | 54:4167f10ecad0 | 3527 | motor[TIRE_BL].pwm = 50; |
yabahiro | 54:4167f10ecad0 | 3528 | motor[TIRE_BL].dir = BACK; |
yabahiro | 54:4167f10ecad0 | 3529 | break; |
yabahiro | 54:4167f10ecad0 | 3530 | default: |
yabahiro | 54:4167f10ecad0 | 3531 | motor[TIRE_FR].pwm = 50; |
yabahiro | 54:4167f10ecad0 | 3532 | motor[TIRE_FR].dir = BRAKE; |
yabahiro | 54:4167f10ecad0 | 3533 | motor[TIRE_FL].pwm = 50; |
yabahiro | 54:4167f10ecad0 | 3534 | motor[TIRE_FL].dir = BRAKE; |
yabahiro | 54:4167f10ecad0 | 3535 | motor[TIRE_BR].pwm = 50; |
yabahiro | 54:4167f10ecad0 | 3536 | motor[TIRE_BR].dir = BRAKE; |
yabahiro | 54:4167f10ecad0 | 3537 | motor[TIRE_BL].pwm = 50; |
yabahiro | 54:4167f10ecad0 | 3538 | motor[TIRE_BL].dir = BRAKE; |
yabahiro | 54:4167f10ecad0 | 3539 | break; |
yabahiro | 53:694dbd7dfa0e | 3540 | } |
kishibekairohan | 13:b6e02d6261d7 | 3541 | } |
kishibekairohan | 13:b6e02d6261d7 | 3542 | #endif |
kishibekairohan | 13:b6e02d6261d7 | 3543 | |
kishibekairohan | 13:b6e02d6261d7 | 3544 | #if USE_PROCESS_NUM>4 |
Ryosei | 27:dd9f27fce7d1 | 3545 | static void Process4() |
M_souta | 22:7d93f79a3686 | 3546 | { |
yabahiro | 48:5562a99479e5 | 3547 | //Oh So 決勝青ゾーン |
yabahiro | 48:5562a99479e5 | 3548 | LED::LED::TapeledMode(2); |
yabahiro | 48:5562a99479e5 | 3549 | countss++; |
yabahiro | 48:5562a99479e5 | 3550 | if(mode==1) {//スタートゾーンから白線検知 |
yabahiro | 48:5562a99479e5 | 3551 | fast=40; |
yabahiro | 48:5562a99479e5 | 3552 | normal=30; |
yabahiro | 48:5562a99479e5 | 3553 | slow=20; |
yabahiro | 48:5562a99479e5 | 3554 | motor[TIRE_FR].pwm = normal+20; |
yabahiro | 48:5562a99479e5 | 3555 | motor[TIRE_FR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3556 | motor[TIRE_FL].pwm = normal+20; |
yabahiro | 48:5562a99479e5 | 3557 | motor[TIRE_FL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3558 | motor[TIRE_BR].pwm = normal+20; |
yabahiro | 48:5562a99479e5 | 3559 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3560 | motor[TIRE_BL].pwm = normal+20; |
yabahiro | 48:5562a99479e5 | 3561 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3562 | if(g[2]==0&&countss>=100000) { |
yabahiro | 48:5562a99479e5 | 3563 | countss=100000; |
yabahiro | 48:5562a99479e5 | 3564 | cross=0; |
yabahiro | 48:5562a99479e5 | 3565 | mode=3; |
yabahiro | 48:5562a99479e5 | 3566 | } |
yabahiro | 48:5562a99479e5 | 3567 | } else if(mode==3) { //横ライントレースから縦ライントレースへ |
yabahiro | 48:5562a99479e5 | 3568 | motor[TIRE_FR].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3569 | motor[TIRE_FR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3570 | motor[TIRE_FL].pwm = 255; |
yabahiro | 48:5562a99479e5 | 3571 | motor[TIRE_FL].dir = BRAKE; |
yabahiro | 48:5562a99479e5 | 3572 | motor[TIRE_BR].pwm = 255; |
yabahiro | 48:5562a99479e5 | 3573 | motor[TIRE_BR].dir = BRAKE; |
yabahiro | 48:5562a99479e5 | 3574 | motor[TIRE_BL].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3575 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3576 | if(g[1]==0) { |
yabahiro | 48:5562a99479e5 | 3577 | mode=10; |
yabahiro | 48:5562a99479e5 | 3578 | countss=100000; |
yabahiro | 48:5562a99479e5 | 3579 | } |
yabahiro | 48:5562a99479e5 | 3580 | } else if(mode==10) { //縦ライントレース |
yabahiro | 48:5562a99479e5 | 3581 | switch(g[1]) { |
yabahiro | 48:5562a99479e5 | 3582 | case 98: |
yabahiro | 48:5562a99479e5 | 3583 | motor[TIRE_FR].pwm = normal+50; |
yabahiro | 48:5562a99479e5 | 3584 | motor[TIRE_FR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3585 | motor[TIRE_FL].pwm = normal+50; |
yabahiro | 48:5562a99479e5 | 3586 | motor[TIRE_FL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3587 | motor[TIRE_BR].pwm = normal+50; |
yabahiro | 48:5562a99479e5 | 3588 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3589 | motor[TIRE_BL].pwm = normal+50; |
yabahiro | 48:5562a99479e5 | 3590 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3591 | mtc=true; |
yabahiro | 49:697b4e9ce884 | 3592 | if(YELLOW) { |
yabahiro | 49:697b4e9ce884 | 3593 | if(countss>80000) { |
yabahiro | 49:697b4e9ce884 | 3594 | cross++; |
yabahiro | 49:697b4e9ce884 | 3595 | countss=0; |
yabahiro | 49:697b4e9ce884 | 3596 | } |
yabahiro | 48:5562a99479e5 | 3597 | |
yabahiro | 49:697b4e9ce884 | 3598 | if(cross==2) { |
yabahiro | 49:697b4e9ce884 | 3599 | fast = 10; |
yabahiro | 49:697b4e9ce884 | 3600 | normal = 10; |
yabahiro | 49:697b4e9ce884 | 3601 | slow = 5; |
yabahiro | 49:697b4e9ce884 | 3602 | } |
yabahiro | 48:5562a99479e5 | 3603 | |
yabahiro | 49:697b4e9ce884 | 3604 | if(cross==3) { |
yabahiro | 49:697b4e9ce884 | 3605 | fast=40; |
yabahiro | 49:697b4e9ce884 | 3606 | normal=30; |
yabahiro | 49:697b4e9ce884 | 3607 | slow=20; |
yabahiro | 49:697b4e9ce884 | 3608 | mode=11; |
yabahiro | 49:697b4e9ce884 | 3609 | countss=0; |
yabahiro | 49:697b4e9ce884 | 3610 | cross=0; |
yabahiro | 49:697b4e9ce884 | 3611 | } |
yabahiro | 49:697b4e9ce884 | 3612 | } else { |
yabahiro | 48:5562a99479e5 | 3613 | mode=11; |
yabahiro | 48:5562a99479e5 | 3614 | } |
yabahiro | 48:5562a99479e5 | 3615 | break; |
yabahiro | 48:5562a99479e5 | 3616 | case 0: |
yabahiro | 48:5562a99479e5 | 3617 | motor[TIRE_FR].pwm = fast+50; |
yabahiro | 48:5562a99479e5 | 3618 | motor[TIRE_FR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3619 | motor[TIRE_FL].pwm = fast+50; |
yabahiro | 48:5562a99479e5 | 3620 | motor[TIRE_FL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3621 | motor[TIRE_BR].pwm = fast+50; |
yabahiro | 48:5562a99479e5 | 3622 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3623 | motor[TIRE_BL].pwm = fast+50; |
yabahiro | 48:5562a99479e5 | 3624 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3625 | mtc=true; |
yabahiro | 48:5562a99479e5 | 3626 | break; |
yabahiro | 48:5562a99479e5 | 3627 | case 255: |
yabahiro | 48:5562a99479e5 | 3628 | motor[TIRE_FR].pwm = fast+50; |
yabahiro | 48:5562a99479e5 | 3629 | motor[TIRE_FR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3630 | motor[TIRE_FL].pwm = slow+50; |
yabahiro | 48:5562a99479e5 | 3631 | motor[TIRE_FL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3632 | motor[TIRE_BR].pwm = slow+50; |
yabahiro | 48:5562a99479e5 | 3633 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3634 | motor[TIRE_BL].pwm = fast+50; |
yabahiro | 48:5562a99479e5 | 3635 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3636 | mtc=true; |
yabahiro | 48:5562a99479e5 | 3637 | break; |
yabahiro | 48:5562a99479e5 | 3638 | case 253: |
yabahiro | 48:5562a99479e5 | 3639 | motor[TIRE_FR].pwm = slow+50; |
yabahiro | 48:5562a99479e5 | 3640 | motor[TIRE_FR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3641 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3642 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3643 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3644 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3645 | motor[TIRE_BL].pwm = slow+50; |
yabahiro | 48:5562a99479e5 | 3646 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3647 | mtc=true; |
yabahiro | 48:5562a99479e5 | 3648 | break; |
yabahiro | 48:5562a99479e5 | 3649 | case 254: |
yabahiro | 48:5562a99479e5 | 3650 | motor[TIRE_FR].pwm = normal+50; |
yabahiro | 48:5562a99479e5 | 3651 | motor[TIRE_FR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3652 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3653 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3654 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3655 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3656 | motor[TIRE_BL].pwm = normal+50; |
yabahiro | 48:5562a99479e5 | 3657 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3658 | mtc=true; |
yabahiro | 48:5562a99479e5 | 3659 | break; |
yabahiro | 48:5562a99479e5 | 3660 | case 1: |
yabahiro | 48:5562a99479e5 | 3661 | motor[TIRE_FR].pwm = slow+50; |
yabahiro | 48:5562a99479e5 | 3662 | motor[TIRE_FR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3663 | motor[TIRE_FL].pwm = fast+50; |
yabahiro | 48:5562a99479e5 | 3664 | motor[TIRE_FL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3665 | motor[TIRE_BR].pwm = fast+50; |
yabahiro | 48:5562a99479e5 | 3666 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3667 | motor[TIRE_BL].pwm = slow+50; |
yabahiro | 48:5562a99479e5 | 3668 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3669 | mtc=true; |
yabahiro | 48:5562a99479e5 | 3670 | break; |
yabahiro | 48:5562a99479e5 | 3671 | case 3: |
yabahiro | 48:5562a99479e5 | 3672 | motor[TIRE_FR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3673 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3674 | motor[TIRE_FL].pwm = slow+50; |
yabahiro | 48:5562a99479e5 | 3675 | motor[TIRE_FL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3676 | motor[TIRE_BR].pwm = slow+50; |
yabahiro | 48:5562a99479e5 | 3677 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3678 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3679 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3680 | mtc=true; |
yabahiro | 48:5562a99479e5 | 3681 | break; |
yabahiro | 48:5562a99479e5 | 3682 | case 2: |
yabahiro | 48:5562a99479e5 | 3683 | motor[TIRE_FR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3684 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3685 | motor[TIRE_FL].pwm = normal+50; |
yabahiro | 48:5562a99479e5 | 3686 | motor[TIRE_FL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3687 | motor[TIRE_BR].pwm = normal+50; |
yabahiro | 48:5562a99479e5 | 3688 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3689 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3690 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3691 | mtc=true; |
yabahiro | 48:5562a99479e5 | 3692 | break; |
yabahiro | 48:5562a99479e5 | 3693 | } |
yabahiro | 48:5562a99479e5 | 3694 | if(g[1]!=98&&mtc==true) { |
yabahiro | 48:5562a99479e5 | 3695 | switch(g[0]) { |
yabahiro | 48:5562a99479e5 | 3696 | case 0: |
yabahiro | 48:5562a99479e5 | 3697 | mtc=false; |
yabahiro | 48:5562a99479e5 | 3698 | break; |
yabahiro | 48:5562a99479e5 | 3699 | case 255: |
yabahiro | 48:5562a99479e5 | 3700 | motor[TIRE_FL].pwm += 3; |
yabahiro | 48:5562a99479e5 | 3701 | mtc=false; |
yabahiro | 48:5562a99479e5 | 3702 | break; |
yabahiro | 48:5562a99479e5 | 3703 | case 253: |
yabahiro | 48:5562a99479e5 | 3704 | motor[TIRE_FL].pwm += 6; |
yabahiro | 48:5562a99479e5 | 3705 | mtc=false; |
yabahiro | 48:5562a99479e5 | 3706 | break; |
yabahiro | 48:5562a99479e5 | 3707 | case 254: |
yabahiro | 48:5562a99479e5 | 3708 | motor[TIRE_FL].pwm += 9; |
yabahiro | 48:5562a99479e5 | 3709 | motor[TIRE_FR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3710 | mtc=false; |
yabahiro | 48:5562a99479e5 | 3711 | break; |
yabahiro | 48:5562a99479e5 | 3712 | case 1: |
yabahiro | 48:5562a99479e5 | 3713 | motor[TIRE_FR].pwm += 3; |
yabahiro | 48:5562a99479e5 | 3714 | mtc=false; |
yabahiro | 48:5562a99479e5 | 3715 | break; |
yabahiro | 48:5562a99479e5 | 3716 | case 3: |
yabahiro | 48:5562a99479e5 | 3717 | motor[TIRE_FR].pwm += 6; |
yabahiro | 48:5562a99479e5 | 3718 | mtc=false; |
yabahiro | 48:5562a99479e5 | 3719 | break; |
yabahiro | 48:5562a99479e5 | 3720 | case 2: |
yabahiro | 48:5562a99479e5 | 3721 | motor[TIRE_FR].pwm += 9; |
yabahiro | 48:5562a99479e5 | 3722 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3723 | mtc=false; |
yabahiro | 48:5562a99479e5 | 3724 | break; |
yabahiro | 48:5562a99479e5 | 3725 | } |
yabahiro | 48:5562a99479e5 | 3726 | } |
yabahiro | 48:5562a99479e5 | 3727 | } else if(mode==11) { |
yabahiro | 48:5562a99479e5 | 3728 | motor[TIRE_FR].pwm = normal; |
yabahiro | 48:5562a99479e5 | 3729 | motor[TIRE_FR].dir = FOR; |
yabahiro | 49:697b4e9ce884 | 3730 | motor[TIRE_FL].pwm = 50; |
yabahiro | 49:697b4e9ce884 | 3731 | motor[TIRE_FL].dir = BRAKE; |
yabahiro | 49:697b4e9ce884 | 3732 | motor[TIRE_BR].pwm = 50; |
yabahiro | 49:697b4e9ce884 | 3733 | motor[TIRE_BR].dir = BRAKE; |
yabahiro | 48:5562a99479e5 | 3734 | motor[TIRE_BL].pwm = normal; |
yabahiro | 48:5562a99479e5 | 3735 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3736 | if(g[2]==0 || g[2]==255 || g[2]==254 || g[2]==253) { |
yabahiro | 48:5562a99479e5 | 3737 | countss=0; |
yabahiro | 48:5562a99479e5 | 3738 | cross=0; |
yabahiro | 48:5562a99479e5 | 3739 | mode=20; |
yabahiro | 48:5562a99479e5 | 3740 | } |
yabahiro | 48:5562a99479e5 | 3741 | } else if(mode==20) { |
yabahiro | 48:5562a99479e5 | 3742 | switch(g[2]) { |
yabahiro | 48:5562a99479e5 | 3743 | case 98: |
yabahiro | 48:5562a99479e5 | 3744 | motor[TIRE_FR].pwm = normal+20; |
yabahiro | 48:5562a99479e5 | 3745 | motor[TIRE_FR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3746 | motor[TIRE_FL].pwm = normal+20; |
yabahiro | 48:5562a99479e5 | 3747 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3748 | motor[TIRE_BR].pwm = normal+20; |
yabahiro | 48:5562a99479e5 | 3749 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3750 | motor[TIRE_BL].pwm = normal+20; |
yabahiro | 48:5562a99479e5 | 3751 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3752 | if(countss>30000) { |
yabahiro | 48:5562a99479e5 | 3753 | cross++; |
yabahiro | 48:5562a99479e5 | 3754 | countss=0; |
yabahiro | 48:5562a99479e5 | 3755 | } |
yabahiro | 48:5562a99479e5 | 3756 | mtc2=true; |
yabahiro | 48:5562a99479e5 | 3757 | |
yabahiro | 48:5562a99479e5 | 3758 | if(YELLOW) { |
yabahiro | 49:697b4e9ce884 | 3759 | solenoid.solenoid4= SOLENOID_ON; |
yabahiro | 48:5562a99479e5 | 3760 | if(cross==1) { |
yabahiro | 48:5562a99479e5 | 3761 | fast=20; |
yabahiro | 48:5562a99479e5 | 3762 | normal=15; |
yabahiro | 48:5562a99479e5 | 3763 | slow=15; |
yabahiro | 48:5562a99479e5 | 3764 | } else if(cross==2) { |
yabahiro | 48:5562a99479e5 | 3765 | mode=21; |
yabahiro | 48:5562a99479e5 | 3766 | countss=0; |
yabahiro | 48:5562a99479e5 | 3767 | cross=0; |
yabahiro | 48:5562a99479e5 | 3768 | } |
yabahiro | 48:5562a99479e5 | 3769 | } else { |
yabahiro | 49:697b4e9ce884 | 3770 | if(cross==2) { |
yabahiro | 49:697b4e9ce884 | 3771 | fast=20; |
yabahiro | 49:697b4e9ce884 | 3772 | normal=15; |
yabahiro | 49:697b4e9ce884 | 3773 | slow=15; |
yabahiro | 49:697b4e9ce884 | 3774 | } |
yabahiro | 48:5562a99479e5 | 3775 | if(cross==3) { |
yabahiro | 48:5562a99479e5 | 3776 | mode=21; |
yabahiro | 48:5562a99479e5 | 3777 | countss=0; |
yabahiro | 48:5562a99479e5 | 3778 | cross=0; |
yabahiro | 48:5562a99479e5 | 3779 | } |
yabahiro | 48:5562a99479e5 | 3780 | } |
yabahiro | 48:5562a99479e5 | 3781 | break; |
yabahiro | 48:5562a99479e5 | 3782 | case 0: |
yabahiro | 48:5562a99479e5 | 3783 | motor[TIRE_FR].pwm = fast+20; |
yabahiro | 48:5562a99479e5 | 3784 | motor[TIRE_FR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3785 | motor[TIRE_FL].pwm = fast+20; |
yabahiro | 48:5562a99479e5 | 3786 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3787 | motor[TIRE_BR].pwm = fast+20; |
yabahiro | 48:5562a99479e5 | 3788 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3789 | motor[TIRE_BL].pwm = fast+20; |
yabahiro | 48:5562a99479e5 | 3790 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3791 | mtc2=true; |
yabahiro | 48:5562a99479e5 | 3792 | break; |
yabahiro | 48:5562a99479e5 | 3793 | case 255: |
yabahiro | 48:5562a99479e5 | 3794 | motor[TIRE_FR].pwm = normal+20; |
yabahiro | 48:5562a99479e5 | 3795 | motor[TIRE_FR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3796 | motor[TIRE_FL].pwm = fast+20; |
yabahiro | 48:5562a99479e5 | 3797 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3798 | motor[TIRE_BR].pwm = fast+20; |
yabahiro | 48:5562a99479e5 | 3799 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3800 | motor[TIRE_BL].pwm = normal+20; |
yabahiro | 48:5562a99479e5 | 3801 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3802 | mtc2=true; |
yabahiro | 48:5562a99479e5 | 3803 | break; |
yabahiro | 48:5562a99479e5 | 3804 | case 253: |
yabahiro | 48:5562a99479e5 | 3805 | motor[TIRE_FR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3806 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3807 | motor[TIRE_FL].pwm = slow+20; |
yabahiro | 48:5562a99479e5 | 3808 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3809 | motor[TIRE_BR].pwm = slow+20; |
yabahiro | 48:5562a99479e5 | 3810 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3811 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3812 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3813 | mtc2=true; |
yabahiro | 48:5562a99479e5 | 3814 | break; |
yabahiro | 48:5562a99479e5 | 3815 | case 254: |
yabahiro | 48:5562a99479e5 | 3816 | motor[TIRE_FR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3817 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3818 | motor[TIRE_FL].pwm = normal+20; |
yabahiro | 48:5562a99479e5 | 3819 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3820 | motor[TIRE_BR].pwm = normal+20; |
yabahiro | 48:5562a99479e5 | 3821 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3822 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3823 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3824 | mtc2=true; |
yabahiro | 48:5562a99479e5 | 3825 | break; |
yabahiro | 48:5562a99479e5 | 3826 | case 1: |
yabahiro | 48:5562a99479e5 | 3827 | motor[TIRE_FR].pwm = fast+20; |
yabahiro | 48:5562a99479e5 | 3828 | motor[TIRE_FR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3829 | motor[TIRE_FL].pwm = slow+20; |
yabahiro | 48:5562a99479e5 | 3830 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3831 | motor[TIRE_BR].pwm = slow+20; |
yabahiro | 48:5562a99479e5 | 3832 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3833 | motor[TIRE_BL].pwm = fast+20; |
yabahiro | 48:5562a99479e5 | 3834 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3835 | mtc2=true; |
yabahiro | 48:5562a99479e5 | 3836 | break; |
yabahiro | 48:5562a99479e5 | 3837 | case 3: |
yabahiro | 48:5562a99479e5 | 3838 | motor[TIRE_FR].pwm = slow+20; |
yabahiro | 48:5562a99479e5 | 3839 | motor[TIRE_FR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3840 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3841 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3842 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3843 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3844 | motor[TIRE_BL].pwm = slow+20; |
yabahiro | 48:5562a99479e5 | 3845 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3846 | mtc2=true; |
yabahiro | 48:5562a99479e5 | 3847 | break; |
yabahiro | 48:5562a99479e5 | 3848 | case 2: |
yabahiro | 48:5562a99479e5 | 3849 | motor[TIRE_FR].pwm = normal+20; |
yabahiro | 48:5562a99479e5 | 3850 | motor[TIRE_FR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3851 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3852 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3853 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3854 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3855 | motor[TIRE_BL].pwm = normal+20; |
yabahiro | 48:5562a99479e5 | 3856 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3857 | mtc2=true; |
yabahiro | 48:5562a99479e5 | 3858 | break; |
yabahiro | 48:5562a99479e5 | 3859 | } |
yabahiro | 48:5562a99479e5 | 3860 | if(g[2]!=98&&mtc2==true) { |
yabahiro | 48:5562a99479e5 | 3861 | switch(g[3]) { |
yabahiro | 48:5562a99479e5 | 3862 | case 0: |
yabahiro | 48:5562a99479e5 | 3863 | mtc2=false; |
yabahiro | 48:5562a99479e5 | 3864 | break; |
yabahiro | 48:5562a99479e5 | 3865 | case 255: |
yabahiro | 48:5562a99479e5 | 3866 | motor[TIRE_BL].pwm += 5; |
yabahiro | 48:5562a99479e5 | 3867 | mtc2=false; |
yabahiro | 48:5562a99479e5 | 3868 | break; |
yabahiro | 48:5562a99479e5 | 3869 | case 253: |
yabahiro | 48:5562a99479e5 | 3870 | motor[TIRE_BL].pwm += 10; |
yabahiro | 48:5562a99479e5 | 3871 | mtc2=false; |
yabahiro | 48:5562a99479e5 | 3872 | break; |
yabahiro | 48:5562a99479e5 | 3873 | case 254: |
yabahiro | 48:5562a99479e5 | 3874 | motor[TIRE_BL].pwm += 15; |
yabahiro | 48:5562a99479e5 | 3875 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3876 | mtc2=false; |
yabahiro | 48:5562a99479e5 | 3877 | break; |
yabahiro | 48:5562a99479e5 | 3878 | case 1: |
yabahiro | 48:5562a99479e5 | 3879 | motor[TIRE_FL].pwm += 5; |
yabahiro | 48:5562a99479e5 | 3880 | mtc2=false; |
yabahiro | 48:5562a99479e5 | 3881 | break; |
yabahiro | 48:5562a99479e5 | 3882 | case 3: |
yabahiro | 48:5562a99479e5 | 3883 | motor[TIRE_FL].pwm += 10; |
yabahiro | 48:5562a99479e5 | 3884 | mtc2=false; |
yabahiro | 48:5562a99479e5 | 3885 | break; |
yabahiro | 48:5562a99479e5 | 3886 | case 2: |
yabahiro | 48:5562a99479e5 | 3887 | motor[TIRE_FL].pwm += 15; |
yabahiro | 48:5562a99479e5 | 3888 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 3889 | mtc2=false; |
yabahiro | 48:5562a99479e5 | 3890 | break; |
yabahiro | 48:5562a99479e5 | 3891 | } |
yabahiro | 48:5562a99479e5 | 3892 | } |
yabahiro | 48:5562a99479e5 | 3893 | } |
yabahiro | 48:5562a99479e5 | 3894 | if(YELLOW) { |
yabahiro | 48:5562a99479e5 | 3895 | if(mode==21) { |
yabahiro | 48:5562a99479e5 | 3896 | motor[TIRE_FR].pwm = 20; |
yabahiro | 48:5562a99479e5 | 3897 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3898 | motor[TIRE_FL].pwm = 20; |
yabahiro | 48:5562a99479e5 | 3899 | motor[TIRE_FL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3900 | motor[TIRE_BR].pwm = 20; |
yabahiro | 48:5562a99479e5 | 3901 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3902 | motor[TIRE_BL].pwm = 20; |
yabahiro | 48:5562a99479e5 | 3903 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3904 | if(g[3]==98&&countss>=10000) { |
yabahiro | 48:5562a99479e5 | 3905 | mode=22; |
yabahiro | 48:5562a99479e5 | 3906 | countss=0; |
yabahiro | 48:5562a99479e5 | 3907 | fast=60; |
yabahiro | 48:5562a99479e5 | 3908 | normal=40; |
yabahiro | 48:5562a99479e5 | 3909 | slow=20; |
yabahiro | 48:5562a99479e5 | 3910 | } |
yabahiro | 48:5562a99479e5 | 3911 | } else if(mode==22) { |
yabahiro | 48:5562a99479e5 | 3912 | if(g[4]==3||g[4]==2) { |
yabahiro | 48:5562a99479e5 | 3913 | motor[TIRE_FR].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3914 | motor[TIRE_FR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3915 | motor[TIRE_FL].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3916 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3917 | motor[TIRE_BR].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3918 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3919 | motor[TIRE_BL].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3920 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3921 | } |
yabahiro | 48:5562a99479e5 | 3922 | if(g[4]==253||g[4]==254) { |
yabahiro | 48:5562a99479e5 | 3923 | motor[TIRE_FR].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3924 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3925 | motor[TIRE_FL].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3926 | motor[TIRE_FL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3927 | motor[TIRE_BR].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3928 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3929 | motor[TIRE_BL].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3930 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3931 | } |
yabahiro | 48:5562a99479e5 | 3932 | switch(g[2]) { |
yabahiro | 48:5562a99479e5 | 3933 | case 0: |
yabahiro | 48:5562a99479e5 | 3934 | motor[TIRE_FR].pwm = 20; |
yabahiro | 48:5562a99479e5 | 3935 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3936 | motor[TIRE_BR].pwm = 20; |
yabahiro | 48:5562a99479e5 | 3937 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3938 | break; |
yabahiro | 48:5562a99479e5 | 3939 | case 255: |
yabahiro | 48:5562a99479e5 | 3940 | motor[TIRE_FR].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3941 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3942 | motor[TIRE_BR].pwm = 20; |
yabahiro | 48:5562a99479e5 | 3943 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3944 | break; |
yabahiro | 48:5562a99479e5 | 3945 | case 253: |
yabahiro | 48:5562a99479e5 | 3946 | motor[TIRE_FR].pwm = 40; |
yabahiro | 48:5562a99479e5 | 3947 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3948 | motor[TIRE_BR].pwm = 20; |
yabahiro | 48:5562a99479e5 | 3949 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3950 | break; |
yabahiro | 48:5562a99479e5 | 3951 | case 254: |
yabahiro | 48:5562a99479e5 | 3952 | motor[TIRE_FR].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3953 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3954 | motor[TIRE_BR].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3955 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3956 | break; |
yabahiro | 48:5562a99479e5 | 3957 | case 1: |
yabahiro | 48:5562a99479e5 | 3958 | motor[TIRE_FR].pwm = 20; |
yabahiro | 48:5562a99479e5 | 3959 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3960 | motor[TIRE_BR].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3961 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3962 | break; |
yabahiro | 48:5562a99479e5 | 3963 | case 3: |
yabahiro | 48:5562a99479e5 | 3964 | motor[TIRE_FR].pwm = 20; |
yabahiro | 48:5562a99479e5 | 3965 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3966 | motor[TIRE_BR].pwm = 40; |
yabahiro | 48:5562a99479e5 | 3967 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3968 | break; |
yabahiro | 48:5562a99479e5 | 3969 | case 2: |
yabahiro | 48:5562a99479e5 | 3970 | motor[TIRE_FR].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3971 | motor[TIRE_FR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3972 | motor[TIRE_BR].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3973 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 3974 | break; |
yabahiro | 48:5562a99479e5 | 3975 | } |
yabahiro | 48:5562a99479e5 | 3976 | switch(g[3]) { |
yabahiro | 48:5562a99479e5 | 3977 | case 0: |
yabahiro | 48:5562a99479e5 | 3978 | motor[TIRE_FL].pwm = 20; |
yabahiro | 48:5562a99479e5 | 3979 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3980 | motor[TIRE_BL].pwm = 20; |
yabahiro | 48:5562a99479e5 | 3981 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3982 | break; |
yabahiro | 48:5562a99479e5 | 3983 | case 255: |
yabahiro | 48:5562a99479e5 | 3984 | motor[TIRE_FL].pwm = 20; |
yabahiro | 48:5562a99479e5 | 3985 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3986 | motor[TIRE_BL].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3987 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3988 | case 253: |
yabahiro | 48:5562a99479e5 | 3989 | motor[TIRE_FL].pwm = 20; |
yabahiro | 48:5562a99479e5 | 3990 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 3991 | motor[TIRE_BL].pwm = 40; |
yabahiro | 48:5562a99479e5 | 3992 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3993 | break; |
yabahiro | 48:5562a99479e5 | 3994 | case 254: |
yabahiro | 48:5562a99479e5 | 3995 | motor[TIRE_FL].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3996 | motor[TIRE_FL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3997 | motor[TIRE_BL].pwm = 30; |
yabahiro | 48:5562a99479e5 | 3998 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 3999 | break; |
yabahiro | 48:5562a99479e5 | 4000 | case 1: |
yabahiro | 48:5562a99479e5 | 4001 | motor[TIRE_FL].pwm = 30; |
yabahiro | 48:5562a99479e5 | 4002 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4003 | motor[TIRE_BL].pwm = 20; |
yabahiro | 48:5562a99479e5 | 4004 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4005 | break; |
yabahiro | 48:5562a99479e5 | 4006 | case 3: |
yabahiro | 48:5562a99479e5 | 4007 | motor[TIRE_FL].pwm = 40; |
yabahiro | 48:5562a99479e5 | 4008 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4009 | motor[TIRE_BL].pwm = 20; |
yabahiro | 48:5562a99479e5 | 4010 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4011 | break; |
yabahiro | 48:5562a99479e5 | 4012 | case 2: |
yabahiro | 48:5562a99479e5 | 4013 | motor[TIRE_FL].pwm = 30; |
yabahiro | 48:5562a99479e5 | 4014 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4015 | motor[TIRE_BL].pwm = 30; |
yabahiro | 48:5562a99479e5 | 4016 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4017 | break; |
yabahiro | 48:5562a99479e5 | 4018 | } |
yabahiro | 48:5562a99479e5 | 4019 | if(g[3]==0&&g[2]==0) { |
yabahiro | 48:5562a99479e5 | 4020 | mode=23; |
yabahiro | 48:5562a99479e5 | 4021 | countss=0; |
yabahiro | 48:5562a99479e5 | 4022 | } |
yabahiro | 48:5562a99479e5 | 4023 | } else if(mode==23) { |
yabahiro | 48:5562a99479e5 | 4024 | switch(g[4]) { |
yabahiro | 48:5562a99479e5 | 4025 | case 98: |
yabahiro | 48:5562a99479e5 | 4026 | motor[TIRE_FR].pwm = fast-5; |
yabahiro | 48:5562a99479e5 | 4027 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4028 | motor[TIRE_FL].pwm = fast-5; |
yabahiro | 48:5562a99479e5 | 4029 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4030 | motor[TIRE_BR].pwm = fast-5; |
yabahiro | 48:5562a99479e5 | 4031 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4032 | motor[TIRE_BL].pwm = fast-5; |
yabahiro | 48:5562a99479e5 | 4033 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4034 | break; |
yabahiro | 48:5562a99479e5 | 4035 | case 99: |
yabahiro | 48:5562a99479e5 | 4036 | motor[TIRE_FR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4037 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4038 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4039 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4040 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4041 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4042 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4043 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4044 | break; |
yabahiro | 48:5562a99479e5 | 4045 | case 0: |
yabahiro | 48:5562a99479e5 | 4046 | motor[TIRE_FR].pwm = fast-5; |
yabahiro | 48:5562a99479e5 | 4047 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4048 | motor[TIRE_FL].pwm = fast-5; |
yabahiro | 48:5562a99479e5 | 4049 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4050 | motor[TIRE_BR].pwm = fast-5; |
yabahiro | 48:5562a99479e5 | 4051 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4052 | motor[TIRE_BL].pwm = fast-5; |
yabahiro | 48:5562a99479e5 | 4053 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4054 | break; |
yabahiro | 48:5562a99479e5 | 4055 | case 255: |
yabahiro | 48:5562a99479e5 | 4056 | motor[TIRE_FR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4057 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4058 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4059 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4060 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4061 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4062 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4063 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4064 | break; |
yabahiro | 48:5562a99479e5 | 4065 | case 253: |
yabahiro | 48:5562a99479e5 | 4066 | motor[TIRE_FR].pwm = fast-5; |
yabahiro | 48:5562a99479e5 | 4067 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4068 | motor[TIRE_FL].pwm = slow-5; |
yabahiro | 48:5562a99479e5 | 4069 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4070 | motor[TIRE_BR].pwm = slow-5; |
yabahiro | 48:5562a99479e5 | 4071 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4072 | motor[TIRE_BL].pwm = fast-5; |
yabahiro | 48:5562a99479e5 | 4073 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4074 | break; |
yabahiro | 48:5562a99479e5 | 4075 | case 254: |
yabahiro | 48:5562a99479e5 | 4076 | motor[TIRE_FR].pwm = fast-5; |
yabahiro | 48:5562a99479e5 | 4077 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4078 | motor[TIRE_FL].pwm = normal-5; |
yabahiro | 48:5562a99479e5 | 4079 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4080 | motor[TIRE_BR].pwm = normal-5; |
yabahiro | 48:5562a99479e5 | 4081 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4082 | motor[TIRE_BL].pwm = fast-5; |
yabahiro | 48:5562a99479e5 | 4083 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4084 | break; |
yabahiro | 48:5562a99479e5 | 4085 | case 1: |
yabahiro | 48:5562a99479e5 | 4086 | motor[TIRE_FR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4087 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4088 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4089 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4090 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4091 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4092 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4093 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4094 | break; |
yabahiro | 48:5562a99479e5 | 4095 | case 3: |
yabahiro | 48:5562a99479e5 | 4096 | motor[TIRE_FR].pwm = slow-5; |
yabahiro | 48:5562a99479e5 | 4097 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4098 | motor[TIRE_FL].pwm = fast-5; |
yabahiro | 48:5562a99479e5 | 4099 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4100 | motor[TIRE_BR].pwm = fast-5; |
yabahiro | 48:5562a99479e5 | 4101 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4102 | motor[TIRE_BL].pwm = slow-5; |
yabahiro | 48:5562a99479e5 | 4103 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4104 | break; |
yabahiro | 48:5562a99479e5 | 4105 | case 2: |
yabahiro | 48:5562a99479e5 | 4106 | motor[TIRE_FR].pwm = normal-5; |
yabahiro | 48:5562a99479e5 | 4107 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4108 | motor[TIRE_FL].pwm = fast-5; |
yabahiro | 48:5562a99479e5 | 4109 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4110 | motor[TIRE_BR].pwm = fast-5; |
yabahiro | 48:5562a99479e5 | 4111 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4112 | motor[TIRE_BL].pwm = normal-5; |
yabahiro | 48:5562a99479e5 | 4113 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4114 | break; |
yabahiro | 48:5562a99479e5 | 4115 | } |
yabahiro | 48:5562a99479e5 | 4116 | if(g[2]==254&&countss>=100000) { |
yabahiro | 48:5562a99479e5 | 4117 | mode=24; |
yabahiro | 48:5562a99479e5 | 4118 | solenoid.solenoid4 = SOLENOID_OFF; |
yabahiro | 48:5562a99479e5 | 4119 | countss=0; |
yabahiro | 48:5562a99479e5 | 4120 | fast=60; |
yabahiro | 48:5562a99479e5 | 4121 | normal=40; |
yabahiro | 48:5562a99479e5 | 4122 | slow=20; |
yabahiro | 48:5562a99479e5 | 4123 | } |
yabahiro | 48:5562a99479e5 | 4124 | } else if(mode==24) { |
yabahiro | 48:5562a99479e5 | 4125 | motor[TIRE_FR].pwm = 60; |
yabahiro | 48:5562a99479e5 | 4126 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4127 | motor[TIRE_FL].pwm = 60; |
yabahiro | 48:5562a99479e5 | 4128 | motor[TIRE_FL].dir = BRAKE; |
yabahiro | 48:5562a99479e5 | 4129 | motor[TIRE_BR].pwm = 60; |
yabahiro | 48:5562a99479e5 | 4130 | motor[TIRE_BR].dir = BRAKE; |
yabahiro | 48:5562a99479e5 | 4131 | motor[TIRE_BL].pwm = 60; |
yabahiro | 48:5562a99479e5 | 4132 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4133 | if(g[0]==0) { |
yabahiro | 48:5562a99479e5 | 4134 | mode=25; |
yabahiro | 48:5562a99479e5 | 4135 | } |
yabahiro | 48:5562a99479e5 | 4136 | } else if(mode==25) { |
yabahiro | 48:5562a99479e5 | 4137 | motor[TIRE_FR].pwm = 100; |
yabahiro | 48:5562a99479e5 | 4138 | motor[TIRE_FR].dir = BRAKE; |
yabahiro | 48:5562a99479e5 | 4139 | motor[TIRE_FL].pwm = 100; |
yabahiro | 48:5562a99479e5 | 4140 | motor[TIRE_FL].dir = BRAKE; |
yabahiro | 48:5562a99479e5 | 4141 | motor[TIRE_BR].pwm = 100; |
yabahiro | 48:5562a99479e5 | 4142 | motor[TIRE_BR].dir = BRAKE; |
yabahiro | 48:5562a99479e5 | 4143 | motor[TIRE_BL].pwm = 100; |
yabahiro | 48:5562a99479e5 | 4144 | motor[TIRE_BL].dir = BRAKE; |
yabahiro | 48:5562a99479e5 | 4145 | if(DOLS==true||UPLS==true) { |
yabahiro | 48:5562a99479e5 | 4146 | motor[MOTOR_0].pwm = 200; |
yabahiro | 48:5562a99479e5 | 4147 | motor[MOTOR_0].dir = BRAKE; |
yabahiro | 48:5562a99479e5 | 4148 | mode=26; |
yabahiro | 48:5562a99479e5 | 4149 | countss=0; |
yabahiro | 48:5562a99479e5 | 4150 | } else { |
yabahiro | 48:5562a99479e5 | 4151 | motor[MOTOR_0].pwm = 100; |
yabahiro | 48:5562a99479e5 | 4152 | motor[MOTOR_0].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4153 | } |
yabahiro | 48:5562a99479e5 | 4154 | } else if(mode==26) { |
yabahiro | 48:5562a99479e5 | 4155 | if(g[0]==98&&countss>=40000) { |
yabahiro | 48:5562a99479e5 | 4156 | mode=31; |
yabahiro | 48:5562a99479e5 | 4157 | countss=0; |
yabahiro | 48:5562a99479e5 | 4158 | } |
yabahiro | 48:5562a99479e5 | 4159 | switch(g[0]) { |
yabahiro | 48:5562a99479e5 | 4160 | case 98: |
yabahiro | 48:5562a99479e5 | 4161 | fast=40; |
yabahiro | 48:5562a99479e5 | 4162 | normal=30; |
yabahiro | 48:5562a99479e5 | 4163 | slow=25; |
yabahiro | 48:5562a99479e5 | 4164 | motor[TIRE_FR].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4165 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4166 | motor[TIRE_FL].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4167 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4168 | motor[TIRE_BR].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4169 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4170 | motor[TIRE_BL].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4171 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4172 | break; |
yabahiro | 48:5562a99479e5 | 4173 | case 0: |
yabahiro | 48:5562a99479e5 | 4174 | motor[TIRE_FR].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4175 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4176 | motor[TIRE_FL].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4177 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4178 | motor[TIRE_BR].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4179 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4180 | motor[TIRE_BL].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4181 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4182 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4183 | break; |
yabahiro | 48:5562a99479e5 | 4184 | case 255: |
yabahiro | 48:5562a99479e5 | 4185 | motor[TIRE_FR].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4186 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4187 | motor[TIRE_FL].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4188 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4189 | motor[TIRE_BR].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4190 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4191 | motor[TIRE_BL].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4192 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4193 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4194 | break; |
yabahiro | 48:5562a99479e5 | 4195 | case 253: |
yabahiro | 48:5562a99479e5 | 4196 | motor[TIRE_FR].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4197 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4198 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4199 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4200 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4201 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4202 | motor[TIRE_BL].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4203 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4204 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4205 | break; |
yabahiro | 48:5562a99479e5 | 4206 | case 254: |
yabahiro | 48:5562a99479e5 | 4207 | motor[TIRE_FR].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4208 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4209 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4210 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4211 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4212 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4213 | motor[TIRE_BL].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4214 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4215 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4216 | break; |
yabahiro | 48:5562a99479e5 | 4217 | case 1: |
yabahiro | 48:5562a99479e5 | 4218 | motor[TIRE_FR].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4219 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4220 | motor[TIRE_FL].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4221 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4222 | motor[TIRE_BR].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4223 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4224 | motor[TIRE_BL].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4225 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4226 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4227 | break; |
yabahiro | 48:5562a99479e5 | 4228 | case 3: |
yabahiro | 48:5562a99479e5 | 4229 | motor[TIRE_FR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4230 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4231 | motor[TIRE_FL].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4232 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4233 | motor[TIRE_BR].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4234 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4235 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4236 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4237 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4238 | break; |
yabahiro | 48:5562a99479e5 | 4239 | case 2: |
yabahiro | 48:5562a99479e5 | 4240 | motor[TIRE_FR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4241 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4242 | motor[TIRE_FL].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4243 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4244 | motor[TIRE_BR].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4245 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4246 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4247 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4248 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4249 | break; |
yabahiro | 48:5562a99479e5 | 4250 | } |
yabahiro | 48:5562a99479e5 | 4251 | if(g[1]!=98&&mtc==true) { |
yabahiro | 48:5562a99479e5 | 4252 | switch(g[1]) { |
yabahiro | 48:5562a99479e5 | 4253 | case 0: |
yabahiro | 48:5562a99479e5 | 4254 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4255 | break; |
yabahiro | 48:5562a99479e5 | 4256 | case 255: |
yabahiro | 48:5562a99479e5 | 4257 | motor[TIRE_BR].pwm += 5; |
yabahiro | 48:5562a99479e5 | 4258 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4259 | break; |
yabahiro | 48:5562a99479e5 | 4260 | case 253: |
yabahiro | 48:5562a99479e5 | 4261 | motor[TIRE_BR].pwm += 10; |
yabahiro | 48:5562a99479e5 | 4262 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4263 | break; |
yabahiro | 48:5562a99479e5 | 4264 | case 254: |
yabahiro | 48:5562a99479e5 | 4265 | motor[TIRE_BR].pwm += 20; |
yabahiro | 48:5562a99479e5 | 4266 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4267 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4268 | break; |
yabahiro | 48:5562a99479e5 | 4269 | case 1: |
yabahiro | 48:5562a99479e5 | 4270 | motor[TIRE_BL].pwm += 5; |
yabahiro | 48:5562a99479e5 | 4271 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4272 | break; |
yabahiro | 48:5562a99479e5 | 4273 | case 3: |
yabahiro | 48:5562a99479e5 | 4274 | motor[TIRE_BL].pwm += 10; |
yabahiro | 48:5562a99479e5 | 4275 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4276 | break; |
yabahiro | 48:5562a99479e5 | 4277 | case 2: |
yabahiro | 48:5562a99479e5 | 4278 | motor[TIRE_BL].pwm += 20; |
yabahiro | 48:5562a99479e5 | 4279 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4280 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4281 | break; |
yabahiro | 48:5562a99479e5 | 4282 | } |
yabahiro | 48:5562a99479e5 | 4283 | } |
yabahiro | 48:5562a99479e5 | 4284 | } |
yabahiro | 48:5562a99479e5 | 4285 | } else { |
yabahiro | 48:5562a99479e5 | 4286 | if(mode==21) { |
yabahiro | 49:697b4e9ce884 | 4287 | if(g[0]==98&&countss>=40000) { |
yabahiro | 48:5562a99479e5 | 4288 | fast=60; |
yabahiro | 48:5562a99479e5 | 4289 | normal=30; |
yabahiro | 48:5562a99479e5 | 4290 | slow=25; |
yabahiro | 48:5562a99479e5 | 4291 | mode=31; |
yabahiro | 48:5562a99479e5 | 4292 | countss=0; |
yabahiro | 48:5562a99479e5 | 4293 | } |
yabahiro | 48:5562a99479e5 | 4294 | switch(g[0]) { |
yabahiro | 48:5562a99479e5 | 4295 | case 98: |
yabahiro | 48:5562a99479e5 | 4296 | fast=40; |
yabahiro | 48:5562a99479e5 | 4297 | normal=30; |
yabahiro | 48:5562a99479e5 | 4298 | slow=25; |
yabahiro | 48:5562a99479e5 | 4299 | motor[TIRE_FR].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4300 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4301 | motor[TIRE_FL].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4302 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4303 | motor[TIRE_BR].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4304 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4305 | motor[TIRE_BL].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4306 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4307 | break; |
yabahiro | 48:5562a99479e5 | 4308 | case 0: |
yabahiro | 48:5562a99479e5 | 4309 | motor[TIRE_FR].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4310 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4311 | motor[TIRE_FL].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4312 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4313 | motor[TIRE_BR].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4314 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4315 | motor[TIRE_BL].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4316 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4317 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4318 | break; |
yabahiro | 48:5562a99479e5 | 4319 | case 255: |
yabahiro | 48:5562a99479e5 | 4320 | motor[TIRE_FR].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4321 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4322 | motor[TIRE_FL].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4323 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4324 | motor[TIRE_BR].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4325 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4326 | motor[TIRE_BL].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4327 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4328 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4329 | break; |
yabahiro | 48:5562a99479e5 | 4330 | case 253: |
yabahiro | 48:5562a99479e5 | 4331 | motor[TIRE_FR].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4332 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4333 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4334 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4335 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4336 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4337 | motor[TIRE_BL].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4338 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4339 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4340 | break; |
yabahiro | 48:5562a99479e5 | 4341 | case 254: |
yabahiro | 48:5562a99479e5 | 4342 | motor[TIRE_FR].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4343 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4344 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4345 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4346 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4347 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4348 | motor[TIRE_BL].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4349 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4350 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4351 | break; |
yabahiro | 48:5562a99479e5 | 4352 | case 1: |
yabahiro | 48:5562a99479e5 | 4353 | motor[TIRE_FR].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4354 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4355 | motor[TIRE_FL].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4356 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4357 | motor[TIRE_BR].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4358 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4359 | motor[TIRE_BL].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4360 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4361 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4362 | break; |
yabahiro | 48:5562a99479e5 | 4363 | case 3: |
yabahiro | 48:5562a99479e5 | 4364 | motor[TIRE_FR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4365 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4366 | motor[TIRE_FL].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4367 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4368 | motor[TIRE_BR].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4369 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4370 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4371 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4372 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4373 | break; |
yabahiro | 48:5562a99479e5 | 4374 | case 2: |
yabahiro | 48:5562a99479e5 | 4375 | motor[TIRE_FR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4376 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4377 | motor[TIRE_FL].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4378 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4379 | motor[TIRE_BR].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4380 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4381 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4382 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4383 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4384 | break; |
yabahiro | 48:5562a99479e5 | 4385 | } |
yabahiro | 48:5562a99479e5 | 4386 | if(g[1]!=98&&mtc==true) { |
yabahiro | 48:5562a99479e5 | 4387 | switch(g[1]) { |
yabahiro | 48:5562a99479e5 | 4388 | case 0: |
yabahiro | 48:5562a99479e5 | 4389 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4390 | break; |
yabahiro | 48:5562a99479e5 | 4391 | case 255: |
yabahiro | 48:5562a99479e5 | 4392 | motor[TIRE_BR].pwm += 5; |
yabahiro | 48:5562a99479e5 | 4393 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4394 | break; |
yabahiro | 48:5562a99479e5 | 4395 | case 253: |
yabahiro | 48:5562a99479e5 | 4396 | motor[TIRE_BR].pwm += 10; |
yabahiro | 48:5562a99479e5 | 4397 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4398 | break; |
yabahiro | 48:5562a99479e5 | 4399 | case 254: |
yabahiro | 48:5562a99479e5 | 4400 | motor[TIRE_BR].pwm += 20; |
yabahiro | 48:5562a99479e5 | 4401 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4402 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4403 | break; |
yabahiro | 48:5562a99479e5 | 4404 | case 1: |
yabahiro | 48:5562a99479e5 | 4405 | motor[TIRE_BL].pwm += 5; |
yabahiro | 48:5562a99479e5 | 4406 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4407 | break; |
yabahiro | 48:5562a99479e5 | 4408 | case 3: |
yabahiro | 48:5562a99479e5 | 4409 | motor[TIRE_BL].pwm += 10; |
yabahiro | 48:5562a99479e5 | 4410 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4411 | break; |
yabahiro | 48:5562a99479e5 | 4412 | case 2: |
yabahiro | 48:5562a99479e5 | 4413 | motor[TIRE_BL].pwm += 20; |
yabahiro | 48:5562a99479e5 | 4414 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4415 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4416 | break; |
yabahiro | 48:5562a99479e5 | 4417 | } |
yabahiro | 48:5562a99479e5 | 4418 | } |
yabahiro | 48:5562a99479e5 | 4419 | } |
yabahiro | 48:5562a99479e5 | 4420 | } |
yabahiro | 48:5562a99479e5 | 4421 | |
yabahiro | 48:5562a99479e5 | 4422 | /* |
yabahiro | 48:5562a99479e5 | 4423 | if(mode==31) { |
yabahiro | 48:5562a99479e5 | 4424 | motor[TIRE_FR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4425 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4426 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4427 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4428 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4429 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4430 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4431 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4432 | if(countss>=5000) { |
yabahiro | 48:5562a99479e5 | 4433 | countss=0; |
yabahiro | 48:5562a99479e5 | 4434 | mode=33; |
yabahiro | 48:5562a99479e5 | 4435 | } |
yabahiro | 48:5562a99479e5 | 4436 | } else if(mode==33) { |
yabahiro | 48:5562a99479e5 | 4437 | motor[TIRE_FR].pwm = 30; |
yabahiro | 48:5562a99479e5 | 4438 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4439 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4440 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4441 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4442 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4443 | motor[TIRE_BL].pwm = 30; |
yabahiro | 48:5562a99479e5 | 4444 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4445 | if(g[3]==0) { |
yabahiro | 48:5562a99479e5 | 4446 | cross=0; |
yabahiro | 48:5562a99479e5 | 4447 | countss=0; |
yabahiro | 48:5562a99479e5 | 4448 | mode=40; |
yabahiro | 48:5562a99479e5 | 4449 | } |
yabahiro | 48:5562a99479e5 | 4450 | } else |
yabahiro | 48:5562a99479e5 | 4451 | */ |
yabahiro | 48:5562a99479e5 | 4452 | if(mode==31) { |
yabahiro | 48:5562a99479e5 | 4453 | motor[TIRE_FR].pwm = 45; |
yabahiro | 48:5562a99479e5 | 4454 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4455 | motor[TIRE_FL].pwm = 255; |
yabahiro | 48:5562a99479e5 | 4456 | motor[TIRE_FL].dir = BRAKE; |
yabahiro | 48:5562a99479e5 | 4457 | motor[TIRE_BR].pwm = 255; |
yabahiro | 48:5562a99479e5 | 4458 | motor[TIRE_BR].dir = BRAKE; |
yabahiro | 48:5562a99479e5 | 4459 | motor[TIRE_BL].pwm = 45; |
yabahiro | 48:5562a99479e5 | 4460 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4461 | if(g[3]==0) { |
yabahiro | 48:5562a99479e5 | 4462 | cross=0; |
yabahiro | 48:5562a99479e5 | 4463 | countss=0; |
yabahiro | 48:5562a99479e5 | 4464 | mode=40; |
yabahiro | 48:5562a99479e5 | 4465 | } |
yabahiro | 48:5562a99479e5 | 4466 | } else if(mode==40) { |
yabahiro | 48:5562a99479e5 | 4467 | switch(g[3]) { |
yabahiro | 48:5562a99479e5 | 4468 | case 98: |
yabahiro | 48:5562a99479e5 | 4469 | motor[TIRE_FR].pwm = normal+15; |
yabahiro | 48:5562a99479e5 | 4470 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4471 | motor[TIRE_FL].pwm = normal+15; |
yabahiro | 48:5562a99479e5 | 4472 | motor[TIRE_FL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4473 | motor[TIRE_BR].pwm = normal+15; |
yabahiro | 48:5562a99479e5 | 4474 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4475 | motor[TIRE_BL].pwm = normal+15; |
yabahiro | 48:5562a99479e5 | 4476 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4477 | if(countss>10000) { |
yabahiro | 48:5562a99479e5 | 4478 | cross++; |
yabahiro | 48:5562a99479e5 | 4479 | countss=0; |
yabahiro | 48:5562a99479e5 | 4480 | } |
yabahiro | 48:5562a99479e5 | 4481 | mtc2=true; |
yabahiro | 48:5562a99479e5 | 4482 | if(cross==1) { |
yabahiro | 48:5562a99479e5 | 4483 | mode=41; |
yabahiro | 48:5562a99479e5 | 4484 | countss=0; |
yabahiro | 48:5562a99479e5 | 4485 | cross=0; |
yabahiro | 48:5562a99479e5 | 4486 | } |
yabahiro | 48:5562a99479e5 | 4487 | break; |
yabahiro | 48:5562a99479e5 | 4488 | case 0: |
yabahiro | 48:5562a99479e5 | 4489 | motor[TIRE_FR].pwm = fast+15; |
yabahiro | 48:5562a99479e5 | 4490 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4491 | motor[TIRE_FL].pwm = fast+15; |
yabahiro | 48:5562a99479e5 | 4492 | motor[TIRE_FL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4493 | motor[TIRE_BR].pwm = fast+15; |
yabahiro | 48:5562a99479e5 | 4494 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4495 | motor[TIRE_BL].pwm = fast+15; |
yabahiro | 48:5562a99479e5 | 4496 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4497 | mtc2=true; |
yabahiro | 48:5562a99479e5 | 4498 | break; |
yabahiro | 48:5562a99479e5 | 4499 | case 255: |
yabahiro | 48:5562a99479e5 | 4500 | motor[TIRE_FR].pwm = slow+15; |
yabahiro | 48:5562a99479e5 | 4501 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4502 | motor[TIRE_FL].pwm = fast+15; |
yabahiro | 48:5562a99479e5 | 4503 | motor[TIRE_FL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4504 | motor[TIRE_BR].pwm = fast+15; |
yabahiro | 48:5562a99479e5 | 4505 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4506 | motor[TIRE_BL].pwm = slow+15; |
yabahiro | 48:5562a99479e5 | 4507 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4508 | mtc2=true; |
yabahiro | 48:5562a99479e5 | 4509 | break; |
yabahiro | 48:5562a99479e5 | 4510 | case 253: |
yabahiro | 48:5562a99479e5 | 4511 | motor[TIRE_FR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4512 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4513 | motor[TIRE_FL].pwm = slow+15; |
yabahiro | 48:5562a99479e5 | 4514 | motor[TIRE_FL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4515 | motor[TIRE_BR].pwm = slow+15; |
yabahiro | 48:5562a99479e5 | 4516 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4517 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4518 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4519 | mtc2=true; |
yabahiro | 48:5562a99479e5 | 4520 | break; |
yabahiro | 48:5562a99479e5 | 4521 | case 254: |
yabahiro | 48:5562a99479e5 | 4522 | motor[TIRE_FR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4523 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4524 | motor[TIRE_FL].pwm = normal+15; |
yabahiro | 48:5562a99479e5 | 4525 | motor[TIRE_FL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4526 | motor[TIRE_BR].pwm = normal+15; |
yabahiro | 48:5562a99479e5 | 4527 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4528 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4529 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4530 | mtc2=true; |
yabahiro | 48:5562a99479e5 | 4531 | break; |
yabahiro | 48:5562a99479e5 | 4532 | case 1: |
yabahiro | 48:5562a99479e5 | 4533 | motor[TIRE_FR].pwm = fast+15; |
yabahiro | 48:5562a99479e5 | 4534 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4535 | motor[TIRE_FL].pwm = slow+15; |
yabahiro | 48:5562a99479e5 | 4536 | motor[TIRE_FL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4537 | motor[TIRE_BR].pwm = slow+15; |
yabahiro | 48:5562a99479e5 | 4538 | motor[TIRE_BR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4539 | motor[TIRE_BL].pwm = fast+15; |
yabahiro | 48:5562a99479e5 | 4540 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4541 | mtc2=true; |
yabahiro | 48:5562a99479e5 | 4542 | break; |
yabahiro | 48:5562a99479e5 | 4543 | case 3: |
yabahiro | 48:5562a99479e5 | 4544 | motor[TIRE_FR].pwm = slow+15; |
yabahiro | 48:5562a99479e5 | 4545 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4546 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4547 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4548 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4549 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4550 | motor[TIRE_BL].pwm = slow+15; |
yabahiro | 48:5562a99479e5 | 4551 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4552 | mtc2=true; |
yabahiro | 48:5562a99479e5 | 4553 | break; |
yabahiro | 48:5562a99479e5 | 4554 | case 2: |
yabahiro | 48:5562a99479e5 | 4555 | motor[TIRE_FR].pwm = normal+15; |
yabahiro | 48:5562a99479e5 | 4556 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4557 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4558 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4559 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4560 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4561 | motor[TIRE_BL].pwm = normal+15; |
yabahiro | 48:5562a99479e5 | 4562 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4563 | mtc2=true; |
yabahiro | 48:5562a99479e5 | 4564 | break; |
yabahiro | 48:5562a99479e5 | 4565 | } |
yabahiro | 48:5562a99479e5 | 4566 | if(g[2]!=98&&mtc2==true) { |
yabahiro | 48:5562a99479e5 | 4567 | switch(g[2]) { |
yabahiro | 48:5562a99479e5 | 4568 | case 0: |
yabahiro | 48:5562a99479e5 | 4569 | mtc2=false; |
yabahiro | 48:5562a99479e5 | 4570 | break; |
yabahiro | 48:5562a99479e5 | 4571 | case 255: |
yabahiro | 48:5562a99479e5 | 4572 | motor[TIRE_FL].pwm += 5; |
yabahiro | 48:5562a99479e5 | 4573 | mtc2=false; |
yabahiro | 48:5562a99479e5 | 4574 | break; |
yabahiro | 48:5562a99479e5 | 4575 | case 253: |
yabahiro | 48:5562a99479e5 | 4576 | motor[TIRE_FL].pwm += 10; |
yabahiro | 48:5562a99479e5 | 4577 | mtc2=false; |
yabahiro | 48:5562a99479e5 | 4578 | break; |
yabahiro | 48:5562a99479e5 | 4579 | case 254: |
yabahiro | 48:5562a99479e5 | 4580 | motor[TIRE_FL].pwm += 20; |
yabahiro | 48:5562a99479e5 | 4581 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4582 | mtc2=false; |
yabahiro | 48:5562a99479e5 | 4583 | break; |
yabahiro | 48:5562a99479e5 | 4584 | case 1: |
yabahiro | 48:5562a99479e5 | 4585 | motor[TIRE_BL].pwm += 5; |
yabahiro | 48:5562a99479e5 | 4586 | mtc2=false; |
yabahiro | 48:5562a99479e5 | 4587 | break; |
yabahiro | 48:5562a99479e5 | 4588 | case 3: |
yabahiro | 48:5562a99479e5 | 4589 | motor[TIRE_BL].pwm += 10; |
yabahiro | 48:5562a99479e5 | 4590 | mtc2=false; |
yabahiro | 48:5562a99479e5 | 4591 | break; |
yabahiro | 48:5562a99479e5 | 4592 | case 2: |
yabahiro | 48:5562a99479e5 | 4593 | motor[TIRE_BL].pwm += 20; |
yabahiro | 48:5562a99479e5 | 4594 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4595 | mtc2=false; |
yabahiro | 48:5562a99479e5 | 4596 | break; |
yabahiro | 48:5562a99479e5 | 4597 | } |
yabahiro | 48:5562a99479e5 | 4598 | } |
yabahiro | 48:5562a99479e5 | 4599 | } else if(mode==41) { |
yabahiro | 48:5562a99479e5 | 4600 | if(LIF||LIB) { |
yabahiro | 48:5562a99479e5 | 4601 | mode=42; |
yabahiro | 48:5562a99479e5 | 4602 | } |
yabahiro | 48:5562a99479e5 | 4603 | motor[TIRE_FR].pwm = 30; |
yabahiro | 48:5562a99479e5 | 4604 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4605 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4606 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4607 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4608 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4609 | motor[TIRE_BL].pwm = 30; |
yabahiro | 48:5562a99479e5 | 4610 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4611 | if(g[1]==0) { |
yabahiro | 48:5562a99479e5 | 4612 | countss=0; |
yabahiro | 48:5562a99479e5 | 4613 | mode=70; |
yabahiro | 48:5562a99479e5 | 4614 | normal=60; |
yabahiro | 48:5562a99479e5 | 4615 | fast=70; |
yabahiro | 48:5562a99479e5 | 4616 | slow=40; |
yabahiro | 48:5562a99479e5 | 4617 | } |
yabahiro | 48:5562a99479e5 | 4618 | } else if(mode==42) { |
yabahiro | 48:5562a99479e5 | 4619 | motor[TIRE_FR].pwm = 40; |
yabahiro | 48:5562a99479e5 | 4620 | motor[TIRE_FR].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4621 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4622 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4623 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4624 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4625 | motor[TIRE_BL].pwm = 40; |
yabahiro | 48:5562a99479e5 | 4626 | motor[TIRE_BL].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4627 | if(g[1]==0) { |
yabahiro | 48:5562a99479e5 | 4628 | countss=0; |
yabahiro | 48:5562a99479e5 | 4629 | mode=70; |
yabahiro | 48:5562a99479e5 | 4630 | } |
yabahiro | 48:5562a99479e5 | 4631 | } else if(mode==70) { |
yabahiro | 48:5562a99479e5 | 4632 | switch(g[0]) { |
yabahiro | 48:5562a99479e5 | 4633 | case 99: |
yabahiro | 48:5562a99479e5 | 4634 | if(countss>=100000) { |
yabahiro | 48:5562a99479e5 | 4635 | mode=100; |
yabahiro | 48:5562a99479e5 | 4636 | } |
yabahiro | 48:5562a99479e5 | 4637 | break; |
yabahiro | 48:5562a99479e5 | 4638 | case 98: |
yabahiro | 48:5562a99479e5 | 4639 | motor[TIRE_FR].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4640 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4641 | motor[TIRE_FL].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4642 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4643 | motor[TIRE_BR].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4644 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4645 | motor[TIRE_BL].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4646 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4647 | break; |
yabahiro | 48:5562a99479e5 | 4648 | case 0: |
yabahiro | 48:5562a99479e5 | 4649 | motor[TIRE_FR].pwm = 80; |
yabahiro | 48:5562a99479e5 | 4650 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4651 | motor[TIRE_FL].pwm = 80; |
yabahiro | 48:5562a99479e5 | 4652 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4653 | motor[TIRE_BR].pwm = 80; |
yabahiro | 48:5562a99479e5 | 4654 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4655 | motor[TIRE_BL].pwm = 80; |
yabahiro | 48:5562a99479e5 | 4656 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4657 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4658 | break; |
yabahiro | 48:5562a99479e5 | 4659 | case 255: |
yabahiro | 48:5562a99479e5 | 4660 | motor[TIRE_FR].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4661 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4662 | motor[TIRE_FL].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4663 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4664 | motor[TIRE_BR].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4665 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4666 | motor[TIRE_BL].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4667 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4668 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4669 | break; |
yabahiro | 48:5562a99479e5 | 4670 | case 253: |
yabahiro | 48:5562a99479e5 | 4671 | motor[TIRE_FR].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4672 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4673 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4674 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4675 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4676 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4677 | motor[TIRE_BL].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4678 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4679 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4680 | break; |
yabahiro | 48:5562a99479e5 | 4681 | case 254: |
yabahiro | 48:5562a99479e5 | 4682 | motor[TIRE_FR].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4683 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4684 | motor[TIRE_FL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4685 | motor[TIRE_FL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4686 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4687 | motor[TIRE_BR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4688 | motor[TIRE_BL].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4689 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4690 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4691 | break; |
yabahiro | 48:5562a99479e5 | 4692 | case 1: |
yabahiro | 48:5562a99479e5 | 4693 | motor[TIRE_FR].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4694 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4695 | motor[TIRE_FL].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4696 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4697 | motor[TIRE_BR].pwm = fast; |
yabahiro | 48:5562a99479e5 | 4698 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4699 | motor[TIRE_BL].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4700 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4701 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4702 | break; |
yabahiro | 48:5562a99479e5 | 4703 | case 3: |
yabahiro | 48:5562a99479e5 | 4704 | motor[TIRE_FR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4705 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4706 | motor[TIRE_FL].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4707 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4708 | motor[TIRE_BR].pwm = slow; |
yabahiro | 48:5562a99479e5 | 4709 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4710 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4711 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4712 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4713 | break; |
yabahiro | 48:5562a99479e5 | 4714 | case 2: |
yabahiro | 48:5562a99479e5 | 4715 | motor[TIRE_FR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4716 | motor[TIRE_FR].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4717 | motor[TIRE_FL].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4718 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4719 | motor[TIRE_BR].pwm = normal; |
yabahiro | 48:5562a99479e5 | 4720 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4721 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4722 | motor[TIRE_BL].dir = FREE; |
yabahiro | 48:5562a99479e5 | 4723 | mtc=true; |
yabahiro | 48:5562a99479e5 | 4724 | break; |
yabahiro | 48:5562a99479e5 | 4725 | } |
yabahiro | 48:5562a99479e5 | 4726 | if(g[1]!=98&&mtc==true) { |
yabahiro | 48:5562a99479e5 | 4727 | switch(g[1]) { |
yabahiro | 48:5562a99479e5 | 4728 | case 0: |
yabahiro | 48:5562a99479e5 | 4729 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4730 | break; |
yabahiro | 48:5562a99479e5 | 4731 | case 255: |
yabahiro | 48:5562a99479e5 | 4732 | motor[TIRE_BR].pwm += 5; |
yabahiro | 48:5562a99479e5 | 4733 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4734 | break; |
yabahiro | 48:5562a99479e5 | 4735 | case 253: |
yabahiro | 48:5562a99479e5 | 4736 | motor[TIRE_BR].pwm += 10; |
yabahiro | 48:5562a99479e5 | 4737 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4738 | break; |
yabahiro | 48:5562a99479e5 | 4739 | case 254: |
yabahiro | 48:5562a99479e5 | 4740 | motor[TIRE_BR].pwm += 20; |
yabahiro | 48:5562a99479e5 | 4741 | motor[TIRE_BL].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4742 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4743 | break; |
yabahiro | 48:5562a99479e5 | 4744 | case 1: |
yabahiro | 48:5562a99479e5 | 4745 | motor[TIRE_BL].pwm += 5; |
yabahiro | 48:5562a99479e5 | 4746 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4747 | break; |
yabahiro | 48:5562a99479e5 | 4748 | case 3: |
yabahiro | 48:5562a99479e5 | 4749 | motor[TIRE_BL].pwm += 10; |
yabahiro | 48:5562a99479e5 | 4750 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4751 | break; |
yabahiro | 48:5562a99479e5 | 4752 | case 2: |
yabahiro | 48:5562a99479e5 | 4753 | motor[TIRE_BL].pwm += 20; |
yabahiro | 48:5562a99479e5 | 4754 | motor[TIRE_BR].pwm = 0; |
yabahiro | 48:5562a99479e5 | 4755 | mtc=false; |
yabahiro | 48:5562a99479e5 | 4756 | break; |
yabahiro | 48:5562a99479e5 | 4757 | } |
yabahiro | 48:5562a99479e5 | 4758 | } |
yabahiro | 48:5562a99479e5 | 4759 | } else if(mode==100) { |
yabahiro | 48:5562a99479e5 | 4760 | motor[TIRE_FR].pwm = 50; |
yabahiro | 48:5562a99479e5 | 4761 | motor[TIRE_FR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4762 | motor[TIRE_FL].pwm = 50; |
yabahiro | 48:5562a99479e5 | 4763 | motor[TIRE_FL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4764 | motor[TIRE_BR].pwm = 50; |
yabahiro | 48:5562a99479e5 | 4765 | motor[TIRE_BR].dir = BACK; |
yabahiro | 48:5562a99479e5 | 4766 | motor[TIRE_BL].pwm = 50; |
yabahiro | 48:5562a99479e5 | 4767 | motor[TIRE_BL].dir = FOR; |
yabahiro | 48:5562a99479e5 | 4768 | } else { |
yabahiro | 48:5562a99479e5 | 4769 | } |
yabahiro | 33:dd598bb23ad1 | 4770 | |
kishibekairohan | 13:b6e02d6261d7 | 4771 | } |
kishibekairohan | 13:b6e02d6261d7 | 4772 | #endif |
kishibekairohan | 13:b6e02d6261d7 | 4773 | |
kishibekairohan | 13:b6e02d6261d7 | 4774 | #if USE_PROCESS_NUM>5 |
Ryosei | 27:dd9f27fce7d1 | 4775 | static void Process5() |
Ryosei | 27:dd9f27fce7d1 | 4776 | { |
yabahiro | 56:61ebd4b759b4 | 4777 | countss++; |
yabahiro | 56:61ebd4b759b4 | 4778 | switch(mode) { |
yabahiro | 56:61ebd4b759b4 | 4779 | case 1: |
yabahiro | 56:61ebd4b759b4 | 4780 | mode=2; |
yabahiro | 56:61ebd4b759b4 | 4781 | countss=0; |
yabahiro | 56:61ebd4b759b4 | 4782 | fast = 60; |
yabahiro | 56:61ebd4b759b4 | 4783 | normal = 40; |
yabahiro | 56:61ebd4b759b4 | 4784 | slow = 30; |
yabahiro | 56:61ebd4b759b4 | 4785 | break; |
yabahiro | 56:61ebd4b759b4 | 4786 | case 2: |
yabahiro | 56:61ebd4b759b4 | 4787 | if(YELLOW) { |
yabahiro | 56:61ebd4b759b4 | 4788 | switch(g[4]) { |
yabahiro | 56:61ebd4b759b4 | 4789 | case 98: |
yabahiro | 56:61ebd4b759b4 | 4790 | motor[TIRE_FR].pwm = fast-5; |
yabahiro | 56:61ebd4b759b4 | 4791 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4792 | motor[TIRE_FL].pwm = fast-5; |
yabahiro | 56:61ebd4b759b4 | 4793 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4794 | motor[TIRE_BR].pwm = fast-5; |
yabahiro | 56:61ebd4b759b4 | 4795 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4796 | motor[TIRE_BL].pwm = fast-5; |
yabahiro | 56:61ebd4b759b4 | 4797 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4798 | break; |
yabahiro | 56:61ebd4b759b4 | 4799 | case 99: |
yabahiro | 56:61ebd4b759b4 | 4800 | motor[TIRE_FR].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 4801 | motor[TIRE_FR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4802 | motor[TIRE_FL].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 4803 | motor[TIRE_FL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4804 | motor[TIRE_BR].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 4805 | motor[TIRE_BR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4806 | motor[TIRE_BL].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 4807 | motor[TIRE_BL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4808 | break; |
yabahiro | 56:61ebd4b759b4 | 4809 | case 0: |
yabahiro | 56:61ebd4b759b4 | 4810 | motor[TIRE_FR].pwm = fast-5; |
yabahiro | 56:61ebd4b759b4 | 4811 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4812 | motor[TIRE_FL].pwm = fast-5; |
yabahiro | 56:61ebd4b759b4 | 4813 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4814 | motor[TIRE_BR].pwm = fast-5; |
yabahiro | 56:61ebd4b759b4 | 4815 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4816 | motor[TIRE_BL].pwm = fast-5; |
yabahiro | 56:61ebd4b759b4 | 4817 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4818 | break; |
yabahiro | 56:61ebd4b759b4 | 4819 | case 255: |
yabahiro | 56:61ebd4b759b4 | 4820 | motor[TIRE_FR].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 4821 | motor[TIRE_FR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4822 | motor[TIRE_FL].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 4823 | motor[TIRE_FL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4824 | motor[TIRE_BR].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 4825 | motor[TIRE_BR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4826 | motor[TIRE_BL].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 4827 | motor[TIRE_BL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4828 | break; |
yabahiro | 56:61ebd4b759b4 | 4829 | case 253: |
yabahiro | 56:61ebd4b759b4 | 4830 | motor[TIRE_FR].pwm = slow+5; |
yabahiro | 56:61ebd4b759b4 | 4831 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4832 | motor[TIRE_FL].pwm = fast-5; |
yabahiro | 56:61ebd4b759b4 | 4833 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4834 | motor[TIRE_BR].pwm = fast-5; |
yabahiro | 56:61ebd4b759b4 | 4835 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4836 | motor[TIRE_BL].pwm = slow+5; |
yabahiro | 56:61ebd4b759b4 | 4837 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4838 | break; |
yabahiro | 56:61ebd4b759b4 | 4839 | case 254: |
yabahiro | 56:61ebd4b759b4 | 4840 | motor[TIRE_FR].pwm = normal+5; |
yabahiro | 56:61ebd4b759b4 | 4841 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4842 | motor[TIRE_FL].pwm = fast-5; |
yabahiro | 56:61ebd4b759b4 | 4843 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4844 | motor[TIRE_BR].pwm = fast-5; |
yabahiro | 56:61ebd4b759b4 | 4845 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4846 | motor[TIRE_BL].pwm = normal+5; |
yabahiro | 56:61ebd4b759b4 | 4847 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4848 | break; |
yabahiro | 56:61ebd4b759b4 | 4849 | case 1: |
yabahiro | 56:61ebd4b759b4 | 4850 | motor[TIRE_FR].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 4851 | motor[TIRE_FR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4852 | motor[TIRE_FL].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 4853 | motor[TIRE_FL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4854 | motor[TIRE_BR].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 4855 | motor[TIRE_BR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4856 | motor[TIRE_BL].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 4857 | motor[TIRE_BL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4858 | break; |
yabahiro | 56:61ebd4b759b4 | 4859 | case 3: |
yabahiro | 56:61ebd4b759b4 | 4860 | motor[TIRE_FR].pwm = fast-5; |
yabahiro | 56:61ebd4b759b4 | 4861 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4862 | motor[TIRE_FL].pwm = slow+5; |
yabahiro | 56:61ebd4b759b4 | 4863 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4864 | motor[TIRE_BR].pwm = slow+5; |
yabahiro | 56:61ebd4b759b4 | 4865 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4866 | motor[TIRE_BL].pwm = fast-5; |
yabahiro | 56:61ebd4b759b4 | 4867 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4868 | break; |
yabahiro | 56:61ebd4b759b4 | 4869 | case 2: |
yabahiro | 56:61ebd4b759b4 | 4870 | motor[TIRE_FR].pwm = fast-5; |
yabahiro | 56:61ebd4b759b4 | 4871 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4872 | motor[TIRE_FL].pwm = normal+5; |
yabahiro | 56:61ebd4b759b4 | 4873 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4874 | motor[TIRE_BR].pwm = normal+5; |
yabahiro | 56:61ebd4b759b4 | 4875 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4876 | motor[TIRE_BL].pwm = fast-5; |
yabahiro | 56:61ebd4b759b4 | 4877 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4878 | break; |
yabahiro | 56:61ebd4b759b4 | 4879 | } |
yabahiro | 56:61ebd4b759b4 | 4880 | if(g[1]==98||g[1]==0||g[1]==1||g[1]==2||g[1]==3||g[1]==254||g[1]==253||g[1]==255) { |
yabahiro | 56:61ebd4b759b4 | 4881 | fast=10; |
yabahiro | 56:61ebd4b759b4 | 4882 | normal=10; |
yabahiro | 56:61ebd4b759b4 | 4883 | slow=10; |
yabahiro | 56:61ebd4b759b4 | 4884 | } |
yabahiro | 56:61ebd4b759b4 | 4885 | if(g[3]==254&&countss>=100000) { |
yabahiro | 56:61ebd4b759b4 | 4886 | mode=3; |
yabahiro | 56:61ebd4b759b4 | 4887 | solenoid.solenoid4 = SOLENOID_OFF; |
yabahiro | 56:61ebd4b759b4 | 4888 | aime.start(); |
yabahiro | 56:61ebd4b759b4 | 4889 | aime.reset(); |
yabahiro | 56:61ebd4b759b4 | 4890 | countss=0; |
yabahiro | 56:61ebd4b759b4 | 4891 | fast=80; |
yabahiro | 56:61ebd4b759b4 | 4892 | normal=60; |
yabahiro | 56:61ebd4b759b4 | 4893 | slow=30; |
yabahiro | 56:61ebd4b759b4 | 4894 | } |
yabahiro | 56:61ebd4b759b4 | 4895 | } else { |
yabahiro | 56:61ebd4b759b4 | 4896 | if(UPLS||DOLS) { |
yabahiro | 56:61ebd4b759b4 | 4897 | if(UPLS||DOLS) { |
yabahiro | 56:61ebd4b759b4 | 4898 | motor[MOTOR_0].pwm = 200; |
yabahiro | 56:61ebd4b759b4 | 4899 | motor[MOTOR_0].dir = BRAKE; |
yabahiro | 56:61ebd4b759b4 | 4900 | fast=60; |
yabahiro | 56:61ebd4b759b4 | 4901 | normal=40; |
yabahiro | 56:61ebd4b759b4 | 4902 | slow=30; |
yabahiro | 56:61ebd4b759b4 | 4903 | countss=0; |
yabahiro | 56:61ebd4b759b4 | 4904 | mode=24; |
yabahiro | 56:61ebd4b759b4 | 4905 | } |
yabahiro | 56:61ebd4b759b4 | 4906 | } else { |
yabahiro | 56:61ebd4b759b4 | 4907 | motor[MOTOR_0].pwm = 100; |
yabahiro | 56:61ebd4b759b4 | 4908 | motor[MOTOR_0].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4909 | } |
yabahiro | 56:61ebd4b759b4 | 4910 | motor[TIRE_FR].pwm = 100; |
yabahiro | 56:61ebd4b759b4 | 4911 | motor[TIRE_FR].dir = BRAKE; |
yabahiro | 56:61ebd4b759b4 | 4912 | motor[TIRE_FL].pwm = 100; |
yabahiro | 56:61ebd4b759b4 | 4913 | motor[TIRE_FL].dir = BRAKE; |
yabahiro | 56:61ebd4b759b4 | 4914 | motor[TIRE_BR].pwm = 100; |
yabahiro | 56:61ebd4b759b4 | 4915 | motor[TIRE_BR].dir = BRAKE; |
yabahiro | 56:61ebd4b759b4 | 4916 | motor[TIRE_BL].pwm = 100; |
yabahiro | 56:61ebd4b759b4 | 4917 | motor[TIRE_BL].dir = BRAKE; |
yabahiro | 56:61ebd4b759b4 | 4918 | } |
yabahiro | 56:61ebd4b759b4 | 4919 | break; |
yabahiro | 56:61ebd4b759b4 | 4920 | case 3: |
yabahiro | 56:61ebd4b759b4 | 4921 | if(YELLOW) { |
yabahiro | 56:61ebd4b759b4 | 4922 | value=aime.read_ms(); |
yabahiro | 56:61ebd4b759b4 | 4923 | if(value>=5000) { |
yabahiro | 56:61ebd4b759b4 | 4924 | mode=4; |
yabahiro | 56:61ebd4b759b4 | 4925 | } |
yabahiro | 56:61ebd4b759b4 | 4926 | if(g[4]==3||g[4]==2) { |
yabahiro | 56:61ebd4b759b4 | 4927 | motor[TIRE_FR].pwm = 20; |
yabahiro | 56:61ebd4b759b4 | 4928 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4929 | motor[TIRE_FL].pwm = 30; |
yabahiro | 56:61ebd4b759b4 | 4930 | motor[TIRE_FL].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4931 | motor[TIRE_BR].pwm = 30; |
yabahiro | 56:61ebd4b759b4 | 4932 | motor[TIRE_BR].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4933 | motor[TIRE_BL].pwm = 20; |
yabahiro | 56:61ebd4b759b4 | 4934 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4935 | } |
yabahiro | 56:61ebd4b759b4 | 4936 | if(g[4]==253||g[4]==254) { |
yabahiro | 56:61ebd4b759b4 | 4937 | motor[TIRE_FR].pwm = 30; |
yabahiro | 56:61ebd4b759b4 | 4938 | motor[TIRE_FR].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4939 | motor[TIRE_FL].pwm = 20; |
yabahiro | 56:61ebd4b759b4 | 4940 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4941 | motor[TIRE_BR].pwm = 20; |
yabahiro | 56:61ebd4b759b4 | 4942 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4943 | motor[TIRE_BL].pwm = 30; |
yabahiro | 56:61ebd4b759b4 | 4944 | motor[TIRE_BL].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4945 | } |
yabahiro | 56:61ebd4b759b4 | 4946 | switch(g[2]) { |
yabahiro | 56:61ebd4b759b4 | 4947 | case 0: |
yabahiro | 56:61ebd4b759b4 | 4948 | motor[TIRE_FR].pwm = 25; |
yabahiro | 56:61ebd4b759b4 | 4949 | motor[TIRE_FR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4950 | motor[TIRE_BR].pwm = 25; |
yabahiro | 56:61ebd4b759b4 | 4951 | motor[TIRE_BR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4952 | break; |
yabahiro | 56:61ebd4b759b4 | 4953 | case 255: |
yabahiro | 56:61ebd4b759b4 | 4954 | motor[TIRE_FR].pwm = 30; |
yabahiro | 56:61ebd4b759b4 | 4955 | motor[TIRE_FR].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4956 | motor[TIRE_BR].pwm = 25; |
yabahiro | 56:61ebd4b759b4 | 4957 | motor[TIRE_BR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4958 | break; |
yabahiro | 56:61ebd4b759b4 | 4959 | case 253: |
yabahiro | 56:61ebd4b759b4 | 4960 | motor[TIRE_FR].pwm = 40; |
yabahiro | 56:61ebd4b759b4 | 4961 | motor[TIRE_FR].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4962 | motor[TIRE_BR].pwm = 25; |
yabahiro | 56:61ebd4b759b4 | 4963 | motor[TIRE_BR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4964 | break; |
yabahiro | 56:61ebd4b759b4 | 4965 | case 254: |
yabahiro | 56:61ebd4b759b4 | 4966 | motor[TIRE_FR].pwm = 30; |
yabahiro | 56:61ebd4b759b4 | 4967 | motor[TIRE_FR].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4968 | motor[TIRE_BR].pwm = 30; |
yabahiro | 56:61ebd4b759b4 | 4969 | motor[TIRE_BR].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 4970 | break; |
yabahiro | 56:61ebd4b759b4 | 4971 | case 1: |
yabahiro | 56:61ebd4b759b4 | 4972 | motor[TIRE_FR].pwm = 25; |
yabahiro | 56:61ebd4b759b4 | 4973 | motor[TIRE_FR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4974 | motor[TIRE_BR].pwm = 30; |
yabahiro | 56:61ebd4b759b4 | 4975 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4976 | break; |
yabahiro | 56:61ebd4b759b4 | 4977 | case 3: |
yabahiro | 56:61ebd4b759b4 | 4978 | motor[TIRE_FR].pwm = 25; |
yabahiro | 56:61ebd4b759b4 | 4979 | motor[TIRE_FR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4980 | motor[TIRE_BR].pwm = 40; |
yabahiro | 56:61ebd4b759b4 | 4981 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4982 | break; |
yabahiro | 56:61ebd4b759b4 | 4983 | case 2: |
yabahiro | 56:61ebd4b759b4 | 4984 | motor[TIRE_FR].pwm = 30; |
yabahiro | 56:61ebd4b759b4 | 4985 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4986 | motor[TIRE_BR].pwm = 30; |
yabahiro | 56:61ebd4b759b4 | 4987 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 4988 | break; |
yabahiro | 56:61ebd4b759b4 | 4989 | } |
yabahiro | 56:61ebd4b759b4 | 4990 | switch(g[3]) { |
yabahiro | 56:61ebd4b759b4 | 4991 | case 0: |
yabahiro | 56:61ebd4b759b4 | 4992 | motor[TIRE_FL].pwm = 25; |
yabahiro | 56:61ebd4b759b4 | 4993 | motor[TIRE_FL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4994 | motor[TIRE_BL].pwm = 25; |
yabahiro | 56:61ebd4b759b4 | 4995 | motor[TIRE_BL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 4996 | break; |
yabahiro | 56:61ebd4b759b4 | 4997 | case 255: |
yabahiro | 56:61ebd4b759b4 | 4998 | motor[TIRE_FL].pwm = 25; |
yabahiro | 56:61ebd4b759b4 | 4999 | motor[TIRE_FL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5000 | motor[TIRE_BL].pwm = 30; |
yabahiro | 56:61ebd4b759b4 | 5001 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5002 | case 253: |
yabahiro | 56:61ebd4b759b4 | 5003 | motor[TIRE_FL].pwm = 25; |
yabahiro | 56:61ebd4b759b4 | 5004 | motor[TIRE_FL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5005 | motor[TIRE_BL].pwm = 40; |
yabahiro | 56:61ebd4b759b4 | 5006 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5007 | break; |
yabahiro | 56:61ebd4b759b4 | 5008 | case 254: |
yabahiro | 56:61ebd4b759b4 | 5009 | motor[TIRE_FL].pwm = 30; |
yabahiro | 56:61ebd4b759b4 | 5010 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5011 | motor[TIRE_BL].pwm = 30; |
yabahiro | 56:61ebd4b759b4 | 5012 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5013 | break; |
yabahiro | 56:61ebd4b759b4 | 5014 | case 1: |
yabahiro | 56:61ebd4b759b4 | 5015 | motor[TIRE_FL].pwm = 30; |
yabahiro | 56:61ebd4b759b4 | 5016 | motor[TIRE_FL].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5017 | motor[TIRE_BL].pwm = 25; |
yabahiro | 56:61ebd4b759b4 | 5018 | motor[TIRE_BL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5019 | break; |
yabahiro | 56:61ebd4b759b4 | 5020 | case 3: |
yabahiro | 56:61ebd4b759b4 | 5021 | motor[TIRE_FL].pwm = 40; |
yabahiro | 56:61ebd4b759b4 | 5022 | motor[TIRE_FL].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5023 | motor[TIRE_BL].pwm = 25; |
yabahiro | 56:61ebd4b759b4 | 5024 | motor[TIRE_BL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5025 | break; |
yabahiro | 56:61ebd4b759b4 | 5026 | case 2: |
yabahiro | 56:61ebd4b759b4 | 5027 | motor[TIRE_FL].pwm = 30; |
yabahiro | 56:61ebd4b759b4 | 5028 | motor[TIRE_FL].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5029 | motor[TIRE_BL].pwm = 30; |
yabahiro | 56:61ebd4b759b4 | 5030 | motor[TIRE_BL].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5031 | break; |
yabahiro | 56:61ebd4b759b4 | 5032 | } |
yabahiro | 56:61ebd4b759b4 | 5033 | if(g[3]==0&&g[2]==0) { |
yabahiro | 56:61ebd4b759b4 | 5034 | mode=25; |
yabahiro | 56:61ebd4b759b4 | 5035 | } |
yabahiro | 56:61ebd4b759b4 | 5036 | } else { |
yabahiro | 56:61ebd4b759b4 | 5037 | if(g[1]==98&&countss>=40000) { |
yabahiro | 56:61ebd4b759b4 | 5038 | mode=31; |
yabahiro | 56:61ebd4b759b4 | 5039 | fast = 60; |
yabahiro | 56:61ebd4b759b4 | 5040 | normal = 40; |
yabahiro | 56:61ebd4b759b4 | 5041 | slow = 30; |
yabahiro | 56:61ebd4b759b4 | 5042 | countss=0; |
yabahiro | 56:61ebd4b759b4 | 5043 | } |
yabahiro | 56:61ebd4b759b4 | 5044 | switch(g[1]) { |
yabahiro | 56:61ebd4b759b4 | 5045 | case 98: |
yabahiro | 56:61ebd4b759b4 | 5046 | fast=40; |
yabahiro | 56:61ebd4b759b4 | 5047 | normal=30; |
yabahiro | 56:61ebd4b759b4 | 5048 | slow=25; |
yabahiro | 56:61ebd4b759b4 | 5049 | motor[TIRE_FR].pwm = normal; |
yabahiro | 56:61ebd4b759b4 | 5050 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5051 | motor[TIRE_FL].pwm = normal; |
yabahiro | 56:61ebd4b759b4 | 5052 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5053 | motor[TIRE_BR].pwm = normal; |
yabahiro | 56:61ebd4b759b4 | 5054 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5055 | motor[TIRE_BL].pwm = normal; |
yabahiro | 56:61ebd4b759b4 | 5056 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5057 | break; |
yabahiro | 56:61ebd4b759b4 | 5058 | case 0: |
yabahiro | 56:61ebd4b759b4 | 5059 | motor[TIRE_FR].pwm = fast; |
yabahiro | 56:61ebd4b759b4 | 5060 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5061 | motor[TIRE_FL].pwm = fast; |
yabahiro | 56:61ebd4b759b4 | 5062 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5063 | motor[TIRE_BR].pwm = fast; |
yabahiro | 56:61ebd4b759b4 | 5064 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5065 | motor[TIRE_BL].pwm = fast; |
yabahiro | 56:61ebd4b759b4 | 5066 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5067 | mtc=true; |
yabahiro | 56:61ebd4b759b4 | 5068 | break; |
yabahiro | 56:61ebd4b759b4 | 5069 | case 255: |
yabahiro | 56:61ebd4b759b4 | 5070 | motor[TIRE_FR].pwm = fast; |
yabahiro | 56:61ebd4b759b4 | 5071 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5072 | motor[TIRE_FL].pwm = slow; |
yabahiro | 56:61ebd4b759b4 | 5073 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5074 | motor[TIRE_BR].pwm = slow; |
yabahiro | 56:61ebd4b759b4 | 5075 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5076 | motor[TIRE_BL].pwm = fast; |
yabahiro | 56:61ebd4b759b4 | 5077 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5078 | mtc=true; |
yabahiro | 56:61ebd4b759b4 | 5079 | break; |
yabahiro | 56:61ebd4b759b4 | 5080 | case 253: |
yabahiro | 56:61ebd4b759b4 | 5081 | motor[TIRE_FR].pwm = slow; |
yabahiro | 56:61ebd4b759b4 | 5082 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5083 | motor[TIRE_FL].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5084 | motor[TIRE_FL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5085 | motor[TIRE_BR].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5086 | motor[TIRE_BR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5087 | motor[TIRE_BL].pwm = slow; |
yabahiro | 56:61ebd4b759b4 | 5088 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5089 | mtc=true; |
yabahiro | 56:61ebd4b759b4 | 5090 | break; |
yabahiro | 56:61ebd4b759b4 | 5091 | case 254: |
yabahiro | 56:61ebd4b759b4 | 5092 | motor[TIRE_FR].pwm = normal; |
yabahiro | 56:61ebd4b759b4 | 5093 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5094 | motor[TIRE_FL].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5095 | motor[TIRE_FL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5096 | motor[TIRE_BR].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5097 | motor[TIRE_BR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5098 | motor[TIRE_BL].pwm = normal; |
yabahiro | 56:61ebd4b759b4 | 5099 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5100 | mtc=true; |
yabahiro | 56:61ebd4b759b4 | 5101 | break; |
yabahiro | 56:61ebd4b759b4 | 5102 | case 1: |
yabahiro | 56:61ebd4b759b4 | 5103 | motor[TIRE_FR].pwm = slow; |
yabahiro | 56:61ebd4b759b4 | 5104 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5105 | motor[TIRE_FL].pwm = fast; |
yabahiro | 56:61ebd4b759b4 | 5106 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5107 | motor[TIRE_BR].pwm = fast; |
yabahiro | 56:61ebd4b759b4 | 5108 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5109 | motor[TIRE_BL].pwm = slow; |
yabahiro | 56:61ebd4b759b4 | 5110 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5111 | mtc=true; |
yabahiro | 56:61ebd4b759b4 | 5112 | break; |
yabahiro | 56:61ebd4b759b4 | 5113 | case 3: |
yabahiro | 56:61ebd4b759b4 | 5114 | motor[TIRE_FR].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5115 | motor[TIRE_FR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5116 | motor[TIRE_FL].pwm = slow; |
yabahiro | 56:61ebd4b759b4 | 5117 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5118 | motor[TIRE_BR].pwm = slow; |
yabahiro | 56:61ebd4b759b4 | 5119 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5120 | motor[TIRE_BL].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5121 | motor[TIRE_BL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5122 | mtc=true; |
yabahiro | 56:61ebd4b759b4 | 5123 | break; |
yabahiro | 56:61ebd4b759b4 | 5124 | case 2: |
yabahiro | 56:61ebd4b759b4 | 5125 | motor[TIRE_FR].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5126 | motor[TIRE_FR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5127 | motor[TIRE_FL].pwm = normal; |
yabahiro | 56:61ebd4b759b4 | 5128 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5129 | motor[TIRE_BR].pwm = normal; |
yabahiro | 56:61ebd4b759b4 | 5130 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5131 | motor[TIRE_BL].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5132 | motor[TIRE_BL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5133 | mtc=true; |
yabahiro | 56:61ebd4b759b4 | 5134 | break; |
yabahiro | 56:61ebd4b759b4 | 5135 | } |
yabahiro | 56:61ebd4b759b4 | 5136 | if(g[1]!=98&&mtc==true) { |
yabahiro | 56:61ebd4b759b4 | 5137 | switch(g[0]) { |
yabahiro | 56:61ebd4b759b4 | 5138 | case 0: |
yabahiro | 56:61ebd4b759b4 | 5139 | mtc=false; |
yabahiro | 56:61ebd4b759b4 | 5140 | break; |
yabahiro | 56:61ebd4b759b4 | 5141 | case 255: |
yabahiro | 56:61ebd4b759b4 | 5142 | motor[TIRE_FL].pwm += 3; |
yabahiro | 56:61ebd4b759b4 | 5143 | mtc=false; |
yabahiro | 56:61ebd4b759b4 | 5144 | break; |
yabahiro | 56:61ebd4b759b4 | 5145 | case 253: |
yabahiro | 56:61ebd4b759b4 | 5146 | motor[TIRE_FL].pwm += 6; |
yabahiro | 56:61ebd4b759b4 | 5147 | mtc=false; |
yabahiro | 56:61ebd4b759b4 | 5148 | break; |
yabahiro | 56:61ebd4b759b4 | 5149 | case 254: |
yabahiro | 56:61ebd4b759b4 | 5150 | motor[TIRE_FL].pwm += 9; |
yabahiro | 56:61ebd4b759b4 | 5151 | motor[TIRE_FR].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5152 | mtc=false; |
yabahiro | 56:61ebd4b759b4 | 5153 | break; |
yabahiro | 56:61ebd4b759b4 | 5154 | case 1: |
yabahiro | 56:61ebd4b759b4 | 5155 | motor[TIRE_FR].pwm += 3; |
yabahiro | 56:61ebd4b759b4 | 5156 | mtc=false; |
yabahiro | 56:61ebd4b759b4 | 5157 | break; |
yabahiro | 56:61ebd4b759b4 | 5158 | case 3: |
yabahiro | 56:61ebd4b759b4 | 5159 | motor[TIRE_FR].pwm += 6; |
yabahiro | 56:61ebd4b759b4 | 5160 | mtc=false; |
yabahiro | 56:61ebd4b759b4 | 5161 | break; |
yabahiro | 56:61ebd4b759b4 | 5162 | case 2: |
yabahiro | 56:61ebd4b759b4 | 5163 | motor[TIRE_FR].pwm += 9; |
yabahiro | 56:61ebd4b759b4 | 5164 | motor[TIRE_FL].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5165 | mtc=false; |
yabahiro | 56:61ebd4b759b4 | 5166 | break; |
yabahiro | 56:61ebd4b759b4 | 5167 | } |
yabahiro | 56:61ebd4b759b4 | 5168 | } |
yabahiro | 56:61ebd4b759b4 | 5169 | } |
yabahiro | 56:61ebd4b759b4 | 5170 | break; |
yabahiro | 56:61ebd4b759b4 | 5171 | case 4: |
yabahiro | 56:61ebd4b759b4 | 5172 | motor[TIRE_FR].pwm = 100; |
yabahiro | 56:61ebd4b759b4 | 5173 | motor[TIRE_FR].dir = BRAKE; |
yabahiro | 56:61ebd4b759b4 | 5174 | motor[TIRE_FL].pwm = 100; |
yabahiro | 56:61ebd4b759b4 | 5175 | motor[TIRE_FL].dir = BRAKE; |
yabahiro | 56:61ebd4b759b4 | 5176 | motor[TIRE_BR].pwm = 100; |
yabahiro | 56:61ebd4b759b4 | 5177 | motor[TIRE_BR].dir = BRAKE; |
yabahiro | 56:61ebd4b759b4 | 5178 | motor[TIRE_BL].pwm = 100; |
yabahiro | 56:61ebd4b759b4 | 5179 | motor[TIRE_BL].dir = BRAKE; |
yabahiro | 56:61ebd4b759b4 | 5180 | if(UPLS==true||DOLS==true) { |
yabahiro | 56:61ebd4b759b4 | 5181 | if(UPLS==true||DOLS==true) { |
yabahiro | 56:61ebd4b759b4 | 5182 | motor[MOTOR_0].pwm = 200; |
yabahiro | 56:61ebd4b759b4 | 5183 | motor[MOTOR_0].dir = BRAKE; |
yabahiro | 56:61ebd4b759b4 | 5184 | countss = 0; |
yabahiro | 56:61ebd4b759b4 | 5185 | mode=26; |
yabahiro | 56:61ebd4b759b4 | 5186 | } |
yabahiro | 56:61ebd4b759b4 | 5187 | } else { |
yabahiro | 56:61ebd4b759b4 | 5188 | motor[MOTOR_0].pwm = 100; |
yabahiro | 56:61ebd4b759b4 | 5189 | motor[MOTOR_0].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5190 | } |
yabahiro | 56:61ebd4b759b4 | 5191 | break; |
yabahiro | 56:61ebd4b759b4 | 5192 | case 5: |
yabahiro | 56:61ebd4b759b4 | 5193 | /* |
yabahiro | 56:61ebd4b759b4 | 5194 | if (g[3] == 0&&countss>=30000) { |
yabahiro | 56:61ebd4b759b4 | 5195 | mode = 40; |
yabahiro | 56:61ebd4b759b4 | 5196 | } |
yabahiro | 56:61ebd4b759b4 | 5197 | */ |
yabahiro | 56:61ebd4b759b4 | 5198 | if (g[1] != 99) { |
yabahiro | 56:61ebd4b759b4 | 5199 | mode = 31; |
yabahiro | 56:61ebd4b759b4 | 5200 | } |
yabahiro | 56:61ebd4b759b4 | 5201 | switch(g[4]) { |
yabahiro | 56:61ebd4b759b4 | 5202 | case 98: |
yabahiro | 56:61ebd4b759b4 | 5203 | motor[TIRE_FR].pwm = 60; |
yabahiro | 56:61ebd4b759b4 | 5204 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5205 | motor[TIRE_FL].pwm = 60; |
yabahiro | 56:61ebd4b759b4 | 5206 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5207 | motor[TIRE_BR].pwm = 60; |
yabahiro | 56:61ebd4b759b4 | 5208 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5209 | motor[TIRE_BL].pwm = 60; |
yabahiro | 56:61ebd4b759b4 | 5210 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5211 | break; |
yabahiro | 56:61ebd4b759b4 | 5212 | case 99: |
yabahiro | 56:61ebd4b759b4 | 5213 | motor[TIRE_FR].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5214 | motor[TIRE_FR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5215 | motor[TIRE_FL].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5216 | motor[TIRE_FL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5217 | motor[TIRE_BR].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5218 | motor[TIRE_BR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5219 | motor[TIRE_BL].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5220 | motor[TIRE_BL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5221 | break; |
yabahiro | 56:61ebd4b759b4 | 5222 | case 0: |
yabahiro | 56:61ebd4b759b4 | 5223 | motor[TIRE_FR].pwm = 60; |
yabahiro | 56:61ebd4b759b4 | 5224 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5225 | motor[TIRE_FL].pwm = 60; |
yabahiro | 56:61ebd4b759b4 | 5226 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5227 | motor[TIRE_BR].pwm = 60; |
yabahiro | 56:61ebd4b759b4 | 5228 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5229 | motor[TIRE_BL].pwm = 60; |
yabahiro | 56:61ebd4b759b4 | 5230 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5231 | break; |
yabahiro | 56:61ebd4b759b4 | 5232 | case 255: |
yabahiro | 56:61ebd4b759b4 | 5233 | motor[TIRE_FR].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5234 | motor[TIRE_FR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5235 | motor[TIRE_FL].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5236 | motor[TIRE_FL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5237 | motor[TIRE_BR].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5238 | motor[TIRE_BR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5239 | motor[TIRE_BL].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5240 | motor[TIRE_BL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5241 | break; |
yabahiro | 56:61ebd4b759b4 | 5242 | case 253: |
yabahiro | 56:61ebd4b759b4 | 5243 | motor[TIRE_FR].pwm = 25; |
yabahiro | 56:61ebd4b759b4 | 5244 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5245 | motor[TIRE_FL].pwm = 60; |
yabahiro | 56:61ebd4b759b4 | 5246 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5247 | motor[TIRE_BR].pwm = 60; |
yabahiro | 56:61ebd4b759b4 | 5248 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5249 | motor[TIRE_BL].pwm = 25; |
yabahiro | 56:61ebd4b759b4 | 5250 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5251 | break; |
yabahiro | 56:61ebd4b759b4 | 5252 | case 254: |
yabahiro | 56:61ebd4b759b4 | 5253 | motor[TIRE_FR].pwm = 40; |
yabahiro | 56:61ebd4b759b4 | 5254 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5255 | motor[TIRE_FL].pwm = 60; |
yabahiro | 56:61ebd4b759b4 | 5256 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5257 | motor[TIRE_BR].pwm = 60; |
yabahiro | 56:61ebd4b759b4 | 5258 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5259 | motor[TIRE_BL].pwm = 40; |
yabahiro | 56:61ebd4b759b4 | 5260 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5261 | break; |
yabahiro | 56:61ebd4b759b4 | 5262 | case 1: |
yabahiro | 56:61ebd4b759b4 | 5263 | motor[TIRE_FR].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5264 | motor[TIRE_FR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5265 | motor[TIRE_FL].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5266 | motor[TIRE_FL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5267 | motor[TIRE_BR].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5268 | motor[TIRE_BR].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5269 | motor[TIRE_BL].pwm = 0; |
yabahiro | 56:61ebd4b759b4 | 5270 | motor[TIRE_BL].dir = FREE; |
yabahiro | 56:61ebd4b759b4 | 5271 | break; |
yabahiro | 56:61ebd4b759b4 | 5272 | case 3: |
yabahiro | 56:61ebd4b759b4 | 5273 | motor[TIRE_FR].pwm = 60; |
yabahiro | 56:61ebd4b759b4 | 5274 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5275 | motor[TIRE_FL].pwm = 25; |
yabahiro | 56:61ebd4b759b4 | 5276 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5277 | motor[TIRE_BR].pwm = 25; |
yabahiro | 56:61ebd4b759b4 | 5278 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5279 | motor[TIRE_BL].pwm = 60; |
yabahiro | 56:61ebd4b759b4 | 5280 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5281 | break; |
yabahiro | 56:61ebd4b759b4 | 5282 | case 2: |
yabahiro | 56:61ebd4b759b4 | 5283 | motor[TIRE_FR].pwm = 60; |
yabahiro | 56:61ebd4b759b4 | 5284 | motor[TIRE_FR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5285 | motor[TIRE_FL].pwm = 40; |
yabahiro | 56:61ebd4b759b4 | 5286 | motor[TIRE_FL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5287 | motor[TIRE_BR].pwm = 40; |
yabahiro | 56:61ebd4b759b4 | 5288 | motor[TIRE_BR].dir = FOR; |
yabahiro | 56:61ebd4b759b4 | 5289 | motor[TIRE_BL].pwm = 60; |
yabahiro | 56:61ebd4b759b4 | 5290 | motor[TIRE_BL].dir = BACK; |
yabahiro | 56:61ebd4b759b4 | 5291 | break; |
yabahiro | 56:61ebd4b759b4 | 5292 | } |
yabahiro | 56:61ebd4b759b4 | 5293 | break; |
yabahiro | 56:61ebd4b759b4 | 5294 | } |
yabahiro | 46:68296caae1af | 5295 | |
kishibekairohan | 13:b6e02d6261d7 | 5296 | } |
kishibekairohan | 13:b6e02d6261d7 | 5297 | #endif |
kishibekairohan | 13:b6e02d6261d7 | 5298 | |
kishibekairohan | 13:b6e02d6261d7 | 5299 | #if USE_PROCESS_NUM>6 |
Ryosei | 27:dd9f27fce7d1 | 5300 | static void Process6() |
kishibekairohan | 13:b6e02d6261d7 | 5301 | { |
Ryosei | 27:dd9f27fce7d1 | 5302 | |
kishibekairohan | 13:b6e02d6261d7 | 5303 | } |
kishibekairohan | 13:b6e02d6261d7 | 5304 | #endif |
kishibekairohan | 13:b6e02d6261d7 | 5305 | |
kishibekairohan | 13:b6e02d6261d7 | 5306 | #if USE_PROCESS_NUM>7 |
kishibekairohan | 13:b6e02d6261d7 | 5307 | static void Process7() |
kishibekairohan | 13:b6e02d6261d7 | 5308 | { |
yabahiro | 33:dd598bb23ad1 | 5309 | |
kishibekairohan | 12:c09b3e08a316 | 5310 | } |
kishibekairohan | 12:c09b3e08a316 | 5311 | #endif |
kishibekairohan | 12:c09b3e08a316 | 5312 | |
Ryosei | 27:dd9f27fce7d1 | 5313 | #if USE_PROCESS_NUM>8 |
kishibekairohan | 13:b6e02d6261d7 | 5314 | static void Process8() |
kishibekairohan | 12:c09b3e08a316 | 5315 | { |
yabahiro | 33:dd598bb23ad1 | 5316 | |
kishibekairohan | 12:c09b3e08a316 | 5317 | } |
kishibekairohan | 12:c09b3e08a316 | 5318 | #endif |
kishibekairohan | 12:c09b3e08a316 | 5319 | |
kishibekairohan | 13:b6e02d6261d7 | 5320 | #if USE_PROCESS_NUM>9 |
kishibekairohan | 13:b6e02d6261d7 | 5321 | static void Process9() |
kishibekairohan | 12:c09b3e08a316 | 5322 | { |
Ryosei | 27:dd9f27fce7d1 | 5323 | |
t_yamamoto | 0:669ef71cba68 | 5324 | } |
t_yamamoto | 0:669ef71cba68 | 5325 | #endif |
t_yamamoto | 0:669ef71cba68 | 5326 | #endif |
t_yamamoto | 0:669ef71cba68 | 5327 | #pragma endregion PROCESS |
t_yamamoto | 0:669ef71cba68 | 5328 | |
t_yamamoto | 0:669ef71cba68 | 5329 | static void AllActuatorReset() |
t_yamamoto | 0:669ef71cba68 | 5330 | { |
yabahiro | 33:dd598bb23ad1 | 5331 | #ifdef USE_SOLENOID |
yabahiro | 33:dd598bb23ad1 | 5332 | solenoid.all = ALL_SOLENOID_OFF; |
yabahiro | 33:dd598bb23ad1 | 5333 | #endif |
yabahiro | 33:dd598bb23ad1 | 5334 | |
yabahiro | 33:dd598bb23ad1 | 5335 | #ifdef USE_MOTOR |
yabahiro | 33:dd598bb23ad1 | 5336 | for (uint8_t i = 0; i < MOUNTING_MOTOR_NUM; i++) { |
yabahiro | 33:dd598bb23ad1 | 5337 | motor[i].dir = FREE; |
yabahiro | 33:dd598bb23ad1 | 5338 | motor[i].pwm = 0; |
yabahiro | 33:dd598bb23ad1 | 5339 | } |
yabahiro | 33:dd598bb23ad1 | 5340 | #endif |
t_yamamoto | 0:669ef71cba68 | 5341 | } |
t_yamamoto | 0:669ef71cba68 | 5342 | |
kishibekairohan | 16:3f2c2d89372b | 5343 | #pragma region USER-DEFINED-FUNCTIONS |
M_souta | 29:44d5454ce8fa | 5344 | |
M_souta | 29:44d5454ce8fa | 5345 | uint8_t SetStatus(int pwmVal) |
Ryosei | 27:dd9f27fce7d1 | 5346 | { |
M_souta | 29:44d5454ce8fa | 5347 | if (pwmVal < 0) return BACK; |
M_souta | 29:44d5454ce8fa | 5348 | else if (pwmVal > 0) return FOR; |
M_souta | 29:44d5454ce8fa | 5349 | else if (pwmVal == 0) return BRAKE; |
M_souta | 29:44d5454ce8fa | 5350 | else return BRAKE; |
M_souta | 22:7d93f79a3686 | 5351 | } |
kishibekairohan | 16:3f2c2d89372b | 5352 | |
M_souta | 29:44d5454ce8fa | 5353 | uint8_t SetPWM(int pwmVal) |
Ryosei | 27:dd9f27fce7d1 | 5354 | { |
M_souta | 29:44d5454ce8fa | 5355 | if (pwmVal == 0 || pwmVal > 255 || pwmVal < -255) return 255; |
M_souta | 29:44d5454ce8fa | 5356 | else return abs(pwmVal); |
M_souta | 22:7d93f79a3686 | 5357 | } |
yabahiro | 55:844ac0974740 | 5358 | /* |
yabahiro | 55:844ac0974740 | 5359 | void Count(){ |
yabahiro | 55:844ac0974740 | 5360 | num++; |
yabahiro | 55:844ac0974740 | 5361 | } |
yabahiro | 55:844ac0974740 | 5362 | */ |
t_yamamoto | 0:669ef71cba68 | 5363 | #pragma endregion |