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