aa

Dependencies:   mbed

Revision:
58:bfc38c43dadb
Parent:
57:ccfd26b94d8a
Child:
59:5cd3875fa96a
--- a/System/Process/Process.cpp	Tue Nov 19 14:21:38 2019 +0000
+++ b/System/Process/Process.cpp	Sat Nov 23 08:59:26 2019 +0000
@@ -280,11 +280,13 @@
             if(ZoneSW) {
                 countss=0;
                 mode=1;
+                aime.start();
                 current = 3;//1119変更した
 
             } else {
                 countss = 0;
                 mode=1;
+                aime.start();
                 current = 2;
             }
         }
@@ -480,6 +482,7 @@
 static void Process2()
 {
     //Oh So 青ゾーン
+    value=aime.read_ms();
     LED::LED::TapeledMode(4);
     countss++;
     switch(mode) {
@@ -495,8 +498,9 @@
             motor[TIRE_BR].dir = FOR;
             motor[TIRE_BL].pwm = normal+20;
             motor[TIRE_BL].dir = BACK;
-            if(g[2]==0&&countss>=300000) {
+            if(g[2]==0&&value>=1500) {
                 countss=100000;
+                aime.reset();
                 cross=0;
                 mode=3;
             }
@@ -512,6 +516,7 @@
             motor[TIRE_BL].dir = BACK;
             if(g[1]==0) {
                 mode=10;
+                aime.reset();
                 countss=100000;
                 fast=80;
                 normal=60;
@@ -530,9 +535,11 @@
                     motor[TIRE_BL].pwm = normal+45;
                     motor[TIRE_BL].dir = BACK;
                     mtc=true;
-                    if(countss>80000) {
+                    if(value>=1200) {
                         cross++;
                         countss=0;
+                        value=0;
+                        aime.reset();
                     }
 
                     if(cross==2) {
@@ -546,6 +553,7 @@
                         normal=30;
                         slow=20;
                         mode=11;
+                        aime.reset();
                         countss=0;
                         cross=0;
                     }
@@ -856,6 +864,8 @@
                     fast=60;
                     normal=40;
                     slow=25;
+                    value=0;
+                    aime.reset();
                 }
             }
             break;
@@ -969,6 +979,7 @@
                         break;
                 }
                 if(g[3]==0&&g[2]==0) {
+                    aime.reset();
                     mode=23;
                     countss=0;
                     fast=80;
@@ -976,23 +987,22 @@
                     slow=30;
                 }
             } else {
-                if(g[0]==98) {
-                    slow=25;
-                    normal=30;
-                    fast=30;
-                }
-                if(g[3]==0) {
+                if(g[3]==0&&value>=2000) {
+                    solenoid.solenoid2 = SOLENOID_OFF;
                     slow=25;
                     normal=40;
                     fast=60;
+                    aime.reset();
                     mode=23;
                 }
                 switch(g[0]) {
                     case 98:
-                        solenoid.solenoid2 = SOLENOID_OFF;
-                        fast=40;
-                        normal=30;
-                        slow=25;
+                        if(value>=1500) {
+                            solenoid.solenoid2 = SOLENOID_OFF;
+                            slow=25;
+                            normal=30;
+                            fast=30;
+                        }
                         motor[TIRE_FR].pwm = normal;
                         motor[TIRE_FR].dir = BACK;
                         motor[TIRE_FL].pwm = normal+5;
@@ -1209,15 +1219,36 @@
                         motor[TIRE_BL].dir = FOR;
                         break;
                 }
+
+
+                /*
+                if(value>=3000) {
+                    mode=24;
+                    aime.reset();
+                    value=0;
+                    solenoid.solenoid2 = SOLENOID_OFF;
+                    countss=0;
+                    fast=80;
+                    normal=60;
+                    slow=30;
+                }
                 if(g[0]==98) {
                     fast=20;
                     normal=15;
                     slow=10;
                 }
-                if(g[2]==254&&countss>=100000) {
+                */
+                if(value>=2000) {
+                    fast=20;
+                    normal=15;
+                    slow=10;
+                }
+                if(g[2]==254&&value>=2700) {
                     mode=24;
                     solenoid.solenoid2 = SOLENOID_OFF;
                     countss=0;
+                    value=0;
+                    aime.reset();
                     fast=80;
                     normal=60;
                     slow=30;
@@ -1231,6 +1262,8 @@
                         normal=40;
                         slow=30;
                         countss=0;
+                        value=0;
+                        aime.reset();
                         mode=24;
                     }
                 } else {
@@ -1249,6 +1282,7 @@
             break;
         case 24:
             if(YELLOW) {
+                /*
                 if(g[4]==3||g[4]==2) {
                     motor[TIRE_FR].pwm = 30;
                     motor[TIRE_FR].dir = FOR;
@@ -1356,11 +1390,14 @@
                         motor[TIRE_BL].dir = FOR;
                         break;
                 }
+
                 if(g[3]==0&&g[2]==0) {
                     mode=25;
                 }
+                */
+                mode=25;
             } else {
-                if(g[0]==98&&countss>=40000) {
+                if(g[0]==98&&value>=2000) {
                     mode=31;
                     fast=60;
                     normal=40;
@@ -1506,6 +1543,8 @@
                     motor[MOTOR_0].dir = BRAKE;
                     countss=0;
                     mode=26;
+                    value=0;
+                    aime.reset();
                 }
             } else {
                 motor[MOTOR_0].pwm = 100;
@@ -1513,7 +1552,7 @@
             }
             break;
         case 26:
-            if(g[0]==98) {
+            if(g[0]==98&&value>=2500) {
                 mode=31;
             }
             switch(g[4]) {
@@ -1966,6 +2005,7 @@
 {
 //Clearly 赤ゾーン
     LED::LED::TapeledMode(3);
+    value=aime.read_ms();
     countss++;
     switch(mode) {
         case 1:
@@ -1980,7 +2020,7 @@
             motor[TIRE_BR].dir = BACK;
             motor[TIRE_BL].pwm = normal+20;
             motor[TIRE_BL].dir = FOR;
-            if(g[2]==0&&countss>=300000) {
+            if(g[2]==0&&value>=1500) {
                 countss=100000;
                 cross=0;
                 mode=3;
@@ -1997,6 +2037,7 @@
             motor[TIRE_BL].dir = BRAKE;
             if(g[0]==0) {
                 mode=10;
+                aime.reset();
                 countss=100000;
                 fast = 80;
                 normal = 60;
@@ -2015,10 +2056,18 @@
                     motor[TIRE_BL].pwm = normal+50;
                     motor[TIRE_BL].dir = FOR;
                     mtc=true;
+                    if(value>=1200) {
+                        cross++;
+                        countss=0;
+                        value=0;
+                        aime.reset();
+                    }
+                    /*
                     if(countss>80000) {
                         cross++;
                         countss=0;
                     }
+                    */
                     if(cross==2) {
                         fast = 10;
                         normal = 10;
@@ -2030,6 +2079,7 @@
                         normal=30;
                         slow=20;
                         mode=11;
+                        aime.reset();
                         countss=0;
                         cross=0;
 
@@ -2322,6 +2372,7 @@
                 motor[TIRE_BL].dir = FOR;
                 if(g[3]==98&&countss>=10000) {
                     mode=22;
+                    aime.reset();
                     countss=0;
                     fast=60;
                     normal=40;
@@ -2338,6 +2389,7 @@
                 motor[TIRE_BL].dir = BACK;
                 if(g[1]==0) {
                     mode=22;
+                    aime.reset();
                     fast=60;
                     normal=40;
                     slow=25;
@@ -2455,18 +2507,26 @@
                 }
                 if(g[3]==0&&g[2]==0) {
                     mode=23;
+                    aime.reset();
                     countss=0;
                     fast = 60;
                     normal = 40;
                     slow = 30;
                 }
             } else {
+                if(value>=2200) {
+                    slow=25;
+                    normal=30;
+                    fast=40;
+                }
+                /*
                 if(g[1]==98) {
                     slow=25;
                     normal=30;
                     fast=40;
                 }
-                if(g[3]==0) {
+                */
+                if(g[3]==0&&value>=2200) {
                     slow=25;
                     normal=40;
                     fast=60;
@@ -2694,21 +2754,37 @@
                         motor[TIRE_BL].dir = BACK;
                         break;
                 }
-                if(g[1]==98) {
-                    fast=10;
-                    normal=10;
+                if(value>=2400) {
+                    fast=20;
+                    normal=15;
                     slow=10;
                 }
-                if(g[3]==254&&countss>=100000) {
+                if(g[3]==254&&value>=2700) {
                     mode=24;
                     solenoid.solenoid4 = SOLENOID_OFF;
-                    aime.start();
                     aime.reset();
                     countss=0;
                     fast=80;
                     normal=60;
                     slow=30;
                 }
+
+                /*
+                if(value>=2500) {
+                    mode=24;
+                    aime.reset();
+                    solenoid.solenoid4 = SOLENOID_OFF;
+                    countss=0;
+                    fast=80;
+                    normal=60;
+                    slow=30;
+                }
+                if(g[1]==98) {
+                    fast=10;
+                    normal=10;
+                    slow=10;
+                }
+                */
             } else {
                 if(UPLS||DOLS) {
                     if(UPLS||DOLS) {