start nextion and esp8266

pull/125/head
Robert Stein 2020-12-09 14:31:10 +01:00
parent 5e0ff35720
commit 8918e8e4b5
13 changed files with 96 additions and 58 deletions

BIN
nextion-ui/SegoeUi16.zi Normal file

Binary file not shown.

BIN
nextion-ui/SegoeUi16B.zi Normal file

Binary file not shown.

BIN
nextion-ui/SegoeUi20.zi Normal file

Binary file not shown.

BIN
nextion-ui/SegoeUi20B.zi Normal file

Binary file not shown.

BIN
nextion-ui/SegoeUi24.zi Normal file

Binary file not shown.

BIN
nextion-ui/SegoeUi24B.zi Normal file

Binary file not shown.

BIN
nextion-ui/hmi-data.HMI Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

View File

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

View File

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

View File

@ -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
#define USE_NEXTION_DISPLAY
#ifdef USE_NEXTION_DISPLAY
#else
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; #ifdef USE_ESP8266
const int SCL_PIN = D1; // original code D5 -- Monitor Easy Board use D1 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 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 //#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

View File

@ -45,6 +45,8 @@ 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)
#if USE_NEXTION_DISPLAY
#else
// Initialize the oled display for I2C_DISPLAY_ADDRESS // Initialize the oled display for I2C_DISPLAY_ADDRESS
// SDA_PIN and SCL_PIN // SDA_PIN and SCL_PIN
#if defined(DISPLAY_SH1106) #if defined(DISPLAY_SH1106)
@ -52,7 +54,6 @@ SOFTWARE.
#else #else
SSD1306Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SCL_PIN); // this is the default SSD1306Wire display(I2C_DISPLAY_ADDRESS, SDA_PIN, SCL_PIN); // this is the default
#endif #endif
OLEDDisplayUi ui( &display ); OLEDDisplayUi ui( &display );
void drawProgress(OLEDDisplay *display, int percentage, String label); void drawProgress(OLEDDisplay *display, int percentage, String label);
@ -64,6 +65,7 @@ void drawHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state);
void drawClock(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y); 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 drawWeather(OLEDDisplay *display, OLEDDisplayUiState* state, int16_t x, int16_t y);
void drawClockHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state); void drawClockHeaderOverlay(OLEDDisplay *display, OLEDDisplayUiState* state);
#endif
// Set the number of Frames supported // Set the number of Frames supported
const int numberOfFrames = 3; const int numberOfFrames = 3;
@ -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