Correction de la lib car erreur de format dans les calculs

Files at this revision

API Documentation at this revision

Comitter:
sandwich
Date:
Wed Aug 06 17:27:29 2014 +0000
Parent:
2:3e5c7afef8f8
Child:
4:ff505486c804
Commit message:
added controller class for hysteresis. Video taking works now as do servos , motor control, and IMU. Not using interrupts anymore

Changed in this revision

MS5803.cpp Show annotated file Show diff for this revision Revisions of this file
MS5803.h Show annotated file Show diff for this revision Revisions of this file
--- a/MS5803.cpp	Thu Jul 24 04:59:22 2014 +0000
+++ b/MS5803.cpp	Wed Aug 06 17:27:29 2014 +0000
@@ -18,10 +18,10 @@
     THE SOFTWARE.
 
   * Library for Pressure Sensors of type MS5803-x of MEAS Switzerland     (www.meas-spec.com).
-  * The driver uses I2C mode (sensor's Protocol Select (PS) pin pulled to high). 
+  * The driver uses I2C mode (sensor's Protocol Select (PS) pin pulled to high).
   * MS5803-01BA was successfully tested by Raig Kaufer.
   * MS5803-14BA (Underwater Pressure Sensor 14 bar) was successfully tested by Robert Katzschmann
-  * Other types of MEAS are compatible but not tested 
+  * Other types of MEAS are compatible but not tested
   * Written by Raig Kaufer, distribute freely!
   * Revised by Robert Katzschmann
  */
@@ -34,17 +34,26 @@
  * Sensor operating function according data sheet
  */
 
+void MS5803::MS5803Init(void)
+{
+    MS5803Reset();
+    MS5803ReadProm();
+    return;
+}
+
 /* Send soft reset to the sensor */
-void MS5803::MS5803Reset(void) {
+void MS5803::MS5803Reset(void)
+{
     /* transmit out 1 byte reset command */
     ms5803_tx_data[0] = ms5803_reset;
     if ( i2c.write( device_address,  ms5803_tx_data, 1 ) );
-    printf("send soft reset");
+    //printf("send soft reset");
     wait_ms(20);
 }
 
 /* read the sensor calibration data from rom */
-void MS5803::MS5803ReadProm(void) {
+void MS5803::MS5803ReadProm(void)
+{
     uint8_t i,j;
     for (i=0; i<8; i++) {
         j = i;
@@ -56,19 +65,22 @@
 }
 
 /* Start the sensor pressure conversion */
-void MS5803::MS5803ConvertD1(void) {
+void MS5803::MS5803ConvertD1(void)
+{
     ms5803_tx_data[0] = ms5803_convD1;
     if ( i2c.write( device_address,  ms5803_tx_data, 1 ) );
 }
 
 /* Start the sensor temperature conversion */
-void MS5803:: MS5803ConvertD2(void) {
+void MS5803:: MS5803ConvertD2(void)
+{
     ms5803_tx_data[0] = ms5803_convD2;
     if ( i2c.write( device_address,  ms5803_tx_data, 1 ) );
 }
 
-/* Read the privious started conversion results */
-int32_t MS5803::MS5803ReadADC(void) {
+/* Read the previous started conversion results */
+int32_t MS5803::MS5803ReadADC(void)
+{
     int32_t adc;
     wait_ms(150);
     ms5803_tx_data[0] = ms5803_ADCread;
@@ -79,20 +91,26 @@
 }
 
 /* return the results */
-float MS5803::MS5803_Pressure (void) {
+float MS5803::MS5803_Pressure (void)
+{
     return P_MS5803;
 }
-float MS5803::MS5803_Temperature (void) {
+float MS5803::MS5803_Temperature (void)
+{
     return T_MS5803;
 }
 
 /* Sensor reading and calculation procedure */
-void MS5803::Barometer_MS5803(void) {
+void MS5803::Barometer_MS5803(void)
+{
     int32_t dT, temp;
     int64_t OFF, SENS, press;
 
-    MS5803Reset();                 // reset the sensor
-    MS5803ReadProm();             // read the calibration values
+    //no need to do this everytime!
+    //MS5803Reset();                 // reset the sensor
+    //MS5803ReadProm();             // read the calibration values
+    
+    
     MS5803ConvertD1();             // start pressure conversion
     D1 = MS5803ReadADC();        // read the pressure value
     MS5803ConvertD2();             // start temperature conversion
--- a/MS5803.h	Thu Jul 24 04:59:22 2014 +0000
+++ b/MS5803.h	Wed Aug 06 17:27:29 2014 +0000
@@ -58,7 +58,7 @@
 #define ms5803_ADCread     0x00 // read ADC command
 #define ms5803_PROMread    0xA0 // read PROM command base address
 
-class MS5803 : public Base {
+class MS5803{
 private:
     int D1, D2, Temp, C[8];
     float T_MS5803, P_MS5803;
@@ -71,6 +71,7 @@
             char ms5803_addr = ms5803_addrCH  )
             : i2c( sda, scl ), device_address( ms5803_addr << 1 ) {
     }
+    void MS5803Init(void);
     void MS5803Reset(void);
     void MS5803ReadProm(void);
     void MS5803ConvertD1(void);