気圧センサLPS22HBのライブラリ
Dependents: Hybrid_IZU2021_MAIN_OS5 Hybrid_IZU2021_MISSION_v2 Hybrid_IZU2021_MAIN Hybrid_IZU2021_MISSION
Revision 1:fdde28032fb5, committed 2021-03-08
- Comitter:
- tanahashi
- Date:
- Mon Mar 08 16:48:54 2021 +0000
- Parent:
- 0:9a7d5d7e63be
- Commit message:
- fixed LSB
Changed in this revision
PQ_LPS22HB.cpp | Show annotated file Show diff for this revision Revisions of this file |
PQ_LPS22HB.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/PQ_LPS22HB.cpp Tue Dec 15 15:37:50 2020 +0000 +++ b/PQ_LPS22HB.cpp Mon Mar 08 16:48:54 2021 +0000 @@ -38,7 +38,7 @@ cmd[0] = LPS22HB_PRESS_XL; _i2c -> write(_addr, cmd, 1); _i2c -> read(_addr, buff, 3); - *press = (int)(buff[0] | buff[1] << 8 | buff[2] << 16) / 4096.0f; + *press = (int)(buff[0] | buff[1] << 8 | buff[2] << 16) / LPS22HB_PRESS_LSB; } void LPS22HB :: read_temp(float *temp) @@ -46,5 +46,5 @@ cmd[0] = LPS22HB_TEMP_L; _i2c -> write(_addr, cmd, 1); _i2c -> read(_addr, buff, 2); - *temp = (short)(buff[0] | buff[1] << 8) * 0.01; + *temp = (short)(buff[0] | buff[1] << 8) * LPS22HB_TEMP_LSB; } \ No newline at end of file
--- a/PQ_LPS22HB.h Tue Dec 15 15:37:50 2020 +0000 +++ b/PQ_LPS22HB.h Mon Mar 08 16:48:54 2021 +0000 @@ -7,6 +7,8 @@ #define LPS22HB_CTRL_REG1 0x10 #define LPS22HB_PRESS_XL 0x28 #define LPS22HB_TEMP_L 0x2B +#define LPS22HB_PRESS_LSB 4096.0 +#define LPS22HB_TEMP_LSB 0.01 /** LPS22HBのライブラリ * @code