From e55f3b6e74f56adffda7ef7760b1b2c1318d031f Mon Sep 17 00:00:00 2001 From: Phat Nguyen Date: Thu, 15 Feb 2024 11:21:04 +0700 Subject: [PATCH 1/5] LED Test on Button --- examples/ONE_I-9PSL/ONE_I-9PSL.ino | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/ONE_I-9PSL/ONE_I-9PSL.ino b/examples/ONE_I-9PSL/ONE_I-9PSL.ino index 1431182..628da16 100644 --- a/examples/ONE_I-9PSL/ONE_I-9PSL.ino +++ b/examples/ONE_I-9PSL/ONE_I-9PSL.ino @@ -986,6 +986,11 @@ static void boardInit(void) { if (ag.pms5003.begin(Serial0) == false) { failedHandler("Init PMS5003 failed"); } + + /** Run LED test on start up */ + if (ag.button.getState() == ag.button.BUTTON_PRESSED) { + ledTest(); + } } /** From 28e5aa4e69015179a63b79651d44d4eb96564eed Mon Sep 17 00:00:00 2001 From: Phat Nguyen Date: Thu, 15 Feb 2024 13:40:42 +0700 Subject: [PATCH 2/5] LED test update: support country `TH` and Show display `Press now for LED test` --- examples/ONE_I-9PSL/ONE_I-9PSL.ino | 49 ++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/examples/ONE_I-9PSL/ONE_I-9PSL.ino b/examples/ONE_I-9PSL/ONE_I-9PSL.ino index 628da16..16f6d51 100644 --- a/examples/ONE_I-9PSL/ONE_I-9PSL.ino +++ b/examples/ONE_I-9PSL/ONE_I-9PSL.ino @@ -194,7 +194,9 @@ public: /** Get "country" */ if (JSON.typeof_(root["country"]) == "string") { - String country = root["country"]; + String _country = root["country"]; + country = _country; + if (country == "US") { inF = true; } else { @@ -406,6 +408,13 @@ public: */ UseLedBar getLedBarMode(void) { return ledBarMode; } + /** + * @brief Get the Country + * + * @return String + */ + String getCountry(void) { return country; } + private: bool inF; /** Temperature unit, true: F, false: C */ bool inUSAQI; /** PMS unit, true: USAQI, false: ugm3 */ @@ -417,6 +426,7 @@ private: UseLedBar ledBarMode = UseLedBarCO2; /** */ char models[20]; /** */ char mqttBroker[256]; /** */ + String country; /***/ }; AgServer agServer; @@ -597,6 +607,19 @@ static void ledTest() { ag.ledBar.show(); delay(1000); } +static void ledTest2Min(void) { + uint32_t tstart = millis(); + + Serial.println("Start run LED test for 2 min"); + while (1) { + ledTest(); + uint32_t ms = (uint32_t)(millis() - tstart); + if (ms >= (60 * 1000 * 2)) { + Serial.println("LED test after 2 min finish"); + break; + } + } +} static void co2Poll(void) { co2Ppm = ag.s8.getCo2(); @@ -814,6 +837,8 @@ static void connectToWifi() { dispSmState = APP_SM_WIFI_MANAGER_STA_CONNECTING; ledSmState = APP_SM_WIFI_MANAGER_STA_CONNECTING; }); + + displayShowText("Connecting to", "config WiFi", "..."); wifiManager.autoConnect(wifiSSID.c_str(), WIFI_HOTSPOT_PASSWORD_DEFAULT); xTaskCreate( [](void *obj) { @@ -988,7 +1013,21 @@ static void boardInit(void) { } /** Run LED test on start up */ - if (ag.button.getState() == ag.button.BUTTON_PRESSED) { + displayShowText("Press now for", "LED test", ""); + bool test = false; + uint32_t stime = millis(); + while (1) { + if (ag.button.getState() == ag.button.BUTTON_PRESSED) { + test = true; + break; + } + delay(1); + uint32_t ms = (uint32_t)(millis() - stime); + if (ms >= 3000) { + break; + } + } + if (test) { ledTest(); } } @@ -1019,7 +1058,11 @@ static void serverConfigPoll(void) { } } if (agServer.isLedBarTestRequested()) { - ledTest(); + if (agServer.getCountry() == "TH") { + ledTest2Min(); + } else { + ledTest(); + } } } } From 5602a456a792e3be348839286e5fdc146a5fe9ff Mon Sep 17 00:00:00 2001 From: Phat Nguyen Date: Thu, 15 Feb 2024 19:48:58 +0700 Subject: [PATCH 3/5] fix: wrong config key for PM Standard --- examples/BASIC_v4/BASIC_v4.ino | 6 +++--- examples/ONE_I-9PSL/ONE_I-9PSL.ino | 6 +++--- examples/Open_Air_O-1PP/Open_Air_O-1PP.ino | 6 +++--- examples/Open_Air_O-1PPT/Open_Air_O-1PPT.ino | 6 +++--- examples/Open_Air_O-1PST/Open_Air_O-1PST.ino | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/BASIC_v4/BASIC_v4.ino b/examples/BASIC_v4/BASIC_v4.ino index c816ab4..2090a24 100644 --- a/examples/BASIC_v4/BASIC_v4.ino +++ b/examples/BASIC_v4/BASIC_v4.ino @@ -160,9 +160,9 @@ public: } } - /** Get "pmsStandard" */ - if (JSON.typeof_(root["pmsStandard"]) == "string") { - String standard = root["pmsStandard"]; + /** Get "pmStandard" */ + if (JSON.typeof_(root["pmStandard"]) == "string") { + String standard = root["pmStandard"]; if (standard == "ugm3") { inUSAQI = false; } else { diff --git a/examples/ONE_I-9PSL/ONE_I-9PSL.ino b/examples/ONE_I-9PSL/ONE_I-9PSL.ino index 16f6d51..df70745 100644 --- a/examples/ONE_I-9PSL/ONE_I-9PSL.ino +++ b/examples/ONE_I-9PSL/ONE_I-9PSL.ino @@ -204,9 +204,9 @@ public: } } - /** Get "pmsStandard" */ - if (JSON.typeof_(root["pmsStandard"]) == "string") { - String standard = root["pmsStandard"]; + /** Get "pmStandard" */ + if (JSON.typeof_(root["pmStandard"]) == "string") { + String standard = root["pmStandard"]; if (standard == "ugm3") { inUSAQI = false; } else { diff --git a/examples/Open_Air_O-1PP/Open_Air_O-1PP.ino b/examples/Open_Air_O-1PP/Open_Air_O-1PP.ino index f726db3..d263232 100644 --- a/examples/Open_Air_O-1PP/Open_Air_O-1PP.ino +++ b/examples/Open_Air_O-1PP/Open_Air_O-1PP.ino @@ -197,9 +197,9 @@ public: } } - /** Get "pmsStandard" */ - if (JSON.typeof_(root["pmsStandard"]) == "string") { - String standard = root["pmsStandard"]; + /** Get "pmStandard" */ + if (JSON.typeof_(root["pmStandard"]) == "string") { + String standard = root["pmStandard"]; if (standard == "ugm3") { inUSAQI = false; } else { diff --git a/examples/Open_Air_O-1PPT/Open_Air_O-1PPT.ino b/examples/Open_Air_O-1PPT/Open_Air_O-1PPT.ino index e95198b..7e01b7a 100644 --- a/examples/Open_Air_O-1PPT/Open_Air_O-1PPT.ino +++ b/examples/Open_Air_O-1PPT/Open_Air_O-1PPT.ino @@ -197,9 +197,9 @@ public: } } - /** Get "pmsStandard" */ - if (JSON.typeof_(root["pmsStandard"]) == "string") { - String standard = root["pmsStandard"]; + /** Get "pmStandard" */ + if (JSON.typeof_(root["pmStandard"]) == "string") { + String standard = root["pmStandard"]; if (standard == "ugm3") { inUSAQI = false; } else { diff --git a/examples/Open_Air_O-1PST/Open_Air_O-1PST.ino b/examples/Open_Air_O-1PST/Open_Air_O-1PST.ino index 8a8eed2..e8e2516 100644 --- a/examples/Open_Air_O-1PST/Open_Air_O-1PST.ino +++ b/examples/Open_Air_O-1PST/Open_Air_O-1PST.ino @@ -201,9 +201,9 @@ public: } } - /** Get "pmsStandard" */ - if (JSON.typeof_(root["pmsStandard"]) == "string") { - String standard = root["pmsStandard"]; + /** Get "pmStandard" */ + if (JSON.typeof_(root["pmStandard"]) == "string") { + String standard = root["pmStandard"]; if (standard == "ugm3") { inUSAQI = false; } else { From 67ad912a71b927fbcb2463879ea2c791e0130291 Mon Sep 17 00:00:00 2001 From: Phat Nguyen Date: Thu, 15 Feb 2024 19:55:17 +0700 Subject: [PATCH 4/5] update `DISPLAY_DELAY_SHOW_CONTENT_MS` from `3000` to `6000` --- examples/BASIC_v4/BASIC_v4.ino | 2 +- examples/ONE_I-9PSL/ONE_I-9PSL.ino | 2 +- examples/Open_Air_O-1PP/Open_Air_O-1PP.ino | 2 +- examples/Open_Air_O-1PPT/Open_Air_O-1PPT.ino | 2 +- examples/Open_Air_O-1PST/Open_Air_O-1PST.ino | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/BASIC_v4/BASIC_v4.ino b/examples/BASIC_v4/BASIC_v4.ino index 2090a24..a967c6b 100644 --- a/examples/BASIC_v4/BASIC_v4.ino +++ b/examples/BASIC_v4/BASIC_v4.ino @@ -51,7 +51,7 @@ CC BY-SA 4.0 Attribution-ShareAlike 4.0 International License #define SENSOR_CO2_UPDATE_INTERVAL 5000 /** ms */ #define SENSOR_PM_UPDATE_INTERVAL 5000 /** ms */ #define SENSOR_TEMP_HUM_UPDATE_INTERVAL 5000 /** ms */ -#define DISPLAY_DELAY_SHOW_CONTENT_MS 3000 /** ms */ +#define DISPLAY_DELAY_SHOW_CONTENT_MS 6000 /** ms */ #define WIFI_HOTSPOT_PASSWORD_DEFAULT \ "cleanair" /** default WiFi AP password \ */ diff --git a/examples/ONE_I-9PSL/ONE_I-9PSL.ino b/examples/ONE_I-9PSL/ONE_I-9PSL.ino index df70745..9023103 100644 --- a/examples/ONE_I-9PSL/ONE_I-9PSL.ino +++ b/examples/ONE_I-9PSL/ONE_I-9PSL.ino @@ -94,7 +94,7 @@ enum { #define SENSOR_CO2_UPDATE_INTERVAL 5000 /** ms */ #define SENSOR_PM_UPDATE_INTERVAL 5000 /** ms */ #define SENSOR_TEMP_HUM_UPDATE_INTERVAL 5000 /** ms */ -#define DISPLAY_DELAY_SHOW_CONTENT_MS 3000 /** ms */ +#define DISPLAY_DELAY_SHOW_CONTENT_MS 6000 /** ms */ #define WIFI_HOTSPOT_PASSWORD_DEFAULT \ "cleanair" /** default WiFi AP password \ */ diff --git a/examples/Open_Air_O-1PP/Open_Air_O-1PP.ino b/examples/Open_Air_O-1PP/Open_Air_O-1PP.ino index d263232..4529758 100644 --- a/examples/Open_Air_O-1PP/Open_Air_O-1PP.ino +++ b/examples/Open_Air_O-1PP/Open_Air_O-1PP.ino @@ -89,7 +89,7 @@ enum { #define SENSOR_CO2_UPDATE_INTERVAL 5000 /** ms */ #define SENSOR_PM_UPDATE_INTERVAL 5000 /** ms */ #define SENSOR_TEMP_HUM_UPDATE_INTERVAL 5000 /** ms */ -#define DISPLAY_DELAY_SHOW_CONTENT_MS 3000 /** ms */ +#define DISPLAY_DELAY_SHOW_CONTENT_MS 6000 /** ms */ #define WIFI_HOTSPOT_PASSWORD_DEFAULT \ "cleanair" /** default WiFi AP password \ */ diff --git a/examples/Open_Air_O-1PPT/Open_Air_O-1PPT.ino b/examples/Open_Air_O-1PPT/Open_Air_O-1PPT.ino index 7e01b7a..231a5a1 100644 --- a/examples/Open_Air_O-1PPT/Open_Air_O-1PPT.ino +++ b/examples/Open_Air_O-1PPT/Open_Air_O-1PPT.ino @@ -89,7 +89,7 @@ enum { #define SENSOR_CO2_UPDATE_INTERVAL 5000 /** ms */ #define SENSOR_PM_UPDATE_INTERVAL 5000 /** ms */ #define SENSOR_TEMP_HUM_UPDATE_INTERVAL 5000 /** ms */ -#define DISPLAY_DELAY_SHOW_CONTENT_MS 3000 /** ms */ +#define DISPLAY_DELAY_SHOW_CONTENT_MS 6000 /** ms */ #define WIFI_HOTSPOT_PASSWORD_DEFAULT \ "cleanair" /** default WiFi AP password \ */ diff --git a/examples/Open_Air_O-1PST/Open_Air_O-1PST.ino b/examples/Open_Air_O-1PST/Open_Air_O-1PST.ino index e8e2516..3e47cd2 100644 --- a/examples/Open_Air_O-1PST/Open_Air_O-1PST.ino +++ b/examples/Open_Air_O-1PST/Open_Air_O-1PST.ino @@ -93,7 +93,7 @@ enum { #define SENSOR_CO2_UPDATE_INTERVAL 5000 /** ms */ #define SENSOR_PM_UPDATE_INTERVAL 5000 /** ms */ #define SENSOR_TEMP_HUM_UPDATE_INTERVAL 5000 /** ms */ -#define DISPLAY_DELAY_SHOW_CONTENT_MS 3000 /** ms */ +#define DISPLAY_DELAY_SHOW_CONTENT_MS 6000 /** ms */ #define WIFI_HOTSPOT_PASSWORD_DEFAULT \ "cleanair" /** default WiFi AP password \ */ From 7ea43fdc7da17f9da9fd6a2ebdd85bf2e539aa6b Mon Sep 17 00:00:00 2001 From: Phat Nguyen Date: Thu, 15 Feb 2024 19:56:46 +0700 Subject: [PATCH 5/5] Update lib version string: `3.0.1` --- src/AirGradient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AirGradient.cpp b/src/AirGradient.cpp index 81743eb..600ce24 100644 --- a/src/AirGradient.cpp +++ b/src/AirGradient.cpp @@ -1,6 +1,6 @@ #include "AirGradient.h" -#define AG_LIB_VER "3.0.0" +#define AG_LIB_VER "3.0.1" AirGradient::AirGradient(BoardType type) : pms5003(type), pms5003t_1(type), pms5003t_2(type), s8(type), sht4x(type),