Compare commits

..

31 Commits
V2.5 ... master

Author SHA1 Message Date
Qrome bd8422b228
Update README.md 2021-04-05 16:18:30 -07:00
Qrome fcc911a772
Update README.md
Updated to state use OLED version 4.1.0
2021-04-05 16:17:30 -07:00
Qrome a9a0348efb
Merge pull request #99 from Qrome/3.0
Change Screen switching time in Web Interface.
2020-07-10 20:10:16 -07:00
Qrome bf0edc197f Qrome - updated readme.md 2020-07-10 20:02:30 -07:00
Qrome 8ce53c2252 Qrome - updated with compiled binary files and updates to readme.md 2020-07-10 19:58:50 -07:00
Qrome 028e80766e
Update README.md 2020-06-06 15:00:00 -07:00
Qrome 9debd96c40
Update README.md 2020-04-25 17:53:01 -07:00
Qrome 3ce8238993
Update README.md 2020-01-15 10:41:43 -07:00
David Payne 993fdf6809 Qrome - updated access to PROGMEM data for ESP8266 Core 2.5.2 support 2019-05-29 15:59:04 -07:00
Chrome Legion d59fa0da47 Qrome - updated to use PROGMEM for HTML form constants to reduce the use of dynamic memory 2019-04-26 22:39:52 -07:00
Chrome Legion 9c3bdfb469 Qrome - updated for requests to Repetier Server 2019-04-18 21:11:28 -07:00
Qrome cd1bc2b62a
Update README.md 2019-04-18 13:00:07 -07:00
David Payne 1ce2e37ff4 Qrome - updated some html label 2019-04-15 15:14:39 -07:00
Chrome Legion b36c6f5307 Qrome - trimmed the temp values for web interface display 2019-04-14 22:19:53 -07:00
Chrome Legion 6e3ce067f6 Qrome - updated to only display print status when printing 2019-04-14 17:47:49 -07:00
Chrome Legion f3fe61eac9 Qrome - added connection test for OctoPrint 2019-04-13 23:22:26 -07:00
Chrome Legion 6c10fcf53c Qrome - fixed some HTML in the home page 2019-04-13 21:36:13 -07:00
Chrome Legion f5afbbdfac Qrome - updated with Repetier configuration and printer selector in the web UI 2019-04-13 21:18:24 -07:00
Chrome Legion 149ca5b051 Qrome - added some updates for Repetier 2019-04-12 23:32:31 -07:00
David Payne ceaa76c945 Qrome - moved printerType to the objects 2019-04-12 09:07:05 -07:00
Chrome Legion 2996572d86 Qrome - updated code format and spelling 2019-04-11 20:34:15 -07:00
David Payne ba1cc15b14 Qrome - updated with Repetier commented out 2019-04-11 16:40:54 -07:00
David Payne be250093a0 Qrome - updated Readme.md with Repetier 2019-04-11 16:30:39 -07:00
David Payne 78d258c465 Qrome - updated Readme.md with Repetier 2019-04-11 16:26:45 -07:00
David Payne c7453a2883 Qrome - updated to include the compile options for Repetier 2019-04-11 16:23:58 -07:00
Qrome 30da7285a3
Merge pull request #84 from kg4iae/2.6
Repetier-Server
2019-04-11 14:57:06 -07:00
kg4iae a20eac341b Add files via upload 2019-04-10 07:53:27 -05:00
Chrome Legion 03d3119e5a Qrome - added web ui configuration for LED flashing 2019-03-20 08:30:35 -07:00
Chrome Legion 4fab27ff34 Qrome - updated version number 2019-03-19 22:45:42 -07:00
Qrome 66348f0ecf
Merge pull request #79 from cbgj/patch-1
Remove "full city list" link from weatherconfig
2019-03-18 13:23:28 -07:00
Christian Bull Gjertsen 7bdca9b156
Remove "full city list" link from weatherconfig
Link broken. This is now a paid feature: https://openweathermap.org/current#bulk
2019-03-18 20:18:44 +01:00
16 changed files with 1922 additions and 1304 deletions

View File

@ -1,30 +1,14 @@
/* 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.
*/
# Printer Monitor (OctoPrint 3D Printer Monitor) # Printer Monitor (OctoPrint 3D Printer Monitor)
## New Easy Monitor Board Kit:
Now available is the Pre Loaded Monitor Board Kit that comes ready to plug and play on your network.
* Kit on Etsy: https://www.etsy.com/listing/823257424
* New 3D printed case design for Monitor Board kit: https://www.thingiverse.com/thing:4538747
* Configuration video: https://www.youtube.com/watch?v=kcBspqWhpIU
## Features: ## Features:
* Displays the print status from OctoPrint Server * Displays the print status from OctoPrint or Repetier Server
* Option to display time and weather when printer is idle
* Estimated time remaining * Estimated time remaining
* Time Printing * Time Printing
* Percentage complete * Percentage complete
@ -42,19 +26,21 @@ SOFTWARE.
* Basic Authentication to protect your settings * Basic Authentication to protect your settings
* Version 2.2 added the ability to update firmware through web interface from a compiled binary * Version 2.2 added the ability to update firmware through web interface from a compiled binary
* Can query the Octoprint [PSU Control plugin](https://plugins.octoprint.org/plugins/psucontrol/) to enter clock or blank mode when PSU is off * Can query the Octoprint [PSU Control plugin](https://plugins.octoprint.org/plugins/psucontrol/) to enter clock or blank mode when PSU is off
* Repetier support added in version 3.0 -- define in Settings.h
* Video: https://youtu.be/niRv9SCgAPk * Video: https://youtu.be/niRv9SCgAPk
* Detailed build video by Chris Riley: https://youtu.be/Rm-l1FSuJpI * Detailed build video by Chris Riley: https://youtu.be/Rm-l1FSuJpI
## Required Parts: ## Required Parts:
* Wemos D1 Mini: https://amzn.to/2ImqD1n * Wemos D1 Mini: https://amzn.to/2ImqD1n
* 0.96" OLED I2C 128x64 Display (12864) SSD1306: https://amzn.to/2InSNF0 * 0.96" OLED I2C 128x64 Display (12864) SSD1306: https://amzn.to/3cyJekU
* (optional) 1.3" I2C OLED Display: https://amzn.to/2IP0gRU (must uncomment #define DISPLAY_SH1106 in the Settings.h to use the 1.3" SSH1106 display) * (optional) 1.3" I2C OLED Display: https://amzn.to/2IP0gRU (must uncomment #define DISPLAY_SH1106 in the Settings.h to use the 1.3" SSH1106 display)
* (optional) Pre loaded Monitor Board kit: https://www.etsy.com/listing/823257424
Note: Using the links provided here help to support these types of projects. Thank you for the support. Note: Using the links provided here help to support these types of projects. Thank you for the support.
## Wiring for the Wemos D1 Mini to the I2C SSD1306 OLED ## Wiring for the Wemos D1 Mini to the I2C SSD1306 OLED
SDA -> D2 SDA -> D2
SCL -> D5 SCL -> D5 / D1 -- for Easy Monitor Board
VCC -> 5V+ VCC -> 5V+
GND -> GND- GND -> GND-
@ -62,19 +48,24 @@ GND -> GND-
## 3D Printed Case by Qrome: ## 3D Printed Case by Qrome:
https://www.thingiverse.com/thing:2884823 -- for the 0.96" OLED Display https://www.thingiverse.com/thing:2884823 -- for the 0.96" OLED Display
https://www.thingiverse.com/thing:2934049 -- for the 1.3" OLED Display https://www.thingiverse.com/thing:2934049 -- for the 1.3" OLED Display
https://www.thingiverse.com/thing:4538747 -- for 0.96" With Easy Monitor Board
## Upgrading from version 2.2 or Higher ## Upgrading from version 2.2 or Higher
Version 2.2 introduced the ability to upgrade pre-compiled firmware from a binary file. In version 2.3 and on you should find binary files that can be uploaded to your printer monitor via the web interface. From the main menu in the web interface select "Firmware Update" and follow the prompts. Version 2.2 introduced the ability to upgrade pre-compiled firmware from a binary file. In version 2.3 and on you should find binary files that can be uploaded to your printer monitor via the web interface. From the main menu in the web interface select "Firmware Update" and follow the prompts.
* **printermonitor.ino.d1_mini_SSD1306.bin** - compiled for Wemos D1 Mini for the smaller 0.96" SSD1306 OLED (default) * **printermonitor.ino.d1_mini_SSD1306.bin** - compiled for Wemos D1 Mini for the smaller 0.96" SSD1306 OLED (default)
* **printermonitor.ino.d1_mini_SH1106.bin** - compiled for Wemos D1 Mini for the larger 1.3" SH1106 OLED * **printermonitor.ino.d1_mini_SH1106.bin** - compiled for Wemos D1 Mini for the larger 1.3" SH1106 OLED
* **printermonitor.ino.d1_mini_repetier_SSD1306.bin** - Repetier version compiled for Wemos D1 Mini for the smaller 0.96" SSD1306 OLED (default)
* **printermonitor.ino.d1_mini_repetier_SH1106.bin** - Repetier version compiled for Wemos D1 Mini for the larger 1.3" SH1106 OLED
* **printermonitor.ino.d1_mini_easyboard.bin** - Version compiled for Easy Monitor Board for the smaller 0.96" SSD1306 OLED (SDA -> D2 and SCL -> D1)
* **printermonitor.ino.d1_mini_easyboard_repetier.bin** - Repetier version compiled for Easy Monitor Board for the smaller 0.96" SSD1306 OLED (SDA -> D2 and SCL -> D1)
## Compiling and Loading to Wemos D1 Mini ## Compiling and Loading to Wemos D1 Mini
It is recommended to use Arduino IDE. You will need to configure Arduino IDE to work with the Wemos board and USB port and installed the required USB drivers etc. It is recommended to use Arduino IDE. You will need to configure Arduino IDE to work with the Wemos board and USB port and installed the required USB drivers etc.
* USB CH340G drivers: https://wiki.wemos.cc/downloads * USB CH340G drivers: https://sparks.gogo.co.nz/ch340.html
* Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field. You can add multiple URLs, separating them with commas. This will add support for the Wemos D1 Mini to Arduino IDE. * Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs field. You can add multiple URLs, separating them with commas. This will add support for the Wemos D1 Mini to Arduino IDE.
* Open Boards Manager from Tools > Board menu and install esp8266 platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation). * Open Boards Manager from Tools > Board menu and install esp8266 Core platform version 2.5.2
* Select Board: "WeMos D1 R2 & mini" * Select Board: "LOLIN(WEMOS) D1 R2 & mini"
* Set 1M SPIFFS -- this project uses SPIFFS for saving and reading configuration settings. * Set 1M SPIFFS -- this project uses SPIFFS for saving and reading configuration settings.
## Loading Supporting Library Files in Arduino ## Loading Supporting Library Files in Arduino
@ -85,14 +76,16 @@ ESP8266WebServer.h
WiFiManager.h --> https://github.com/tzapu/WiFiManager WiFiManager.h --> https://github.com/tzapu/WiFiManager
ESP8266mDNS.h ESP8266mDNS.h
ArduinoOTA.h --> Arduino OTA Library ArduinoOTA.h --> Arduino OTA Library
"SSD1306Wire.h" --> https://github.com/ThingPulse/esp8266-oled-ssd1306 "SSD1306Wire.h" --> https://github.com/ThingPulse/esp8266-oled-ssd1306/releases/tag/4.1.0 (version 4.1.0)
"OLEDDisplayUi.h" "OLEDDisplayUi.h"
Note Printer-Monitor version 2.5 and later include ArduinoJson (version 5.13.1). Note Printer-Monitor version 2.5 and later include ArduinoJson (version 5.13.1).
## Initial Configuration ## Initial Configuration
All settings may be managed from the Web Interface, however, you may update the **Settings.h** file manually -- but it is not required. There is also an option to display current weather when the print is off-line. All settings may be managed from the Web Interface, however, you may update the **Settings.h** file manually -- but it is not required. There is also an option to display current weather when the print is off-line.
* Your OctoPrint API Key from your OctoPrint -> User Settings -> Current API Key * If you are using the Easy Monitor Board you must set the const int SCL_PIN = D1 in the Settings.h file.
* By default OctoPrint client is selected. If you wish to use Repetier then uncomment //#define USE_REPETIER_CLIENT in the Settings.h file.
* Your OctoPrint API Key from your OctoPrint -> User Settings -> Current API Key -- similar for Repetier API Key.
* Optional OpenWeatherMap API Key -- if you want current weather when not printing. Get the api key from: https://openweathermap.org/ * Optional OpenWeatherMap API Key -- if you want current weather when not printing. Get the api key from: https://openweathermap.org/
NOTE: The settings in the Settings.h are the default settings for the first loading. After loading you will manage changes to the settings via the Web Interface. If you want to change settings again in the settings.h, you will need to erase the file system on the Wemos or use the “Reset Settings” option in the Web Interface. NOTE: The settings in the Settings.h are the default settings for the first loading. After loading you will manage changes to the settings via the Web Interface. If you want to change settings again in the settings.h, you will need to erase the file system on the Wemos or use the “Reset Settings” option in the Web Interface.
@ -116,6 +109,8 @@ Please do not feel obligated, but donations and tips are warmly welcomed. I hav
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6VPMTLASLSKWE) [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=6VPMTLASLSKWE)
Or -- you can buy me something from my Amazon Wishlist: https://www.amazon.com/hz/wishlist/ls/GINC2PHRNEY3
## Contributors ## Contributors
David Payne -- Principal developer and architect David Payne -- Principal developer and architect
Daniel Eichhorn -- Author of the TimeClient class and OLEDDisplayUi Daniel Eichhorn -- Author of the TimeClient class and OLEDDisplayUi
@ -131,3 +126,26 @@ Thanks for your contribution.
![Printer Monitor Temps](/images/temperatures.jpg) ![Printer Monitor Temps](/images/temperatures.jpg)
![Printer Monitor Time Remaining](/images/time_remaining.jpg) ![Printer Monitor Time Remaining](/images/time_remaining.jpg)
![Printer Monitor Printing Time](/images/printing_time.jpg) ![Printer Monitor Printing Time](/images/printing_time.jpg)
/* 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.
*/

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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;
}

View File

@ -37,6 +37,7 @@ private:
String myApiKey = ""; String myApiKey = "";
String encodedAuth = ""; String encodedAuth = "";
boolean pollPsu; boolean pollPsu;
const String printerType = "OctoPrint";
void resetPrintData(); void resetPrintData();
boolean validate(); boolean validate();
@ -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);
}; };

View File

@ -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;
}

View File

@ -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);
};

View File

@ -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
@ -90,12 +92,13 @@ boolean DISPLAYCLOCK = true; // true = Show Clock when not printing / false =
// 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;
const int SCL_PIN = D5; const int SCL_PIN = D5; // original code D5 -- Monitor Easy Board use D1
boolean INVERT_DISPLAY = false; // true = pins at top | false = pins at the bottom boolean INVERT_DISPLAY = false; // true = pins at top | false = pins at the bottom
//#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

File diff suppressed because it is too large Load Diff