Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 7:8407141d1f70
- Parent:
- 6:496f4e967298
- Child:
- 8:505d06bba7b1
diff -r 496f4e967298 -r 8407141d1f70 main.cpp
--- a/main.cpp Mon Sep 08 01:18:37 2014 +0000
+++ b/main.cpp Mon Sep 08 01:54:25 2014 +0000
@@ -1,6 +1,11 @@
#include "mbed.h"
+#include <math.h>
#include "LPS331_I2C.h"
+//気圧計算用
+#define P0 1013.25f //海面気圧(hPa)
+#define TEMP 20 //気温(度)
+
DigitalOut myled(LED1);
DigitalOut JPlow(p5); // p6ピンでLowを検出させるために使用。隣同士(p5,p6)のピンをショートさせるとログ出力停止
DigitalIn JP(p6);
@@ -28,7 +33,14 @@
int ms=0; // リセットからの経過時間(単位:ミリ秒(MilliSecond)
float pres=lps331.getPressure(); // 気圧
float temp=lps331.getTemperature(); // 気温
+ float height; // 高度
+//★デバッグ用
+ pres = 900;
+
+ height = ( (powf((P0/pres),1/5.257f)-1)*(TEMP+273.15) ) / 0.0065f;
+ printf("height = %5.1f\r\n", height);
+
if(JP==0) { // JPが0(GND)だったら、
break; //whileのループを終了
}
@@ -36,7 +48,7 @@
ms = t.read_ms(); //現在時刻を取得
FILE *fp = fopen("/local/data.txt", "a");
- fprintf(fp, "%10d,%6.2f,%4.1f\r\n", ms, pres, temp); // 時刻,気圧,気温を出力
+ fprintf(fp, "%10d,%6.2f,%4.1f,%5.1f\r\n", ms, pres, temp, height); // 時刻,気圧,気温を出力
fclose(fp);
wait(0.05); // LED点滅