LPS22HBのライブラリ
Dependents: HYBRYD2018_IZU_ROCKET Hybrid_IZU201811_STMBBM_v4 Hybrid_IZU2019
Diff: pqLPS22HB_lib.cpp
- Revision:
- 1:42cd33e0f174
- Parent:
- 0:52880f880b81
- Child:
- 2:96d154c590f4
--- a/pqLPS22HB_lib.cpp Mon Jun 26 08:16:14 2017 +0000 +++ b/pqLPS22HB_lib.cpp Thu Aug 10 21:00:39 2017 +0000 @@ -1,5 +1,6 @@ #include "pqLPS22HB_lib.h" #include "mbed.h" +#include "math.h" /********** コンストラクタ @@ -117,3 +118,16 @@ return 20.0 + (float)(data_t[0] | data_t[1] << 8) / 480.0f; } } + +/********** +高度を計算(float) +・引数に0m地点での気圧・温度を入れる +・計算式のソース:http://www.geocities.jp/u4ren6/Main/Excel_Data0017.html +**********/ +float pqLPS22HB_lib :: getAlt(float P_0, float T_0){ + pres_0 = P_0; + temp_0 = T_0; + pres_now = getPres(); + + return -(273.0 + temp_0) / 0.0342 * log(pres_now / pres_0); +}