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:
/* 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);
}
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);
myApiKey = ApiKey;
myPort = port;
@ -43,7 +43,7 @@ void OctoPrintClient::updatePrintClient(String ApiKey, String server, int port,
pollPsu = psu;
}
boolean OctoPrintClient::validate() {
boolean KlipperPrintClient::validate() {
boolean rtnValue = false;
printerData.error = "";
if (String(myServer) == "") {
@ -58,7 +58,7 @@ boolean OctoPrintClient::validate() {
return rtnValue;
}
WiFiClient OctoPrintClient::getSubmitRequest(String apiGetData) {
WiFiClient KlipperPrintClient::getSubmitRequest(String apiGetData) {
WiFiClient printClient;
printClient.setTimeout(5000);
@ -113,7 +113,7 @@ WiFiClient OctoPrintClient::getSubmitRequest(String apiGetData) {
return printClient;
}
WiFiClient OctoPrintClient::getPostRequest(String apiPostData, String apiPostBody) {
WiFiClient KlipperPrintClient::getPostRequest(String apiPostData, String apiPostBody) {
WiFiClient printClient;
printClient.setTimeout(5000);
@ -173,7 +173,7 @@ WiFiClient OctoPrintClient::getPostRequest(String apiPostData, String apiPostBod
return printClient;
}
void OctoPrintClient::getPrinterJobResults() {
void KlipperPrintClient::getPrinterJobResults() {
if (!validate()) {
return;
}
@ -249,7 +249,7 @@ void OctoPrintClient::getPrinterJobResults() {
}
}
void OctoPrintClient::getPrinterPsuState() {
void KlipperPrintClient::getPrinterPsuState() {
//**** get the PSU state (if enabled and printer operational)
if (pollPsu && isOperational()) {
if (!validate()) {
@ -286,7 +286,7 @@ void OctoPrintClient::getPrinterPsuState() {
}
// Reset all PrinterData
void OctoPrintClient::resetPrintData() {
void KlipperPrintClient::resetPrintData() {
printerData.averagePrintTime = "";
printerData.estimatedPrintTime = "";
printerData.fileName = "";
@ -307,39 +307,39 @@ void OctoPrintClient::resetPrintData() {
printerData.error = "";
}
String OctoPrintClient::getAveragePrintTime(){
String KlipperPrintClient::getAveragePrintTime(){
return printerData.averagePrintTime;
}
String OctoPrintClient::getEstimatedPrintTime() {
String KlipperPrintClient::getEstimatedPrintTime() {
return printerData.estimatedPrintTime;
}
String OctoPrintClient::getFileName() {
String KlipperPrintClient::getFileName() {
return printerData.fileName;
}
String OctoPrintClient::getFileSize() {
String KlipperPrintClient::getFileSize() {
return printerData.fileSize;
}
String OctoPrintClient::getLastPrintTime(){
String KlipperPrintClient::getLastPrintTime(){
return printerData.lastPrintTime;
}
String OctoPrintClient::getProgressCompletion() {
String KlipperPrintClient::getProgressCompletion() {
return String(printerData.progressCompletion.toInt());
}
String OctoPrintClient::getProgressFilepos() {
String KlipperPrintClient::getProgressFilepos() {
return printerData.progressFilepos;
}
String OctoPrintClient::getProgressPrintTime() {
String KlipperPrintClient::getProgressPrintTime() {
return printerData.progressPrintTime;
}
String OctoPrintClient::getProgressPrintTimeLeft() {
String KlipperPrintClient::getProgressPrintTimeLeft() {
String rtnValue = printerData.progressPrintTimeLeft;
if (getProgressCompletion() == "100") {
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;
}
String OctoPrintClient::getState() {
String KlipperPrintClient::getState() {
return printerData.state;
}
boolean OctoPrintClient::isPrinting() {
boolean KlipperPrintClient::isPrinting() {
return printerData.isPrinting;
}
boolean OctoPrintClient::isPSUoff() {
boolean KlipperPrintClient::isPSUoff() {
return printerData.isPSUoff;
}
boolean OctoPrintClient::isOperational() {
boolean KlipperPrintClient::isOperational() {
boolean operational = false;
if (printerData.state == "Operational" || isPrinting()) {
operational = true;
@ -367,48 +367,48 @@ boolean OctoPrintClient::isOperational() {
return operational;
}
String OctoPrintClient::getTempBedActual() {
String KlipperPrintClient::getTempBedActual() {
return printerData.bedTemp;
}
String OctoPrintClient::getTempBedTarget() {
String KlipperPrintClient::getTempBedTarget() {
return printerData.bedTargetTemp;
}
String OctoPrintClient::getTempToolActual() {
String KlipperPrintClient::getTempToolActual() {
return printerData.toolTemp;
}
String OctoPrintClient::getTempToolTarget() {
String KlipperPrintClient::getTempToolTarget() {
return printerData.toolTargetTemp;
}
String OctoPrintClient::getFilamentLength() {
String KlipperPrintClient::getFilamentLength() {
return printerData.filamentLength;
}
String OctoPrintClient::getError() {
String KlipperPrintClient::getError() {
return printerData.error;
}
String OctoPrintClient::getValueRounded(String value) {
String KlipperPrintClient::getValueRounded(String value) {
float f = value.toFloat();
int rounded = (int)(f+0.5f);
return String(rounded);
}
String OctoPrintClient::getPrinterType() {
String KlipperPrintClient::getPrinterType() {
return printerType;
}
int OctoPrintClient::getPrinterPort() {
int KlipperPrintClient::getPrinterPort() {
return myPort;
}
String OctoPrintClient::getPrinterName() {
String KlipperPrintClient::getPrinterName() {
return printerData.printerName;
}
void OctoPrintClient::setPrinterName(String printer) {
void KlipperPrintClient::setPrinterName(String printer) {
printerData.printerName = printer;
}

View File

@ -29,7 +29,7 @@ SOFTWARE.
#include "libs/ArduinoJson/ArduinoJson.h"
#include <base64.h>
class OctoPrintClient {
class KlipperPrintClient {
private:
char myServer[100];
@ -72,7 +72,7 @@ private:
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 getPrinterPsuState();
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)
Copyright (c) 2018 David Payne
@ -61,10 +81,14 @@ SOFTWARE.
// Start Settings
//******************************
// ESP32/ESP8266 compatibility!
//#define USE_ESP8266
// 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_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
String PrinterApiKey = ""; // ApiKey from your User Account on OctoPrint / Repetier
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://)
@ -95,11 +119,21 @@ int minutesBetweenDataRefresh = 15;
boolean DISPLAYCLOCK = true; // true = Show Clock when not printing / false = turn off display when not printing
// Display Settings
const int I2C_DISPLAY_ADDRESS = 0x3c; // I2C Address of your Display (usually 0x3c or 0x3d)
const int SDA_PIN = D2;
const int SCL_PIN = D1; // original code D5 -- Monitor Easy Board use D1
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 USE_NEXTION_DISPLAY
#ifdef USE_NEXTION_DISPLAY
#else
const int I2C_DISPLAY_ADDRESS = 0x3c; // I2C Address of your Display (usually 0x3c or 0x3d)
#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
const int externalLight = LED_BUILTIN; // LED will always flash on bootup or Wifi Errors

View File

@ -45,26 +45,28 @@ SOFTWARE.
#define numberOfMinutes(_time_) ((_time_ / SECS_PER_MIN) % SECS_PER_MIN)
#define numberOfHours(_time_) (_time_ / SECS_PER_HOUR)
// 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);
#if USE_NEXTION_DISPLAY
#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
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
const int numberOfFrames = 3;
FrameCallback frames[numberOfFrames];
@ -88,6 +90,8 @@ boolean displayOn = true;
// Printer Client
#if defined(USE_REPETIER_CLIENT)
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)
DuetClient printerClient(PrinterApiKey, PrinterServer, PrinterPort, PrinterAuthUser, PrinterAuthPass, HAS_PSU);
#else