フェイルセーフ完成版

Dependencies:   HCSR04_2 MPU6050_2 mbed SDFileSystem3

Fork of Autoflight2018_53 by 航空研究会

Revision:
38:ef0f39dfc98a
Parent:
37:990047c4dc20
Child:
39:b8d5be233b70
--- a/main.cpp	Tue Sep 25 09:28:13 2018 +0000
+++ b/main.cpp	Tue Sep 25 09:43:16 2018 +0000
@@ -1159,16 +1159,16 @@
         flg_setInStartAuto = true;
     }else if(!CheckSW_Up(Ch7)){
         flg_setInStartAuto = false;
-        led2 = 0;
+        led4 = 0;
     }
     autopwm[THR]=oldTHR;
 
     newYaw_Moebius = TranslateNewYaw(nowAngle[YAW], FirstYAW_Moebius);
 
-    if(RotateCounter == 0 && newYaw_Moebius >90.0 && newYaw_Moebius < 180.0)    {RotateCounter++; led2 = 1; pc.printf("Rotate 90\r\n");}
-    if(RotateCounter == 1 && newYaw_Moebius >-180.0 && newYaw_Moebius < -90.0)  {RotateCounter++; led2 = 0; pc.printf("Rotate 180\r\n");}
-    if(RotateCounter == 2 && newYaw_Moebius >-90.0 && newYaw_Moebius <-10.0)   {RotateCounter++; led2 = 1; pc.printf("Rotate 270\r\n");}
-    if(RotateCounter == 3 && newYaw_Moebius >0.0 && newYaw_Moebius < 90.0)     {RotateCounter++; led2 = 0; pc.printf("Change Rotate direction\r\n");}
+    if(RotateCounter == 0 && newYaw_Moebius >90.0 && newYaw_Moebius < 180.0)    {RotateCounter++; led4 = 1; pc.printf("Rotate 90\r\n");}
+    if(RotateCounter == 1 && newYaw_Moebius >-180.0 && newYaw_Moebius < -90.0)  {RotateCounter++; led4 = 0; pc.printf("Rotate 180\r\n");}
+    if(RotateCounter == 2 && newYaw_Moebius >-90.0 && newYaw_Moebius <-10.0)   {RotateCounter++; led4 = 1; pc.printf("Rotate 270\r\n");}
+    if(RotateCounter == 3 && newYaw_Moebius >0.0 && newYaw_Moebius < 90.0)     {RotateCounter++; led4 = 0; pc.printf("Change Rotate direction\r\n");}
 
 
     if(RotateCounter <= 3) UpdateTargetAngle_Rightloop_short(targetAngle);    
@@ -1210,18 +1210,18 @@
         //一定高度or15秒でled点灯
         NVIC_DisableIRQ(EXTI9_5_IRQn);
         if((groundcount>5 && g_distance>0) || t_diff > 15){
-            led2 = 1;
+            led4 = 1;
             //pc.printf("Call [Stop!] calling!\r\n");
         }
         
-        if(g_distance<180 && g_distance > 0) {
+        if(g_distance<250 && g_distance > 0) {
             groundcount++;
         }
         NVIC_EnableIRQ(EXTI9_5_IRQn);
     }else{
         t_diff = 0;
         groundcount = 0;
-        led2 = 0;
+        led4 = 0;
     }
     
         NVIC_DisableIRQ(EXTI9_5_IRQn);