aa

Dependencies:   mbed TrapezoidControl QEI

Files at this revision

API Documentation at this revision

Comitter:
yabahiro
Date:
Fri Sep 20 02:47:02 2019 +0000
Parent:
29:c78a46f51209
Commit message:
aa

Changed in this revision

System/Process/Process.cpp Show annotated file Show diff for this revision Revisions of this file
System/Process/Process.h Show annotated file Show diff for this revision Revisions of this file
diff -r c78a46f51209 -r 9450dc1d53cc System/Process/Process.cpp
--- a/System/Process/Process.cpp	Thu Sep 19 05:42:23 2019 +0000
+++ b/System/Process/Process.cpp	Fri Sep 20 02:47:02 2019 +0000
@@ -292,10 +292,12 @@
 bool dz4i=false;
 
 bool zone;
+bool through=false;
 
 int mode =1;
 int cross=0;//十字数える用
 int count=100000;//wait代替え
+int slow=30;
 
 
 static void Process1()
@@ -360,7 +362,7 @@
     if(controller->Button.A) {
         if(dz3==true) {
             if(dz3i==false) {
-                solenoid.solenoid3 = SOLENOID_ON;
+
                 dz3i=true;
             } else {
                 solenoid.solenoid3 = SOLENOID_OFF;
@@ -412,7 +414,7 @@
 
 static void Process2()
 {
-//    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]);
+ //   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]);
     count++;
     if(mode==0&&StertSW) {
         if(ThSW) {
@@ -459,26 +461,30 @@
         } else if(mode==3) { //横ライントレースから縦ライントレースへ
             motor[TIRE_FR].pwm = 0;
             motor[TIRE_FR].dir = FREE;
-            motor[TIRE_FL].pwm = 20;
+            motor[TIRE_FL].pwm = slow;
             motor[TIRE_FL].dir = FOR;
-            motor[TIRE_BR].pwm = 20;
+            motor[TIRE_BR].pwm = slow;
             motor[TIRE_BR].dir = BACK;
             motor[TIRE_BL].pwm = 0;
             motor[TIRE_BL].dir = FREE;
-            if(count>100000&&g[0]==0) {
+            if(g[0]==0) {
+                through=true;
+            }
+            if(through==true&&g[0]==255) {
+                through=false;
                 count=0;
-                mode=10;
+                mode=4;
             }
         } else if(mode==4) { //横ライントレースから縦ライントレースへ
-            motor[TIRE_FR].pwm = 15;
+            motor[TIRE_FR].pwm = slow;
             motor[TIRE_FR].dir = BACK;
-            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].pwm = slow;
             motor[TIRE_FL].dir = BACK;
-            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].pwm = slow;
             motor[TIRE_BR].dir = FOR;
-            motor[TIRE_BL].pwm = 15;
+            motor[TIRE_BL].pwm = slow;
             motor[TIRE_BL].dir = FOR;
-            if(count>30000&&g[0]==0) {
+            if(g[0]==0) {
                 count=0;
                 cross=0;
                 mode=10;
@@ -618,26 +624,29 @@
         } else if(mode==11) {
             motor[TIRE_FR].pwm = 0;
             motor[TIRE_FR].dir = FREE;
-            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].pwm = slow;
             motor[TIRE_FL].dir = FOR;
-            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].pwm = slow;
             motor[TIRE_BR].dir = BACK;
             motor[TIRE_BL].pwm = 0;
             motor[TIRE_BL].dir = FREE;
-            if(count>5000&&g[2]==0) {
-                count=0;
+            if(g[2]==0) {
+                through=true;
+            }
+            if(through==true&&g[2]==255) {
+                through=false;
                 mode=12;
             }
         } else if(mode==12) {
-            motor[TIRE_FR].pwm = 15;
+            motor[TIRE_FR].pwm = slow;
             motor[TIRE_FR].dir = FOR;
-            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].pwm = slow;
             motor[TIRE_FL].dir = BACK;
-            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].pwm = slow;
             motor[TIRE_BR].dir = FOR;
-            motor[TIRE_BL].pwm = 15;
+            motor[TIRE_BL].pwm = slow;
             motor[TIRE_BL].dir = BACK;
-            if(count>10000&&g[2]==0) {
+            if(g[2]==0) {
                 count=0;
                 cross=0;
                 mode=20;
@@ -778,26 +787,30 @@
         } else if(mode==21) {
             motor[TIRE_FR].pwm = 0;
             motor[TIRE_FR].dir = FREE;
-            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].pwm = slow;
             motor[TIRE_FL].dir = FOR;
-            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].pwm = slow;
             motor[TIRE_BR].dir = BACK;
             motor[TIRE_BL].pwm = 0;
             motor[TIRE_BL].dir = FREE;
-            if(count>2000&&g[0]==0) {
-                count=0;
+            if(g[0]==0) {
+                through=true;
+            }
+            if(through==true&&g[0]==255) {
+                through=false;
                 mode=22;
             }
         } else if(mode==22) {
-            motor[TIRE_FR].pwm = 15;
+            motor[TIRE_FR].pwm = slow;
             motor[TIRE_FR].dir = BACK;
-            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].pwm = slow;
             motor[TIRE_FL].dir = BACK;
-            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].pwm = slow;
             motor[TIRE_BR].dir = FOR;
-            motor[TIRE_BL].pwm = 15;
+            motor[TIRE_BL].pwm = slow;
             motor[TIRE_BL].dir = FOR;
-            if(count>5000&&g[0]==0) {
+            if(g[0]==0) {
+                solenoid.solenoid3 = SOLENOID_ON;
                 count=0;
                 cross=0;
                 mode=30;
@@ -819,6 +832,7 @@
                     }
                     mtc=true;
                     if(cross==1) {
+                        solenoid.solenoid3 = SOLENOID_OFF;
                         mode=31;
                         count=0;
                     }
diff -r c78a46f51209 -r 9450dc1d53cc System/Process/Process.h
--- a/System/Process/Process.h	Thu Sep 19 05:42:23 2019 +0000
+++ b/System/Process/Process.h	Fri Sep 20 02:47:02 2019 +0000
@@ -16,7 +16,7 @@
 #define MOTOR_0 4
 
 #define StertSW LimitSw::IsPressed(9) //スタートスイッチ
-#define ZoneSW  LimitSw::IsPressed(11) //赤ゾーン用スイッチ
+#define ZoneSW  LimitSw::IsPressed(10) //赤ゾーン用スイッチ
 #define ThSW LimitSw::IsPressed(4) //シーツタオルスイッチ
 
 typedef union