Merge with 3.0 Branch, Night Mode !, Changes and Translations
I Cloned the Master Branch... did some changes and saw there are a 3.0 branch.....with similar changes -.-' Whats diffenrent here: -Merged with 3.0 and my Fork -Add Screensaver Mode (Display Clock and weather if the Printer ist operational or offline....this was some of changes wich i did too :D ) -Add a Night Mode wich dim the Display to the minimum (enable in the webinterface) -A lot of Cosmetic and Label changes for the Web Interface and the Printer Monitor -Add German translations for Weather Main Strings (because OWM.org only translate the descriptions ) -maybe thing i forget XDpull/92/head
parent
cd1bc2b62a
commit
5f9361ba77
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -27,10 +27,10 @@ SOFTWARE.
|
||||||
#include "OctoPrintClient.h"
|
#include "OctoPrintClient.h"
|
||||||
|
|
||||||
OctoPrintClient::OctoPrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu) {
|
OctoPrintClient::OctoPrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu) {
|
||||||
updateOctoPrintClient(ApiKey, server, port, user, pass, psu);
|
updatePrintClient(ApiKey, server, port, user, pass, psu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OctoPrintClient::updateOctoPrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu) {
|
void OctoPrintClient::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;
|
||||||
|
|
@ -236,6 +236,8 @@ void OctoPrintClient::getPrinterJobResults() {
|
||||||
String printing = (const char*)root2["state"]["flags"]["printing"];
|
String printing = (const char*)root2["state"]["flags"]["printing"];
|
||||||
if (printing == "true") {
|
if (printing == "true") {
|
||||||
printerData.isPrinting = true;
|
printerData.isPrinting = true;
|
||||||
|
} else {
|
||||||
|
printerData.isPrinting = false;
|
||||||
}
|
}
|
||||||
printerData.toolTemp = (const char*)root2["temperature"]["tool0"]["actual"];
|
printerData.toolTemp = (const char*)root2["temperature"]["tool0"]["actual"];
|
||||||
printerData.toolTargetTemp = (const char*)root2["temperature"]["tool0"]["target"];
|
printerData.toolTargetTemp = (const char*)root2["temperature"]["tool0"]["target"];
|
||||||
|
|
@ -394,3 +396,19 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
int OctoPrintClient::getPrinterPort() {
|
||||||
|
return myPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
String OctoPrintClient::getPrinterName() {
|
||||||
|
return printerData.printerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OctoPrintClient::setPrinterName(String printer) {
|
||||||
|
printerData.printerName = printer;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -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();
|
||||||
|
|
@ -64,6 +65,7 @@ private:
|
||||||
boolean isPrinting;
|
boolean isPrinting;
|
||||||
boolean isPSUoff;
|
boolean isPSUoff;
|
||||||
String error;
|
String error;
|
||||||
|
String printerName;
|
||||||
} PrinterStruct;
|
} PrinterStruct;
|
||||||
|
|
||||||
PrinterStruct printerData;
|
PrinterStruct printerData;
|
||||||
|
|
@ -73,7 +75,7 @@ public:
|
||||||
OctoPrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu);
|
OctoPrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu);
|
||||||
void getPrinterJobResults();
|
void getPrinterJobResults();
|
||||||
void getPrinterPsuState();
|
void getPrinterPsuState();
|
||||||
void updateOctoPrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu);
|
void updatePrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu);
|
||||||
|
|
||||||
String getAveragePrintTime();
|
String getAveragePrintTime();
|
||||||
String getEstimatedPrintTime();
|
String getEstimatedPrintTime();
|
||||||
|
|
@ -95,4 +97,8 @@ public:
|
||||||
String getFilamentLength();
|
String getFilamentLength();
|
||||||
String getValueRounded(String value);
|
String getValueRounded(String value);
|
||||||
String getError();
|
String getError();
|
||||||
|
String getPrinterType();
|
||||||
|
int getPrinterPort();
|
||||||
|
String getPrinterName();
|
||||||
|
void setPrinterName(String printer);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,367 @@
|
||||||
|
/** The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2018 David Payne
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
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
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Additional Contributions:
|
||||||
|
/* 15 Jan 2019 : Owen Carter : Add psucontrol query via POST api call */
|
||||||
|
/* 07 April 2019 : Jon Smith : Redesigned this class for Repetier Server */
|
||||||
|
|
||||||
|
#include "RepetierClient.h"
|
||||||
|
|
||||||
|
RepetierClient::RepetierClient(String ApiKey, String server, int port, String user, String pass, boolean psu) {
|
||||||
|
updatePrintClient(ApiKey, server, port, user, pass, psu);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RepetierClient::updatePrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu) {
|
||||||
|
server.toCharArray(myServer, 100);
|
||||||
|
myApiKey = ApiKey;
|
||||||
|
myPort = port;
|
||||||
|
encodedAuth = "";
|
||||||
|
if (user != "") {
|
||||||
|
String userpass = user + ":" + pass;
|
||||||
|
base64 b64;
|
||||||
|
encodedAuth = b64.encode(userpass, true);
|
||||||
|
}
|
||||||
|
pollPsu = psu;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean RepetierClient::validate() {
|
||||||
|
boolean rtnValue = false;
|
||||||
|
printerData.error = "";
|
||||||
|
if (String(myServer) == "") {
|
||||||
|
printerData.error += "Server address is required; ";
|
||||||
|
}
|
||||||
|
if (myApiKey == "") {
|
||||||
|
printerData.error += "ApiKey is required; ";
|
||||||
|
}
|
||||||
|
if (printerData.error == "") {
|
||||||
|
rtnValue = true;
|
||||||
|
}
|
||||||
|
return rtnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
WiFiClient RepetierClient::getSubmitRequest(String apiGetData) {
|
||||||
|
WiFiClient printClient;
|
||||||
|
printClient.setTimeout(5000);
|
||||||
|
|
||||||
|
Serial.println("Getting Repetier Data via GET");
|
||||||
|
Serial.println(apiGetData);
|
||||||
|
result = "";
|
||||||
|
if (printClient.connect(myServer, myPort)) { //starts client connection, checks for connection
|
||||||
|
printClient.println(apiGetData);
|
||||||
|
printClient.println("Host: " + String(myServer) + ":" + String(myPort));
|
||||||
|
printClient.println("X-Api-Key: " + myApiKey);
|
||||||
|
if (encodedAuth != "") {
|
||||||
|
printClient.print("Authorization: ");
|
||||||
|
printClient.println("Basic " + encodedAuth);
|
||||||
|
}
|
||||||
|
printClient.println("User-Agent: ArduinoWiFi/1.1");
|
||||||
|
printClient.println("Connection: close");
|
||||||
|
if (printClient.println() == 0) {
|
||||||
|
Serial.println("Connection to " + String(myServer) + ":" + String(myPort) + " failed.");
|
||||||
|
Serial.println();
|
||||||
|
resetPrintData();
|
||||||
|
printerData.error = "Connection to " + String(myServer) + ":" + String(myPort) + " failed.";
|
||||||
|
return printClient;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Serial.println("Connection to Repetier failed: " + String(myServer) + ":" + String(myPort)); //error message if no client connect
|
||||||
|
Serial.println();
|
||||||
|
resetPrintData();
|
||||||
|
printerData.error = "Connection to Repetier failed: " + String(myServer) + ":" + String(myPort);
|
||||||
|
return printClient;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
// Check HTTP status
|
||||||
|
char status[32] = {0};
|
||||||
|
printClient.readBytesUntil('\r', status, sizeof(status));
|
||||||
|
if (strcmp(status, "HTTP/1.1 200 OK") != 0) {
|
||||||
|
Serial.print(F("Unexpected response: "));
|
||||||
|
Serial.println(status);
|
||||||
|
printerData.state = "";
|
||||||
|
printerData.error = "Response: " + String(status);
|
||||||
|
return printClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip HTTP headers
|
||||||
|
char endOfHeaders[] = "\r\n\r\n";
|
||||||
|
if (!printClient.find(endOfHeaders)) {
|
||||||
|
Serial.println(F("Invalid response"));
|
||||||
|
printerData.error = "Invalid response from " + String(myServer) + ":" + String(myPort);
|
||||||
|
printerData.state = "";
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
return printClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RepetierClient::getPrinterJobResults() {
|
||||||
|
if (!validate()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//**** get the Printer Job status
|
||||||
|
String apiGetData = "GET /printer/api/?a=listPrinter&apikey=" + myApiKey;
|
||||||
|
WiFiClient printClient = getSubmitRequest(apiGetData);
|
||||||
|
if (printerData.error != "") {
|
||||||
|
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;
|
||||||
|
DynamicJsonBuffer jsonBuffer(bufferSize);
|
||||||
|
|
||||||
|
// Parse JSON object
|
||||||
|
JsonArray& root = jsonBuffer.parseArray(printClient);
|
||||||
|
|
||||||
|
if (!root.success()) {
|
||||||
|
printerData.error = "Repetier Data Parsing failed: " + String(myServer) + ":" + String(myPort);
|
||||||
|
Serial.println(printerData.error);
|
||||||
|
printerData.state = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int inx = 0;
|
||||||
|
int count = root.size();
|
||||||
|
Serial.println("Size of root: " + String(count));
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
Serial.println("Printer: " + String((const char*)root[i]["slug"]));
|
||||||
|
if (String((const char*)root[i]["slug"]) == printerData.printerName) {
|
||||||
|
inx = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonObject& pr = root[inx];
|
||||||
|
|
||||||
|
//printerData.averagePrintTime = (const char*)pr[""];
|
||||||
|
printerData.estimatedPrintTime = (const char*)pr["printTime"];
|
||||||
|
printerData.fileName = (const char*) pr["job"];
|
||||||
|
printerData.fileSize = (const char*) pr["totalLines"];
|
||||||
|
//printerData.filamentLength = (const char*) pr[""];
|
||||||
|
printerData.state = (const char*) pr["online"];
|
||||||
|
//printerData.lastPrintTime = (const char*) pr[""];
|
||||||
|
printerData.progressCompletion = (const char*) pr["done"];
|
||||||
|
printerData.progressFilepos = (const char*) pr["linesSend"];
|
||||||
|
printerData.progressPrintTime = (const char*) pr["printedTimeComp"];
|
||||||
|
|
||||||
|
//Figure out Time Left
|
||||||
|
long timeTot=0;
|
||||||
|
long timeElap=0;
|
||||||
|
long timeLeft=0;
|
||||||
|
if (printerData.estimatedPrintTime != "" ) {
|
||||||
|
timeTot = atol(pr["printTime"]);
|
||||||
|
}
|
||||||
|
if (printerData.progressPrintTime != "") {
|
||||||
|
timeElap= atol(pr["printedTimeComp"]);
|
||||||
|
}
|
||||||
|
timeLeft = timeTot-timeElap;
|
||||||
|
printerData.progressPrintTimeLeft = String(timeLeft);
|
||||||
|
|
||||||
|
if (printerData.fileName != "none") {
|
||||||
|
printerData.isPrinting = true;
|
||||||
|
} else {
|
||||||
|
printerData.isPrinting = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (printerData.isPrinting) {
|
||||||
|
Serial.println("Printing: " + printerData.fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isOperational()) {
|
||||||
|
Serial.println("Status: " + printerData.state);
|
||||||
|
} else {
|
||||||
|
Serial.println("Printer Not Operational");
|
||||||
|
}
|
||||||
|
|
||||||
|
//**** get the Printer Temps and Stat
|
||||||
|
apiGetData = "GET /printer/api/?a=stateList&apikey=" + myApiKey;
|
||||||
|
printClient = getSubmitRequest(apiGetData);
|
||||||
|
if (printerData.error != "") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const size_t bufferSize2 = 3*JSON_OBJECT_SIZE(2) + 2*JSON_OBJECT_SIZE(3) + JSON_OBJECT_SIZE(9) + 300;
|
||||||
|
DynamicJsonBuffer jsonBuffer2(bufferSize2);
|
||||||
|
|
||||||
|
//Parse JSON object
|
||||||
|
JsonObject& root2 = jsonBuffer2.parseObject(printClient);
|
||||||
|
|
||||||
|
//Select printer
|
||||||
|
JsonObject& pr2 = root2[printerData.printerName];
|
||||||
|
|
||||||
|
if (!root2.success()) {
|
||||||
|
printerData.isPrinting = false;
|
||||||
|
printerData.toolTemp = "";
|
||||||
|
printerData.toolTargetTemp = "";
|
||||||
|
printerData.bedTemp = "";
|
||||||
|
printerData.bedTargetTemp = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printerData.toolTemp = (const char*) pr2["extruder"][0]["tempRead"];
|
||||||
|
printerData.toolTargetTemp = (const char*) pr2["extruder"][0]["tempSet"];
|
||||||
|
printerData.bedTemp = (const char*) pr2["heatedBeds"][0]["tempRead"];
|
||||||
|
printerData.bedTargetTemp = (const char*) pr2["heatedBeds"][0]["tempSet"];
|
||||||
|
|
||||||
|
if (printerData.isPrinting) {
|
||||||
|
Serial.println("Status: " + printerData.state + " " + printerData.fileName + "(" + printerData.progressCompletion + "%)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RepetierClient::getPrinterPsuState() {
|
||||||
|
//**** get the PSU state (if enabled and printer operational)
|
||||||
|
//Not implemented in Repetier Server AFAIK
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset all PrinterData
|
||||||
|
void RepetierClient::resetPrintData() {
|
||||||
|
printerData.averagePrintTime = "";
|
||||||
|
printerData.estimatedPrintTime = "";
|
||||||
|
printerData.fileName = "";
|
||||||
|
printerData.fileSize = "";
|
||||||
|
printerData.lastPrintTime = "";
|
||||||
|
printerData.progressCompletion = "";
|
||||||
|
printerData.progressFilepos = "";
|
||||||
|
printerData.progressPrintTime = "";
|
||||||
|
printerData.progressPrintTimeLeft = "";
|
||||||
|
printerData.state = "";
|
||||||
|
printerData.toolTemp = "";
|
||||||
|
printerData.toolTargetTemp = "";
|
||||||
|
printerData.filamentLength = "";
|
||||||
|
printerData.bedTemp = "";
|
||||||
|
printerData.bedTargetTemp = "";
|
||||||
|
printerData.isPrinting = false;
|
||||||
|
printerData.isPSUoff = false;
|
||||||
|
printerData.error = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getAveragePrintTime(){
|
||||||
|
return printerData.averagePrintTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getEstimatedPrintTime() {
|
||||||
|
return printerData.estimatedPrintTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getFileName() {
|
||||||
|
return printerData.fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getFileSize() {
|
||||||
|
return printerData.fileSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getLastPrintTime(){
|
||||||
|
return printerData.lastPrintTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getProgressCompletion() {
|
||||||
|
return String(printerData.progressCompletion.toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getProgressFilepos() {
|
||||||
|
return printerData.progressFilepos;
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getProgressPrintTime() {
|
||||||
|
return printerData.progressPrintTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getProgressPrintTimeLeft() {
|
||||||
|
String rtnValue = printerData.progressPrintTimeLeft;
|
||||||
|
if (getProgressCompletion() == "100") {
|
||||||
|
rtnValue = "0"; // Print is done so this should be 0 this is a fix for OctoPrint
|
||||||
|
}
|
||||||
|
return rtnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getState() {
|
||||||
|
String rtnValue = "Offline";
|
||||||
|
if (printerData.state == "1") {
|
||||||
|
rtnValue = "Operational";
|
||||||
|
}
|
||||||
|
return rtnValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean RepetierClient::isPrinting() {
|
||||||
|
return printerData.isPrinting;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean RepetierClient::isPSUoff() {
|
||||||
|
return printerData.isPSUoff;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean RepetierClient::isOperational() {
|
||||||
|
boolean operational = false;
|
||||||
|
if (printerData.state == "1" || isPrinting()) {
|
||||||
|
operational = true;
|
||||||
|
}
|
||||||
|
return operational;
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getTempBedActual() {
|
||||||
|
String temp = printerData.bedTemp;
|
||||||
|
temp.remove(temp.indexOf(".") + 3);
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getTempBedTarget() {
|
||||||
|
return printerData.bedTargetTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getTempToolActual() {
|
||||||
|
String temp = printerData.toolTemp;
|
||||||
|
temp.remove(temp.indexOf(".") + 3);
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getTempToolTarget() {
|
||||||
|
return printerData.toolTargetTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getFilamentLength() {
|
||||||
|
return printerData.filamentLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getError() {
|
||||||
|
return printerData.error;
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getValueRounded(String value) {
|
||||||
|
float f = value.toFloat();
|
||||||
|
int rounded = (int)(f+0.5f);
|
||||||
|
return String(rounded);
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getPrinterType() {
|
||||||
|
return printerType;
|
||||||
|
}
|
||||||
|
|
||||||
|
int RepetierClient::getPrinterPort() {
|
||||||
|
return myPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
String RepetierClient::getPrinterName() {
|
||||||
|
return printerData.printerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RepetierClient::setPrinterName(String printer) {
|
||||||
|
printerData.printerName = printer;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,104 @@
|
||||||
|
/** The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2018 David Payne
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
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
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* 07 April 2019 : Jon Smith : added class for Repetier Server (kg4iae@github)*/
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include "libs/ArduinoJson/ArduinoJson.h"
|
||||||
|
#include <base64.h>
|
||||||
|
|
||||||
|
class RepetierClient {
|
||||||
|
|
||||||
|
private:
|
||||||
|
char myServer[100];
|
||||||
|
int myPort = 3344;
|
||||||
|
String myApiKey = "";
|
||||||
|
String encodedAuth = "";
|
||||||
|
boolean pollPsu;
|
||||||
|
const String printerType = "Repetier";
|
||||||
|
|
||||||
|
void resetPrintData();
|
||||||
|
boolean validate();
|
||||||
|
WiFiClient getSubmitRequest(String apiGetData);
|
||||||
|
WiFiClient getPostRequest(String apiPostData, String apiPostBody);
|
||||||
|
|
||||||
|
String result;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
String averagePrintTime;
|
||||||
|
String estimatedPrintTime;
|
||||||
|
String fileName;
|
||||||
|
String fileSize;
|
||||||
|
String lastPrintTime;
|
||||||
|
String progressCompletion;
|
||||||
|
String progressFilepos;
|
||||||
|
String progressPrintTime;
|
||||||
|
String progressPrintTimeLeft;
|
||||||
|
String state;
|
||||||
|
String toolTemp;
|
||||||
|
String toolTargetTemp;
|
||||||
|
String filamentLength;
|
||||||
|
String bedTemp;
|
||||||
|
String bedTargetTemp;
|
||||||
|
boolean isPrinting;
|
||||||
|
boolean isPSUoff;
|
||||||
|
String error;
|
||||||
|
String printerName;
|
||||||
|
} PrinterStruct;
|
||||||
|
|
||||||
|
PrinterStruct printerData;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
RepetierClient(String ApiKey, String server, int port, String user, String pass, boolean psu);
|
||||||
|
void getPrinterJobResults();
|
||||||
|
void getPrinterPsuState();
|
||||||
|
void updatePrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu);
|
||||||
|
|
||||||
|
String getAveragePrintTime();
|
||||||
|
String getEstimatedPrintTime();
|
||||||
|
String getFileName();
|
||||||
|
String getFileSize();
|
||||||
|
String getLastPrintTime();
|
||||||
|
String getProgressCompletion();
|
||||||
|
String getProgressFilepos();
|
||||||
|
String getProgressPrintTime();
|
||||||
|
String getProgressPrintTimeLeft();
|
||||||
|
String getState();
|
||||||
|
boolean isPrinting();
|
||||||
|
boolean isOperational();
|
||||||
|
boolean isPSUoff();
|
||||||
|
String getTempBedActual();
|
||||||
|
String getTempBedTarget();
|
||||||
|
String getTempToolActual();
|
||||||
|
String getTempToolTarget();
|
||||||
|
String getFilamentLength();
|
||||||
|
String getValueRounded(String value);
|
||||||
|
String getError();
|
||||||
|
String getPrinterType();
|
||||||
|
int getPrinterPort();
|
||||||
|
String getPrinterName();
|
||||||
|
void setPrinterName(String printer);
|
||||||
|
};
|
||||||
|
|
@ -45,6 +45,7 @@ SOFTWARE.
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
#include <ESP8266HTTPUpdateServer.h>
|
#include <ESP8266HTTPUpdateServer.h>
|
||||||
#include "TimeClient.h"
|
#include "TimeClient.h"
|
||||||
|
#include "RepetierClient.h"
|
||||||
#include "OctoPrintClient.h"
|
#include "OctoPrintClient.h"
|
||||||
#include "OpenWeatherMapClient.h"
|
#include "OpenWeatherMapClient.h"
|
||||||
#include "WeatherStationFonts.h"
|
#include "WeatherStationFonts.h"
|
||||||
|
|
@ -57,13 +58,14 @@ SOFTWARE.
|
||||||
// Start Settings
|
// Start Settings
|
||||||
//******************************
|
//******************************
|
||||||
|
|
||||||
// OctoPrint Monitoring -- Monitor your 3D printer OctoPrint Server
|
// OctoPrint / Repetier Monitoring -- Monitor your 3D OctoPrint or Repetier Server
|
||||||
String OctoPrintApiKey = ""; // ApiKey from your User Account on OctoPrint
|
//#define USE_REPETIER_CLIENT // Uncomment this line to use the Repetier Printer Server -- OctoPrint is used by default and is most common
|
||||||
String OctoPrintHostName = "octopi";// Default 'octopi' -- or hostname if different (optional if your IP changes)
|
String PrinterApiKey = ""; // ApiKey from your User Account on OctoPrint / Repetier
|
||||||
String OctoPrintServer = ""; // IP or Address of your OctoPrint Server (DO NOT include http://)
|
String PrinterHostName = "octopi";// Default 'octopi' -- or hostname if different (optional if your IP changes)
|
||||||
int OctoPrintPort = 80; // the port you are running your OctoPrint server on (usually 80);
|
String PrinterServer = ""; // IP or Address of your OctoPrint / Repetier Server (DO NOT include http://)
|
||||||
String OctoAuthUser = ""; // only used if you have haproxy or basic athentintication turned on (not default)
|
int PrinterPort = 80; // the port you are running your OctoPrint / Repetier server on (usually 80);
|
||||||
String OctoAuthPass = ""; // only used with haproxy or basic auth (only needed if you must authenticate)
|
String PrinterAuthUser = ""; // only used if you have haproxy or basic athentintication turned on (not default)
|
||||||
|
String PrinterAuthPass = ""; // only used with haproxy or basic auth (only needed if you must authenticate)
|
||||||
|
|
||||||
// Weather Configuration
|
// Weather Configuration
|
||||||
boolean DISPLAYWEATHER = true; // true = show weather when not printing / false = no weather
|
boolean DISPLAYWEATHER = true; // true = show weather when not printing / false = no weather
|
||||||
|
|
@ -87,6 +89,9 @@ boolean IS_24HOUR = false; // 23:00 millitary 24 hour clock
|
||||||
int minutesBetweenDataRefresh = 15;
|
int minutesBetweenDataRefresh = 15;
|
||||||
boolean DISPLAYCLOCK = true; // true = Show Clock when not printing / false = turn off display when not printing
|
boolean DISPLAYCLOCK = true; // true = Show Clock when not printing / false = turn off display when not printing
|
||||||
|
|
||||||
|
// Nightmode
|
||||||
|
boolean USE_NIGHT = false; // Dim the Screen if enabled
|
||||||
|
|
||||||
// Display Settings
|
// Display Settings
|
||||||
const int I2C_DISPLAY_ADDRESS = 0x3c; // I2C Address of your Display (usually 0x3c or 0x3d)
|
const int I2C_DISPLAY_ADDRESS = 0x3c; // I2C Address of your Display (usually 0x3c or 0x3d)
|
||||||
const int SDA_PIN = D2;
|
const int SDA_PIN = D2;
|
||||||
|
|
@ -95,7 +100,8 @@ boolean INVERT_DISPLAY = false; // true = pins at top | false = pins at the bott
|
||||||
//#define DISPLAY_SH1106 // Uncomment this line to use the SH1106 display -- SSD1306 is used by default and is most common
|
//#define DISPLAY_SH1106 // Uncomment this line to use the SH1106 display -- SSD1306 is used by default and is most common
|
||||||
|
|
||||||
// LED Settings
|
// LED Settings
|
||||||
const int externalLight = LED_BUILTIN; // Set to unused pin, like D1, to disable use of built-in LED (LED_BUILTIN)
|
const int externalLight = LED_BUILTIN; // LED will always flash on bootup or Wifi Errors
|
||||||
|
boolean USE_FLASH = true; // true = System LED will Flash on Service Calls; false = disabled LED flashing
|
||||||
|
|
||||||
// PSU Control
|
// PSU Control
|
||||||
boolean HAS_PSU = false; // Set to true if https://github.com/kantlivelong/OctoPrint-PSUControl/ in use
|
boolean HAS_PSU = false; // Set to true if https://github.com/kantlivelong/OctoPrint-PSUControl/ in use
|
||||||
|
|
|
||||||
|
|
@ -59,4 +59,3 @@ class TimeClient {
|
||||||
long getCurrentEpochWithUtcOffset();
|
long getCurrentEpochWithUtcOffset();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1298,4 +1298,3 @@ const char Meteocons_Plain_10[] PROGMEM = {
|
||||||
0xFC,0x0F,0x20,0x02,0x10,0x02,0x10,0x02,0xE0,0x01, // 254
|
0xFC,0x0F,0x20,0x02,0x10,0x02,0x10,0x02,0xE0,0x01, // 254
|
||||||
0x30,0x08,0xC4,0x04,0x00,0x03,0xC4,0x00,0x30 // 255
|
0x30,0x08,0xC4,0x04,0x00,0x03,0xC4,0x00,0x30 // 255
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,9 @@ SOFTWARE.
|
||||||
|
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
#define VERSION "2.5"
|
#define VERSION "3.1"
|
||||||
|
|
||||||
#define HOSTNAME "OctMon-"
|
#define HOSTNAME "PrintMon-"
|
||||||
#define CONFIG "/conf.txt"
|
#define CONFIG "/conf.txt"
|
||||||
|
|
||||||
/* Useful Constants */
|
/* Useful Constants */
|
||||||
|
|
@ -84,8 +84,12 @@ String lastSecond = "xx";
|
||||||
String lastReportStatus = "";
|
String lastReportStatus = "";
|
||||||
boolean displayOn = true;
|
boolean displayOn = true;
|
||||||
|
|
||||||
// OctoPrint Client
|
// Printer Client
|
||||||
OctoPrintClient printerClient(OctoPrintApiKey, OctoPrintServer, OctoPrintPort, OctoAuthUser, OctoAuthPass, HAS_PSU);
|
#if defined(USE_REPETIER_CLIENT)
|
||||||
|
RepetierClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU);
|
||||||
|
#else
|
||||||
|
OctoPrintClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU);
|
||||||
|
#endif
|
||||||
int printerCount = 0;
|
int printerCount = 0;
|
||||||
|
|
||||||
// Weather Client
|
// Weather Client
|
||||||
|
|
@ -98,47 +102,43 @@ int8_t getWifiQuality();
|
||||||
ESP8266WebServer server(WEBSERVER_PORT);
|
ESP8266WebServer server(WEBSERVER_PORT);
|
||||||
ESP8266HTTPUpdateServer serverUpdater;
|
ESP8266HTTPUpdateServer serverUpdater;
|
||||||
|
|
||||||
String WEB_ACTIONS = "<a class='w3-bar-item w3-button' href='/'><i class='fa fa-home'></i> Home</a>"
|
static const char WEB_ACTIONS[] PROGMEM = "<a class='w3-bar-item w3-button' href='/'><i class='fa fa-home'></i> Home</a>"
|
||||||
"<a class='w3-bar-item w3-button' href='/configure'><i class='fa fa-cog'></i> Configure</a>"
|
"<a class='w3-bar-item w3-button' href='/configure'><i class='fa fa-cog'></i> Settings</a>"
|
||||||
"<a class='w3-bar-item w3-button' href='/configureweather'><i class='fa fa-cloud'></i> Weather</a>"
|
"<a class='w3-bar-item w3-button' href='/configureweather'><i class='fa fa-cloud'></i> Weather</a>"
|
||||||
"<a class='w3-bar-item w3-button' href='/systemreset' onclick='return confirm(\"Do you want to reset to default settings?\")'><i class='fa fa-undo'></i> Reset Settings</a>"
|
"<a class='w3-bar-item w3-button' href='/systemreset' onclick='return confirm(\"Do you want to reset to default settings?\")'><i class='fa fa-undo'></i> Reset Settings</a>"
|
||||||
"<a class='w3-bar-item w3-button' href='/forgetwifi' onclick='return confirm(\"Do you want to forget to WiFi connection?\")'><i class='fa fa-wifi'></i> Forget WiFi</a>"
|
"<a class='w3-bar-item w3-button' href='/forgetwifi' onclick='return confirm(\"Do you want to forget to WiFi connection?\")'><i class='fa fa-wifi'></i> Forget WiFi</a>"
|
||||||
"<a class='w3-bar-item w3-button' href='/update'><i class='fa fa-wrench'></i> Firmware Update</a>"
|
"<a class='w3-bar-item w3-button' href='/update'><i class='fa fa-wrench'></i> Firmware Update</a>"
|
||||||
"<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/NeoRame/Printer-Monitor_DE' 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 = ""; // moved to config to make it dynamic
|
||||||
"<p><label>OctoPrint API Key (get from your server)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='octoPrintApiKey' value='%OCTOKEY%' maxlength='60'></p>"
|
|
||||||
"<p><label>OctoPrint Host Name (usually octopi)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='octoPrintHostName' value='%OCTOHOST%' maxlength='60'></p>"
|
static const char CLOCK_FORM[] PROGMEM = "<hr><p><input name='isClockEnabled' class='w3-check w3-margin-top' type='checkbox' %IS_CLOCK_CHECKED%> Display Clock when printer is operational or off</p>"
|
||||||
"<p><label>OctoPrint Address (do not include http://)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='octoPrintAddress' value='%OCTOADDRESS%' maxlength='60'></p>"
|
|
||||||
"<p><label>OctoPrint Port</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='octoPrintPort' value='%OCTOPORT%' maxlength='5' onkeypress='return isNumberKey(event)'></p>"
|
|
||||||
"<p><label>OctoPrint 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>OctoPrint 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='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='useNight' class='w3-check w3-margin-top' type='checkbox' %USENIGHT%> Night Mode (Dim the Screen)</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>"
|
||||||
|
"<p><input name='useFlash' class='w3-check w3-margin-top' type='checkbox' %USEFLASH%> Flash System LED on Service Calls</p>"
|
||||||
"<p><input name='hasPSU' class='w3-check w3-margin-top' type='checkbox' %HAS_PSU_CHECKED%> Use OctoPrint PSU control plugin for clock/blank</p>"
|
"<p><input name='hasPSU' class='w3-check w3-margin-top' type='checkbox' %HAS_PSU_CHECKED%> Use OctoPrint PSU control plugin for clock/blank</p>"
|
||||||
"<p>Clock Sync / Weather Refresh (minutes) <select class='w3-option w3-padding' name='refresh'>%OPTIONS%</select></p>";
|
"<p>Clock Sync / Weather Refresh (minutes) <select class='w3-option w3-padding' name='refresh'>%OPTIONS%</select></p>";
|
||||||
|
|
||||||
String THEME_FORM = "<p>Theme Color <select class='w3-option w3-padding' name='theme'>%THEME_OPTIONS%</select></p>"
|
static const char THEME_FORM[] PROGMEM = "<p>Theme Color <select class='w3-option w3-padding' name='theme'>%THEME_OPTIONS%</select></p>"
|
||||||
"<p><label>UTC Time Offset</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='utcoffset' value='%UTCOFFSET%' maxlength='12'></p><hr>"
|
"<p><label>UTC Time Offset</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='utcoffset' value='%UTCOFFSET%' maxlength='12'></p><hr>"
|
||||||
"<p><input name='isBasicAuth' class='w3-check w3-margin-top' type='checkbox' %IS_BASICAUTH_CHECKED%> Use Security Credentials for Configuration Changes</p>"
|
"<p><input name='isBasicAuth' class='w3-check w3-margin-top' type='checkbox' %IS_BASICAUTH_CHECKED%> Use Security Credentials for Configuration Changes</p>"
|
||||||
"<p><label>User ID (for this interface)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='userid' value='%USERID%' maxlength='20'></p>"
|
"<p><label>User ID (for this interface)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='userid' value='%USERID%' maxlength='20'></p>"
|
||||||
"<p><label>Password </label><input class='w3-input w3-border w3-margin-bottom' type='password' name='stationpassword' value='%STATIONPASSWORD%'></p>"
|
"<p><label>Password </label><input class='w3-input w3-border w3-margin-bottom' type='password' name='stationpassword' value='%STATIONPASSWORD%'></p>"
|
||||||
"<button class='w3-button w3-block w3-grey w3-section w3-padding' type='submit'>Save</button></form>";
|
"<button class='w3-button w3-block w3-grey w3-section w3-padding' type='submit'>Save</button></form>";
|
||||||
|
|
||||||
String WEATHER_FORM = "<form class='w3-container' action='/updateweatherconfig' method='get'><h2>Weather Config:</h2>"
|
static const char WEATHER_FORM[] PROGMEM = "<form class='w3-container' action='/updateweatherconfig' method='get'><h2>Weather Config:</h2>"
|
||||||
"<p><input name='isWeatherEnabled' class='w3-check w3-margin-top' type='checkbox' %IS_WEATHER_CHECKED%> Display Weather when printer is off</p>"
|
"<p><input name='isWeatherEnabled' class='w3-check w3-margin-top' type='checkbox' %IS_WEATHER_CHECKED%> Display Weather when printer is off</p>"
|
||||||
"<label>OpenWeatherMap API Key (get from <a href='https://openweathermap.org/' target='_BLANK'>here</a>)</label>"
|
"<label>OpenWeatherMap API Key (get from <a href='https://openweathermap.org/' target='_BLANK'>here</a>)</label>"
|
||||||
"<input class='w3-input w3-border w3-margin-bottom' type='text' name='openWeatherMapApiKey' value='%WEATHERKEY%' maxlength='60'>"
|
"<input class='w3-input w3-border w3-margin-bottom' type='text' name='openWeatherMapApiKey' value='%WEATHERKEY%' maxlength='60'>"
|
||||||
"<p><label>%CITYNAME1% (<a href='http://openweathermap.org/find' target='_BLANK'><i class='fa fa-search'></i>Search for City ID</a>) "
|
"<p><label>%CITYNAME1% (<a href='http://openweathermap.org/find' target='_BLANK'><i class='fa fa-search'></i>Search for City ID</a>) "
|
||||||
"or full <a href='http://openweathermap.org/help/city_list.txt' target='_BLANK'>city list</a></label>"
|
|
||||||
"<input class='w3-input w3-border w3-margin-bottom' type='text' name='city1' value='%CITY1%' onkeypress='return isNumberKey(event)'></p>"
|
"<input class='w3-input w3-border w3-margin-bottom' type='text' name='city1' value='%CITY1%' onkeypress='return isNumberKey(event)'></p>"
|
||||||
"<p><input name='metric' class='w3-check w3-margin-top' type='checkbox' %METRIC%> Use Metric (Celsius)</p>"
|
"<p><input name='metric' class='w3-check w3-margin-top' type='checkbox' %METRIC%> Use Metric (Celsius)</p>"
|
||||||
"<p>Weather Language <select class='w3-option w3-padding' name='language'>%LANGUAGEOPTIONS%</select></p>"
|
"<p>Weather Language (for the Weather Descriptions, mostly) <select class='w3-option w3-padding' name='language'>%LANGUAGEOPTIONS%</select></p>"
|
||||||
"<button class='w3-button w3-block w3-grey w3-section w3-padding' type='submit'>Save</button></form>"
|
"<button class='w3-button w3-block w3-grey w3-section w3-padding' type='submit'>Save</button></form>"
|
||||||
"<script>function isNumberKey(e){var h=e.which?e.which:event.keyCode;return!(h>31&&(h<48||h>57))}</script>";
|
"<script>function isNumberKey(e){var h=e.which?e.which:event.keyCode;return!(h>31&&(h<48||h>57))}</script>";
|
||||||
|
|
||||||
String LANG_OPTIONS = "<option>ar</option>"
|
static const char LANG_OPTIONS[] PROGMEM = "<option>ar</option>"
|
||||||
"<option>bg</option>"
|
"<option>bg</option>"
|
||||||
"<option>ca</option>"
|
"<option>ca</option>"
|
||||||
"<option>cz</option>"
|
"<option>cz</option>"
|
||||||
|
|
@ -172,7 +172,7 @@ String LANG_OPTIONS = "<option>ar</option>"
|
||||||
"<option>zh_cn</option>"
|
"<option>zh_cn</option>"
|
||||||
"<option>zh_tw</option>";
|
"<option>zh_tw</option>";
|
||||||
|
|
||||||
String COLOR_THEMES = "<option>red</option>"
|
static const char COLOR_THEMES[] PROGMEM = "<option>red</option>"
|
||||||
"<option>pink</option>"
|
"<option>pink</option>"
|
||||||
"<option>purple</option>"
|
"<option>purple</option>"
|
||||||
"<option>deep-purple</option>"
|
"<option>deep-purple</option>"
|
||||||
|
|
@ -208,6 +208,9 @@ void setup() {
|
||||||
// Initialize digital pin for LED (little blue light on the Wemos D1 Mini)
|
// Initialize digital pin for LED (little blue light on the Wemos D1 Mini)
|
||||||
pinMode(externalLight, OUTPUT);
|
pinMode(externalLight, OUTPUT);
|
||||||
|
|
||||||
|
//Some Defaults before loading from Config.txt
|
||||||
|
PrinterPort = printerClient.getPrinterPort();
|
||||||
|
|
||||||
readSettings();
|
readSettings();
|
||||||
|
|
||||||
// initialize display
|
// initialize display
|
||||||
|
|
@ -222,7 +225,7 @@ void setup() {
|
||||||
display.setFont(ArialMT_Plain_16);
|
display.setFont(ArialMT_Plain_16);
|
||||||
display.setTextAlignment(TEXT_ALIGN_CENTER);
|
display.setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
display.setContrast(255); // default is 255
|
display.setContrast(255); // default is 255
|
||||||
display.drawString(64, 5, "Printer Monitor\nBy Qrome\nV" + String(VERSION));
|
display.drawString(64, 5, "Printer Monitor\nfor " + printerClient.getPrinterType() + "\nV" + String(VERSION));
|
||||||
display.display();
|
display.display();
|
||||||
|
|
||||||
//WiFiManager
|
//WiFiManager
|
||||||
|
|
@ -311,7 +314,7 @@ void setup() {
|
||||||
display.setTextAlignment(TEXT_ALIGN_CENTER);
|
display.setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
display.setFont(ArialMT_Plain_10);
|
display.setFont(ArialMT_Plain_10);
|
||||||
display.drawString(64, 10, "Web Interface On");
|
display.drawString(64, 10, "Web Interface On");
|
||||||
display.drawString(64, 20, "You May Connect to IP");
|
display.drawString(64, 20, "You May Connect to IP:");
|
||||||
display.setFont(ArialMT_Plain_16);
|
display.setFont(ArialMT_Plain_16);
|
||||||
display.drawString(64, 30, WiFi.localIP().toString());
|
display.drawString(64, 30, WiFi.localIP().toString());
|
||||||
display.drawString(64, 46, "Port: " + String(WEBSERVER_PORT));
|
display.drawString(64, 46, "Port: " + String(WEBSERVER_PORT));
|
||||||
|
|
@ -325,40 +328,40 @@ void setup() {
|
||||||
display.drawString(64, 20, "Enable in Settings.h");
|
display.drawString(64, 20, "Enable in Settings.h");
|
||||||
display.display();
|
display.display();
|
||||||
}
|
}
|
||||||
flashLED(5, 500);
|
flashLED(5, 100);
|
||||||
findMDNS(); //go find Octoprint Server by the hostname
|
findMDNS(); //go find Printer Server by the hostname
|
||||||
Serial.println("*** Leaving setup()");
|
Serial.println("*** Leaving setup()");
|
||||||
}
|
}
|
||||||
|
|
||||||
void findMDNS() {
|
void findMDNS() {
|
||||||
if (OctoPrintHostName == "" || ENABLE_OTA == false) {
|
if (PrinterHostName == "" || ENABLE_OTA == false) {
|
||||||
return; // nothing to do here
|
return; // nothing to do here
|
||||||
}
|
}
|
||||||
// We now query our network for 'web servers' service
|
// We now query our network for 'web servers' service
|
||||||
// over tcp, and get the number of available devices
|
// over tcp, and get the number of available devices
|
||||||
int n = MDNS.queryService("http", "tcp");
|
int n = MDNS.queryService("http", "tcp");
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
Serial.println("no services found - make sure OctoPrint server is turned on");
|
Serial.println("no services found - make sure Printer server is turned on");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Serial.println("*** Looking for " + OctoPrintHostName + " over mDNS");
|
Serial.println("*** Looking for " + PrinterHostName + " over mDNS");
|
||||||
for (int i = 0; i < n; ++i) {
|
for (int i = 0; i < n; ++i) {
|
||||||
// Going through every available service,
|
// Going through every available service,
|
||||||
// we're searching for the one whose hostname
|
// we're searching for the one whose hostname
|
||||||
// matches what we want, and then get its IP
|
// matches what we want, and then get its IP
|
||||||
Serial.println("Found: " + MDNS.hostname(i));
|
Serial.println("Found: " + MDNS.hostname(i));
|
||||||
if (MDNS.hostname(i) == OctoPrintHostName) {
|
if (MDNS.hostname(i) == PrinterHostName) {
|
||||||
IPAddress serverIp = MDNS.IP(i);
|
IPAddress serverIp = MDNS.IP(i);
|
||||||
OctoPrintServer = serverIp.toString();
|
PrinterServer = serverIp.toString();
|
||||||
OctoPrintPort = MDNS.port(i); // save the port
|
PrinterPort = MDNS.port(i); // save the port
|
||||||
Serial.println("*** Found OctoPrint Server " + OctoPrintHostName + " http://" + OctoPrintServer + ":" + OctoPrintPort);
|
Serial.println("*** Found Printer Server " + PrinterHostName + " http://" + PrinterServer + ":" + PrinterPort);
|
||||||
writeSettings(); // update the settings
|
writeSettings(); // update the settings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//************************************************************
|
//************************************************************
|
||||||
// Main Looop
|
// Main Loop
|
||||||
//************************************************************
|
//************************************************************
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
|
|
@ -369,19 +372,19 @@ void loop() {
|
||||||
|
|
||||||
if (lastMinute != timeClient.getMinutes() && !printerClient.isPrinting()) {
|
if (lastMinute != timeClient.getMinutes() && !printerClient.isPrinting()) {
|
||||||
// Check status every 60 seconds
|
// Check status every 60 seconds
|
||||||
digitalWrite(externalLight, LOW);
|
ledOnOff(true);
|
||||||
lastMinute = timeClient.getMinutes(); // reset the check value
|
lastMinute = timeClient.getMinutes(); // reset the check value
|
||||||
printerClient.getPrinterJobResults();
|
printerClient.getPrinterJobResults();
|
||||||
printerClient.getPrinterPsuState();
|
printerClient.getPrinterPsuState();
|
||||||
digitalWrite(externalLight, HIGH);
|
ledOnOff(false);
|
||||||
} else if (printerClient.isPrinting()) {
|
} else if (printerClient.isPrinting()) {
|
||||||
if (lastSecond != timeClient.getSeconds() && timeClient.getSeconds().endsWith("0")) {
|
if (lastSecond != timeClient.getSeconds() && timeClient.getSeconds().endsWith("0")) {
|
||||||
lastSecond = timeClient.getSeconds();
|
lastSecond = timeClient.getSeconds();
|
||||||
// every 10 seconds while printing get an update
|
// every 10 seconds while printing get an update
|
||||||
digitalWrite(externalLight, LOW);
|
ledOnOff(true);
|
||||||
printerClient.getPrinterJobResults();
|
printerClient.getPrinterJobResults();
|
||||||
printerClient.getPrinterPsuState();
|
printerClient.getPrinterPsuState();
|
||||||
digitalWrite(externalLight, HIGH);
|
ledOnOff(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -398,7 +401,7 @@ void loop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void getUpdateTime() {
|
void getUpdateTime() {
|
||||||
digitalWrite(externalLight, LOW); // turn on the LED
|
ledOnOff(true); // turn on the LED
|
||||||
Serial.println();
|
Serial.println();
|
||||||
|
|
||||||
if (displayOn && DISPLAYWEATHER) {
|
if (displayOn && DISPLAYWEATHER) {
|
||||||
|
|
@ -412,7 +415,7 @@ void getUpdateTime() {
|
||||||
lastEpoch = timeClient.getCurrentEpoch();
|
lastEpoch = timeClient.getCurrentEpoch();
|
||||||
Serial.println("Local time: " + timeClient.getAmPmFormattedTime());
|
Serial.println("Local time: " + timeClient.getAmPmFormattedTime());
|
||||||
|
|
||||||
digitalWrite(externalLight, HIGH); // turn off the LED
|
ledOnOff(false); // turn off the LED
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean authentication() {
|
boolean authentication() {
|
||||||
|
|
@ -454,15 +457,20 @@ void handleUpdateConfig() {
|
||||||
if (!authentication()) {
|
if (!authentication()) {
|
||||||
return server.requestAuthentication();
|
return server.requestAuthentication();
|
||||||
}
|
}
|
||||||
OctoPrintApiKey = server.arg("octoPrintApiKey");
|
if (server.hasArg("printer")) {
|
||||||
OctoPrintHostName = server.arg("octoPrintHostName");
|
printerClient.setPrinterName(server.arg("printer"));
|
||||||
OctoPrintServer = server.arg("octoPrintAddress");
|
}
|
||||||
OctoPrintPort = server.arg("octoPrintPort").toInt();
|
PrinterApiKey = server.arg("PrinterApiKey");
|
||||||
OctoAuthUser = server.arg("octoUser");
|
PrinterHostName = server.arg("PrinterHostName");
|
||||||
OctoAuthPass = server.arg("octoPass");
|
PrinterServer = server.arg("PrinterAddress");
|
||||||
|
PrinterPort = server.arg("PrinterPort").toInt();
|
||||||
|
PrinterAuthUser = server.arg("octoUser");
|
||||||
|
PrinterAuthPass = server.arg("octoPass");
|
||||||
DISPLAYCLOCK = server.hasArg("isClockEnabled");
|
DISPLAYCLOCK = server.hasArg("isClockEnabled");
|
||||||
IS_24HOUR = server.hasArg("is24hour");
|
IS_24HOUR = server.hasArg("is24hour");
|
||||||
|
USE_NIGHT = server.hasArg("useNight");
|
||||||
INVERT_DISPLAY = server.hasArg("invDisp");
|
INVERT_DISPLAY = server.hasArg("invDisp");
|
||||||
|
USE_FLASH = server.hasArg("useFlash");
|
||||||
HAS_PSU = server.hasArg("hasPSU");
|
HAS_PSU = server.hasArg("hasPSU");
|
||||||
minutesBetweenDataRefresh = server.arg("refresh").toInt();
|
minutesBetweenDataRefresh = server.arg("refresh").toInt();
|
||||||
themeColor = server.arg("theme");
|
themeColor = server.arg("theme");
|
||||||
|
|
@ -502,7 +510,7 @@ void handleWeatherConfigure() {
|
||||||
if (!authentication()) {
|
if (!authentication()) {
|
||||||
return server.requestAuthentication();
|
return server.requestAuthentication();
|
||||||
}
|
}
|
||||||
digitalWrite(externalLight, LOW);
|
ledOnOff(true);
|
||||||
String html = "";
|
String html = "";
|
||||||
|
|
||||||
server.sendHeader("Cache-Control", "no-cache, no-store");
|
server.sendHeader("Cache-Control", "no-cache, no-store");
|
||||||
|
|
@ -514,7 +522,7 @@ void handleWeatherConfigure() {
|
||||||
html = getHeader();
|
html = getHeader();
|
||||||
server.sendContent(html);
|
server.sendContent(html);
|
||||||
|
|
||||||
String form = WEATHER_FORM;
|
String form = FPSTR(WEATHER_FORM);
|
||||||
String isWeatherChecked = "";
|
String isWeatherChecked = "";
|
||||||
if (DISPLAYWEATHER) {
|
if (DISPLAYWEATHER) {
|
||||||
isWeatherChecked = "checked='checked'";
|
isWeatherChecked = "checked='checked'";
|
||||||
|
|
@ -528,7 +536,7 @@ void handleWeatherConfigure() {
|
||||||
checked = "checked='checked'";
|
checked = "checked='checked'";
|
||||||
}
|
}
|
||||||
form.replace("%METRIC%", checked);
|
form.replace("%METRIC%", checked);
|
||||||
String options = LANG_OPTIONS;
|
String options = FPSTR(LANG_OPTIONS);
|
||||||
options.replace(">"+String(WeatherLanguage)+"<", " selected>"+String(WeatherLanguage)+"<");
|
options.replace(">"+String(WeatherLanguage)+"<", " selected>"+String(WeatherLanguage)+"<");
|
||||||
form.replace("%LANGUAGEOPTIONS%", options);
|
form.replace("%LANGUAGEOPTIONS%", options);
|
||||||
server.sendContent(form);
|
server.sendContent(form);
|
||||||
|
|
@ -537,14 +545,14 @@ void handleWeatherConfigure() {
|
||||||
server.sendContent(html);
|
server.sendContent(html);
|
||||||
server.sendContent("");
|
server.sendContent("");
|
||||||
server.client().stop();
|
server.client().stop();
|
||||||
digitalWrite(externalLight, HIGH);
|
ledOnOff(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleConfigure() {
|
void handleConfigure() {
|
||||||
if (!authentication()) {
|
if (!authentication()) {
|
||||||
return server.requestAuthentication();
|
return server.requestAuthentication();
|
||||||
}
|
}
|
||||||
digitalWrite(externalLight, LOW);
|
ledOnOff(true);
|
||||||
String html = "";
|
String html = "";
|
||||||
|
|
||||||
server.sendHeader("Cache-Control", "no-cache, no-store");
|
server.sendHeader("Cache-Control", "no-cache, no-store");
|
||||||
|
|
@ -556,19 +564,73 @@ void handleConfigure() {
|
||||||
html = getHeader();
|
html = getHeader();
|
||||||
server.sendContent(html);
|
server.sendContent(html);
|
||||||
|
|
||||||
|
CHANGE_FORM = "<form class='w3-container' action='/updateconfig' method='get'><h2>Settings:</h2>"
|
||||||
|
"<p><label>" + printerClient.getPrinterType() + " API Key (get from your server)</label>"
|
||||||
|
"<input class='w3-input w3-border w3-margin-bottom' type='text' name='PrinterApiKey' id='PrinterApiKey' value='%OCTOKEY%' maxlength='60'></p>";
|
||||||
|
if (printerClient.getPrinterType() == "OctoPrint") {
|
||||||
|
CHANGE_FORM += "<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>";
|
||||||
|
}
|
||||||
|
CHANGE_FORM += "<p><label>" + printerClient.getPrinterType() + " Address (do not include http://)</label>"
|
||||||
|
"<input class='w3-input w3-border w3-margin-bottom' type='text' name='PrinterAddress' id='PrinterAddress' value='%OCTOADDRESS%' maxlength='60'></p>"
|
||||||
|
"<p><label>" + printerClient.getPrinterType() + " Port</label>"
|
||||||
|
"<input class='w3-input w3-border w3-margin-bottom' type='text' name='PrinterPort' id='PrinterPort' value='%OCTOPORT%' maxlength='5' onkeypress='return isNumberKey(event)'></p>";
|
||||||
|
if (printerClient.getPrinterType() == "Repetier") {
|
||||||
|
CHANGE_FORM += //"<input type='button' value='Verbindung testen' onclick='testRepetier()'>"
|
||||||
|
"<input class='w3-button w3-light-gray w3-border w3-border-gray w3-hover-gray w3-round-xxlarge' type='button'value='RepetierTest' onclick='testRepetier()'></p>"
|
||||||
|
"<input type='hidden' id='selectedPrinter' value='" + printerClient.getPrinterName() + "'><p id='RepetierTest'></p>"
|
||||||
|
"<script>testRepetier();</script>";
|
||||||
|
} else {
|
||||||
|
CHANGE_FORM += //"<input type='button' value='Teste Verbindung und API JSON Antwort' onclick='testOctoPrint()'><p id='OctoPrintTest'></p>"
|
||||||
|
"<input class='w3-button w3-light-gray w3-border w3-border-gray w3-hover-gray w3-round-xxlarge' type='button' id='OctoPrintTest' value='Test Connection and API JSON Response' onclick='testOctoPrint()'></p>";
|
||||||
|
}
|
||||||
|
CHANGE_FORM += "<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>" + printerClient.getPrinterType() + " Password </label><input class='w3-input w3-border w3-margin-bottom' type='password' name='octoPass' value='%OCTOPASS%'></p>";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (printerClient.getPrinterType() == "Repetier") {
|
||||||
|
html = "<script>function testRepetier(){var e=document.getElementById(\"RepetierTest\"),r=document.getElementById(\"PrinterAddress\").value,"
|
||||||
|
"t=document.getElementById(\"PrinterPort\").value;if(\"\"==r||\"\"==t)return e.innerHTML=\"* Address and Port are required\","
|
||||||
|
"void(e.style.background=\"\");var n=\"http://\"+r+\":\"+t;n+=\"/printer/api/?a=listPrinter&apikey=\"+document.getElementById(\"PrinterApiKey\").value,"
|
||||||
|
"console.log(n);var o=new XMLHttpRequest;o.open(\"GET\",n,!0),o.onload=function(){if(200===o.status){var r=JSON.parse(o.responseText);"
|
||||||
|
"if(!r.error&&r.length>0){var t=\"<label>Connected -- Select Printer</label> \";t+=\"<select class='w3-option w3-padding' name='printer'>\";"
|
||||||
|
"var n=document.getElementById(\"selectedPrinter\").value,i=\"\";for(printer in r)i=r[printer].slug==n?\"selected\":\"\","
|
||||||
|
"t+=\"<option value='\"+r[printer].slug+\"' \"+i+\">\"+r[printer].name+\"</option>\";t+=\"</select>\","
|
||||||
|
"e.innerHTML=t,e.style.background=\"lime\"}else e.innerHTML=\"Error invalid API Key: \"+r.error,"
|
||||||
|
"e.style.background=\"red\"}else e.innerHTML=\"Error: \"+o.statusText,e.style.background=\"red\"},"
|
||||||
|
"o.onerror=function(){e.innerHTML=\"Error connecting to server -- check IP and Port\",e.style.background=\"red\"},o.send(null)}</script>";
|
||||||
|
|
||||||
|
server.sendContent(html);
|
||||||
|
} else {
|
||||||
|
html = "<script>function testOctoPrint(){var e=document.getElementById(\"OctoPrintTest\"),t=document.getElementById(\"PrinterAddress\").value,"
|
||||||
|
"n=document.getElementById(\"PrinterPort\").value;if(e.innerHTML=\"\",\"\"==t||\"\"==n)return e.innerHTML=\"* Address and Port are required\","
|
||||||
|
"void(e.style.background=\"\");var r=\"http://\"+t+\":\"+n;r+=\"/api/job?apikey=\"+document.getElementById(\"PrinterApiKey\").value,window.open(r,\"_blank\").focus()}</script>";
|
||||||
|
server.sendContent(html);
|
||||||
|
}
|
||||||
|
|
||||||
String form = CHANGE_FORM;
|
String form = CHANGE_FORM;
|
||||||
|
|
||||||
form.replace("%OCTOKEY%", OctoPrintApiKey);
|
form.replace("%OCTOKEY%", PrinterApiKey);
|
||||||
form.replace("%OCTOHOST%", OctoPrintHostName);
|
form.replace("%OCTOHOST%", PrinterHostName);
|
||||||
form.replace("%OCTOADDRESS%", OctoPrintServer);
|
form.replace("%OCTOADDRESS%", PrinterServer);
|
||||||
form.replace("%OCTOPORT%", String(OctoPrintPort));
|
form.replace("%OCTOPORT%", String(PrinterPort));
|
||||||
form.replace("%OCTOUSER%", OctoAuthUser);
|
form.replace("%OCTOUSER%", PrinterAuthUser);
|
||||||
form.replace("%OCTOPASS%", OctoAuthPass);
|
form.replace("%OCTOPASS%", PrinterAuthPass);
|
||||||
|
|
||||||
|
server.sendContent(form);
|
||||||
|
|
||||||
|
form = FPSTR(CLOCK_FORM);
|
||||||
|
|
||||||
String isClockChecked = "";
|
String isClockChecked = "";
|
||||||
if (DISPLAYCLOCK) {
|
if (DISPLAYCLOCK) {
|
||||||
isClockChecked = "checked='checked'";
|
isClockChecked = "checked='checked'";
|
||||||
}
|
}
|
||||||
form.replace("%IS_CLOCK_CHECKED%", isClockChecked);
|
form.replace("%IS_CLOCK_CHECKED%", isClockChecked);
|
||||||
|
String isNightchecked = "";
|
||||||
|
if (USE_NIGHT) {
|
||||||
|
isNightchecked = "checked='checked'";
|
||||||
|
}
|
||||||
|
form.replace("%USENIGHT%", isNightchecked);
|
||||||
String is24hourChecked = "";
|
String is24hourChecked = "";
|
||||||
if (IS_24HOUR) {
|
if (IS_24HOUR) {
|
||||||
is24hourChecked = "checked='checked'";
|
is24hourChecked = "checked='checked'";
|
||||||
|
|
@ -579,6 +641,11 @@ void handleConfigure() {
|
||||||
isInvDisp = "checked='checked'";
|
isInvDisp = "checked='checked'";
|
||||||
}
|
}
|
||||||
form.replace("%IS_INVDISP_CHECKED%", isInvDisp);
|
form.replace("%IS_INVDISP_CHECKED%", isInvDisp);
|
||||||
|
String isFlashLED = "";
|
||||||
|
if (USE_FLASH) {
|
||||||
|
isFlashLED = "checked='checked'";
|
||||||
|
}
|
||||||
|
form.replace("%USEFLASH%", isFlashLED);
|
||||||
String hasPSUchecked = "";
|
String hasPSUchecked = "";
|
||||||
if (HAS_PSU) {
|
if (HAS_PSU) {
|
||||||
hasPSUchecked = "checked='checked'";
|
hasPSUchecked = "checked='checked'";
|
||||||
|
|
@ -591,9 +658,9 @@ void handleConfigure() {
|
||||||
|
|
||||||
server.sendContent(form);
|
server.sendContent(form);
|
||||||
|
|
||||||
form = THEME_FORM;
|
form = FPSTR(THEME_FORM);
|
||||||
|
|
||||||
String themeOptions = COLOR_THEMES;
|
String themeOptions = FPSTR(COLOR_THEMES);
|
||||||
themeOptions.replace(">"+String(themeColor)+"<", " selected>"+String(themeColor)+"<");
|
themeOptions.replace(">"+String(themeColor)+"<", " selected>"+String(themeColor)+"<");
|
||||||
form.replace("%THEME_OPTIONS%", themeOptions);
|
form.replace("%THEME_OPTIONS%", themeOptions);
|
||||||
form.replace("%UTCOFFSET%", String(UtcOffset));
|
form.replace("%UTCOFFSET%", String(UtcOffset));
|
||||||
|
|
@ -611,11 +678,11 @@ void handleConfigure() {
|
||||||
server.sendContent(html);
|
server.sendContent(html);
|
||||||
server.sendContent("");
|
server.sendContent("");
|
||||||
server.client().stop();
|
server.client().stop();
|
||||||
digitalWrite(externalLight, HIGH);
|
ledOnOff(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayMessage(String message) {
|
void displayMessage(String message) {
|
||||||
digitalWrite(externalLight, LOW);
|
ledOnOff(true);
|
||||||
|
|
||||||
server.sendHeader("Cache-Control", "no-cache, no-store");
|
server.sendHeader("Cache-Control", "no-cache, no-store");
|
||||||
server.sendHeader("Pragma", "no-cache");
|
server.sendHeader("Pragma", "no-cache");
|
||||||
|
|
@ -630,7 +697,7 @@ void displayMessage(String message) {
|
||||||
server.sendContent("");
|
server.sendContent("");
|
||||||
server.client().stop();
|
server.client().stop();
|
||||||
|
|
||||||
digitalWrite(externalLight, HIGH);
|
ledOnOff(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void redirectHome() {
|
void redirectHome() {
|
||||||
|
|
@ -648,10 +715,11 @@ String getHeader() {
|
||||||
}
|
}
|
||||||
|
|
||||||
String getHeader(boolean refresh) {
|
String getHeader(boolean refresh) {
|
||||||
String menu = WEB_ACTIONS;
|
String menu = FPSTR(WEB_ACTIONS);
|
||||||
|
|
||||||
String html = "<!DOCTYPE HTML>";
|
String html = "<!DOCTYPE HTML>";
|
||||||
html += "<html><head><title>Printer Monitor</title><link rel='icon' href='data:;base64,='>";
|
html += "<html><head><title>Printer Monitor</title><link rel='icon' href='data:;base64,='>";
|
||||||
|
html += "<meta name=\"apple-mobile-web-app-capable\" content=\"yes\">";
|
||||||
html += "<meta charset='UTF-8'>";
|
html += "<meta charset='UTF-8'>";
|
||||||
html += "<meta name='viewport' content='width=device-width, initial-scale=1'>";
|
html += "<meta name='viewport' content='width=device-width, initial-scale=1'>";
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
|
|
@ -696,7 +764,7 @@ String getFooter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayPrinterStatus() {
|
void displayPrinterStatus() {
|
||||||
digitalWrite(externalLight, LOW);
|
ledOnOff(true);
|
||||||
String html = "";
|
String html = "";
|
||||||
|
|
||||||
server.sendHeader("Cache-Control", "no-cache, no-store");
|
server.sendHeader("Cache-Control", "no-cache, no-store");
|
||||||
|
|
@ -711,16 +779,27 @@ void displayPrinterStatus() {
|
||||||
displayTime = timeClient.getHours() + ":" + timeClient.getMinutes() + ":" + timeClient.getSeconds();
|
displayTime = timeClient.getHours() + ":" + timeClient.getMinutes() + ":" + timeClient.getSeconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
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>" + printerClient.getPrinterType() + " Monitor</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 += "Host Name: " + OctoPrintHostName + "<br>";
|
if (printerClient.getPrinterType() == "Repetier") {
|
||||||
|
html += "Drucker Name: " + printerClient.getPrinterName() + " <a href='/configure' title='Configure'><i class='fa fa-cog'></i></a><br>";
|
||||||
|
} else {
|
||||||
|
html += "Host Name: " + PrinterHostName + " <a href='/configure' title='Configure'><i class='fa fa-cog'></i></a><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>";
|
||||||
} else {
|
} else {
|
||||||
html += "Status: " + printerClient.getState();
|
html += "Status: " ;
|
||||||
if (printerClient.isPSUoff() && HAS_PSU) {
|
if (printerClient.isPSUoff() && HAS_PSU) {
|
||||||
html += ", PSU off";
|
html += printerClient.getState() + ", PSU off";
|
||||||
|
}
|
||||||
|
if (printerClient.isPrinting()) {
|
||||||
|
html += "Printing";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
html += printerClient.getState();
|
||||||
}
|
}
|
||||||
html += "<br>";
|
html += "<br>";
|
||||||
}
|
}
|
||||||
|
|
@ -754,14 +833,15 @@ void displayPrinterStatus() {
|
||||||
minutes = numberOfMinutes(val);
|
minutes = numberOfMinutes(val);
|
||||||
seconds = numberOfSeconds(val);
|
seconds = numberOfSeconds(val);
|
||||||
html += "Printing Time: " + zeroPad(hours) + ":" + zeroPad(minutes) + ":" + zeroPad(seconds) + "<br>";
|
html += "Printing Time: " + zeroPad(hours) + ":" + zeroPad(minutes) + ":" + zeroPad(seconds) + "<br>";
|
||||||
html += "<style>#myProgress {width: 100%;background-color: #ddd;}#myBar {width: " + printerClient.getProgressCompletion() + "%;height: 30px;background-color: #4CAF50;}</style>";
|
html += "<div class=\"w3-light-grey w3-round-xlarge\"><div class=\"w3-container w3-green w3-center w3-round-xlarge\" style=\"width:" + printerClient.getProgressCompletion() + "%\"><div class=\"w3-text-black\">" + printerClient.getProgressCompletion() + "%</div></div></div>";
|
||||||
html += "<div id=\"myProgress\"><div id=\"myBar\" class=\"w3-medium w3-center\">" + printerClient.getProgressCompletion() + "%</div></div>";
|
|
||||||
} else {
|
} else {
|
||||||
html += "<hr>";
|
html += "<hr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
html += "</p></div></div>";
|
html += "</p></div></div>";
|
||||||
|
|
||||||
|
html += "<div class='w3-cell-row' style='width:100%'><h3>Time: " + displayTime + "</h3></div>";
|
||||||
|
|
||||||
server.sendContent(html); // spit out what we got
|
server.sendContent(html); // spit out what we got
|
||||||
html = "";
|
html = "";
|
||||||
|
|
||||||
|
|
@ -772,17 +852,15 @@ void displayPrinterStatus() {
|
||||||
html += "<p>Weather Error: <strong>" + weatherClient.getError() + "</strong></p>";
|
html += "<p>Weather Error: <strong>" + weatherClient.getError() + "</strong></p>";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
html += "<div class='w3-cell-row' style='width:100%'><h2>" + weatherClient.getCity(0) + ", " + weatherClient.getCountry(0) + "</h2></div><div class='w3-cell-row'>";
|
html += "<div class='w3-cell-row' style='width:100%'><h2>" + weatherClient.getCity(0) + ", " + weatherClient.getTempRounded(0) + getTempSymbol(true) +"</h2></div><div class='w3-cell-row'>";
|
||||||
html += "<div class='w3-cell w3-left w3-medium' style='width:120px'>";
|
html += "<div class='w3-cell w3-left' style='width:200px'>";
|
||||||
html += "<img src='http://openweathermap.org/img/w/" + weatherClient.getIcon(0) + ".png' alt='" + weatherClient.getDescription(0) + "'><br>";
|
html += "<img src='http://openweathermap.org/img/wn/" + weatherClient.getIcon(0) + ".png' alt='" + weatherClient.getDescription(0) + "'><span class='w3-large'>" +getTranslate() +"</span><br>";
|
||||||
html += weatherClient.getHumidity(0) + "% Humidity<br>";
|
html += weatherClient.getDescription(0) + "<br>";
|
||||||
html += weatherClient.getWind(0) + " <span class='w3-tiny'>" + getSpeedSymbol() + "</span> Wind<br>";
|
html += "<span class='w3-medium'>" + weatherClient.getHumidity(0) + "% Humidity</span><br>";
|
||||||
|
html += "<span class='w3-medium'>" + weatherClient.getWind(0) + "</span><span class='w3-tiny'>" + getSpeedSymbol() + "</span><span class='w3-medium'> Wind</span><br>";
|
||||||
|
html += "<a class='w3-medium' href='https://www.google.com/maps/@" + weatherClient.getLat(0) + "," + weatherClient.getLon(0) + ",10000m/data=' target='_BLANK'><i class='fa fa-map-marker' style='color:red'></i> Map It!</a><br>";
|
||||||
|
html += "</div>";
|
||||||
html += "</div>";
|
html += "</div>";
|
||||||
html += "<div class='w3-cell w3-container' style='width:100%'><p>";
|
|
||||||
html += weatherClient.getCondition(0) + " (" + weatherClient.getDescription(0) + ")<br>";
|
|
||||||
html += weatherClient.getTempRounded(0) + getTempSymbol(true) + "<br>";
|
|
||||||
html += "<a href='https://www.google.com/maps/@" + weatherClient.getLat(0) + "," + weatherClient.getLon(0) + ",10000m/data=!3m1!1e3' target='_BLANK'><i class='fa fa-map-marker' style='color:red'></i> Map It!</a><br>";
|
|
||||||
html += "</p></div></div>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
server.sendContent(html); // spit out what we got
|
server.sendContent(html); // spit out what we got
|
||||||
|
|
@ -792,7 +870,7 @@ void displayPrinterStatus() {
|
||||||
server.sendContent(String(getFooter()));
|
server.sendContent(String(getFooter()));
|
||||||
server.sendContent("");
|
server.sendContent("");
|
||||||
server.client().stop();
|
server.client().stop();
|
||||||
digitalWrite(externalLight, HIGH);
|
ledOnOff(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void configModeCallback (WiFiManager *myWiFiManager) {
|
void configModeCallback (WiFiManager *myWiFiManager) {
|
||||||
|
|
@ -817,12 +895,22 @@ void configModeCallback (WiFiManager *myWiFiManager) {
|
||||||
flashLED(20, 50);
|
flashLED(20, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ledOnOff(boolean value) {
|
||||||
|
if (USE_FLASH) {
|
||||||
|
if (value) {
|
||||||
|
digitalWrite(externalLight, LOW); // LED ON
|
||||||
|
} else {
|
||||||
|
digitalWrite(externalLight, HIGH); // LED OFF
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void flashLED(int number, int delayTime) {
|
void flashLED(int number, int delayTime) {
|
||||||
for (int inx = 0; inx < number; inx++) {
|
for (int inx = 0; inx <= number; inx++) {
|
||||||
delay(delayTime);
|
delay(delayTime);
|
||||||
digitalWrite(externalLight, LOW);
|
digitalWrite(externalLight, LOW); // ON
|
||||||
delay(delayTime);
|
delay(delayTime);
|
||||||
digitalWrite(externalLight, HIGH);
|
digitalWrite(externalLight, HIGH); // OFF
|
||||||
delay(delayTime);
|
delay(delayTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -830,19 +918,36 @@ void flashLED(int number, int delayTime) {
|
||||||
void drawScreen1(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
|
void drawScreen1(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
|
||||||
String bed = printerClient.getValueRounded(printerClient.getTempBedActual());
|
String bed = printerClient.getValueRounded(printerClient.getTempBedActual());
|
||||||
String tool = printerClient.getValueRounded(printerClient.getTempToolActual());
|
String tool = printerClient.getValueRounded(printerClient.getTempToolActual());
|
||||||
|
|
||||||
|
// Nightmode, dim the Display. 0 is the darkest and 255 the brightest
|
||||||
|
if (USE_NIGHT) {
|
||||||
|
if (!displayOn) {
|
||||||
|
enableDisplay(false);
|
||||||
|
} else {
|
||||||
|
display->setBrightness(0); // default is 0
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!displayOn) {
|
||||||
|
enableDisplay(false);
|
||||||
|
} else {
|
||||||
|
display->setBrightness(255); // default is 255
|
||||||
|
}
|
||||||
|
}
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
display->setFont(ArialMT_Plain_16);
|
display->setFont(ArialMT_Plain_16);
|
||||||
if (bed != "0") {
|
if (bed != "0") {
|
||||||
display->drawString(64 + x, 0 + y, "Bed / Tool Temp");
|
display->drawString(25 + x, 0 + y, "Tool");
|
||||||
|
display->drawString(91 + x, 0 + y, "Bed");
|
||||||
} else {
|
} else {
|
||||||
display->drawString(64 + x, 0 + y, "Tool Temp");
|
display->drawString(64 + x, 0 + y, "Tool Temp");
|
||||||
}
|
}
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(ArialMT_Plain_24);
|
display->setFont(ArialMT_Plain_24);
|
||||||
if (bed != "0") {
|
if (bed != "0") {
|
||||||
|
display->setTextAlignment(TEXT_ALIGN_RIGHT);
|
||||||
|
display->drawString(50 + x, 14 + y, tool + "°");
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->drawString(2 + x, 14 + y, bed + "°");
|
display->drawString(76 + x, 14 + y, bed + "°");
|
||||||
display->drawString(64 + x, 14 + y, tool + "°");
|
|
||||||
} else {
|
} else {
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
display->drawString(64 + x, 14 + y, tool + "°");
|
display->drawString(64 + x, 14 + y, tool + "°");
|
||||||
|
|
@ -850,22 +955,65 @@ void drawScreen1(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawScreen2(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
|
void drawScreen2(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
|
||||||
|
|
||||||
|
// Nightmode, dim the Display. 0 is the darkest and 255 the brightest
|
||||||
|
if (USE_NIGHT) {
|
||||||
|
if (!displayOn) {
|
||||||
|
enableDisplay(false);
|
||||||
|
} else {
|
||||||
|
display->setBrightness(0); // default is 255
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!displayOn) {
|
||||||
|
enableDisplay(false);
|
||||||
|
} else {
|
||||||
|
display->setBrightness(255); // default is 255
|
||||||
|
}
|
||||||
|
}
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
display->setFont(ArialMT_Plain_16);
|
display->setFont(ArialMT_Plain_16);
|
||||||
|
|
||||||
display->drawString(64 + x, 0 + y, "Time Remaining");
|
display->drawString(64 + x, 0 + y, "Time Remaining");
|
||||||
//display->setTextAlignment(TEXT_ALIGN_LEFT);
|
|
||||||
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(ArialMT_Plain_24);
|
display->setFont(ArialMT_Plain_24);
|
||||||
int val = printerClient.getProgressPrintTimeLeft().toInt();
|
int val = printerClient.getProgressPrintTimeLeft().toInt();
|
||||||
int hours = numberOfHours(val);
|
int hours = numberOfHours(val);
|
||||||
int minutes = numberOfMinutes(val);
|
String hour = zeroPad(hours);
|
||||||
int seconds = numberOfSeconds(val);
|
display->drawString(22 + x, 14 + y, hour);
|
||||||
|
|
||||||
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
display->setFont(ArialMT_Plain_10);
|
||||||
|
display->drawString(50 + x, 26 + y, "hr");
|
||||||
|
|
||||||
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
display->setFont(ArialMT_Plain_24);
|
||||||
|
int minutes = numberOfMinutes(val);
|
||||||
|
String minute = zeroPad(minutes);
|
||||||
|
display->drawString(72 + x, 14 + y, minute);
|
||||||
|
|
||||||
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
|
display->setFont(ArialMT_Plain_10);
|
||||||
|
display->drawString(100 + x, 26 + y, "min.");
|
||||||
|
|
||||||
String time = zeroPad(hours) + ":" + zeroPad(minutes) + ":" + zeroPad(seconds);
|
|
||||||
display->drawString(64 + x, 14 + y, time);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawScreen3(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
|
void drawScreen3(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
|
||||||
|
|
||||||
|
// Nightmode, dim the Display. 0 is the darkest and 255 the brightest
|
||||||
|
if (USE_NIGHT) {
|
||||||
|
if (!displayOn) {
|
||||||
|
enableDisplay(false);
|
||||||
|
} else {
|
||||||
|
display->setBrightness(0); // default is 255
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!displayOn) {
|
||||||
|
enableDisplay(false);
|
||||||
|
} else {
|
||||||
|
display->setBrightness(255); // default is 255
|
||||||
|
}
|
||||||
|
}
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
display->setFont(ArialMT_Plain_16);
|
display->setFont(ArialMT_Plain_16);
|
||||||
|
|
||||||
|
|
@ -882,19 +1030,53 @@ 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) {
|
||||||
|
|
||||||
|
// Nightmode, dim the Display. 0 is the darkest and 255 the brightest
|
||||||
|
if (USE_NIGHT) {
|
||||||
|
if (!displayOn) {
|
||||||
|
enableDisplay(false);
|
||||||
|
} else {
|
||||||
|
display->setBrightness(0); // default is 255
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!displayOn) {
|
||||||
|
enableDisplay(false);
|
||||||
|
} else {
|
||||||
|
display->setBrightness(255); // default is 255
|
||||||
|
}
|
||||||
|
}
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
|
|
||||||
String displayTime = timeClient.getAmPmHours() + ":" + timeClient.getMinutes() + ":" + timeClient.getSeconds();
|
String displayTime = timeClient.getAmPmHours() + ":" + timeClient.getMinutes() + ":" + timeClient.getSeconds();
|
||||||
if (IS_24HOUR) {
|
if (IS_24HOUR) {
|
||||||
displayTime = timeClient.getHours() + ":" + timeClient.getMinutes() + ":" + timeClient.getSeconds();
|
displayTime = timeClient.getHours() + ":" + timeClient.getMinutes() + ":" + timeClient.getSeconds();
|
||||||
}
|
}
|
||||||
|
String displayName = PrinterHostName;
|
||||||
|
if (printerClient.getPrinterType() == "Repetier") {
|
||||||
|
displayName = printerClient.getPrinterName();
|
||||||
|
}
|
||||||
display->setFont(ArialMT_Plain_16);
|
display->setFont(ArialMT_Plain_16);
|
||||||
display->drawString(64 + x, 0 + y, OctoPrintHostName);
|
display->drawString(64 + x, 0 + y, displayName);
|
||||||
display->setFont(ArialMT_Plain_24);
|
display->setFont(ArialMT_Plain_24);
|
||||||
display->drawString(64 + x, 17 + y, displayTime);
|
display->drawString(64 + x, 17 + y, displayTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawWeather(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
|
void drawWeather(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y) {
|
||||||
|
|
||||||
|
// Nightmode, dim the Display. 0 is the darkest and 255 the brightest
|
||||||
|
if (USE_NIGHT) {
|
||||||
|
if (!displayOn) {
|
||||||
|
enableDisplay(false);
|
||||||
|
} else {
|
||||||
|
display->setBrightness(0); // default is 255
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!displayOn) {
|
||||||
|
enableDisplay(false);
|
||||||
|
} else {
|
||||||
|
display->setBrightness(255); // default is 255
|
||||||
|
}
|
||||||
|
}
|
||||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||||
display->setFont(ArialMT_Plain_24);
|
display->setFont(ArialMT_Plain_24);
|
||||||
display->drawString(0 + x, 0 + y, weatherClient.getTempRounded(0) + getTempSymbol());
|
display->drawString(0 + x, 0 + y, weatherClient.getTempRounded(0) + getTempSymbol());
|
||||||
|
|
@ -902,7 +1084,7 @@ void drawWeather(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int
|
||||||
display->setFont(ArialMT_Plain_24);
|
display->setFont(ArialMT_Plain_24);
|
||||||
|
|
||||||
display->setFont(ArialMT_Plain_16);
|
display->setFont(ArialMT_Plain_16);
|
||||||
display->drawString(0 + x, 24 + y, weatherClient.getCondition(0));
|
display->drawString(0 + x, 24 + y, getTranslate());
|
||||||
display->setFont((const uint8_t*)Meteocons_Plain_42);
|
display->setFont((const uint8_t*)Meteocons_Plain_42);
|
||||||
display->drawString(86 + x, 0 + y, weatherClient.getWeatherIcon(0));
|
display->drawString(86 + x, 0 + y, weatherClient.getWeatherIcon(0));
|
||||||
}
|
}
|
||||||
|
|
@ -981,12 +1163,16 @@ void drawClockHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state) {
|
||||||
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
display->setTextAlignment(TEXT_ALIGN_CENTER);
|
||||||
if (printerClient.isPSUoff()) {
|
if (printerClient.isPSUoff()) {
|
||||||
display->drawString(64, 47, "psu off");
|
display->drawString(64, 47, "psu off");
|
||||||
|
} else if (printerClient.getState() == "Operational") {
|
||||||
|
display->drawString(64, 47, "Operational");
|
||||||
} else {
|
} else {
|
||||||
display->drawString(64, 47, "offline");
|
display->drawString(64, 47, "offline");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (printerClient.isPSUoff()) {
|
if (printerClient.isPSUoff()) {
|
||||||
display->drawString(0, 47, "psu off");
|
display->drawString(0, 47, "psu off");
|
||||||
|
} else if (printerClient.getState() == "Operational") {
|
||||||
|
display->drawString(0, 47, "Operational");
|
||||||
} else {
|
} else {
|
||||||
display->drawString(0, 47, "offline");
|
display->drawString(0, 47, "offline");
|
||||||
}
|
}
|
||||||
|
|
@ -1031,20 +1217,23 @@ void writeSettings() {
|
||||||
} else {
|
} else {
|
||||||
Serial.println("Saving settings now...");
|
Serial.println("Saving settings now...");
|
||||||
f.println("UtcOffset=" + String(UtcOffset));
|
f.println("UtcOffset=" + String(UtcOffset));
|
||||||
f.println("octoKey=" + OctoPrintApiKey);
|
f.println("printerApiKey=" + PrinterApiKey);
|
||||||
f.println("octoHost=" + OctoPrintHostName);
|
f.println("printerHostName=" + PrinterHostName);
|
||||||
f.println("octoServer=" + OctoPrintServer);
|
f.println("printerServer=" + PrinterServer);
|
||||||
f.println("octoPort=" + String(OctoPrintPort));
|
f.println("printerPort=" + String(PrinterPort));
|
||||||
f.println("octoUser=" + OctoAuthUser);
|
f.println("printerName=" + printerClient.getPrinterName());
|
||||||
f.println("octoPass=" + OctoAuthPass);
|
f.println("printerAuthUser=" + PrinterAuthUser);
|
||||||
|
f.println("printerAuthPass=" + PrinterAuthPass);
|
||||||
f.println("refreshRate=" + String(minutesBetweenDataRefresh));
|
f.println("refreshRate=" + String(minutesBetweenDataRefresh));
|
||||||
f.println("themeColor=" + themeColor);
|
f.println("themeColor=" + themeColor);
|
||||||
f.println("IS_BASIC_AUTH=" + String(IS_BASIC_AUTH));
|
f.println("IS_BASIC_AUTH=" + String(IS_BASIC_AUTH));
|
||||||
f.println("www_username=" + String(www_username));
|
f.println("www_username=" + String(www_username));
|
||||||
f.println("www_password=" + String(www_password));
|
f.println("www_password=" + String(www_password));
|
||||||
f.println("DISPLAYCLOCK=" + String(DISPLAYCLOCK));
|
f.println("DISPLAYCLOCK=" + String(DISPLAYCLOCK));
|
||||||
|
f.println("USE_NIGHT=" + String(USE_NIGHT));
|
||||||
f.println("is24hour=" + String(IS_24HOUR));
|
f.println("is24hour=" + String(IS_24HOUR));
|
||||||
f.println("invertDisp=" + String(INVERT_DISPLAY));
|
f.println("invertDisp=" + String(INVERT_DISPLAY));
|
||||||
|
f.println("USE_FLASH=" + String(USE_FLASH));
|
||||||
f.println("isWeather=" + String(DISPLAYWEATHER));
|
f.println("isWeather=" + String(DISPLAYWEATHER));
|
||||||
f.println("weatherKey=" + WeatherApiKey);
|
f.println("weatherKey=" + WeatherApiKey);
|
||||||
f.println("CityID=" + String(CityIDs[0]));
|
f.println("CityID=" + String(CityIDs[0]));
|
||||||
|
|
@ -1072,34 +1261,40 @@ void readSettings() {
|
||||||
UtcOffset = line.substring(line.lastIndexOf("UtcOffset=") + 10).toFloat();
|
UtcOffset = line.substring(line.lastIndexOf("UtcOffset=") + 10).toFloat();
|
||||||
Serial.println("UtcOffset=" + String(UtcOffset));
|
Serial.println("UtcOffset=" + String(UtcOffset));
|
||||||
}
|
}
|
||||||
if (line.indexOf("octoKey=") >= 0) {
|
if (line.indexOf("printerApiKey=") >= 0) {
|
||||||
OctoPrintApiKey = line.substring(line.lastIndexOf("octoKey=") + 8);
|
PrinterApiKey = line.substring(line.lastIndexOf("printerApiKey=") + 14);
|
||||||
OctoPrintApiKey.trim();
|
PrinterApiKey.trim();
|
||||||
Serial.println("OctoPrintApiKey=" + OctoPrintApiKey);
|
Serial.println("PrinterApiKey=" + PrinterApiKey);
|
||||||
}
|
}
|
||||||
if (line.indexOf("octoHost=") >= 0) {
|
if (line.indexOf("printerHostName=") >= 0) {
|
||||||
OctoPrintHostName = line.substring(line.lastIndexOf("octoHost=") + 9);
|
PrinterHostName = line.substring(line.lastIndexOf("printerHostName=") + 16);
|
||||||
OctoPrintHostName.trim();
|
PrinterHostName.trim();
|
||||||
Serial.println("OctoPrintHostName=" + OctoPrintHostName);
|
Serial.println("PrinterHostName=" + PrinterHostName);
|
||||||
}
|
}
|
||||||
if (line.indexOf("octoServer=") >= 0) {
|
if (line.indexOf("printerServer=") >= 0) {
|
||||||
OctoPrintServer = line.substring(line.lastIndexOf("octoServer=") + 11);
|
PrinterServer = line.substring(line.lastIndexOf("printerServer=") + 14);
|
||||||
OctoPrintServer.trim();
|
PrinterServer.trim();
|
||||||
Serial.println("OctoPrintServer=" + OctoPrintServer);
|
Serial.println("PrinterServer=" + PrinterServer);
|
||||||
}
|
}
|
||||||
if (line.indexOf("octoPort=") >= 0) {
|
if (line.indexOf("printerPort=") >= 0) {
|
||||||
OctoPrintPort = line.substring(line.lastIndexOf("octoPort=") + 9).toInt();
|
PrinterPort = line.substring(line.lastIndexOf("printerPort=") + 12).toInt();
|
||||||
Serial.println("OctoPrintPort=" + String(OctoPrintPort));
|
Serial.println("PrinterPort=" + String(PrinterPort));
|
||||||
}
|
}
|
||||||
if (line.indexOf("octoUser=") >= 0) {
|
if (line.indexOf("printerName=") >= 0) {
|
||||||
OctoAuthUser = line.substring(line.lastIndexOf("octoUser=") + 9);
|
String printer = line.substring(line.lastIndexOf("printerName=") + 12);
|
||||||
OctoAuthUser.trim();
|
printer.trim();
|
||||||
Serial.println("OctoAuthUser=" + OctoAuthUser);
|
printerClient.setPrinterName(printer);
|
||||||
|
Serial.println("PrinterName=" + printerClient.getPrinterName());
|
||||||
}
|
}
|
||||||
if (line.indexOf("octoPass=") >= 0) {
|
if (line.indexOf("printerAuthUser=") >= 0) {
|
||||||
OctoAuthPass = line.substring(line.lastIndexOf("octoPass=") + 9);
|
PrinterAuthUser = line.substring(line.lastIndexOf("printerAuthUser=") + 16);
|
||||||
OctoAuthPass.trim();
|
PrinterAuthUser.trim();
|
||||||
Serial.println("OctoAuthPass=" + OctoAuthPass);
|
Serial.println("PrinterAuthUser=" + PrinterAuthUser);
|
||||||
|
}
|
||||||
|
if (line.indexOf("printerAuthPass=") >= 0) {
|
||||||
|
PrinterAuthPass = line.substring(line.lastIndexOf("printerAuthPass=") + 16);
|
||||||
|
PrinterAuthPass.trim();
|
||||||
|
Serial.println("PrinterAuthPass=" + PrinterAuthPass);
|
||||||
}
|
}
|
||||||
if (line.indexOf("refreshRate=") >= 0) {
|
if (line.indexOf("refreshRate=") >= 0) {
|
||||||
minutesBetweenDataRefresh = line.substring(line.lastIndexOf("refreshRate=") + 12).toInt();
|
minutesBetweenDataRefresh = line.substring(line.lastIndexOf("refreshRate=") + 12).toInt();
|
||||||
|
|
@ -1130,6 +1325,10 @@ void readSettings() {
|
||||||
DISPLAYCLOCK = line.substring(line.lastIndexOf("DISPLAYCLOCK=") + 13).toInt();
|
DISPLAYCLOCK = line.substring(line.lastIndexOf("DISPLAYCLOCK=") + 13).toInt();
|
||||||
Serial.println("DISPLAYCLOCK=" + String(DISPLAYCLOCK));
|
Serial.println("DISPLAYCLOCK=" + String(DISPLAYCLOCK));
|
||||||
}
|
}
|
||||||
|
if(line.indexOf("USE_NIGHT=") >= 0) {
|
||||||
|
USE_NIGHT = line.substring(line.lastIndexOf("USE_NIGHT=") + 10).toInt();
|
||||||
|
Serial.println("USE_NIGHT=" + String(USE_NIGHT));
|
||||||
|
}
|
||||||
if (line.indexOf("is24hour=") >= 0) {
|
if (line.indexOf("is24hour=") >= 0) {
|
||||||
IS_24HOUR = line.substring(line.lastIndexOf("is24hour=") + 9).toInt();
|
IS_24HOUR = line.substring(line.lastIndexOf("is24hour=") + 9).toInt();
|
||||||
Serial.println("IS_24HOUR=" + String(IS_24HOUR));
|
Serial.println("IS_24HOUR=" + String(IS_24HOUR));
|
||||||
|
|
@ -1138,6 +1337,10 @@ void readSettings() {
|
||||||
INVERT_DISPLAY = line.substring(line.lastIndexOf("invertDisp=") + 11).toInt();
|
INVERT_DISPLAY = line.substring(line.lastIndexOf("invertDisp=") + 11).toInt();
|
||||||
Serial.println("INVERT_DISPLAY=" + String(INVERT_DISPLAY));
|
Serial.println("INVERT_DISPLAY=" + String(INVERT_DISPLAY));
|
||||||
}
|
}
|
||||||
|
if(line.indexOf("USE_FLASH=") >= 0) {
|
||||||
|
USE_FLASH = line.substring(line.lastIndexOf("USE_FLASH=") + 10).toInt();
|
||||||
|
Serial.println("USE_FLASH=" + String(USE_FLASH));
|
||||||
|
}
|
||||||
if (line.indexOf("hasPSU=") >= 0) {
|
if (line.indexOf("hasPSU=") >= 0) {
|
||||||
HAS_PSU = line.substring(line.lastIndexOf("hasPSU=") + 7).toInt();
|
HAS_PSU = line.substring(line.lastIndexOf("hasPSU=") + 7).toInt();
|
||||||
Serial.println("HAS_PSU=" + String(HAS_PSU));
|
Serial.println("HAS_PSU=" + String(HAS_PSU));
|
||||||
|
|
@ -1166,7 +1369,7 @@ void readSettings() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fr.close();
|
fr.close();
|
||||||
printerClient.updateOctoPrintClient(OctoPrintApiKey, OctoPrintServer, OctoPrintPort, OctoAuthUser, OctoAuthPass, HAS_PSU);
|
printerClient.updatePrintClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU);
|
||||||
weatherClient.updateWeatherApiKey(WeatherApiKey);
|
weatherClient.updateWeatherApiKey(WeatherApiKey);
|
||||||
weatherClient.updateLanguage(WeatherLanguage);
|
weatherClient.updateLanguage(WeatherLanguage);
|
||||||
weatherClient.setMetric(IS_METRIC);
|
weatherClient.setMetric(IS_METRIC);
|
||||||
|
|
@ -1218,7 +1421,7 @@ void checkDisplay() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (DISPLAYCLOCK) {
|
} else if (DISPLAYCLOCK) {
|
||||||
if ((!printerClient.isOperational() || printerClient.isPSUoff()) && !isClockOn) {
|
if ((!printerClient.isPrinting() || printerClient.isPSUoff()) && !isClockOn) {
|
||||||
Serial.println("Clock Mode is turned on.");
|
Serial.println("Clock Mode is turned on.");
|
||||||
if (!DISPLAYWEATHER) {
|
if (!DISPLAYWEATHER) {
|
||||||
ui.disableAutoTransition();
|
ui.disableAutoTransition();
|
||||||
|
|
@ -1232,7 +1435,7 @@ void checkDisplay() {
|
||||||
}
|
}
|
||||||
ui.setOverlays(clockOverlay, numberOfOverlays);
|
ui.setOverlays(clockOverlay, numberOfOverlays);
|
||||||
isClockOn = true;
|
isClockOn = true;
|
||||||
} else if (printerClient.isOperational() && !printerClient.isPSUoff() && isClockOn) {
|
} else if (printerClient.isPrinting() && !printerClient.isPSUoff() && isClockOn) {
|
||||||
Serial.println("Printer Monitor is active.");
|
Serial.println("Printer Monitor is active.");
|
||||||
ui.setFrames(frames, numberOfFrames);
|
ui.setFrames(frames, numberOfFrames);
|
||||||
ui.setOverlays(overlays, numberOfOverlays);
|
ui.setOverlays(overlays, numberOfOverlays);
|
||||||
|
|
@ -1258,3 +1461,44 @@ void enableDisplay(boolean enable) {
|
||||||
displayOffEpoch = lastEpoch;
|
displayOffEpoch = lastEpoch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Weather String Translation
|
||||||
|
String getTranslate() {
|
||||||
|
String rtnValue = "";
|
||||||
|
if (WeatherLanguage == "de") { //If Language set to German
|
||||||
|
if (weatherClient.getCondition(0) == "Clear") {
|
||||||
|
rtnValue = "Klar";
|
||||||
|
} else if (weatherClient.getCondition(0) == "Clouds") {
|
||||||
|
rtnValue = "Wolken";
|
||||||
|
} else if (weatherClient.getCondition(0) == "Rain") {
|
||||||
|
rtnValue = "Regen";
|
||||||
|
} else if (weatherClient.getCondition(0) == "Snow") {
|
||||||
|
rtnValue = "Schnee";
|
||||||
|
} else if (weatherClient.getCondition(0) == "Drizzle") {
|
||||||
|
rtnValue = "Nieseln";
|
||||||
|
} else if (weatherClient.getCondition(0) == "Thunderstorm") {
|
||||||
|
rtnValue = "Gewitter";
|
||||||
|
} else if (weatherClient.getCondition(0) == "Mist") {
|
||||||
|
rtnValue = "Nebel";
|
||||||
|
} else if (weatherClient.getCondition(0) == "Smoke") {
|
||||||
|
rtnValue = "Rauch";
|
||||||
|
} else if (weatherClient.getCondition(0) == "Haze") {
|
||||||
|
rtnValue = "Dunst";
|
||||||
|
} else if (weatherClient.getCondition(0) == "Dust") {
|
||||||
|
rtnValue = "Staub";
|
||||||
|
} else if (weatherClient.getCondition(0) == "Fog") {
|
||||||
|
rtnValue = "Nebel";
|
||||||
|
} else if (weatherClient.getCondition(0) == "Sand") {
|
||||||
|
rtnValue = "Sand";
|
||||||
|
} else if (weatherClient.getCondition(0) == "Ash") {
|
||||||
|
rtnValue = "Asche";
|
||||||
|
} else if (weatherClient.getCondition(0) == "Squall") {
|
||||||
|
rtnValue = "Böen";
|
||||||
|
} else if (weatherClient.getCondition(0) == "Tornado") {
|
||||||
|
rtnValue = "Tornado";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rtnValue = weatherClient.getCondition(0); //Else choose the set Language
|
||||||
|
}
|
||||||
|
return rtnValue;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue