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.
Fork of MS5837 by
Revision 1:a8eea2a2263f, committed 2018-08-13
- Comitter:
- CodyMarquardt
- Date:
- Mon Aug 13 18:48:45 2018 +0000
- Parent:
- 0:5f6034409fd0
- Commit message:
- copy mini glider programs to FSG group
Changed in this revision
MS5837.cpp | Show annotated file Show diff for this revision Revisions of this file |
MS5837.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/MS5837.cpp Sun May 28 10:29:51 2017 +0000 +++ b/MS5837.cpp Mon Aug 13 18:48:45 2018 +0000 @@ -19,7 +19,7 @@ /* transmit out 1 byte reset command */ ms5837_tx_data[0] = ms5837_reset; if ( i2c.write( device_address, ms5837_tx_data, 1 ) ); - printf("send soft reset\n"); + //printf("send soft reset\n\r"); wait_ms(20); } @@ -103,6 +103,30 @@ } } -float MS5837::depth(void) { - return (P_MS5837/100)*1.019716; +float MS5837::get_depth_initial(void){ + depth_iter = 0; + Depth_0 = 0; + for(int i = 0; i < 5; i++){ + Barometer_MS5837(); + depth_iter = ((P_MS5837)*1.019716); + Depth_0 = depth_iter + Depth_0; + } + Depth_0 = Depth_0/5; + if(Depth_0 < 1000 || Depth_0 > 1100){ + MS5837Init(); + get_depth_initial(); + } + return Depth_0; +} + +float MS5837::get_depth(void) { + depth_iter = 0; + depth = 0; + for(int i = 0; i <= 2; i++){ + Barometer_MS5837(); + depth_iter = ((P_MS5837)*1.019716)-Depth_0; + depth = depth_iter + depth; + } + depth = depth/3; + return depth; } \ No newline at end of file
--- a/MS5837.h Sun May 28 10:29:51 2017 +0000 +++ b/MS5837.h Mon Aug 13 18:48:45 2018 +0000 @@ -35,7 +35,7 @@ class MS5837{ private: int D1, D2, Temp, C[8]; - float T_MS5837, P_MS5837; + float T_MS5837, P_MS5837,depth_iter,depth; /* Data buffers */ char ms5837_rx_data[MS5837_RX_DEPTH]; char ms5837_tx_data[MS5837_TX_DEPTH]; @@ -54,7 +54,9 @@ float MS5837_Pressure (void); float MS5837_Temperature (void); void Barometer_MS5837(void); - float depth(void); + float get_depth(void); + float get_depth_initial(void); + float Depth_0; private: I2C i2c;