Qrome - moved printerType to the objects

pull/99/head
David Payne 2019-04-12 09:07:05 -07:00
parent 2996572d86
commit ceaa76c945
5 changed files with 360 additions and 350 deletions

View File

@ -394,3 +394,7 @@ String OctoPrintClient::getValueRounded(String value) {
int rounded = (int)(f+0.5f); int rounded = (int)(f+0.5f);
return String(rounded); return String(rounded);
} }
String OctoPrintClient::getPrinterType() {
return printerType;
}

View File

@ -37,6 +37,7 @@ private:
String myApiKey = ""; String myApiKey = "";
String encodedAuth = ""; String encodedAuth = "";
boolean pollPsu; boolean pollPsu;
const String printerType = "OctoPrint";
void resetPrintData(); void resetPrintData();
boolean validate(); boolean validate();
@ -95,4 +96,5 @@ public:
String getFilamentLength(); String getFilamentLength();
String getValueRounded(String value); String getValueRounded(String value);
String getError(); String getError();
String getPrinterType();
}; };

View File

@ -1,341 +1,345 @@
/** The MIT License (MIT) /** The MIT License (MIT)
Copyright (c) 2018 David Payne Copyright (c) 2018 David Payne
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
// Additional Contributions: // Additional Contributions:
/* 15 Jan 2019 : Owen Carter : Add psucontrol query via POST api call */ /* 15 Jan 2019 : Owen Carter : Add psucontrol query via POST api call */
/* 07 April 2019 : Jon Smith : Redesigned this class for Repetier Server */ /* 07 April 2019 : Jon Smith : Redesigned this class for Repetier Server */
#include "RepetierClient.h" #include "RepetierClient.h"
RepetierClient::RepetierClient(String ApiKey, String server, int port, String user, String pass, boolean psu) { RepetierClient::RepetierClient(String ApiKey, String server, int port, String user, String pass, boolean psu) {
updatePrintClient(ApiKey, server, port, user, pass, psu); updatePrintClient(ApiKey, server, port, user, pass, psu);
} }
void RepetierClient::updatePrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu) { void RepetierClient::updatePrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu) {
server.toCharArray(myServer, 100); server.toCharArray(myServer, 100);
myApiKey = ApiKey; myApiKey = ApiKey;
myPort = port; myPort = port;
encodedAuth = ""; encodedAuth = "";
if (user != "") { if (user != "") {
String userpass = user + ":" + pass; String userpass = user + ":" + pass;
base64 b64; base64 b64;
encodedAuth = b64.encode(userpass, true); encodedAuth = b64.encode(userpass, true);
} }
pollPsu = psu; pollPsu = psu;
} }
boolean RepetierClient::validate() { boolean RepetierClient::validate() {
boolean rtnValue = false; boolean rtnValue = false;
printerData.error = ""; printerData.error = "";
if (String(myServer) == "") { if (String(myServer) == "") {
printerData.error += "Server address is required; "; printerData.error += "Server address is required; ";
} }
if (myApiKey == "") { if (myApiKey == "") {
printerData.error += "ApiKey is required; "; printerData.error += "ApiKey is required; ";
} }
if (printerData.error == "") { if (printerData.error == "") {
rtnValue = true; rtnValue = true;
} }
return rtnValue; return rtnValue;
} }
WiFiClient RepetierClient::getSubmitRequest(String apiGetData) { WiFiClient RepetierClient::getSubmitRequest(String apiGetData) {
WiFiClient printClient; WiFiClient printClient;
printClient.setTimeout(5000); printClient.setTimeout(5000);
Serial.println("Getting Repetier Data via GET"); Serial.println("Getting Repetier Data via GET");
Serial.println(apiGetData); Serial.println(apiGetData);
result = ""; result = "";
if (printClient.connect(myServer, myPort)) { //starts client connection, checks for connection if (printClient.connect(myServer, myPort)) { //starts client connection, checks for connection
printClient.println(apiGetData); printClient.println(apiGetData);
printClient.println("Host: " + String(myServer) + ":" + String(myPort)); printClient.println("Host: " + String(myServer) + ":" + String(myPort));
printClient.println("X-Api-Key: " + myApiKey); printClient.println("X-Api-Key: " + myApiKey);
if (encodedAuth != "") { if (encodedAuth != "") {
printClient.print("Authorization: "); printClient.print("Authorization: ");
printClient.println("Basic " + encodedAuth); printClient.println("Basic " + encodedAuth);
} }
printClient.println("User-Agent: ArduinoWiFi/1.1"); printClient.println("User-Agent: ArduinoWiFi/1.1");
printClient.println("Connection: close"); printClient.println("Connection: close");
if (printClient.println() == 0) { if (printClient.println() == 0) {
Serial.println("Connection to " + String(myServer) + ":" + String(myPort) + " failed."); Serial.println("Connection to " + String(myServer) + ":" + String(myPort) + " failed.");
Serial.println(); Serial.println();
resetPrintData(); resetPrintData();
printerData.error = "Connection to " + String(myServer) + ":" + String(myPort) + " failed."; printerData.error = "Connection to " + String(myServer) + ":" + String(myPort) + " failed.";
return printClient; return printClient;
} }
} }
else { else {
Serial.println("Connection to Repetier failed: " + String(myServer) + ":" + String(myPort)); //error message if no client connect Serial.println("Connection to Repetier failed: " + String(myServer) + ":" + String(myPort)); //error message if no client connect
Serial.println(); Serial.println();
resetPrintData(); resetPrintData();
printerData.error = "Connection to Repetier failed: " + String(myServer) + ":" + String(myPort); printerData.error = "Connection to Repetier failed: " + String(myServer) + ":" + String(myPort);
return printClient; return printClient;
} }
// Check HTTP status // Check HTTP status
char status[32] = {0}; char status[32] = {0};
printClient.readBytesUntil('\r', status, sizeof(status)); printClient.readBytesUntil('\r', status, sizeof(status));
if (strcmp(status, "Host: 200 OK") != 0) { if (strcmp(status, "Host: 200 OK") != 0) {
Serial.print(F("Unexpected response: ")); Serial.print(F("Unexpected response: "));
Serial.println(status); Serial.println(status);
printerData.state = ""; printerData.state = "";
printerData.error = "Response: " + String(status); printerData.error = "Response: " + String(status);
return printClient; return printClient;
} }
// Skip HTTP headers // Skip HTTP headers
char endOfHeaders[] = "\r\n\r\n"; char endOfHeaders[] = "\r\n\r\n";
if (!printClient.find(endOfHeaders)) { if (!printClient.find(endOfHeaders)) {
Serial.println(F("Invalid response")); Serial.println(F("Invalid response"));
printerData.error = "Invalid response from " + String(myServer) + ":" + String(myPort); printerData.error = "Invalid response from " + String(myServer) + ":" + String(myPort);
printerData.state = ""; printerData.state = "";
} }
return printClient; return printClient;
} }
void RepetierClient::getPrinterJobResults() { void RepetierClient::getPrinterJobResults() {
if (!validate()) { if (!validate()) {
return; return;
} }
//**** get the Printer Job status //**** get the Printer Job status
String apiGetData = "GET /printer/api/?a=listPrinter"; String apiGetData = "GET /printer/api/?a=listPrinter";
WiFiClient printClient = getSubmitRequest(apiGetData); WiFiClient printClient = getSubmitRequest(apiGetData);
if (printerData.error != "") { if (printerData.error != "") {
return; return;
} }
const size_t bufferSize = JSON_OBJECT_SIZE(1) + JSON_OBJECT_SIZE(2) + JSON_OBJECT_SIZE(3) + 2*JSON_OBJECT_SIZE(5) + JSON_OBJECT_SIZE(6) + 710; const size_t bufferSize = JSON_OBJECT_SIZE(1) + JSON_OBJECT_SIZE(2) + JSON_OBJECT_SIZE(3) + 2*JSON_OBJECT_SIZE(5) + JSON_OBJECT_SIZE(6) + 710;
DynamicJsonBuffer jsonBuffer(bufferSize); DynamicJsonBuffer jsonBuffer(bufferSize);
// Parse JSON object // Parse JSON object
JsonArray& root = jsonBuffer.parseArray(printClient); JsonArray& root = jsonBuffer.parseArray(printClient);
if (!root.success()) { if (!root.success()) {
Serial.println("Repetier Data Parsing failed: " + String(myServer) + ":" + String(myPort)); Serial.println("Repetier Data Parsing failed: " + String(myServer) + ":" + String(myPort));
printerData.error = "Repetier Data Parsing failed: " + String(myServer) + ":" + String(myPort); printerData.error = "Repetier Data Parsing failed: " + String(myServer) + ":" + String(myPort);
printerData.state = ""; printerData.state = "";
return; return;
} }
///Selecting First printer ///Selecting First printer
JsonObject& pr = root[0]; JsonObject& pr = root[0];
//printerData.averagePrintTime = (const char*)pr[""]; //printerData.averagePrintTime = (const char*)pr[""];
printerData.estimatedPrintTime = (const char*)pr["printTime"]; printerData.estimatedPrintTime = (const char*)pr["printTime"];
printerData.fileName = (const char*) pr["job"]; printerData.fileName = (const char*) pr["job"];
printerData.fileSize = (const char*) pr["totalLines"]; printerData.fileSize = (const char*) pr["totalLines"];
//printerData.filamentLength = (const char*) pr[""]; //printerData.filamentLength = (const char*) pr[""];
printerData.state = (const char*) pr["online"]; printerData.state = (const char*) pr["online"];
//printerData.lastPrintTime = (const char*) pr[""]; //printerData.lastPrintTime = (const char*) pr[""];
printerData.progressCompletion = (const char*) pr["done"]; printerData.progressCompletion = (const char*) pr["done"];
printerData.progressFilepos = (const char*) pr["linesSend"]; printerData.progressFilepos = (const char*) pr["linesSend"];
printerData.progressPrintTime = (const char*) pr["printedTimeComp"]; printerData.progressPrintTime = (const char*) pr["printedTimeComp"];
//Figure out Time Left //Figure out Time Left
long timeTot=0; long timeTot=0;
long timeElap=0; long timeElap=0;
long timeLeft=0; long timeLeft=0;
if (printerData.estimatedPrintTime != "" ) { if (printerData.estimatedPrintTime != "" ) {
timeTot = atol(pr["printTime"]); timeTot = atol(pr["printTime"]);
} }
if (printerData.progressPrintTime != "") { if (printerData.progressPrintTime != "") {
timeElap= atol(pr["printedTimeComp"]); timeElap= atol(pr["printedTimeComp"]);
} }
timeLeft = timeTot-timeElap; timeLeft = timeTot-timeElap;
printerData.progressPrintTimeLeft = String(timeLeft); printerData.progressPrintTimeLeft = String(timeLeft);
String printing = (const char*) pr["job"]; String printing = (const char*) pr["job"];
if (printing != "none") { if (printing != "none") {
printerData.isPrinting = true; printerData.isPrinting = true;
} else { } else {
printerData.isPrinting=false; printerData.isPrinting=false;
} }
Serial.println("PT: " + printerData.progressPrintTime); Serial.println("PT: " + printerData.progressPrintTime);
Serial.println("PTC: " + printerData.estimatedPrintTime); Serial.println("PTC: " + printerData.estimatedPrintTime);
Serial.println("ST: " + printerData.lastPrintTime); Serial.println("ST: " + printerData.lastPrintTime);
Serial.println("TimeLeft: " + printerData.progressPrintTimeLeft); Serial.println("TimeLeft: " + printerData.progressPrintTimeLeft);
if (printerData.isPrinting) { if (printerData.isPrinting) {
Serial.println("I think I am printing"); Serial.println("I think I am printing");
} }
if (isOperational()) { if (isOperational()) {
Serial.println("Status: " + printerData.state); Serial.println("Status: " + printerData.state);
} else { } else {
Serial.println("Printer Not Operational"); Serial.println("Printer Not Operational");
} }
//**** get the Printer Temps and Stat //**** get the Printer Temps and Stat
apiGetData = "GET /printer/api/?a=stateList"; apiGetData = "GET /printer/api/?a=stateList";
printClient = getSubmitRequest(apiGetData); printClient = getSubmitRequest(apiGetData);
if (printerData.error != "") { if (printerData.error != "") {
return; return;
} }
const size_t bufferSize2 = 3*JSON_OBJECT_SIZE(2) + 2*JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(9) + 300; const size_t bufferSize2 = 3*JSON_OBJECT_SIZE(2) + 2*JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(9) + 300;
DynamicJsonBuffer jsonBuffer2(bufferSize2); DynamicJsonBuffer jsonBuffer2(bufferSize2);
//Parse JSON object //Parse JSON object
JsonObject& root2 = jsonBuffer2.parseObject(printClient); JsonObject& root2 = jsonBuffer2.parseObject(printClient);
//Select printer //Select printer
String slug=(const char*) pr["slug"]; String slug=(const char*) pr["slug"];
JsonObject& pr2 = root2[slug]; JsonObject& pr2 = root2[slug];
if (!root2.success()) { if (!root2.success()) {
printerData.isPrinting = false; printerData.isPrinting = false;
printerData.toolTemp = ""; printerData.toolTemp = "";
printerData.toolTargetTemp = ""; printerData.toolTargetTemp = "";
printerData.bedTemp = ""; printerData.bedTemp = "";
printerData.bedTargetTemp = (const char*) pr2["heatBeds"][0]["tempSet"]; printerData.bedTargetTemp = (const char*) pr2["heatBeds"][0]["tempSet"];
return; return;
} }
printerData.toolTemp = (const char*) pr2["extruder"][0]["tempRead"]; printerData.toolTemp = (const char*) pr2["extruder"][0]["tempRead"];
printerData.toolTargetTemp = (const char*) pr2["extruder"][0]["tempSet"]; printerData.toolTargetTemp = (const char*) pr2["extruder"][0]["tempSet"];
printerData.bedTemp = (const char*) pr2["heatedBeds"][0]["tempRead"]; printerData.bedTemp = (const char*) pr2["heatedBeds"][0]["tempRead"];
printerData.bedTargetTemp = (const char*) pr2["heatedBeds"][0]["tempSet"]; printerData.bedTargetTemp = (const char*) pr2["heatedBeds"][0]["tempSet"];
if (printerData.isPrinting) { if (printerData.isPrinting) {
Serial.println("Status: " + printerData.state + " " + printerData.fileName + "(" + printerData.progressCompletion + "%)"); Serial.println("Status: " + printerData.state + " " + printerData.fileName + "(" + printerData.progressCompletion + "%)");
} }
} }
void RepetierClient::getPrinterPsuState() { void RepetierClient::getPrinterPsuState() {
//**** get the PSU state (if enabled and printer operational) //**** get the PSU state (if enabled and printer operational)
//Not implemented in Repetier Server AFAIK //Not implemented in Repetier Server AFAIK
} }
// Reset all PrinterData // Reset all PrinterData
void RepetierClient::resetPrintData() { void RepetierClient::resetPrintData() {
printerData.averagePrintTime = ""; printerData.averagePrintTime = "";
printerData.estimatedPrintTime = ""; printerData.estimatedPrintTime = "";
printerData.fileName = ""; printerData.fileName = "";
printerData.fileSize = ""; printerData.fileSize = "";
printerData.lastPrintTime = ""; printerData.lastPrintTime = "";
printerData.progressCompletion = ""; printerData.progressCompletion = "";
printerData.progressFilepos = ""; printerData.progressFilepos = "";
printerData.progressPrintTime = ""; printerData.progressPrintTime = "";
printerData.progressPrintTimeLeft = ""; printerData.progressPrintTimeLeft = "";
printerData.state = ""; printerData.state = "";
printerData.toolTemp = ""; printerData.toolTemp = "";
printerData.toolTargetTemp = ""; printerData.toolTargetTemp = "";
printerData.filamentLength = ""; printerData.filamentLength = "";
printerData.bedTemp = ""; printerData.bedTemp = "";
printerData.bedTargetTemp = ""; printerData.bedTargetTemp = "";
printerData.isPrinting = false; printerData.isPrinting = false;
printerData.isPSUoff = false; printerData.isPSUoff = false;
printerData.error = ""; printerData.error = "";
} }
String RepetierClient::getAveragePrintTime(){ String RepetierClient::getAveragePrintTime(){
return printerData.averagePrintTime; return printerData.averagePrintTime;
} }
String RepetierClient::getEstimatedPrintTime() { String RepetierClient::getEstimatedPrintTime() {
return printerData.estimatedPrintTime; return printerData.estimatedPrintTime;
} }
String RepetierClient::getFileName() { String RepetierClient::getFileName() {
return printerData.fileName; return printerData.fileName;
} }
String RepetierClient::getFileSize() { String RepetierClient::getFileSize() {
return printerData.fileSize; return printerData.fileSize;
} }
String RepetierClient::getLastPrintTime(){ String RepetierClient::getLastPrintTime(){
return printerData.lastPrintTime; return printerData.lastPrintTime;
} }
String RepetierClient::getProgressCompletion() { String RepetierClient::getProgressCompletion() {
return String(printerData.progressCompletion.toInt()); return String(printerData.progressCompletion.toInt());
} }
String RepetierClient::getProgressFilepos() { String RepetierClient::getProgressFilepos() {
return printerData.progressFilepos; return printerData.progressFilepos;
} }
String RepetierClient::getProgressPrintTime() { String RepetierClient::getProgressPrintTime() {
return printerData.progressPrintTime; return printerData.progressPrintTime;
} }
String RepetierClient::getProgressPrintTimeLeft() { String RepetierClient::getProgressPrintTimeLeft() {
String rtnValue = printerData.progressPrintTimeLeft; String rtnValue = printerData.progressPrintTimeLeft;
if (getProgressCompletion() == "100") { if (getProgressCompletion() == "100") {
rtnValue = "0"; // Print is done so this should be 0 this is a fix for OctoPrint rtnValue = "0"; // Print is done so this should be 0 this is a fix for OctoPrint
} }
return rtnValue; return rtnValue;
} }
String RepetierClient::getState() { String RepetierClient::getState() {
return printerData.state; return printerData.state;
} }
boolean RepetierClient::isPrinting() { boolean RepetierClient::isPrinting() {
return printerData.isPrinting; return printerData.isPrinting;
} }
boolean RepetierClient::isPSUoff() { boolean RepetierClient::isPSUoff() {
return printerData.isPSUoff; return printerData.isPSUoff;
} }
boolean RepetierClient::isOperational() { boolean RepetierClient::isOperational() {
boolean operational = false; boolean operational = false;
if (printerData.state == "Operational" || isPrinting()) { if (printerData.state == "Operational" || isPrinting()) {
operational = true; operational = true;
} }
return operational; return operational;
} }
String RepetierClient::getTempBedActual() { String RepetierClient::getTempBedActual() {
return printerData.bedTemp; return printerData.bedTemp;
} }
String RepetierClient::getTempBedTarget() { String RepetierClient::getTempBedTarget() {
return printerData.bedTargetTemp; return printerData.bedTargetTemp;
} }
String RepetierClient::getTempToolActual() { String RepetierClient::getTempToolActual() {
return printerData.toolTemp; return printerData.toolTemp;
} }
String RepetierClient::getTempToolTarget() { String RepetierClient::getTempToolTarget() {
return printerData.toolTargetTemp; return printerData.toolTargetTemp;
} }
String RepetierClient::getFilamentLength() { String RepetierClient::getFilamentLength() {
return printerData.filamentLength; return printerData.filamentLength;
} }
String RepetierClient::getError() { String RepetierClient::getError() {
return printerData.error; return printerData.error;
} }
String RepetierClient::getValueRounded(String value) { String RepetierClient::getValueRounded(String value) {
float f = value.toFloat(); float f = value.toFloat();
int rounded = (int)(f+0.5f); int rounded = (int)(f+0.5f);
return String(rounded); return String(rounded);
} }
String RepetierClient::getPrinterType() {
return printerType;
}

View File

@ -37,6 +37,7 @@ private:
String myApiKey = ""; String myApiKey = "";
String encodedAuth = ""; String encodedAuth = "";
boolean pollPsu; boolean pollPsu;
const String printerType = "Repetier";
void resetPrintData(); void resetPrintData();
boolean validate(); boolean validate();
@ -95,4 +96,5 @@ public:
String getFilamentLength(); String getFilamentLength();
String getValueRounded(String value); String getValueRounded(String value);
String getError(); String getError();
String getPrinterType();
}; };

View File

@ -87,10 +87,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);
String printerType = "Repetier";
#else #else
OctoPrintClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU); OctoPrintClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU);
String printerType = "OctoPrint";
#endif #endif
int printerCount = 0; int printerCount = 0;
@ -113,12 +111,12 @@ String WEB_ACTIONS = "<a class='w3-bar-item w3-button' href='/'><i class='fa fa
"<a class='w3-bar-item w3-button' href='https://github.com/Qrome' target='_blank'><i class='fa fa-question-circle'></i> About</a>"; "<a class='w3-bar-item w3-button' href='https://github.com/Qrome' target='_blank'><i class='fa fa-question-circle'></i> About</a>";
String CHANGE_FORM = "<form class='w3-container' action='/updateconfig' method='get'><h2>Station Config:</h2>" String CHANGE_FORM = "<form class='w3-container' action='/updateconfig' method='get'><h2>Station Config:</h2>"
"<p><label>" + printerType + " API Key (get from your server)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='PrinterApiKey' value='%OCTOKEY%' maxlength='60'></p>" "<p><label>" + printerClient.getPrinterType() + " API Key (get from your server)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='PrinterApiKey' value='%OCTOKEY%' maxlength='60'></p>"
"<p><label>" + printerType + " Host Name (usually octopi)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='PrinterHostName' value='%OCTOHOST%' maxlength='60'></p>" "<p><label>" + printerClient.getPrinterType() + " Host Name (usually octopi)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='PrinterHostName' value='%OCTOHOST%' maxlength='60'></p>"
"<p><label>" + printerType + " Address (do not include http://)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='PrinterAddress' value='%OCTOADDRESS%' maxlength='60'></p>" "<p><label>" + printerClient.getPrinterType() + " Address (do not include http://)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='PrinterAddress' value='%OCTOADDRESS%' maxlength='60'></p>"
"<p><label>" + printerType + " Port</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='PrinterPort' value='%OCTOPORT%' maxlength='5' onkeypress='return isNumberKey(event)'></p>" "<p><label>" + printerClient.getPrinterType() + " Port</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='PrinterPort' value='%OCTOPORT%' maxlength='5' onkeypress='return isNumberKey(event)'></p>"
"<p><label>" + printerType + " User (only needed if you have haproxy or basic auth turned on)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='octoUser' value='%OCTOUSER%' maxlength='30'></p>" "<p><label>" + printerClient.getPrinterType() + " User (only needed if you have haproxy or basic auth turned on)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='octoUser' value='%OCTOUSER%' maxlength='30'></p>"
"<p><label>" + printerType + " Password </label><input class='w3-input w3-border w3-margin-bottom' type='password' name='octoPass' value='%OCTOPASS%'></p><hr>" "<p><label>" + printerClient.getPrinterType() + " Password </label><input class='w3-input w3-border w3-margin-bottom' type='password' name='octoPass' value='%OCTOPASS%'></p><hr>"
"<p><input name='isClockEnabled' class='w3-check w3-margin-top' type='checkbox' %IS_CLOCK_CHECKED%> Display Clock when printer is off</p>" "<p><input name='isClockEnabled' class='w3-check w3-margin-top' type='checkbox' %IS_CLOCK_CHECKED%> Display Clock when printer is off</p>"
"<p><input name='is24hour' class='w3-check w3-margin-top' type='checkbox' %IS_24HOUR_CHECKED%> Use 24 Hour Clock (military time)</p>" "<p><input name='is24hour' class='w3-check w3-margin-top' type='checkbox' %IS_24HOUR_CHECKED%> Use 24 Hour Clock (military time)</p>"
"<p><input name='invDisp' class='w3-check w3-margin-top' type='checkbox' %IS_INVDISP_CHECKED%> Flip display orientation</p>" "<p><input name='invDisp' class='w3-check w3-margin-top' type='checkbox' %IS_INVDISP_CHECKED%> Flip display orientation</p>"
@ -725,7 +723,7 @@ void displayPrinterStatus() {
html += "<div class='w3-cell-row' style='width:100%'><h2>Time: " + displayTime + "</h2></div><div class='w3-cell-row'>"; html += "<div class='w3-cell-row' style='width:100%'><h2>Time: " + displayTime + "</h2></div><div class='w3-cell-row'>";
html += "<div class='w3-cell w3-container' style='width:100%'><p>"; html += "<div class='w3-cell w3-container' style='width:100%'><p>";
html += printerType + " Host Name: " + PrinterHostName + "<br>"; html += printerClient.getPrinterType() + " Host Name: " + PrinterHostName + "<br>";
if (printerClient.getError() != "") { if (printerClient.getError() != "") {
html += "Status: Offline<br>"; html += "Status: Offline<br>";
html += "Reason: " + printerClient.getError() + "<br>"; html += "Reason: " + printerClient.getError() + "<br>";