mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-18 19:22:08 +02:00
LED test update: support country TH
and Show display Press now for LED test
This commit is contained in:
@ -194,7 +194,9 @@ public:
|
|||||||
|
|
||||||
/** Get "country" */
|
/** Get "country" */
|
||||||
if (JSON.typeof_(root["country"]) == "string") {
|
if (JSON.typeof_(root["country"]) == "string") {
|
||||||
String country = root["country"];
|
String _country = root["country"];
|
||||||
|
country = _country;
|
||||||
|
|
||||||
if (country == "US") {
|
if (country == "US") {
|
||||||
inF = true;
|
inF = true;
|
||||||
} else {
|
} else {
|
||||||
@ -406,6 +408,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
UseLedBar getLedBarMode(void) { return ledBarMode; }
|
UseLedBar getLedBarMode(void) { return ledBarMode; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the Country
|
||||||
|
*
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
String getCountry(void) { return country; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool inF; /** Temperature unit, true: F, false: C */
|
bool inF; /** Temperature unit, true: F, false: C */
|
||||||
bool inUSAQI; /** PMS unit, true: USAQI, false: ugm3 */
|
bool inUSAQI; /** PMS unit, true: USAQI, false: ugm3 */
|
||||||
@ -417,6 +426,7 @@ private:
|
|||||||
UseLedBar ledBarMode = UseLedBarCO2; /** */
|
UseLedBar ledBarMode = UseLedBarCO2; /** */
|
||||||
char models[20]; /** */
|
char models[20]; /** */
|
||||||
char mqttBroker[256]; /** */
|
char mqttBroker[256]; /** */
|
||||||
|
String country; /***/
|
||||||
};
|
};
|
||||||
AgServer agServer;
|
AgServer agServer;
|
||||||
|
|
||||||
@ -597,6 +607,19 @@ static void ledTest() {
|
|||||||
ag.ledBar.show();
|
ag.ledBar.show();
|
||||||
delay(1000);
|
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) {
|
static void co2Poll(void) {
|
||||||
co2Ppm = ag.s8.getCo2();
|
co2Ppm = ag.s8.getCo2();
|
||||||
@ -814,6 +837,8 @@ static void connectToWifi() {
|
|||||||
dispSmState = APP_SM_WIFI_MANAGER_STA_CONNECTING;
|
dispSmState = APP_SM_WIFI_MANAGER_STA_CONNECTING;
|
||||||
ledSmState = 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);
|
wifiManager.autoConnect(wifiSSID.c_str(), WIFI_HOTSPOT_PASSWORD_DEFAULT);
|
||||||
xTaskCreate(
|
xTaskCreate(
|
||||||
[](void *obj) {
|
[](void *obj) {
|
||||||
@ -988,7 +1013,21 @@ static void boardInit(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Run LED test on start up */
|
/** 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();
|
ledTest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1019,7 +1058,11 @@ static void serverConfigPoll(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (agServer.isLedBarTestRequested()) {
|
if (agServer.isLedBarTestRequested()) {
|
||||||
ledTest();
|
if (agServer.getCountry() == "TH") {
|
||||||
|
ledTest2Min();
|
||||||
|
} else {
|
||||||
|
ledTest();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user