skipper_raspi_uart_test

Dependencies:   mbed MPU6050_2 HMC5883L_4 SDFileSystem3

Revision:
26:ea86e69563b5
Parent:
25:1f938342d5f9
Child:
27:f67efcee6509
--- a/main.cpp	Tue Feb 19 09:52:43 2019 +0000
+++ b/main.cpp	Tue Feb 19 10:36:19 2019 +0000
@@ -79,6 +79,7 @@
 enum Angle{ROLL, PITCH, YAW};   //yaw:北を0とした絶対角度
 
 Timer t;
+Timer t2;
 
 FILE *g_fp;
 
@@ -151,11 +152,6 @@
         pc.printf("Position\r\n");
         pc.printf("g_landingcommand=%c\r\n",g_landingcommand);
         
-        g_fp = fopen( "/sd/Datalog01.txt" ,"w+" );
-        fprintf(g_fp, "g_landingcommands = %c\r\n",g_landingcommand);
-        
-        fclose(g_fp);
-        
         NVIC_DisableIRQ(USART1_IRQn);
         NVIC_DisableIRQ(USART2_IRQn);
         if(g_landingcommand!='N') MatchPosition();
@@ -188,6 +184,9 @@
             servoL.pulsewidth_us(Servo_NEUTRAL_L);
             NVIC_EnableIRQ(USART1_IRQn);
             NVIC_EnableIRQ(USART2_IRQn);
+            g_fp = fopen( "/sd/Datalog01.txt" ,"a" );
+            fprintf(g_fp, "Not found\r\n.");        
+            fclose(g_fp);
             break;
             
         case 'Y': //MOVE_FORWARD
@@ -530,6 +529,12 @@
     led2 = 1;
     led3 = 1;
     led4 = 1;
+    
+    servoR.pulsewidth_us(Servo_NEUTRAL_R);       //servo initialize
+    servoL.pulsewidth_us(Servo_NEUTRAL_L);
+    servoTurnTable.pulsewidth_us(Turntable_NEUTRAL);
+    servoCameradeg.pulsewidth_us(Camera_deg_A);
+    servoCameraPinto.pulsewidth_us(focus_NEUTRAL);
      
     SetOptions(&Servo_NEUTRAL_R, &Servo_NEUTRAL_L,
                &Servo_high_FORWARD_R, &Servo_high_FORWARD_L,
@@ -545,14 +550,6 @@
     Init_sensors();
     //switch2.rise(ResetTrim);
     
-    g_fp = fopen( "/sd/Datalog01.txt" ,"w+" );
-    if( g_fp == NULL ) {
-        pc.printf( "ファイルオープンエラー\r\n" );
-    }
-    fprintf(g_fp,"Fall Start.\r\n");
-   
-    fclose( g_fp );
-    
     //NVIC_SetPriority(USART1_IRQn,0);
     //NVIC_SetPriority(EXTI0_IRQn,1);
     //NVIC_SetPriority(TIM5_IRQn,2);
@@ -599,6 +596,16 @@
         
     wait(0.2);
     
+    
+    g_fp = fopen( "/sd/Datalog01.txt" ,"a" );
+    if( g_fp == NULL ) {
+        pc.printf( "ファイルオープンエラー\r\n" );
+    }
+    fprintf(g_fp,"-------------------------\r\n");
+    fprintf(g_fp,"All initialized.\r\n");
+    fclose( g_fp );
+    
+    
     pc.printf("All initialized\r\n");
     setupFlag=true;
 }