Update printermonitor.ino

Add Moonraker compatibility
pull/176/head
Eduardo Romero Q. 2025-09-17 09:07:40 +01:00 committed by GitHub
parent bc2cb9e25a
commit b4e50d6c69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 4 deletions

View File

@ -23,6 +23,7 @@ SOFTWARE.
// Additional Contributions: // Additional Contributions:
/* 15 Jan 2019 : Owen Carter : Add psucontrol option and processing */ /* 15 Jan 2019 : Owen Carter : Add psucontrol option and processing */
/* 18 Feb 2022 : Robert von Könemann @vknmnn : Lets us select Moonraker + fix usage of AMPM/24Hrs time */
/********************************************** /**********************************************
* Edit Settings.h for personalization * Edit Settings.h for personalization
@ -87,6 +88,8 @@ boolean displayOn = true;
// Printer Client // Printer Client
#if defined(USE_REPETIER_CLIENT) #if defined(USE_REPETIER_CLIENT)
RepetierClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU); RepetierClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU);
#elif defined(USE_MOONRAKER_CLIENT)
MoonrakerClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU);
#else #else
OctoPrintClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU); OctoPrintClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU);
#endif #endif
@ -418,7 +421,12 @@ void getUpdateTime() {
//Update the Time //Update the Time
timeClient.updateTime(); timeClient.updateTime();
lastEpoch = timeClient.getCurrentEpoch(); lastEpoch = timeClient.getCurrentEpoch();
Serial.println("Hora local: " + timeClient.getAmPmFormattedTime());
if (IS_24HOUR) {
Serial.println("Local time: " + timeClient.getFormattedTime());
} else {
Serial.println("Local time: " + timeClient.getAmPmFormattedTime());
}
ledOnOff(false); // turn off the LED ledOnOff(false); // turn off the LED
} }
@ -770,9 +778,11 @@ void displayPrinterStatus() {
server.send(200, "text/html", ""); server.send(200, "text/html", "");
server.sendContent(String(getHeader(true))); server.sendContent(String(getHeader(true)));
String displayTime = timeClient.getAmPmHours() + ":" + timeClient.getMinutes() + ":" + timeClient.getSeconds() + " " + timeClient.getAmPm(); String displayTime;
if (IS_24HOUR) { if (IS_24HOUR) {
displayTime = timeClient.getHours() + ":" + timeClient.getMinutes() + ":" + timeClient.getSeconds(); displayTime = timeClient.getHours() + ":" + timeClient.getMinutes() + ":" + timeClient.getSeconds();
} else {
displayTime = timeClient.getAmPmHours() + ":" + timeClient.getMinutes() + ":" + timeClient.getSeconds() + " " + timeClient.getAmPm();
} }
html += "<div class='w3-cell-row' style='width:100%'><h2>" + printerClient.getPrinterType() + " Monitor</h2></div><div class='w3-cell-row'>"; html += "<div class='w3-cell-row' style='width:100%'><h2>" + printerClient.getPrinterType() + " Monitor</h2></div><div class='w3-cell-row'>";
@ -966,9 +976,11 @@ void drawScreen3(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int
void drawClock(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) { void drawClock(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
display->setTextAlignment(TEXT_ALIGN_CENTER); display->setTextAlignment(TEXT_ALIGN_CENTER);
String displayTime = timeClient.getAmPmHours() + ":" + timeClient.getMinutes() + ":" + timeClient.getSeconds(); String displayTime;
if (IS_24HOUR) { if (IS_24HOUR) {
displayTime = timeClient.getHours() + ":" + timeClient.getMinutes() + ":" + timeClient.getSeconds(); displayTime = timeClient.getHours() + ":" + timeClient.getMinutes() + ":" + timeClient.getSeconds();
} else {
displayTime = timeClient.getAmPmHours() + ":" + timeClient.getMinutes() + ":" + timeClient.getSeconds();
} }
String displayName = PrinterHostName; String displayName = PrinterHostName;
if (printerClient.getPrinterType() == "Repetier") { if (printerClient.getPrinterType() == "Repetier") {
@ -1029,9 +1041,11 @@ String zeroPad(int value) {
void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) { void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) {
display->setColor(WHITE); display->setColor(WHITE);
display->setFont(ArialMT_Plain_16); display->setFont(ArialMT_Plain_16);
String displayTime = timeClient.getAmPmHours() + ":" + timeClient.getMinutes(); String displayTime;
if (IS_24HOUR) { if (IS_24HOUR) {
displayTime = timeClient.getHours() + ":" + timeClient.getMinutes(); displayTime = timeClient.getHours() + ":" + timeClient.getMinutes();
} else {
displayTime = timeClient.getAmPmHours() + ":" + timeClient.getMinutes();
} }
display->setTextAlignment(TEXT_ALIGN_LEFT); display->setTextAlignment(TEXT_ALIGN_LEFT);
display->drawString(0, 48, displayTime); display->drawString(0, 48, displayTime);