diff --git a/printermonitor/printermonitor.ino b/printermonitor/printermonitor.ino index 3fdca1f..50fd98d 100644 --- a/printermonitor/printermonitor.ino +++ b/printermonitor/printermonitor.ino @@ -64,12 +64,13 @@ void drawScreen5(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state); void drawClock(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y); void drawWeather(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y); +void drawUpdate(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y); void drawClockHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state); // Set the number of Frames supported const int numberOfFrames = 5; FrameCallback frames[numberOfFrames]; -FrameCallback clockFrame[2]; +FrameCallback clockFrame[3]; boolean isClockOn = false; OverlayCallback overlays[] = { drawHeaderOverlay }; @@ -265,6 +266,7 @@ void setup() { frames[4] = drawScreen5; clockFrame[0] = drawClock; clockFrame[1] = drawWeather; + clockFrame[2] = drawUpdate; ui.setOverlays(overlays, numberOfOverlays); // Inital UI takes care of initalising the display too. @@ -755,7 +757,7 @@ String getFooter() { if (lastReportStatus != "") { html += " Report Status: " + lastReportStatus + "
"; } - html += " Version: " + String(VERSION) + "
"; + html += " Version: " + String(VERSION) + " Next Update: " + getTimeTillUpdate() + "
"; html += " Signal Strength: "; html += String(rssi) + "%"; html += ""; @@ -810,6 +812,12 @@ void displayPrinterStatus() { float fLength = float(filamentLength) / 1000; html += "Filament: " + String(fLength) + "m
"; } + if (printerClient.isPrinting()) { + html += "Layer: " + printerClient.getCurrentLayer() + " / " + printerClient.getTotalLayers() + "
"; + } + if (printerClient.isPrinting()) { + html += "Estimated Finish Time: " + printerClient.getEstimatedEndTime() + "
"; + } html += "Tool Temperature: " + printerClient.getTempToolActual() + "° C
"; if ( printerClient.getTempBedActual() != 0 ) { @@ -1025,6 +1033,39 @@ void drawWeather(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int display->drawString(86 + x, 0 + y, weatherClient.getWeatherIcon(0)); } +void drawUpdate(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) { + display->setTextAlignment(TEXT_ALIGN_CENTER); + display->setFont(ArialMT_Plain_16); + + display->drawString(64 + x, 0 + y, "Next Update:"); + //display->setTextAlignment(TEXT_ALIGN_LEFT); + display->setFont(ArialMT_Plain_24); + + display->drawString(64 + x, 14 + y, getTimeTillUpdate()); +} + +String getTimeTillUpdate() { + String rtnValue = ""; + + long timeToUpdate = (((minutesBetweenDataRefresh * 60) + lastEpoch) - timeClient.getCurrentEpoch()); + + int hours = numberOfHours(timeToUpdate); + int minutes = numberOfMinutes(timeToUpdate); + int seconds = numberOfSeconds(timeToUpdate); + + rtnValue += String(hours) + ":"; + if (minutes < 10) { + rtnValue += "0"; + } + rtnValue += String(minutes) + ":"; + if (seconds < 10) { + rtnValue += "0"; + } + rtnValue += String(seconds); + + return rtnValue; +} + String getTempSymbol() { return getTempSymbol(false); }