pressure-wrapper: add structure for pressure_data

This commit is contained in:
Evgenii Meshcheriakov
2022-10-17 10:40:14 +03:00
parent 1524171e31
commit 98ae07bc18
5 changed files with 45 additions and 6 deletions

View File

@@ -15,10 +15,15 @@
#define READADD 0x81
#define WRITEADD 0x80
typedef struct _PRESSURE{
uint8_t rBuffer[2];
uint8_t crc;
}PRESSURE_DATA;
class PressureWrapper
{
public:
PressureWrapper ();
PressureWrapper (I2C *i2c);
/**
* @brief Get the Status object
*
@@ -26,12 +31,13 @@ public:
* @return false
*/
bool getStatus ();
int16_t getPressure ();
PRESSURE_DATA* getPressure ();
virtual ~PressureWrapper ();
private:
I2C *i2c;
PRESSURE_DATA data = {{0, 0}, 0};
};
#endif /* PRESSUREWRAPPER_H_ */

View File

@@ -7,12 +7,25 @@
#include <PressureWrapper.h>
PressureWrapper::PressureWrapper ()
PressureWrapper::PressureWrapper (I2C *i2c) : i2c(i2c)
{
// TODO Auto-generated constructor stub
}
PressureWrapper::~PressureWrapper ()
{
// TODO Auto-generated destructor stub
}
bool PressureWrapper::getStatus() {
uint8_t control_register = 0x01;
uint8_t status = 0;
i2c->transaction(ADDRESS, &control_register, 1, &status, 1);
}
PRESSURE_DATA* PressureWrapper::getPressure () {
uint8_t getMeasurementComm = 0xF1;
i2c->transaction(ADDRESS, &getMeasurementComm, 1, data.rBuffer, 3);
//i2c->transaction(ADDRESS, &getMeasurementComm, 1, data.crc, 1);
return &data;
}