mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-15 08:56:34 +02:00
Move common function to separate file
This commit is contained in:
@ -202,18 +202,3 @@ void PMS5003T::handle(void) { pms.handle(); }
|
|||||||
*/
|
*/
|
||||||
bool PMS5003T::isFailed(void) { return pms.isFailed(); }
|
bool PMS5003T::isFailed(void) { return pms.isFailed(); }
|
||||||
|
|
||||||
float PMS5003T::temperatureCompensated(float temp) {
|
|
||||||
if (temp < 10.0f) {
|
|
||||||
return temp * 1.327f - 6.738f;
|
|
||||||
}
|
|
||||||
return temp * 1.181f - 5.113f;
|
|
||||||
}
|
|
||||||
|
|
||||||
float PMS5003T::humidityCompensated(float hum) {
|
|
||||||
hum = hum * 1.259f + 7.34f;
|
|
||||||
|
|
||||||
if (hum > 100.0f) {
|
|
||||||
hum = 100.0f;
|
|
||||||
}
|
|
||||||
return hum;
|
|
||||||
}
|
|
||||||
|
@ -3,13 +3,14 @@
|
|||||||
|
|
||||||
#include "../Main/BoardDef.h"
|
#include "../Main/BoardDef.h"
|
||||||
#include "PMS.h"
|
#include "PMS.h"
|
||||||
|
#include "PMS5003TBase.h"
|
||||||
#include "Stream.h"
|
#include "Stream.h"
|
||||||
#include <HardwareSerial.h>
|
#include <HardwareSerial.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The class define how to handle PMS5003T sensor bas on @ref PMS class
|
* @brief The class define how to handle PMS5003T sensor bas on @ref PMS class
|
||||||
*/
|
*/
|
||||||
class PMS5003T {
|
class PMS5003T: public PMS5003TBase {
|
||||||
public:
|
public:
|
||||||
PMS5003T(BoardType def);
|
PMS5003T(BoardType def);
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
@ -28,8 +29,6 @@ public:
|
|||||||
int convertPm25ToUsAqi(int pm25);
|
int convertPm25ToUsAqi(int pm25);
|
||||||
float getTemperature(void);
|
float getTemperature(void);
|
||||||
float getRelativeHumidity(void);
|
float getRelativeHumidity(void);
|
||||||
float temperatureCompensated(float temp);
|
|
||||||
float humidityCompensated(float hum);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _isBegin = false;
|
bool _isBegin = false;
|
||||||
|
21
src/PMS/PMS5003TBase.cpp
Normal file
21
src/PMS/PMS5003TBase.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include "PMS5003TBase.h"
|
||||||
|
|
||||||
|
PMS5003TBase::PMS5003TBase() {}
|
||||||
|
|
||||||
|
PMS5003TBase::~PMS5003TBase() {}
|
||||||
|
|
||||||
|
float PMS5003TBase::temperatureCompensated(float temp) {
|
||||||
|
if (temp < 10.0f) {
|
||||||
|
return temp * 1.327f - 6.738f;
|
||||||
|
}
|
||||||
|
return temp * 1.181f - 5.113f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float PMS5003TBase::humidityCompensated(float hum) {
|
||||||
|
hum = hum * 1.259f + 7.34f;
|
||||||
|
|
||||||
|
if (hum > 100.0f) {
|
||||||
|
hum = 100.0f;
|
||||||
|
}
|
||||||
|
return hum;
|
||||||
|
}
|
15
src/PMS/PMS5003TBase.h
Normal file
15
src/PMS/PMS5003TBase.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef _PMS5003T_BASE_H_
|
||||||
|
#define _PMS5003T_BASE_H_
|
||||||
|
|
||||||
|
class PMS5003TBase
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
|
||||||
|
public:
|
||||||
|
PMS5003TBase();
|
||||||
|
~PMS5003TBase();
|
||||||
|
float temperatureCompensated(float temp);
|
||||||
|
float humidityCompensated(float hum);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user