round real value with 2 decimal on server sync data json

This commit is contained in:
Phat Nguyen
2024-02-17 12:47:51 +07:00
parent 7c63af5ba9
commit 8c94cea764
5 changed files with 30 additions and 22 deletions

View File

@ -36,3 +36,7 @@ int AirGradient::getI2cSclPin(void) {
String AirGradient::getVersion(void) { return AG_LIB_VER; }
BoardType AirGradient::getBoardType(void) { return boardType; }
double AirGradient::round2(double value) {
return (int)(value * 100 + 0.5) / 100.0;
}

View File

@ -107,6 +107,14 @@ public:
*/
String getVersion(void);
/**
* @brief Round double value with for 2 decimal
*
* @param valuem Round value
* @return double
*/
double round2(double value);
private:
BoardType boardType;
};