Qrome - added some updates for Repetier

pull/99/head
Chrome Legion 2019-04-12 23:32:31 -07:00
parent ceaa76c945
commit 149ca5b051
6 changed files with 2382 additions and 2344 deletions

View File

@ -398,3 +398,11 @@ String OctoPrintClient::getValueRounded(String value) {
String OctoPrintClient::getPrinterType() { String OctoPrintClient::getPrinterType() {
return printerType; return printerType;
} }
int OctoPrintClient::getPrinterPort() {
return myPort;
}
String OctoPrintClient::getPrinterName() {
return printerData.printerName;
}

View File

@ -65,6 +65,7 @@ private:
boolean isPrinting; boolean isPrinting;
boolean isPSUoff; boolean isPSUoff;
String error; String error;
String printerName;
} PrinterStruct; } PrinterStruct;
PrinterStruct printerData; PrinterStruct printerData;
@ -97,4 +98,6 @@ public:
String getValueRounded(String value); String getValueRounded(String value);
String getError(); String getError();
String getPrinterType(); String getPrinterType();
int getPrinterPort();
String getPrinterName();
}; };

View File

@ -131,7 +131,6 @@ void RepetierClient::getPrinterJobResults() {
// 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);
@ -139,8 +138,8 @@ void RepetierClient::getPrinterJobResults() {
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"];
@ -152,6 +151,7 @@ void RepetierClient::getPrinterJobResults() {
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"];
printerData.printerName = (const char*) pr["slug"];
//Figure out Time Left //Figure out Time Left
long timeTot=0; long timeTot=0;
@ -166,20 +166,14 @@ void RepetierClient::getPrinterJobResults() {
timeLeft = timeTot-timeElap; timeLeft = timeTot-timeElap;
printerData.progressPrintTimeLeft = String(timeLeft); printerData.progressPrintTimeLeft = String(timeLeft);
String printing = (const char*) pr["job"]; if (printerData.fileName != "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("PTC: " + printerData.estimatedPrintTime);
Serial.println("ST: " + printerData.lastPrintTime);
Serial.println("TimeLeft: " + printerData.progressPrintTimeLeft);
if (printerData.isPrinting) { if (printerData.isPrinting) {
Serial.println("I think I am printing"); Serial.println("Printing: " + printerData.fileName);
} }
if (isOperational()) { if (isOperational()) {
@ -201,15 +195,14 @@ void RepetierClient::getPrinterJobResults() {
JsonObject& root2 = jsonBuffer2.parseObject(printClient); JsonObject& root2 = jsonBuffer2.parseObject(printClient);
//Select printer //Select printer
String slug=(const char*) pr["slug"]; JsonObject& pr2 = root2[printerData.printerName];
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 = "";
return; return;
} }
@ -248,6 +241,7 @@ void RepetierClient::resetPrintData() {
printerData.isPrinting = false; printerData.isPrinting = false;
printerData.isPSUoff = false; printerData.isPSUoff = false;
printerData.error = ""; printerData.error = "";
printerData.printerName = "";
} }
String RepetierClient::getAveragePrintTime(){ String RepetierClient::getAveragePrintTime(){
@ -343,3 +337,11 @@ String RepetierClient::getValueRounded(String value) {
String RepetierClient::getPrinterType() { String RepetierClient::getPrinterType() {
return printerType; return printerType;
} }
int RepetierClient::getPrinterPort() {
return myPort;
}
String RepetierClient::getPrinterName() {
return printerData.printerName;
}

View File

@ -65,6 +65,7 @@ private:
boolean isPrinting; boolean isPrinting;
boolean isPSUoff; boolean isPSUoff;
String error; String error;
String printerName;
} PrinterStruct; } PrinterStruct;
PrinterStruct printerData; PrinterStruct printerData;
@ -97,4 +98,6 @@ public:
String getValueRounded(String value); String getValueRounded(String value);
String getError(); String getError();
String getPrinterType(); String getPrinterType();
int getPrinterPort();
String getPrinterName();
}; };

View File

@ -59,7 +59,7 @@ SOFTWARE.
//****************************** //******************************
// OctoPrint / Repetier Monitoring -- Monitor your 3D OctoPrint or Repetier Server // OctoPrint / Repetier Monitoring -- Monitor your 3D OctoPrint or Repetier Server
//#define USE_REPETIER_CLIENT // Uncomment this line to use the Repetier Printer Server -- OctoPrint is used by default and is most common #define USE_REPETIER_CLIENT // Uncomment this line to use the Repetier Printer Server -- OctoPrint is used by default and is most common
String PrinterApiKey = ""; // ApiKey from your User Account on OctoPrint / Repetier String PrinterApiKey = ""; // ApiKey from your User Account on OctoPrint / Repetier
String PrinterHostName = "octopi";// Default 'octopi' -- or hostname if different (optional if your IP changes) String PrinterHostName = "octopi";// Default 'octopi' -- or hostname if different (optional if your IP changes)
String PrinterServer = ""; // IP or Address of your OctoPrint / Repetier Server (DO NOT include http://) String PrinterServer = ""; // IP or Address of your OctoPrint / Repetier Server (DO NOT include http://)

View File

@ -110,19 +110,7 @@ String WEB_ACTIONS = "<a class='w3-bar-item w3-button' href='/'><i class='fa fa
"<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/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 = ""; // moved to setup to make it dynamic
"<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>" + 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>" + 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>" + 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>" + 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><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='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>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>" String THEME_FORM = "<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>"
@ -202,6 +190,22 @@ String COLOR_THEMES = "<option>red</option>"
void setup() { void setup() {
CHANGE_FORM = "<form class='w3-container' action='/updateconfig' method='get'><h2>Station Config:</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' value='%OCTOKEY%' maxlength='60'></p>";
if (printerClient.getPrinterType() != "Repetier") {
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' value='%OCTOADDRESS%' maxlength='60'></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>" + 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><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='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>Clock Sync / Weather Refresh (minutes) <select class='w3-option w3-padding' name='refresh'>%OPTIONS%</select></p>";
Serial.begin(115200); Serial.begin(115200);
SPIFFS.begin(); SPIFFS.begin();
delay(10); delay(10);
@ -212,6 +216,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
@ -223,10 +230,16 @@ void setup() {
display.display(); display.display();
//display.flipScreenVertically(); //display.flipScreenVertically();
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.setFont(ArialMT_Plain_16);
display.drawString(64, 1, "Printer Monitor");
display.setFont(ArialMT_Plain_10);
display.drawString(64, 18, "for " + printerClient.getPrinterType());
display.setFont(ArialMT_Plain_16);
display.drawString(64, 30, "By Qrome");
display.drawString(64, 46, "V" + String(VERSION));
display.display(); display.display();
//WiFiManager //WiFiManager
@ -723,7 +736,12 @@ 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 += printerClient.getPrinterType() + " Host Name: " + PrinterHostName + "<br>"; if (printerClient.getPrinterType() == "Repetier") {
html += printerClient.getPrinterType() + " Printer Name: " + printerClient.getPrinterName() + "<br>";
} else {
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>";
@ -908,8 +926,12 @@ void drawClock(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16
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, PrinterHostName); 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);
} }