Files
airgradient/src/AirGradient.cpp
T

71 lines
1.6 KiB
C++
Raw Normal View History

#include "AirGradient.h"
2024-04-04 18:35:15 +07:00
#ifdef ESP8266
#include <ESP8266WiFi.h>
#else
2024-04-03 21:26:04 +07:00
#include "WiFi.h"
2024-04-04 18:35:15 +07:00
#endif
AirGradient::AirGradient(BoardType type)
: pms5003(type), pms5003t_1(type), pms5003t_2(type), s8(type), sgp41(type),
display(type), boardType(type), button(type), statusLed(type),
ledBar(type), watchdog(type), sht(type) {}
/**
* @brief Get pin number for I2C SDA
*
* @return int -1 if invalid
*/
int AirGradient::getI2cSdaPin(void) {
const BoardDef *bsp = getBoardDef(this->boardType);
if ((bsp == nullptr) || (bsp->I2C.supported == false)) {
return -1;
}
return bsp->I2C.sda_pin;
}
/**
* @brief Get pin number for I2C SCL
*
* @return int -1 if invalid
*/
int AirGradient::getI2cSclPin(void) {
const BoardDef *bsp = getBoardDef(this->boardType);
if ((bsp == nullptr) || (bsp->I2C.supported == false)) {
return -1;
}
return bsp->I2C.scl_pin;
}
2024-04-23 05:59:58 +07:00
String AirGradient::getVersion(void) { return GIT_VERSION; }
BoardType AirGradient::getBoardType(void) { return boardType; }
double AirGradient::round2(double value) {
return (int)(value * 100 + 0.5) / 100.0;
}
2024-02-29 10:22:05 +07:00
String AirGradient::getBoardName(void) {
return String(getBoardDefName(boardType));
}
2024-04-03 21:26:04 +07:00
2024-04-07 16:39:01 +07:00
/**
* @brief Board Type is ONE_INDOOR
*
* @return true ONE_INDOOR
* @return false Other
*/
bool AirGradient::isOne(void) {
2024-04-03 21:26:04 +07:00
return boardType == BoardType::ONE_INDOOR;
}
2024-06-19 15:17:48 +07:00
bool AirGradient::isPro4_2(void) {
return boardType == BoardType::DIY_PRO_INDOOR_V4_2;
}
2024-04-03 21:26:04 +07:00
String AirGradient::deviceId(void) {
String mac = WiFi.macAddress();
mac.replace(":", "");
mac.toLowerCase();
return mac;
}