Dependencies:   MPU6050 MS5607 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /*
00002 alt  →altitude
00003 pres →pressure
00004 acc  →acceleration
00005 */
00006  
00007  
00008 //todo 単位系どうなってるの?
00009 
00010 #include "mbed.h"
00011 #include "math.h"
00012 #include "MPU6050.h"
00013 #include "MS5607I2C.h"
00014 
00015 //todo defineの整理
00016 #define ALT_TOP 100
00017 #define ALT_LEAFING 300
00018 #define ACC 4*9.8
00019 #define COUNT 5
00020 
00021 
00022 MPU6050 mpu(p9,p10); //tx,rx
00023 MS5607I2C ms(p9,p10,false); //tx, rx, csピンがGND
00024 DigitalOut myled1(LED1);
00025 DigitalOut myled2(LED2);
00026 DigitalOut myled3(LED3);
00027 DigitalOut myled4(LED4);
00028 float alt=ms.getAltitude();
00029 float acc[3];
00030 float acc_total;
00031 float time_alt;
00032 float time_acc;
00033 int   cnt_alt=0;
00034 int   cnt_acc;
00035 
00036 //todo 変数の追加
00037 
00038 Timer timer;
00039 
00040 
00041     
00042 void judge_top(){
00043    
00044     while(1){
00045         if(ALT_TOP>=alt){
00046             cnt_alt++;
00047         }
00048         if(timer.read()>0.5){
00049             cnt_alt=0;
00050         }
00051         if(cnt_alt>=COUNT){
00052             myled1=1;
00053             //open the servos
00054         }else{
00055             myled1=0;
00056             }
00057     }
00058 }
00059      
00060 
00061 int main(){
00062     while(1){
00063         judge_top();
00064     }
00065 }