From 1109ef250fecd2102f01878f64228e5b6826623d Mon Sep 17 00:00:00 2001 From: victor7376 <74020611+victor7376@users.noreply.github.com> Date: Sat, 13 Mar 2021 13:00:15 +0000 Subject: [PATCH] Added Total Layers Added in Total Layers and changed the size of the font of the number of layers to a smaller size. --- printermonitor/OctoPrintClient.cpp | 7 ++++++- printermonitor/OctoPrintClient.h | 2 ++ printermonitor/printermonitor.ino | 5 +++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/printermonitor/OctoPrintClient.cpp b/printermonitor/OctoPrintClient.cpp index f68fd4b..71121f3 100644 --- a/printermonitor/OctoPrintClient.cpp +++ b/printermonitor/OctoPrintClient.cpp @@ -266,7 +266,7 @@ void OctoPrintClient::getPrinterJobResults() { printerData.estimatedEndTime = (const char*)root3["print"]["estimatedEndTime"]; printerData.currentLayer = (const char*)root3["layer"]["current"]; - + printerData.totalLayers = (const char*)root3["layer"]["total"]; if (isPrinting()) { Serial.println("Status: " + printerData.state + " " + printerData.fileName + "(" + printerData.progressCompletion + "%)"); @@ -330,6 +330,7 @@ void OctoPrintClient::resetPrintData() { printerData.isPSUoff = false; printerData.error = ""; printerData.currentLayer = ""; + printerData.totalLayers = ""; printerData.estimatedEndTime = ""; } @@ -337,6 +338,10 @@ String OctoPrintClient::getCurrentLayer(){ return printerData.currentLayer; } +String OctoPrintClient::getTotalLayers(){ + return printerData.totalLayers; +} + String OctoPrintClient::getEstimatedEndTime(){ return printerData.estimatedEndTime; } diff --git a/printermonitor/OctoPrintClient.h b/printermonitor/OctoPrintClient.h index daca713..1253e9a 100644 --- a/printermonitor/OctoPrintClient.h +++ b/printermonitor/OctoPrintClient.h @@ -60,6 +60,7 @@ private: String toolTemp; String toolTargetTemp; String currentLayer; + String totalLayers; String estimatedEndTime; String filamentLength; String bedTemp; @@ -99,6 +100,7 @@ public: String getFilamentLength(); String getEstimatedEndTime(); String getCurrentLayer(); + String getTotalLayers(); String getValueRounded(String value); String getError(); String getPrinterType(); diff --git a/printermonitor/printermonitor.ino b/printermonitor/printermonitor.ino index a6e1e98..3fdca1f 100644 --- a/printermonitor/printermonitor.ino +++ b/printermonitor/printermonitor.ino @@ -970,14 +970,15 @@ void drawScreen3(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int void drawScreen4(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) { String layer = printerClient.getCurrentLayer(); + String totalLayers = printerClient.getTotalLayers(); display->setTextAlignment(TEXT_ALIGN_CENTER); display->setFont(ArialMT_Plain_16); display->drawString(64 + x, 0 + y, "Layer"); //display->setTextAlignment(TEXT_ALIGN_LEFT); - display->setFont(ArialMT_Plain_24); + display->setFont(ArialMT_Plain_16); - display->drawString(64 + x, 14 + y, layer); + display->drawString(64 + x, 14 + y, layer+ " / " + totalLayers); }