";
@@ -585,6 +608,13 @@ void drawScreen3(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int
display->drawString(64 + x, 14 + y, time);
}
+void drawClock(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
+ display->setTextAlignment(TEXT_ALIGN_CENTER);
+ display->setFont(ArialMT_Plain_24);
+ String time = timeClient.getAmPmHours() + ":" + timeClient.getMinutes() + ":" + timeClient.getSeconds();
+ display->drawString(64 + x, 10 + y, time);
+}
+
String zeroPad(int value) {
String rtnValue = String(value);
if (value < 10) {
@@ -614,6 +644,28 @@ void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) {
display->drawHorizontalLine(0, 43, updatePos);
display->drawHorizontalLine(0, 44, updatePos);
display->drawHorizontalLine(0, 45, updatePos);
+
+ drawRssi(display);
+}
+
+void drawClockHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) {
+ display->setColor(WHITE);
+ display->setFont(ArialMT_Plain_16);
+ String time = timeClient.getAmPm();
+ display->setTextAlignment(TEXT_ALIGN_LEFT);
+ display->drawString(0, 48, time);
+ display->setFont(ArialMT_Plain_16);
+ display->setTextAlignment(TEXT_ALIGN_CENTER);
+ display->drawString(64, 48, "offline");
+ display->setTextAlignment(TEXT_ALIGN_LEFT);
+
+ display->drawRect(0, 41, 128, 2);
+
+ drawRssi(display);
+}
+
+void drawRssi(OLEDDisplay *display) {
+
int8_t quality = getWifiQuality();
for (int8_t i = 0; i < 4; i++) {
@@ -653,6 +705,7 @@ void writeSettings() {
f.println("themeColor=" + themeColor);
f.println("www_username=" + String(www_username));
f.println("www_password=" + String(www_password));
+ f.println("DISPLAYCLOCK=" + String(DISPLAYCLOCK));
}
f.close();
readSettings();
@@ -709,11 +762,13 @@ void readSettings() {
temp.toCharArray(www_password, sizeof(temp));
Serial.println("www_password=" + String(www_password));
}
+ if (line.indexOf("DISPLAYCLOCK=") >= 0) {
+ DISPLAYCLOCK = line.substring(line.lastIndexOf("DISPLAYCLOCK=") + 13).toInt();
+ Serial.println("DISPLAYCLOCK=" + String(DISPLAYCLOCK));
+ }
}
fr.close();
timeClient.setUtcOffset(UtcOffset);
- printerClient.updateOctoPrintClient(OctoPrintApiKey, OctoPrintServer, OctoPrintPort);
- printerClient.getPrinterJobResults();
}
int getMinutesFromLastRefresh() {
@@ -728,7 +783,10 @@ int getMinutesFromLastDisplay() {
// Toggle on and off the display if user defined times
void checkDisplay() {
- if (displayOn && !(printerClient.isOperational() || printerClient.isPrinting())) {
+ if (!displayOn && DISPLAYCLOCK) {
+ enableDisplay(true);
+ }
+ if (displayOn && !(printerClient.isOperational() || printerClient.isPrinting()) && !DISPLAYCLOCK) {
// Put Display to sleep
display.clear();
display.display();
@@ -739,8 +797,9 @@ void checkDisplay() {
display.display();
delay(5000);
enableDisplay(false);
- return;
- } else if (!displayOn) {
+ Serial.println("Printer is offline going down to sleep...");
+ return;
+ } else if (!displayOn && !DISPLAYCLOCK) {
if (printerClient.isOperational()) {
// Wake the Screen up
enableDisplay(true);
@@ -751,9 +810,25 @@ void checkDisplay() {
display.setContrast(255); // default is 255
display.drawString(64, 5, "Printer Online\nWake up...");
display.display();
+ Serial.println("Printer is online waking up...");
delay(5000);
return;
}
+ } else if (DISPLAYCLOCK) {
+ if (!printerClient.isOperational() && !isClockOn) {
+ Serial.println("Clock Mode is turned on.");
+ ui.disableAutoTransition();
+ ui.setFrames(clockFrame, 1);
+ clockFrame[0] = drawClock;
+ ui.setOverlays(clockOverlay, numberOfOverlays);
+ isClockOn = true;
+ } else if (printerClient.isOperational() && isClockOn) {
+ Serial.println("Printer Monitor is active.");
+ ui.setFrames(frames, numberOfFrames);
+ ui.setOverlays(overlays, numberOfOverlays);
+ ui.enableAutoTransition();
+ isClockOn = false;
+ }
}
}