![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
2018.08能代CORE'S キッチン ミッション用プログラム
Fork of mission by
Diff: main.cpp
- Revision:
- 1:9833a893b719
- Parent:
- 0:31fa273aa56d
- Child:
- 2:b145797d04fb
--- a/main.cpp Fri Aug 03 01:09:43 2018 +0000 +++ b/main.cpp Sun Aug 05 03:15:22 2018 +0000 @@ -3,9 +3,9 @@ #include "BMP180.h" #define p0 1013.25f//海面気圧 -#define TIME_TOP 14 -#define TIME_WATER 20 -#define TIME_BUZZER 25 +#define TIME_TOP 3 +#define TIME_WATER 5 +#define TIME_BUZZER 16 #define NUM 5 #define RATE 10 @@ -20,10 +20,11 @@ DigitalIn rec1(p5); DigitalIn rec2(p6); DigitalOut heat(p22); -DigitalOut buzzer(p20); +DigitalOut buzzer(p21); DigitalOut myled1(LED1); DigitalOut myled2(LED2); DigitalOut myled3(LED3); +DigitalOut myled4(LED4); BMP180 bmp (p28, p27); LocalFileSystem local("local"); @@ -45,12 +46,16 @@ int altitude; int med_alt; -int main(){ - _heater_acc(); - Phase=EGG; - tic_mission.attach(&_mission,1.0/RATE); - tic_buzzer.attach(&_buzzer,1.0/RATE); +int main(){ + buzzer=0; + _heater_acc(); + Phase=RISE; + tic_mission.attach(&_mission,1.0/10); + //tic_buzzer.attach(&_buzzer,1.0/RATE); while(1){ + _buzzer(); + /*if(Phase=BUZZER){ + tic_mission.detach();*/ if(timer_top.read()>=TIME_BUZZER){ buzzer=0; } @@ -59,27 +64,28 @@ void _mission(){ + myled4=!myled4; switch(Phase){ case EGG: - buzzer=0; + //buzzer=0; myled1=0; myled2=0; timer_all.start(); - FILE *fp; - fp = fopen("/local/out.txt", "a"); - 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); - wait(1.0); - servo_open1.pulsewidth(0.005); - servo_open2.pulsewidth(0.024); - fprintf(fp, "%f:サーボ_開く\n\r",timer_all); - fclose(fp); - Phase=RISE; - break; - case RISE: + //FILE *fp; + //fp = fopen("/local/out.txt", "a"); + //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); + wait(1.0); + servo_open1.pulsewidth(0.005); + servo_open2.pulsewidth(0.024); + //fprintf(fp, "%f:サーボ_開く\n\r",timer_all); + //fclose(fp); + Phase=RISE; + break; + case RISE: bmp.Initialize(BMP180_OSS_ULTRA_LOW_POWER); //pc.printf("Temperature ,Pressure, Altitude\r\n"); int j; @@ -98,11 +104,12 @@ } //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); myled1=1; timer_top.start(); + //tic_buzzer.attach(&_buzzer,1.0/100); Phase=DROP; } break; @@ -122,28 +129,30 @@ Cnt_water=0; } //pc.printf("%d\n\r",Cnt_water); - if(Cnt_water>=3||timer_top.read()>=TIME_WATER){ - fp = fopen("/local/out.txt", "a"); + if(/*Cnt_water>=3||*/timer_top.read()>=TIME_WATER){ + //fp = fopen("/local/out.txt", "a"); //pc.printf("着水判定"); myled2=1; heat=0; buzzer=1; - fprintf(fp, "%f:ヒーターOFF\nブザーON\n\r",timer_all); - fclose(fp); + //tic_buzzer.attach(&_buzzer,0.5); + //fprintf(fp, "%f:ヒーターOFF\nブザーON\n\r",timer_all); + //fclose(fp); Phase=BUZZER; + // tic_mission.detach(); } //break; /*case BUZZER: - if(timer_top>=TIME_BUZZER){ + if(timer_top.read()>=TIME_BUZZER){ fp = fopen("/local/out.txt", "a"); buzzer=0; fprintf(fp, "%f:ブザーOFF\n\r",timer_all); fclose(fp); } break;*/ - } + } } void _heater_acc(){ @@ -156,7 +165,6 @@ } if(rec2==1){ break; - }else if(rec2==0){ } } } @@ -164,7 +172,7 @@ void _buzzer(){ myled3=!myled3; if(rec2==1){ - buzzer=0; + buzzer=1; }else if(rec2==0){ buzzer=0; }