Forked Changes to Pressure sensor

Dependents:   WiFiDipCortexSensor

Fork of MPL3115A2 by Michael Lange

Pressure.h

Committer:
sophtware
Date:
2014-04-01
Revision:
0:beb43bc3d6d4
Child:
3:7c7c1ea6fc33

File content as of revision 0:beb43bc3d6d4:

/*
    MPL3115A2 Barometric Pressure and Tempurature Sensor Library
    By: Michael Lange
    Date: March 31, 2014
    License: This code is public domain.
 
    This class encapsulates a pressure reading from the sensor.
 
 */
 
 
#ifndef PRESSURE_H
#define PRESSURE_H

#include "mbed.h"

class Pressure
{
public:

    static const int size = 3;
    enum unitsType { PASCALS, PSI, INHG, MMHG };

    Pressure();
    Pressure(float a, unitsType units = PASCALS);
    Pressure(const char* compressed);
    Pressure(const char msb, const char csb, const char lsb);

    operator char*(void) { return _compressed; }
    operator float(void) { return _pressure; }

    float pressure(unitsType units = PASCALS);
    void setPressure();
    void setPressure(const char* compressed);
    void setPressure(const char msb, const char csb, const char lsb);
    void setPressure(float a, unitsType units = PASCALS);

    const char* print(unitsType units = PASCALS);
    
private:
    float _pressure;
    char  _compressed[3];
    char  _printBuffer[9];
};

#endif // PRESSURE_H