start nextion and esp8266
parent
5e0ff35720
commit
8918e8e4b5
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.
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
Binary file not shown.
|
|
@ -24,13 +24,13 @@ SOFTWARE.
|
||||||
// Additional Contributions:
|
// Additional Contributions:
|
||||||
/* 15 Jan 2019 : Owen Carter : Add psucontrol query via POST api call */
|
/* 15 Jan 2019 : Owen Carter : Add psucontrol query via POST api call */
|
||||||
|
|
||||||
#include "OctoPrintClient.h"
|
#include "KlipperPrintClient.h"
|
||||||
|
|
||||||
OctoPrintClient::OctoPrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu) {
|
KlipperPrintClient::KlipperPrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu) {
|
||||||
updatePrintClient(ApiKey, server, port, user, pass, psu);
|
updatePrintClient(ApiKey, server, port, user, pass, psu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OctoPrintClient::updatePrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu) {
|
void KlipperPrintClient::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;
|
||||||
|
|
@ -43,7 +43,7 @@ void OctoPrintClient::updatePrintClient(String ApiKey, String server, int port,
|
||||||
pollPsu = psu;
|
pollPsu = psu;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean OctoPrintClient::validate() {
|
boolean KlipperPrintClient::validate() {
|
||||||
boolean rtnValue = false;
|
boolean rtnValue = false;
|
||||||
printerData.error = "";
|
printerData.error = "";
|
||||||
if (String(myServer) == "") {
|
if (String(myServer) == "") {
|
||||||
|
|
@ -58,7 +58,7 @@ boolean OctoPrintClient::validate() {
|
||||||
return rtnValue;
|
return rtnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
WiFiClient OctoPrintClient::getSubmitRequest(String apiGetData) {
|
WiFiClient KlipperPrintClient::getSubmitRequest(String apiGetData) {
|
||||||
WiFiClient printClient;
|
WiFiClient printClient;
|
||||||
printClient.setTimeout(5000);
|
printClient.setTimeout(5000);
|
||||||
|
|
||||||
|
|
@ -113,7 +113,7 @@ WiFiClient OctoPrintClient::getSubmitRequest(String apiGetData) {
|
||||||
return printClient;
|
return printClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
WiFiClient OctoPrintClient::getPostRequest(String apiPostData, String apiPostBody) {
|
WiFiClient KlipperPrintClient::getPostRequest(String apiPostData, String apiPostBody) {
|
||||||
WiFiClient printClient;
|
WiFiClient printClient;
|
||||||
printClient.setTimeout(5000);
|
printClient.setTimeout(5000);
|
||||||
|
|
||||||
|
|
@ -173,7 +173,7 @@ WiFiClient OctoPrintClient::getPostRequest(String apiPostData, String apiPostBod
|
||||||
return printClient;
|
return printClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OctoPrintClient::getPrinterJobResults() {
|
void KlipperPrintClient::getPrinterJobResults() {
|
||||||
if (!validate()) {
|
if (!validate()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -249,7 +249,7 @@ void OctoPrintClient::getPrinterJobResults() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OctoPrintClient::getPrinterPsuState() {
|
void KlipperPrintClient::getPrinterPsuState() {
|
||||||
//**** get the PSU state (if enabled and printer operational)
|
//**** get the PSU state (if enabled and printer operational)
|
||||||
if (pollPsu && isOperational()) {
|
if (pollPsu && isOperational()) {
|
||||||
if (!validate()) {
|
if (!validate()) {
|
||||||
|
|
@ -286,7 +286,7 @@ void OctoPrintClient::getPrinterPsuState() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset all PrinterData
|
// Reset all PrinterData
|
||||||
void OctoPrintClient::resetPrintData() {
|
void KlipperPrintClient::resetPrintData() {
|
||||||
printerData.averagePrintTime = "";
|
printerData.averagePrintTime = "";
|
||||||
printerData.estimatedPrintTime = "";
|
printerData.estimatedPrintTime = "";
|
||||||
printerData.fileName = "";
|
printerData.fileName = "";
|
||||||
|
|
@ -307,39 +307,39 @@ void OctoPrintClient::resetPrintData() {
|
||||||
printerData.error = "";
|
printerData.error = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getAveragePrintTime(){
|
String KlipperPrintClient::getAveragePrintTime(){
|
||||||
return printerData.averagePrintTime;
|
return printerData.averagePrintTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getEstimatedPrintTime() {
|
String KlipperPrintClient::getEstimatedPrintTime() {
|
||||||
return printerData.estimatedPrintTime;
|
return printerData.estimatedPrintTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getFileName() {
|
String KlipperPrintClient::getFileName() {
|
||||||
return printerData.fileName;
|
return printerData.fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getFileSize() {
|
String KlipperPrintClient::getFileSize() {
|
||||||
return printerData.fileSize;
|
return printerData.fileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getLastPrintTime(){
|
String KlipperPrintClient::getLastPrintTime(){
|
||||||
return printerData.lastPrintTime;
|
return printerData.lastPrintTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getProgressCompletion() {
|
String KlipperPrintClient::getProgressCompletion() {
|
||||||
return String(printerData.progressCompletion.toInt());
|
return String(printerData.progressCompletion.toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getProgressFilepos() {
|
String KlipperPrintClient::getProgressFilepos() {
|
||||||
return printerData.progressFilepos;
|
return printerData.progressFilepos;
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getProgressPrintTime() {
|
String KlipperPrintClient::getProgressPrintTime() {
|
||||||
return printerData.progressPrintTime;
|
return printerData.progressPrintTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getProgressPrintTimeLeft() {
|
String KlipperPrintClient::getProgressPrintTimeLeft() {
|
||||||
String rtnValue = printerData.progressPrintTimeLeft;
|
String rtnValue = printerData.progressPrintTimeLeft;
|
||||||
if (getProgressCompletion() == "100") {
|
if (getProgressCompletion() == "100") {
|
||||||
rtnValue = "0"; // Print is done so this should be 0 this is a fix for OctoPrint
|
rtnValue = "0"; // Print is done so this should be 0 this is a fix for OctoPrint
|
||||||
|
|
@ -347,19 +347,19 @@ String OctoPrintClient::getProgressPrintTimeLeft() {
|
||||||
return rtnValue;
|
return rtnValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getState() {
|
String KlipperPrintClient::getState() {
|
||||||
return printerData.state;
|
return printerData.state;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean OctoPrintClient::isPrinting() {
|
boolean KlipperPrintClient::isPrinting() {
|
||||||
return printerData.isPrinting;
|
return printerData.isPrinting;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean OctoPrintClient::isPSUoff() {
|
boolean KlipperPrintClient::isPSUoff() {
|
||||||
return printerData.isPSUoff;
|
return printerData.isPSUoff;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean OctoPrintClient::isOperational() {
|
boolean KlipperPrintClient::isOperational() {
|
||||||
boolean operational = false;
|
boolean operational = false;
|
||||||
if (printerData.state == "Operational" || isPrinting()) {
|
if (printerData.state == "Operational" || isPrinting()) {
|
||||||
operational = true;
|
operational = true;
|
||||||
|
|
@ -367,48 +367,48 @@ boolean OctoPrintClient::isOperational() {
|
||||||
return operational;
|
return operational;
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getTempBedActual() {
|
String KlipperPrintClient::getTempBedActual() {
|
||||||
return printerData.bedTemp;
|
return printerData.bedTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getTempBedTarget() {
|
String KlipperPrintClient::getTempBedTarget() {
|
||||||
return printerData.bedTargetTemp;
|
return printerData.bedTargetTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getTempToolActual() {
|
String KlipperPrintClient::getTempToolActual() {
|
||||||
return printerData.toolTemp;
|
return printerData.toolTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getTempToolTarget() {
|
String KlipperPrintClient::getTempToolTarget() {
|
||||||
return printerData.toolTargetTemp;
|
return printerData.toolTargetTemp;
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getFilamentLength() {
|
String KlipperPrintClient::getFilamentLength() {
|
||||||
return printerData.filamentLength;
|
return printerData.filamentLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getError() {
|
String KlipperPrintClient::getError() {
|
||||||
return printerData.error;
|
return printerData.error;
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getValueRounded(String value) {
|
String KlipperPrintClient::getValueRounded(String value) {
|
||||||
float f = value.toFloat();
|
float f = value.toFloat();
|
||||||
int rounded = (int)(f+0.5f);
|
int rounded = (int)(f+0.5f);
|
||||||
return String(rounded);
|
return String(rounded);
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getPrinterType() {
|
String KlipperPrintClient::getPrinterType() {
|
||||||
return printerType;
|
return printerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
int OctoPrintClient::getPrinterPort() {
|
int KlipperPrintClient::getPrinterPort() {
|
||||||
return myPort;
|
return myPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
String OctoPrintClient::getPrinterName() {
|
String KlipperPrintClient::getPrinterName() {
|
||||||
return printerData.printerName;
|
return printerData.printerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OctoPrintClient::setPrinterName(String printer) {
|
void KlipperPrintClient::setPrinterName(String printer) {
|
||||||
printerData.printerName = printer;
|
printerData.printerName = printer;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ SOFTWARE.
|
||||||
#include "libs/ArduinoJson/ArduinoJson.h"
|
#include "libs/ArduinoJson/ArduinoJson.h"
|
||||||
#include <base64.h>
|
#include <base64.h>
|
||||||
|
|
||||||
class OctoPrintClient {
|
class KlipperPrintClient {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char myServer[100];
|
char myServer[100];
|
||||||
|
|
@ -72,7 +72,7 @@ private:
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OctoPrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu);
|
KlipperPrintClient(String ApiKey, String server, int port, String user, String pass, boolean psu);
|
||||||
void getPrinterJobResults();
|
void getPrinterJobResults();
|
||||||
void getPrinterPsuState();
|
void getPrinterPsuState();
|
||||||
void updatePrintClient(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);
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,23 @@
|
||||||
|
#include <doxygen.h>
|
||||||
|
#include <NexButton.h>
|
||||||
|
#include <NexConfig.h>
|
||||||
|
#include <NexCrop.h>
|
||||||
|
#include <NexGauge.h>
|
||||||
|
#include <NexHardware.h>
|
||||||
|
#include <NexHotspot.h>
|
||||||
|
#include <NexObject.h>
|
||||||
|
#include <NexPage.h>
|
||||||
|
#include <NexPicture.h>
|
||||||
|
#include <NexProgressBar.h>
|
||||||
|
#include <NexSlider.h>
|
||||||
|
#include <NexText.h>
|
||||||
|
#include <NexTimer.h>
|
||||||
|
#include <Nextion.h>
|
||||||
|
#include <NexTouch.h>
|
||||||
|
#include <NexVar.h>
|
||||||
|
#include <NexWaveform.h>
|
||||||
|
#include <SoftwareSerial.h>
|
||||||
|
|
||||||
/** The MIT License (MIT)
|
/** The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2018 David Payne
|
Copyright (c) 2018 David Payne
|
||||||
|
|
@ -61,10 +81,14 @@ SOFTWARE.
|
||||||
// Start Settings
|
// Start Settings
|
||||||
//******************************
|
//******************************
|
||||||
|
|
||||||
|
// ESP32/ESP8266 compatibility!
|
||||||
|
//#define USE_ESP8266
|
||||||
|
|
||||||
// OctoPrint / Repetier / Klipper/ Duet Monitoring -- Monitor your 3D OctoPrint or Repetier Server
|
// OctoPrint / Repetier / Klipper/ Duet Monitoring -- Monitor your 3D OctoPrint or Repetier Server
|
||||||
#define USE_DUET_CLIENT // Uncomment this line to use the Duet Printer Server -- OctoPrint is used by default and is most common
|
#define USE_DUET_CLIENT // Uncomment this line to use the Duet Printer Server -- OctoPrint is used by default and is most common
|
||||||
#define USE_KLIPPER_CLIENT // Uncomment this line to use the Duet Printer Server -- OctoPrint is used by default and is most common
|
//#define USE_KLIPPER_CLIENT // Uncomment this line to use the Duet 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
|
//#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 = "";// Default 'octopi' -- or hostname if different (optional if your IP changes)
|
String PrinterHostName = "";// 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://)
|
||||||
|
|
@ -95,11 +119,21 @@ 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
|
||||||
|
|
||||||
// Display Settings
|
// Display Settings
|
||||||
const int I2C_DISPLAY_ADDRESS = 0x3c; // I2C Address of your Display (usually 0x3c or 0x3d)
|
#define USE_NEXTION_DISPLAY
|
||||||
const int SDA_PIN = D2;
|
#ifdef USE_NEXTION_DISPLAY
|
||||||
const int SCL_PIN = D1; // original code D5 -- Monitor Easy Board use D1
|
#else
|
||||||
boolean INVERT_DISPLAY = true; // true = pins at top | false = pins at the bottom
|
const int I2C_DISPLAY_ADDRESS = 0x3c; // I2C Address of your Display (usually 0x3c or 0x3d)
|
||||||
//#define DISPLAY_SH1106 // Uncomment this line to use the SH1106 display -- SSD1306 is used by default and is most common
|
#ifdef USE_ESP8266
|
||||||
|
const int SDA_PIN = 21;
|
||||||
|
const int SCL_PIN = 22; // original code D5 -- Monitor Easy Board use D1
|
||||||
|
#else
|
||||||
|
const int SDA_PIN = D1;
|
||||||
|
const int SCL_PIN = D2; // original code D5 -- Monitor Easy Board use D1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
boolean INVERT_DISPLAY = true; // 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
|
||||||
|
#endif
|
||||||
|
|
||||||
// LED Settings
|
// LED Settings
|
||||||
const int externalLight = LED_BUILTIN; // LED will always flash on bootup or Wifi Errors
|
const int externalLight = LED_BUILTIN; // LED will always flash on bootup or Wifi Errors
|
||||||
|
|
|
||||||
|
|
@ -45,26 +45,28 @@ SOFTWARE.
|
||||||
#define numberOfMinutes(_time_) ((_time_ / SECS_PER_MIN) % SECS_PER_MIN)
|
#define numberOfMinutes(_time_) ((_time_ / SECS_PER_MIN) % SECS_PER_MIN)
|
||||||
#define numberOfHours(_time_) (_time_ / SECS_PER_HOUR)
|
#define numberOfHours(_time_) (_time_ / SECS_PER_HOUR)
|
||||||
|
|
||||||
// Initialize the oled display for I2C_DISPLAY_ADDRESS
|
#if USE_NEXTION_DISPLAY
|
||||||
// SDA_PIN and SCL_PIN
|
|
||||||
#if defined(DISPLAY_SH1106)
|
|
||||||
SH1106Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SCL_PIN);
|
|
||||||
#else
|
#else
|
||||||
SSD1306Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SCL_PIN); // this is the default
|
// Initialize the oled display for I2C_DISPLAY_ADDRESS
|
||||||
|
// SDA_PIN and SCL_PIN
|
||||||
|
#if defined(DISPLAY_SH1106)
|
||||||
|
SH1106Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SCL_PIN);
|
||||||
|
#else
|
||||||
|
SSD1306Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SCL_PIN); // this is the default
|
||||||
|
#endif
|
||||||
|
OLEDDisplayUi ui( &display );
|
||||||
|
|
||||||
|
void drawProgress(OLEDDisplay *display, int percentage, String label);
|
||||||
|
void drawOtaProgress(unsigned int, unsigned int);
|
||||||
|
void drawScreen1(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
|
||||||
|
void drawScreen2(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
|
||||||
|
void drawScreen3(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
|
||||||
|
void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state);
|
||||||
|
void drawClock(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
|
||||||
|
void drawWeather(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
|
||||||
|
void drawClockHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OLEDDisplayUi ui( &display );
|
|
||||||
|
|
||||||
void drawProgress(OLEDDisplay *display, int percentage, String label);
|
|
||||||
void drawOtaProgress(unsigned int, unsigned int);
|
|
||||||
void drawScreen1(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
|
|
||||||
void drawScreen2(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
|
|
||||||
void drawScreen3(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
|
|
||||||
void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state);
|
|
||||||
void drawClock(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
|
|
||||||
void drawWeather(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
|
|
||||||
void drawClockHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state);
|
|
||||||
|
|
||||||
// Set the number of Frames supported
|
// Set the number of Frames supported
|
||||||
const int numberOfFrames = 3;
|
const int numberOfFrames = 3;
|
||||||
FrameCallback frames[numberOfFrames];
|
FrameCallback frames[numberOfFrames];
|
||||||
|
|
@ -88,6 +90,8 @@ boolean displayOn = true;
|
||||||
// Printer Client
|
// Printer Client
|
||||||
#if defined(USE_REPETIER_CLIENT)
|
#if defined(USE_REPETIER_CLIENT)
|
||||||
RepetierClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU);
|
RepetierClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU);
|
||||||
|
#elif defined(USE_KLIPPER_CLIENT)
|
||||||
|
KlipperClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU);
|
||||||
#elif defined(USE_DUET_CLIENT)
|
#elif defined(USE_DUET_CLIENT)
|
||||||
DuetClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU);
|
DuetClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU);
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue