ESP-Ventilation/esp-vent-main/inc/PressureWrapper.h
2022-10-24 16:16:49 +03:00

63 lines
925 B
C++

/*
* PressureWrapper.h
*
* Created on: 5 Oct 2022
* Author: evgenymeshcheryakov
*/
#ifndef PRESSUREWRAPPER_H_
#define PRESSUREWRAPPER_H_
#include "I2C.h"
#include <cstdio>
#define ADDRESS 0x40
/**
* @brief structure to hold a raw data from
* the pressure sensor
*/
typedef struct _PRESSURE
{
uint8_t rBuffer[2];
uint8_t crc;
} PRESSURE_DATA;
class PressureWrapper
{
public:
PressureWrapper ();
/*
* @return pressure in Pascal
*/
int getPressure ();
/**
* @brief Check if sensor is ready
*
* @return true if awake
* @return false if asleep
*/
bool isAwake ();
/**
* @brief Wake the sensor up
*
*/
void wakeUp ();
virtual ~PressureWrapper ();
private:
I2C *i2c;
PRESSURE_DATA data = { { 0, 0 }, 0 };
/*
* @return struct with pressure data in
* rBuffer and CRC check in crc
*/
bool getRawPressure ();
};
#endif /* PRESSUREWRAPPER_H_ */