You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.7 KiB
79 lines
2.7 KiB
#pragma once
|
|
#include <stddef.h>
|
|
#include <stdio.h>
|
|
|
|
#include "base/config_service.hpp"
|
|
#include "stm32basic/modbus/modbus_block_host.hpp"
|
|
#include "stm32basic/zsdk.hpp"
|
|
|
|
namespace iflytop {
|
|
|
|
#define PXX_PRESSURE_SENSOR_NUM 10
|
|
|
|
class HPP272 {
|
|
public:
|
|
#pragma pack(1)
|
|
typedef struct {
|
|
uint16_t hydrogen_peroxide_volume; // ppm 0x0100
|
|
uint16_t h2o_h2o2_rs; // %RS * 100
|
|
uint16_t temperature1; // °C * 100
|
|
uint16_t relative_humidity; // %RH * 100
|
|
uint16_t absolute_hydrogen_peroxide; // mg/m3
|
|
uint16_t h2o_h2o2dew_point_temperature; // °C * 100
|
|
uint16_t reserved1; //
|
|
uint16_t water_volume; // ppm
|
|
uint16_t water_vapor_pressure; // hpa
|
|
uint16_t absolute_humidity; // g/m3
|
|
uint16_t water_vapor_saturation_pressure_h2o; // hpa
|
|
uint16_t temperature2; // °C * 100
|
|
uint16_t h2o2_vapor_pressure; // hpa
|
|
uint16_t water_vapor_saturation_pressure_h2o_h2o2; // hpa
|
|
} hpp272_data_t;
|
|
#pragma pack()
|
|
|
|
private:
|
|
/***********************************************************************************************************************
|
|
* DATA *
|
|
***********************************************************************************************************************/
|
|
|
|
ModbusBlockHost* m_modbusBlockHost = NULL;
|
|
|
|
int32_t m_id = 0;
|
|
zmutex m_lock;
|
|
|
|
hpp272_data_t m_readbuf;
|
|
|
|
hpp272_data_t m_cachedata;
|
|
int32_t m_cache_errorcode = 0;
|
|
zmutex m_cache_lock;
|
|
|
|
public:
|
|
/***********************************************************************************************************************
|
|
* FUNC *
|
|
***********************************************************************************************************************/
|
|
|
|
/**
|
|
* @brief
|
|
*
|
|
* @param modbusBlockHost
|
|
*/
|
|
void init(ModbusBlockHost* modbusBlockHost);
|
|
|
|
bool ping(int id);
|
|
bool ping();
|
|
void setid(int32_t id);
|
|
|
|
void read_calibration_date(int32_t* year, int32_t* month, int32_t* day); // TODO
|
|
int32_t read_errorcode(); // see datasheet page83
|
|
bool read_reg(int32_t add, uint16_t* val, size_t len);
|
|
bool read_sensor_data(hpp272_data_t* sensordata);
|
|
|
|
void updateSensorDataAndErrorcode();
|
|
|
|
int32_t read_cache_errorcode();
|
|
bool read_cache_sensor_data(hpp272_data_t* sensordata);
|
|
|
|
public:
|
|
};
|
|
|
|
} // namespace iflytop
|