Skip to content

Commit

Permalink
Merge branch 'melkati:development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
Coscolin authored Jun 3, 2024
2 parents 781e99f + ff9da7f commit 9be2a0a
Show file tree
Hide file tree
Showing 18 changed files with 579 additions and 437 deletions.
374 changes: 179 additions & 195 deletions .github/workflows/release3.yml

Large diffs are not rendered by default.

54 changes: 49 additions & 5 deletions CO2_Gadget.ino
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
/*****************************************************************************************************/

// ▐▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▌
// ▐ ____ ___ ____ ____ _ _ ▌
// ▐ / ___/ _ \___ \ / ___| __ _ __| | __ _ ___| |_ ▌
// ▐ | | | | | |__) | | | _ / _` |/ _` |/ _` |/ _ \ __| ▌
// ▐ | |__| |_| / __/ | |_| | (_| | (_| | (_| | __/ |_ ▌
// ▐ \____\___/_____| \____|\__,_|\__,_|\__, |\___|\__| ▌
// ▐ |___/ ▌
// ▐▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▌

// CO2 Gadget Advanced Firmware
//
// Copyright (C) 2021-2024 Mariete & CO2 Gadget Contributors
// Contact: https://emariete.com
//
// This file is part of the CO2 Gadget firmware.
//
// The CO2 Gadget firmware is free software: you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// The emariete.com Website and Documentation is distributed in the hope that
// it will be useful, but WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the emariete.com Website and Documentation. If not, see
// <http://www.gnu.org/licenses/>

// ▐▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▌
// ▐ _ _ ▌
// ▐ ___ _ __ ___ __ _ _ __(_) ___| |_ ___ ___ ___ _ __ ___ ▌
// ▐ / _ \ '_ ` _ \ / _` | '__| |/ _ \ __/ _ \ / __/ _ \| '_ ` _ \ ▌
// ▐ | __/ | | | | | (_| | | | | __/ || __/| (_| (_) | | | | | | ▌
// ▐ \___|_| |_| |_|\__,_|_| |_|\___|\__\___(_)___\___/|_| |_| |_| ▌
// ▐▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▌

/*****************************************************************************************************/

#define SUPPORT_CAPTIVE_PORTAL // Please, don't disable this.

// Functions and enum definitions
void reverseButtons(bool reversed); // Defined in CO2_Gadget_Buttons.h
void outputsLoop(); // Defined in CO2_Gadget_Main.h
Expand Down Expand Up @@ -47,11 +91,11 @@ uint16_t WiFiConnectionRetries = 0;
uint16_t maxWiFiConnectionRetries = 10;
bool wifiChanged = false;
bool useStaticIP = false; // Set to true if you want to use a static IP
IPAddress staticIP(192, 168, 1, 199); // Change this to the desired IP
IPAddress gateway(192, 168, 1, 1); // Change this to your network's gateway
IPAddress subnet(255, 255, 255, 0); // Change this to your network's subnet mask
IPAddress dns1(8, 8, 8, 8); // Change this to your preferred DNS server
IPAddress dns2(8, 8, 4, 4); // Change this to your secondary DNS server
IPAddress staticIP(192, 168, 1, 199); // Static IP address
IPAddress gateway(192, 168, 1, 1); // Network gateway
IPAddress subnet(255, 255, 255, 0); // Subnet mask
IPAddress dns1(8, 8, 8, 8); // DNS server
IPAddress dns2(8, 8, 4, 4); // DNS server

// MQTT options
bool activeMQTT = true;
Expand Down
2 changes: 1 addition & 1 deletion CO2_Gadget_EINK.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,8 @@ void initDisplay(bool fastMode = false) {

void showBatteryIcon(int32_t posX, int32_t posY, bool forceRedraw) {
publishMQTTLogData("-->[EINK] Battery Level: " + String(batteryLevel) + "% Battery voltage: " + String(batteryVoltage) + "V");
// Serial.println("-->[EINK] Drawn battery icon at " + String(posX) + ", " + String(posY) + " with level " + String(batteryLevel) + "% and voltage " + String(batteryVoltage) + "V");
display.fillRect(posX, posY, display.width() - posX, 16, GxEPD_WHITE);
if (!displayShowBattery) return;
if (workingOnExternalPower) {
// display.drawRoundRect(posX + 8, posY, 16 + 6, 16 + 6, 2, GxEPD_BLACK);
display.drawBitmap(posX + 16, posY, iconUSB, 16, 16, GxEPD_WHITE, GxEPD_BLACK);
Expand Down
11 changes: 11 additions & 0 deletions CO2_Gadget_Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ bool handleSavePreferencesFromJSON(String jsonPreferences) {
preferences.begin("CO2-Gadget", false);
customCalibrationValue = JsonDocument["customCalValue"];
if (tempOffset != float(JsonDocument["tempOffset"])) {
Serial.println("-->[PREF] Temp Offset changed from " + String(tempOffset) + " to " + String(JsonDocument["tempOffset"].as<String>()));
tempOffset = float(JsonDocument["tempOffset"]);
sensors.setTempOffset(tempOffset);
}
Expand All @@ -733,6 +734,7 @@ bool handleSavePreferencesFromJSON(String jsonPreferences) {
batteryDischargedMillivolts = JsonDocument["batDischgd"];
batteryFullyChargedMillivolts = JsonDocument["batChargd"];
if (vRef != JsonDocument["vRef"]) { // If battery reference changed, apply it
Serial.println("-->[PREF] vRef changed from " + String(vRef) + " to " + String(JsonDocument["vRef"].as<String>()));
vRef = JsonDocument["vRef"];
battery.begin(vRef, voltageDividerRatio, &asigmoidal);
readBatteryVoltage();
Expand Down Expand Up @@ -763,6 +765,7 @@ bool handleSavePreferencesFromJSON(String jsonPreferences) {
debugSensors = JsonDocument["debugSensors"];
#if defined(SUPPORT_TFT) || defined(SUPPORT_OLED) || defined(SUPPORT_EINK)
if (displayReverse != JsonDocument["displayReverse"]) {
Serial.println("-->[PREF] Display Reverse changed from " + String(displayReverse) + " to " + String(JsonDocument["displayReverse"].as<String>()));
displayReverse = JsonDocument["displayReverse"];
setDisplayReverse(displayReverse);
reverseButtons(displayReverse);
Expand Down Expand Up @@ -790,31 +793,37 @@ bool handleSavePreferencesFromJSON(String jsonPreferences) {
}

if (displayShowTemperature != JsonDocument["showTemp"]) {
Serial.println("-->[PREF] Display Temperature changed from " + String(displayShowTemperature) + " to " + String(JsonDocument["showTemp"].as<String>()));
displayShowTemperature = JsonDocument["showTemp"];
shouldRedrawDisplay = true;
}

if (displayShowHumidity != JsonDocument["showHumidity"]) {
Serial.println("-->[PREF] Display Humidity changed from " + String(displayShowHumidity) + " to " + String(JsonDocument["showHumidity"].as<String>()));
displayShowHumidity = JsonDocument["showHumidity"];
shouldRedrawDisplay = true;
}

if (displayShowBattery != JsonDocument["showBattery"]) {
Serial.println("-->[PREF] Display Battery changed from " + String(displayShowBattery) + " to " + String(JsonDocument["showBattery"].as<String>()));
displayShowBattery = JsonDocument["showBattery"];
shouldRedrawDisplay = true;
}

if (displayShowBatteryVoltage != JsonDocument["showBattVolt"]) {
Serial.println("-->[PREF] Display Battery Voltage changed from " + String(displayShowBatteryVoltage) + " to " + String(JsonDocument["showBattVolt"].as<String>()));
displayShowBatteryVoltage = JsonDocument["showBattVolt"];
shouldRedrawDisplay = true;
}

if (displayShowCO2 != JsonDocument["showCO2"]) {
Serial.println("-->[PREF] Display CO2 changed from " + String(displayShowCO2) + " to " + String(JsonDocument["showCO2"].as<String>()));
displayShowCO2 = JsonDocument["showCO2"];
shouldRedrawDisplay = true;
}

if (displayShowPM25 != JsonDocument["showPM25"]) {
Serial.println("-->[PREF] Display PM2.5 changed from " + String(displayShowPM25) + " to " + String(JsonDocument["showPM25"].as<String>()));
displayShowPM25 = JsonDocument["showPM25"];
shouldRedrawDisplay = true;
}
Expand Down Expand Up @@ -854,11 +863,13 @@ bool handleSavePreferencesFromJSON(String jsonPreferences) {

// If JsonDocument["wifiPass"] is present and different from the current one, update the wifiPass variable
if (JsonDocument.containsKey("wifiPass") && wifiPass != JsonDocument["wifiPass"].as<String>().c_str()) {
Serial.println("-->[PREF] WiFi Password changed. Updating WiFi Password in preferences");
wifiPass = JsonDocument["wifiPass"].as<String>().c_str();
wifiChanged = true;
}
// If JsonDocument["mqttPass"] is present and different from the current one, update the mqttPass variable
if (JsonDocument.containsKey("mqttPass") && mqttPass != JsonDocument["mqttPass"].as<String>().c_str()) {
Serial.println("-->[PREF] MQTT Password changed. Updating MQTT Password in preferences");
mqttPass = JsonDocument["mqttPass"].as<String>().c_str();
wifiChanged = true;
}
Expand Down
1 change: 1 addition & 0 deletions CO2_Gadget_WIFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,7 @@ void initWebServer() {
Serial.println(response);
#endif
handleSavePreferencesFromJSON(response);
timeCaptivePortalStarted = millis();
} else {
Serial.println("---> [WiFi] Error: request is null");
}
Expand Down
Loading

0 comments on commit 9be2a0a

Please sign in to comment.