Add support board DIY Pro 3.7 and add example

This commit is contained in:
Phat Nguyen
2024-06-20 11:34:23 +07:00
parent 7560251deb
commit 0119a4d62a
13 changed files with 1099 additions and 77 deletions

View File

@ -224,7 +224,7 @@ void StateMachine::co2Calibration(void) {
/** Count down to 0 then start */
for (int i = 0; i < SENSOR_CO2_CALIB_COUNTDOWN_MAX; i++) {
if (ag->isOne() || (ag->isPro4_2())) {
if (ag->isOne() || (ag->isPro4_2()) || ag->isPro3_7()) {
String str =
"after " + String(SENSOR_CO2_CALIB_COUNTDOWN_MAX - i) + " sec";
disp.setText("Start CO2 calib", str.c_str(), "");
@ -236,13 +236,13 @@ void StateMachine::co2Calibration(void) {
}
if (ag->s8.setBaselineCalibration()) {
if (ag->isOne() || (ag->isPro4_2())) {
if (ag->isOne() || (ag->isPro4_2()) || ag->isPro3_7()) {
disp.setText("Calibration", "success", "");
} else {
logInfo("CO2 Calibration: success");
}
delay(1000);
if (ag->isOne() || (ag->isPro4_2())) {
if (ag->isOne() || (ag->isPro4_2()) || ag->isPro3_7()) {
disp.setText("Wait for", "calib finish", "...");
} else {
logInfo("CO2 Calibration: Wait for calibration finish...");
@ -254,7 +254,7 @@ void StateMachine::co2Calibration(void) {
delay(1000);
count++;
}
if (ag->isOne() || (ag->isPro4_2())) {
if (ag->isOne() || (ag->isPro4_2()) || ag->isPro3_7()) {
String str = "after " + String(count);
disp.setText("Calib finish", str.c_str(), "sec");
} else {
@ -262,7 +262,7 @@ void StateMachine::co2Calibration(void) {
}
delay(2000);
} else {
if (ag->isOne() || (ag->isPro4_2())) {
if (ag->isOne() || (ag->isPro4_2()) || ag->isPro3_7()) {
disp.setText("Calibration", "failure!!!", "");
} else {
logInfo("CO2 Calibration: failure!!!");
@ -399,7 +399,7 @@ StateMachine::~StateMachine() {}
*/
void StateMachine::displayHandle(AgStateMachineState state) {
// Ignore handle if not ONE_INDOOR board
if (!(ag->isOne() || (ag->isPro4_2()))) {
if (!(ag->isOne() || (ag->isPro4_2()) || ag->isPro3_7())) {
if (state == AgStateMachineCo2Calibration) {
co2Calibration();
}

View File

@ -19,7 +19,7 @@ String Measurements::toString(bool localServer, AgFirmwareMode fwMode, int rssi,
}
}
if (ag->isOne() || (ag->isPro4_2())) {
if (ag->isOne() || (ag->isPro4_2()) || ag->isPro3_7()) {
if (config->hasSensorPMS1) {
if (this->pm01_1 >= 0) {
root["pm01"] = this->pm01_1;

View File

@ -49,7 +49,7 @@ bool WifiConnector::connect(void) {
WIFI()->setSaveConfigCallback([this]() { _wifiSaveConfig(); });
WIFI()->setSaveParamsCallback([this]() { _wifiSaveParamCallback(); });
WIFI()->setConfigPortalTimeoutCallback([this]() {_wifiTimeoutCallback();});
if (ag->isOne() || (ag->isPro4_2())) {
if (ag->isOne() || (ag->isPro4_2()) || ag->isPro3_7()) {
disp.setText("Connecting to", "WiFi", "...");
} else {
logInfo("Connecting to WiFi...");
@ -142,7 +142,7 @@ bool WifiConnector::connect(void) {
/** Show display wifi connect result failed */
if (WiFi.isConnected() == false) {
sm.handleLeds(AgStateMachineWiFiManagerConnectFailed);
if (ag->isOne() || ag->isPro4_2()) {
if (ag->isOne() || ag->isPro4_2() || ag->isPro3_7()) {
sm.displayHandle(AgStateMachineWiFiManagerConnectFailed);
}
delay(6000);
@ -247,7 +247,7 @@ void WifiConnector::_wifiProcess() {
if (WiFi.isConnected() == false) {
/** Display countdown */
uint32_t ms;
if (ag->isOne() || (ag->isPro4_2())) {
if (ag->isOne() || (ag->isPro4_2()) || ag->isPro3_7()) {
ms = (uint32_t)(millis() - dispPeriod);
if (ms >= 1000) {
dispPeriod = millis();

View File

@ -62,6 +62,10 @@ bool AirGradient::isPro4_2(void) {
return boardType == BoardType::DIY_PRO_INDOOR_V4_2;
}
bool AirGradient::isPro3_7(void) {
return boardType == BoardType::DIY_PRO_INDOOR_V3_7;
}
String AirGradient::deviceId(void) {
String mac = WiFi.macAddress();
mac.replace(":", "");

View File

@ -141,6 +141,13 @@ public:
* @return false No
*/
bool isPro4_2(void);
/**
* @brief Check that Airgradient object is DIY_PRO 3.7 indoor
*
* @return true Yes
* @return false No
*/
bool isPro3_7(void);
/**
* @brief Get device Id

View File

@ -235,92 +235,168 @@ const BoardDef bsps[_BOARD_MAX] = {
.name = "ONE_INDOOR",
},
/** OPEN_AIR_OUTDOOR */
[OPEN_AIR_OUTDOOR] = {
.SenseAirS8 =
{
.uart_tx_pin = 1,
.uart_rx_pin = 0,
[OPEN_AIR_OUTDOOR] =
{
.SenseAirS8 =
{
.uart_tx_pin = 1,
.uart_rx_pin = 0,
#if defined(ESP8266)
.supported = false,
.supported = false,
#else
.supported = true,
.supported = true,
#endif
},
/** Use UART0 don't use define pin number */
.Pms5003 =
{
.uart_tx_pin = -1,
.uart_rx_pin = -1,
},
/** Use UART0 don't use define pin number */
.Pms5003 =
{
.uart_tx_pin = -1,
.uart_rx_pin = -1,
#if defined(ESP8266)
.supported = false,
.supported = false,
#else
.supported = true,
.supported = true,
#endif
},
.I2C =
{
.sda_pin = 7,
.scl_pin = 6,
},
.I2C =
{
.sda_pin = 7,
.scl_pin = 6,
#if defined(ESP8266)
.supported = false,
.supported = false,
#else
.supported = true,
.supported = true,
#endif
},
.SW =
{
},
.SW =
{
#if defined(ESP8266)
.pin = -1,
.activeLevel = 1,
.supported = false,
.pin = -1,
.activeLevel = 1,
.supported = false,
#else
.pin = 9,
.activeLevel = 0,
.supported = true,
.pin = 9,
.activeLevel = 0,
.supported = true,
#endif
},
.LED =
{
},
.LED =
{
#if defined(ESP8266)
.pin = -1,
.rgbNum = 0,
.onState = 0,
.supported = false,
.rgbSupported = false,
.pin = -1,
.rgbNum = 0,
.onState = 0,
.supported = false,
.rgbSupported = false,
#else
.pin = 10,
.rgbNum = 0,
.onState = 1,
.supported = true,
.rgbSupported = false,
.pin = 10,
.rgbNum = 0,
.onState = 1,
.supported = true,
.rgbSupported = false,
#endif
},
.OLED =
{
},
.OLED =
{
#if defined(ESP8266)
.width = 0,
.height = 0,
.addr = 0,
.supported = false,
.width = 0,
.height = 0,
.addr = 0,
.supported = false,
#else
.width = 128,
.height = 64,
.addr = 0x3C,
.supported = true,
.width = 128,
.height = 64,
.addr = 0x3C,
.supported = true,
#endif
},
.WDG =
{
},
.WDG =
{
#if defined(ESP8266)
.resetPin = -1,
.supported = false,
.resetPin = -1,
.supported = false,
#else
.resetPin = 2,
.supported = true,
.resetPin = 2,
.supported = true,
#endif
},
.name = "OPEN_AIR_OUTDOOR",
}};
},
.name = "OPEN_AIR_OUTDOOR",
},
/** DIY_PRO_INDOOR_V3_7 */
[DIY_PRO_INDOOR_V3_7] =
{
.SenseAirS8 =
{
.uart_tx_pin = 2,
.uart_rx_pin = 0,
#if defined(ESP8266)
.supported = true,
#else
.supported = false,
#endif
},
.Pms5003 =
{
.uart_tx_pin = 14,
.uart_rx_pin = 12,
#if defined(ESP8266)
.supported = true,
#else
.supported = false,
#endif
},
.I2C =
{
.sda_pin = 4,
.scl_pin = 5,
#if defined(ESP8266)
.supported = true,
#else
.supported = false,
#endif
},
.SW =
{
#if defined(ESP8266)
.pin = -1, /** D7 */
.activeLevel = 0,
.supported = false,
#else
.pin = -1,
.activeLevel = 1,
.supported = false,
#endif
},
.LED =
{
.pin = -1,
.rgbNum = 0,
.onState = 0,
.supported = false,
.rgbSupported = false,
},
.OLED =
{
#if defined(ESP8266)
.width = 128,
.height = 64,
.addr = 0x3C,
.supported = true,
#else
.width = 0,
.height = 0,
.addr = 0,
.supported = false,
#endif
},
.WDG =
{
.resetPin = -1,
.supported = false,
},
.name = "DIY_PRO_INDOOR_V3_7",
},
};
/**
* @brief Get Board Support Package
@ -337,9 +413,9 @@ const BoardDef *getBoardDef(BoardType def) {
/**
* @brief Get the Board Name
*
*
* @param type BoarType
* @return const char*
* @return const char*
*/
const char *getBoardDefName(BoardType type) {
if (type >= _BOARD_MAX) {

View File

@ -21,6 +21,7 @@ enum BoardType {
DIY_PRO_INDOOR_V4_2 = 0x01,
ONE_INDOOR = 0x02,
OPEN_AIR_OUTDOOR = 0x03,
DIY_PRO_INDOOR_V3_7 = 0x04,
_BOARD_MAX
};