2018.08能代CORE'S キッチン ミッション用プログラム

Dependencies:   BMP180 mbed

Fork of mission by hitomi shio

Revision:
2:b145797d04fb
Parent:
1:9833a893b719
Child:
3:0562feabce7b
--- a/main.cpp	Sun Aug 05 03:15:22 2018 +0000
+++ b/main.cpp	Sun Aug 05 12:37:59 2018 +0000
@@ -45,43 +45,50 @@
 int            Cnt_top=0,Cnt_water=0;
 int            altitude;
 int            med_alt; 
+FILE *fp; 
 
 int main(){
+    //FILE *fp; 
+    fp = fopen("/local/out.txt", "a"); 
+    fprintf(fp,"%f:Hello,World\n\r");
     buzzer=0; 
     _heater_acc(); 
     Phase=RISE;  
     tic_mission.attach(&_mission,1.0/10);
     //tic_buzzer.attach(&_buzzer,1.0/RATE);
-    while(1){
+    /*while(1){
         _buzzer();
-        /*if(Phase=BUZZER){ 
+        /*if(Phase==BUZZER){ 
             tic_mission.detach();*/
         if(timer_top.read()>=TIME_BUZZER){
             buzzer=0;
         }
-    }
+    
 }
     
     
 void _mission(){
+    if(Phase==BUZZER){
+        _buzzer();
+    }
     myled4=!myled4;
     switch(Phase){
         case EGG:            
-                        //buzzer=0;
+                        buzzer=0;
                         myled1=0;
                         myled2=0;
                         timer_all.start();
-                        //FILE *fp; 
+                        FILE *fp; 
                         //fp = fopen("/local/out.txt", "a"); 
-                        //fprintf(fp,"%f:ヒーターON\n\r",timer_all);
+                        fprintf(fp,"%f:ヒーターON\n\r",timer_all);
                         timer_acc.start();
                         servo_crack1.pulsewidth(0.005);
                         servo_crack2.pulsewidth(0.024);
-                        //fprintf(fp, "%f:サーボ_割る\n\r",timer_all);
+                        fprintf(fp, "%f:サーボ_割る\n\r",timer_all);
                         wait(1.0);
                         servo_open1.pulsewidth(0.005);
                         servo_open2.pulsewidth(0.024);
-                        //fprintf(fp, "%f:サーボ_開く\n\r",timer_all);
+                        fprintf(fp, "%f:サーボ_開く\n\r",timer_all);
                         //fclose(fp);
                         Phase=RISE;
                         break;
@@ -104,9 +111,10 @@
                         }
                         //pc.printf("%d\n\r",Cnt_top);
                         if(Cnt_top>=3||timer_acc.read()>=TIME_TOP){
-                            //fp = fopen("/local/out.txt", "a");
+                            fp = fopen("/local/out.txt", "a");
                             //pc.printf("頂点判定");
-                            //fprintf(fp, "%f:頂点判定\n\r",timer_all);
+                            fprintf(fp, "%f:頂点判定\n\r",timer_all);
+                            fclose(fp);
                             myled1=1;
                             timer_top.start();
                             //tic_buzzer.attach(&_buzzer,1.0/100);
@@ -130,17 +138,18 @@
                         }
                         //pc.printf("%d\n\r",Cnt_water);
                         if(/*Cnt_water>=3||*/timer_top.read()>=TIME_WATER){
-                            //fp = fopen("/local/out.txt", "a"); 
+                            fp = fopen("/local/out.txt", "a"); 
                             //pc.printf("着水判定");
                             myled2=1;
                             heat=0;
                             buzzer=1;
-                            //tic_buzzer.attach(&_buzzer,0.5);
-                            //fprintf(fp, "%f:ヒーターOFF\nブザーON\n\r",timer_all);
+                            //tic_buzzer.attach(&_buzzer,1/100);
+                            fprintf(fp, "%f:ヒーターOFF\nブザーON\n\r",timer_all);
                             //fclose(fp);
                             Phase=BUZZER;
-                            //
-                            tic_mission.detach();
+                            //tic_buzzer.attach(&_buzzer,1.0/40);
+                            //tic_mission.detach();
+                            
                         }
                         //break;
                         
@@ -184,7 +193,7 @@
      
 float _median(float data[], int num){
     float *data_cpy, ans;
-    data_cpy = new float[num];
+    data_cpy = new float[num]; 
     memcpy(data_cpy,data,sizeof(float)*num);
  
     for(int i=0; i<num; i++){