diff --git a/printermonitor/OctoPrintClient.cpp b/printermonitor/OctoPrintClient.cpp index 204f9b9..b2879ca 100644 --- a/printermonitor/OctoPrintClient.cpp +++ b/printermonitor/OctoPrintClient.cpp @@ -286,4 +286,10 @@ String OctoPrintClient::getFilamentLength() { String OctoPrintClient::getError() { return printerData.error; +} + +String OctoPrintClient::getValueRounded(String value) { + float f = value.toFloat(); + int rounded = (int)(f+0.5f); + return String(rounded); } diff --git a/printermonitor/OctoPrintClient.h b/printermonitor/OctoPrintClient.h index 0871868..1d02836 100644 --- a/printermonitor/OctoPrintClient.h +++ b/printermonitor/OctoPrintClient.h @@ -85,6 +85,7 @@ class OctoPrintClient { String getTempToolActual(); String getTempToolTarget(); String getFilamentLength(); + String getValueRounded(String value); String getError(); }; diff --git a/printermonitor/Settings.h b/printermonitor/Settings.h index bd4fdb8..0cc3525 100644 --- a/printermonitor/Settings.h +++ b/printermonitor/Settings.h @@ -76,7 +76,7 @@ const boolean INVERT_DISPLAY = false; // true = pins at top | false = pins at th //#define DISPLAY_SH1106 // Uncomment this line to use the SH1106 display -- SSD1306 is used by default and is most common boolean ENABLE_OTA = true; // this will allow you to load firmware to the device over WiFi (see OTA for ESP8266) - +String OTA_Password = ""; // Set an OTA password here -- leave blank if you don't want to be prompted for password //****************************** // End Settings //****************************** diff --git a/printermonitor/printermonitor.ino b/printermonitor/printermonitor.ino index ca68cf0..3945f17 100644 --- a/printermonitor/printermonitor.ino +++ b/printermonitor/printermonitor.ino @@ -27,7 +27,7 @@ SOFTWARE. #include "Settings.h" -#define VERSION "1.6" +#define VERSION "1.7" #define HOSTNAME "OctMon-" #define CONFIG "/conf.txt" @@ -229,6 +229,9 @@ void setup() { else if (error == OTA_END_ERROR) Serial.println("End Failed"); }); ArduinoOTA.setHostname((const char *)hostname.c_str()); + if (OTA_Password != "") { + ArduinoOTA.setPassword(((const char *)OTA_Password.c_str())); + } ArduinoOTA.begin(); } @@ -630,10 +633,10 @@ void drawScreen1(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int display->drawString(64 + x, 0 + y, "Bed / Tool Temp"); display->setTextAlignment(TEXT_ALIGN_LEFT); display->setFont(ArialMT_Plain_24); - int bed = printerClient.getTempBedActual().toInt(); - int tool = printerClient.getTempToolActual().toInt(); - display->drawString(2 + x, 14 + y, String(bed) + "°"); - display->drawString(64 + x, 14 + y, String(tool) + "°"); + String bed = printerClient.getValueRounded(printerClient.getTempBedActual()); + String tool = printerClient.getValueRounded(printerClient.getTempToolActual()); + display->drawString(2 + x, 14 + y, bed + "°"); + display->drawString(64 + x, 14 + y, tool + "°"); } void drawScreen2(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {