From f3844ea773f7fb1d45385d463368649669565c7f Mon Sep 17 00:00:00 2001
From: Chrome Legion
";
if (printerClient.getError() != "") {
html += "Error: " + printerClient.getError() + "
";
@@ -610,8 +622,11 @@ void drawScreen3(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int
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 displayTime = timeClient.getAmPmHours() + ":" + timeClient.getMinutes() + ":" + timeClient.getSeconds();
+ if (IS_24HOUR) {
+ displayTime = timeClient.getHours() + ":" + timeClient.getMinutes() + ":" + timeClient.getSeconds();
+ }
+ display->drawString(64 + x, 10 + y, displayTime);
}
String zeroPad(int value) {
@@ -625,12 +640,19 @@ String zeroPad(int value) {
void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) {
display->setColor(WHITE);
display->setFont(ArialMT_Plain_16);
- String time = timeClient.getAmPmHours() + ":" + timeClient.getMinutes();
+ String displayTime = timeClient.getAmPmHours() + ":" + timeClient.getMinutes();
+ if (IS_24HOUR) {
+ displayTime = timeClient.getHours() + ":" + timeClient.getMinutes();
+ }
display->setTextAlignment(TEXT_ALIGN_LEFT);
- display->drawString(0, 48, time);
- String ampm = timeClient.getAmPm();
- display->setFont(ArialMT_Plain_10);
- display->drawString(39, 54, ampm);
+ display->drawString(0, 48, displayTime);
+
+ if (!IS_24HOUR) {
+ String ampm = timeClient.getAmPm();
+ display->setFont(ArialMT_Plain_10);
+ display->drawString(39, 54, ampm);
+ }
+
display->setFont(ArialMT_Plain_16);
display->setTextAlignment(TEXT_ALIGN_LEFT);
String percent = String(printerClient.getProgressCompletion()) + "%";
@@ -705,6 +727,7 @@ void writeSettings() {
f.println("www_username=" + String(www_username));
f.println("www_password=" + String(www_password));
f.println("DISPLAYCLOCK=" + String(DISPLAYCLOCK));
+ f.println("is24hour=" + String(IS_24HOUR));
}
f.close();
readSettings();
@@ -765,6 +788,10 @@ void readSettings() {
DISPLAYCLOCK = line.substring(line.lastIndexOf("DISPLAYCLOCK=") + 13).toInt();
Serial.println("DISPLAYCLOCK=" + String(DISPLAYCLOCK));
}
+ if (line.indexOf("is24hour=") >= 0) {
+ IS_24HOUR = line.substring(line.lastIndexOf("is24hour=") + 9).toInt();
+ Serial.println("IS_24HOUR=" + String(IS_24HOUR));
+ }
}
fr.close();
printerClient.updateOctoPrintClient(OctoPrintApiKey, OctoPrintServer, OctoPrintPort);
From 886bb7fb6be2c80bd1c2641a397dfb1916541a6e Mon Sep 17 00:00:00 2001
From: Qrome <32021227+Qrome@users.noreply.github.com>
Date: Thu, 24 May 2018 07:12:44 -0700
Subject: [PATCH 2/2] Updated features
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index a4ba517..571dce6 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,7 @@ SOFTWARE.
* Screen turns off when printer is turned off or disconnected
* Screen turns on when printer is Operational or connected
* Option to display a clock screen instead of sleep mode
+* Option to display 24 hour clock or AM/PM style
* Sample rate is every 60 seconds when not printing
* Sample rate is every 10 seconds when printing
* Fully configurable from the web interface (not required to update Settings.h)