forked from airgradienthq/arduino
Update comment
This commit is contained in:
@@ -1,6 +1,13 @@
|
|||||||
#include "PMS.h"
|
#include "PMS.h"
|
||||||
#include "../Main/BoardDef.h"
|
#include "../Main/BoardDef.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Init and check that sensor has connected
|
||||||
|
*
|
||||||
|
* @param stream UART stream
|
||||||
|
* @return true Sucecss
|
||||||
|
* @return false Failure
|
||||||
|
*/
|
||||||
bool PMSBase::begin(Stream *stream) {
|
bool PMSBase::begin(Stream *stream) {
|
||||||
this->stream = stream;
|
this->stream = stream;
|
||||||
|
|
||||||
@@ -26,7 +33,8 @@ bool PMSBase::begin(Stream *stream) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read PMS data as 1.5sec period
|
* @brief Check and read sensor data then update variable.
|
||||||
|
* Check result from method @isFailed before get value
|
||||||
*/
|
*/
|
||||||
void PMSBase::handle() {
|
void PMSBase::handle() {
|
||||||
uint32_t ms;
|
uint32_t ms;
|
||||||
@@ -37,8 +45,12 @@ void PMSBase::handle() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ms = (uint32_t)(millis() - lastRead);
|
ms = (uint32_t)(millis() - lastRead);
|
||||||
/** Ignore read data if two time call less then 1sec. In active mode the
|
/**
|
||||||
* data sync perido is 1sec. Two times read must be large or equal 2.5sec */
|
* The PMS in Active mode sends an update data every 1 second. If we read
|
||||||
|
* exactly every 1 sec then we may or may not get an update (depending on
|
||||||
|
* timing tolerances). Hence we read every 2.5 seconds and expect 2 ..3
|
||||||
|
* updates,
|
||||||
|
*/
|
||||||
if (ms < 2500) {
|
if (ms < 2500) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -109,7 +121,7 @@ void PMSBase::handle() {
|
|||||||
|
|
||||||
// Reduce core panic: delay 1 ms each 32bytes data
|
// Reduce core panic: delay 1 ms each 32bytes data
|
||||||
bcount++;
|
bcount++;
|
||||||
if((bcount % 32) == 0){
|
if ((bcount % 32) == 0) {
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -148,6 +148,16 @@ void PMS5003::end(void) {
|
|||||||
AgLog("De-initialize");
|
AgLog("De-initialize");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check and read PMS sensor data. This method should be callack from
|
||||||
|
* loop process to continoue check sensor data if it's available
|
||||||
|
*/
|
||||||
void PMS5003::handle(void) { pms.handle(); }
|
void PMS5003::handle(void) { pms.handle(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get sensor status
|
||||||
|
*
|
||||||
|
* @return true No problem
|
||||||
|
* @return false Communication timeout or sensor has removed
|
||||||
|
*/
|
||||||
bool PMS5003::isFailed(void) { return pms.isFailed(); }
|
bool PMS5003::isFailed(void) { return pms.isFailed(); }
|
||||||
|
@@ -198,18 +198,25 @@ void PMS5003T::end(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read PMS on loop
|
* @brief Check and read PMS sensor data. This method should be callack from
|
||||||
*
|
* loop process to continoue check sensor data if it's available
|
||||||
*/
|
*/
|
||||||
void PMS5003T::handle(void) { pms.handle(); }
|
void PMS5003T::handle(void) { pms.handle(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get PMS status
|
* @brief Get sensor status
|
||||||
* @return true Failed
|
*
|
||||||
* @return false No Problem
|
* @return true No problem
|
||||||
|
* @return false Communication timeout or sensor has removed
|
||||||
*/
|
*/
|
||||||
bool PMS5003T::isFailed(void) { return pms.isFailed(); }
|
bool PMS5003T::isFailed(void) { return pms.isFailed(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Correct the PMS5003T relactive humidity
|
||||||
|
*
|
||||||
|
* @param inHum Input humidity
|
||||||
|
* @return float Corrected humidity
|
||||||
|
*/
|
||||||
float PMS5003T::correctionRelativeHumidity(float inHum) {
|
float PMS5003T::correctionRelativeHumidity(float inHum) {
|
||||||
float hum = inHum * 1.259 + 7.34;
|
float hum = inHum * 1.259 + 7.34;
|
||||||
if (hum > 100.0f) {
|
if (hum > 100.0f) {
|
||||||
|
Reference in New Issue
Block a user