Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
pnt325 committed Mar 16, 2024
2 parents 3d243cb + 4a36cf0 commit 15dec40
Showing 1 changed file with 55 additions and 13 deletions.
68 changes: 55 additions & 13 deletions examples/ONE/ONE.ino
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,7 @@ public:
uint8_t ledBarMode = UseLedBarOff;
if (JSON.typeof_(root["ledBarMode"]) == "string") {
String mode = root["ledBarMode"];
if (mode == "co2") {
ledBarMode = UseLedBarCO2;
} else if (mode == "pm") {
ledBarMode = UseLedBarPM;
} else if (mode == "off") {
ledBarMode = UseLedBarOff;
} else {
ledBarMode = UseLedBarOff;
}
ledBarMode = parseLedBarMode(mode);
}

/** Get model */
Expand Down Expand Up @@ -446,6 +438,24 @@ public:
*/
UseLedBar getLedBarMode(void) { return (UseLedBar)config.useRGBLedBar; }

/**
* @brief Return the name of the led bare mode.
*
* @return String
*/
String getLedBarModeName(void) {
UseLedBar ledBarMode = getLedBarMode();
if (ledBarMode == UseLedBarOff) {
return String("off");
} else if (ledBarMode == UseLedBarPM) {
return String("pm");
} else if (ledBarMode == UseLedBarCO2) {
return String("co2");
} else {
return String("off");
}
}

/**
* @brief Get the Country
*
Expand Down Expand Up @@ -516,6 +526,21 @@ private:
EEPROM.commit();
Serial.println("Save config");
}

UseLedBar parseLedBarMode(String mode) {
UseLedBar ledBarMode = UseLedBarOff;
if (mode == "co2") {
ledBarMode = UseLedBarCO2;
} else if (mode == "pm") {
ledBarMode = UseLedBarPM;
} else if (mode == "off") {
ledBarMode = UseLedBarOff;
} else {
ledBarMode = UseLedBarOff;
}

return ledBarMode;
}
};
AgServer agServer;

Expand Down Expand Up @@ -1080,7 +1105,7 @@ void webServerMetricsGet(void) {
add_metric("temperature",
"The ambient temperature as measured by the AirGradient SHT "
"sensor, in degrees Celsius",
"gauge", "celcius");
"gauge", "celsius");
add_metric_point("", String(temp));
}
if (hum >= 0) {
Expand Down Expand Up @@ -1150,18 +1175,30 @@ static String getServerSyncData(bool localServer) {
root["pm10"] = pm10;
}
if (pm03PCount >= 0) {
root["pm003_count"] = pm03PCount;
if (localServer) {
root["pm003Count"] = pm03PCount;
} else {
root["pm003_count"] = pm03PCount;
}
}
}
if (hasSensorSGP) {
if (tvocIndex >= 0) {
root["tvoc_index"] = tvocIndex;
if (localServer) {
root["tvocIndex"] = tvocIndex;
} else {
root["tvoc_index"] = tvocIndex;
}
}
if (tvocRawIndex >= 0) {
root["tvoc_raw"] = tvocRawIndex;
}
if (noxIndex >= 0) {
root["nox_index"] = noxIndex;
if (localServer) {
root["noxIndex"] = noxIndex;
} else {
root["nox_index"] = noxIndex;
}
}
if (noxRawIndex >= 0) {
root["nox_raw"] = noxRawIndex;
Expand All @@ -1177,6 +1214,11 @@ static String getServerSyncData(bool localServer) {
}
root["boot"] = bootCount;

if (localServer) {
root["ledMode"] = agServer.getLedBarModeName();
root["firmwareVersion"] = ag.getVersion();
}

return JSON.stringify(root);
}

Expand Down

0 comments on commit 15dec40

Please sign in to comment.