diff --git a/src/main.cpp b/src/main.cpp index 4a5be4f..8ea62c1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -120,6 +120,14 @@ time_t getTimestamp() { } +float mapf(float x, float in_min, float in_max, float out_min, float out_max) { + float newval = (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; + if (newval > out_max) newval = out_max; + if (newval < out_min) newval = out_min; + return newval; +} + + void poweroffDevices() { display.powerOff(); @@ -175,13 +183,6 @@ void wifiConnect() { wifiMulti.addAP(WIFI_SSID2, WIFI_PASSWD2); wifiMulti.addAP(WIFI_SSID3, WIFI_PASSWD3); - Serial.println(WIFI_SSID); - Serial.println(WIFI_PASSWD); - Serial.println(WIFI_SSID2); - Serial.println(WIFI_PASSWD2); - Serial.println(WIFI_SSID3); - Serial.println(WIFI_PASSWD3); - IPAddress ip = IPAddress(network.ip); IPAddress dns = IPAddress(network.dns); IPAddress subnet = IPAddress(network.subnet); @@ -487,12 +488,19 @@ void displayValues() { display.drawLine(0,y_offset+10,display.width(), y_offset+10, GxEPD_BLACK); // Status + display.setFont(NULL); display.setCursor(190,y_offset+0); if(WiFi.status() == WL_CONNECTED) { display.print("W"); } else { display.print("_"); } + if (sensor_readings.voltage <= 4.0F) { + display.setCursor(220,y_offset+0); + int battery_percent = mapf(sensor_readings.voltage, 3.3, 4.1, 0, 100); + display.printf("%3d", battery_percent); + display.print(" \%"); + } // Temp display.drawRect(0,y_offset+10,64,50,GxEPD_BLACK);