2017年3月,伊豆大島共同打上実験 CORE_缶ロケチーム電装

Dependencies:   MPU6050 MS5607 mbed SDFileSystem

Revision:
13:f73b4beded57
Parent:
12:211d2c6d2afc
Child:
14:cbee1bfdfca7
diff -r 211d2c6d2afc -r f73b4beded57 main.cpp
--- a/main.cpp	Fri Mar 03 01:26:07 2017 +0000
+++ b/main.cpp	Fri Mar 03 05:14:02 2017 +0000
@@ -65,6 +65,7 @@
 #define SERVO_1 2
 #define SERVO_2 3
 #define MODE 4
+#define DEBUG 5
 /**/
 #define P0 1013.25f//海面気圧[hPa]
 #define ACC 4096.0f//加速度オフセット値
@@ -122,8 +123,6 @@
    fp = fopen("/sd/log.txt", "w");
    fprintf(fp, "pressure,temperature,ax,ay,az,gx,gy,gz\r\n");
    device.attach(&_Input,Serial::RxIrq);
-   loop_log.attach(&_Log,1.0/RATE_LOG);
-   loop_open.attach(&_Open,1.0/RATE_OPEN);
    while(1);
 }
 /*開放用関数 RATE_OPEN[Hz]で判定を行う*/
@@ -147,7 +146,6 @@
                   }else{
                      if(timer.read()>t_launch+1.0) cnt_judge = 0;
                   }
-                  device.printf("%f\r\n",acc4open);
                   break;
       case FLIGHT://飛翔中(パラシュート開放判定)
                   alt4open[col_open] = _GetAlt(ms5607.getPressure()/100,ms5607.getTemperature());
@@ -227,32 +225,51 @@
                      Input_mode = SERVO_1;
                      device.printf("\r\nInput_mode:SERVO\r\n");
                      device.printf("\r\n0:All\r\n1:Parachute\r\n2:Cansat\r\n>>");
+                  }else if(c=='c'){
+                     Input_mode = MODE;
+                     device.printf("\r\nn:NORMAL\r\nf:FLIGHT\r\nt:TEST\r\n>>");
                   }else{
-                     device.printf("\r\nthis command is not found:%c\r\n",c);    
-                     device.printf("\r\nInput_mode:NORMAL\r\ns:SERVO\r\n");
+                     device.printf("\r\nthis command is not found:%c\r\n",c);
+                     device.printf("\r\nInput_mode:NORMAL\r\ns:SERVO\r\nc:ChangeMode\r\n>>");
                   }
                   break;
       case SERVO_1:
                   input_buff[0] = (int)(c-'0');
                   if(c=='0'||c=='1'||c=='2'){
                      Input_mode = SERVO_2;
-                     device.printf("\r\n0:OPEN\r\n1:CLOSE\r\n>>");                     
-                  }else{                 
-                     device.printf("\r\nthis servo_num is not found:%d\r\n",input_buff[0]);    
-                     device.printf("\r\nInput_mode:NORMAL\r\ns:SERVO\r\n>>");
-                     Input_mode = NORMAL;                     
+                     device.printf("\r\n0:OPEN\r\n1:CLOSE\r\n>>");
+                  }else{
+                     device.printf("\r\nthis servo_num is not found:%d\r\n",input_buff[0]);
+                     device.printf("\r\nInput_mode:NORMAL\r\ns:SERVO\r\nc:ChangeMode\r\n>>");
+                     Input_mode = NORMAL;
                   }
                   break;
       case SERVO_2:
                   if(c=='0')_Servo(input_buff[0],UNLOCK);
                   else if(c=='1')_Servo(input_buff[0],LOCK);
-                  else{ 
-                     device.printf("\r\nthis motion_num is not found:%c\r\n",c);    
-                  }
-                  device.printf("Input_mode:NORMAL\r\ns:SERVO\r\n");
+                  else device.printf("\r\nthis motion_num is not found:%c\r\n",c);
+                  device.printf("\r\nInput_mode:NORMAL\r\ns:SERVO\r\nc:ChangeMode\r\n>>");
                   Input_mode = NORMAL;
                   break;
       case MODE:
+                  if(c=='n'){
+                     Input_mode = NORMAL;
+                     device.printf("\r\nInput_mode:NORMAL\r\ns:SERVO\r\nc:ChangeMode\r\n>>");
+                  }else if(c=='f'){
+                     Input_mode = BAN;
+                     device.printf("\r\nyou will be able to reset only after this action!");
+                     fp = fopen("/sd/log.txt", "w");
+                     fprintf(fp, "pressure,temperature,ax,ay,az,gx,gy,gz\r\n");
+                     Phase = LAUNCH;
+                     loop_log.attach(&_Log,1.0/RATE_LOG);
+                     loop_open.attach(&_Open,1.0/RATE_OPEN);
+                     device.printf("\r\nFLIGHT-Mode ON!\r\n");
+                  }else if(c=='d'){
+                     Input_mode = DEBUG;
+                  }
+                  break;
+      case DEBUG:
+
                   break;
       case BAN://reset only
                   break;
@@ -262,10 +279,10 @@
 }
 
 /*その他雑関数*/
-float _GetAlt(float press, float temp){
+float _GetAlt(float press, float temp){//高度計算
     return (pow((P0/press), (1.0f/5.257f))-1.0f)*(temp+273.15f)/0.0065f;
 }
-float _Median(float data[], int num){
+float _Median(float data[], int num){//中央値計算
    float median;
    float *sort = (float *)malloc(sizeof(float)*num);
    for(int i=0; i<num; i++) sort[i] = data[i];