201803_oshima_jodam_test
Dependencies: BMP180 MPU6050 SDFileSystem mbed
Fork of SDFileSystem_HelloWorld by
Diff: main.cpp
- Revision:
- 3:a7b39e55d100
- Parent:
- 2:0deade364b73
- Child:
- 4:44e13dd5250b
--- a/main.cpp Tue Feb 20 03:02:02 2018 +0000 +++ b/main.cpp Tue Feb 20 03:14:24 2018 +0000 @@ -5,7 +5,7 @@ #define UNLOCK 1 #define LOCK 0 -#define TIMER 30 +#define TIMER 30 //開放タイマー SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board BMP180 bmp(p28,p27); @@ -22,7 +22,7 @@ Ticker kaihou; Timer timer1; - +/*とりあえず全てグローバル変数化してます。*/ //カウント変数 int Cnt_buff = 0; int Cnt_para = 0; @@ -50,7 +50,7 @@ int main() { - twe.printf("Hello World!\n"); + twe.printf("Hello World!\r\n"); /*SDカード動作確認*/ mkdir("/sd/mydir", 0777); FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); @@ -60,11 +60,13 @@ fprintf(fp, "Hello fun SD Card World!"); fclose(fp); +/*I2C初期化*/ bmp.Initialize(60,BMP180_OSS_ULTRA_LOW_POWER); mpu.setAcceleroRange(0); mpu.setGyroRange(0); twe.printf("I2C_initialize_ok\r\n"); - + +/*地上高度取得*/ for(i=0; i<10; i++){ bmp.ReadData(&temperature,&pressure); Alt_buff[i]=get_Alt(pressure, temperature); @@ -127,7 +129,7 @@ void _open(){ - if(Cnt_open == 0){ + if(Cnt_open == 0){ //20回に一回保存(20回に1回openとclose) fp = fopen("/sd/mydir/sdtest.txt", "a"); if(fp == NULL)twe.printf("ERROR\r\n"); } @@ -152,7 +154,7 @@ if(Cnt_buff == 10 && tf_para == true){ t = timer1.read(); - if(Cnt_para>=7 || t > TIMER){ //10回中6回小さけれ落下と判断(最初はぜってぇ大きいから実質6/9) + if(Cnt_para>=7 || t > TIMER){ //10回中7回小さけれ落下と判断(最初はぜってぇ大きいから実質7/9) _para(UNLOCK); tf_para = false; timer1.stop(); @@ -164,7 +166,7 @@ fprintf(fp, "%f,%f,%f,%f,%f,%f,%f\r\n",Alt_now,a[0],a[1],a[2],d[0],d[1],d[2]); - twe.printf("%f,%f,%f,%f,%f,%f,%f\r\n",Alt_now,a[0],a[1],a[2],d[0],d[1],d[2]); + twe.printf("%f,%f,%f,%f,%f,%f,%f\r\n",Alt_now,a[0],a[1],a[2],d[0],d[1],d[2]); //todo要らん場合は適宜コメントアウト Cnt_buff++; Cnt_open++;