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