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