diff --git a/src/Configuration.h b/src/Configuration.h index 73cf9ab..1f9cd79 100644 --- a/src/Configuration.h +++ b/src/Configuration.h @@ -10,8 +10,8 @@ /** * Basic software settings */ -#define VERSION "4.0" -#define HOSTNAME "PrintMon-" +#define VERSION "1.0" +#define HOSTNAME "PrintBuddy-" #define CONFIG "/conf.txt" // true = Enables debug message on terminal | false = disable all debug messages #define DEBUG_MODE_ENABLE true diff --git a/src/Display/OledDisplay.cpp b/src/Display/OledDisplay.cpp index 3210010..ca82eb5 100644 --- a/src/Display/OledDisplay.cpp +++ b/src/Display/OledDisplay.cpp @@ -58,11 +58,11 @@ void OledDisplay::showBootScreen() { this->oledDisplay->setTextAlignment(TEXT_ALIGN_CENTER); this->oledDisplay->setContrast(255); // default is 255 this->oledDisplay->setFont(ArialMT_Plain_16); - this->oledDisplay->drawString(64, 1, "Printer Monitor"); + this->oledDisplay->drawString(64, 1, "PrintBuddy"); this->oledDisplay->setFont(ArialMT_Plain_10); this->oledDisplay->drawString(64, 18, "for " + this->globalDataController->getPrinterClient()->getPrinterType()); this->oledDisplay->setFont(ArialMT_Plain_16); - this->oledDisplay->drawString(64, 30, "By Qrome"); + this->oledDisplay->drawString(64, 30, "By XXXXXX"); this->oledDisplay->drawString(64, 46, "V" + this->globalDataController->getVersion()); this->oledDisplay->display(); } @@ -158,7 +158,7 @@ void OledDisplay::checkDisplay() { this->ui->setOverlays(clockOverlay, 1); this->isClockOn = true; } else if (printerClient->isPrinting() && !printerClient->isPSUoff() && this->isClockOn) { - this->debugController->printLn("Printer Monitor is active."); + this->debugController->printLn("PrintBuddy is active."); this->ui->setFrames(frames, 3); this->ui->setOverlays(overlays, 1); this->ui->enableAutoTransition(); diff --git a/src/Network/WebServer.cpp b/src/Network/WebServer.cpp index 29c330b..9223594 100644 --- a/src/Network/WebServer.cpp +++ b/src/Network/WebServer.cpp @@ -1,12 +1,6 @@ #include "WebServer.h" -static const char WEB_ACTIONS[] PROGMEM = " Home" - " Configure" - " Weather" - " Reset Settings" - " Forget WiFi" - " Firmware Update" - " About"; + String CHANGE_FORM = ""; // moved to config to make it dynamic @@ -111,8 +105,10 @@ void WebServer::setup() { this->server->on("/updateweatherconfig", []() { obj->handleUpdateWeather(); }); this->server->on("/configure", []() { obj->handleConfigure(); }); this->server->on("/configureweather", []() { obj->handleWeatherConfigure(); }); + this->server->on("/update", HTTP_GET, []() { obj->handleUpdatePage(); }); this->server->onNotFound([]() { obj->redirectHome(); }); this->serverUpdater->setup(this->server, "/update", this->globalDataController->getWebserverUsername(), this->globalDataController->getWebserverPassword()); + // Start the server this->server->begin(); @@ -146,16 +142,10 @@ void WebServer::redirectHome() { } void WebServer::displayPrinterStatus() { - this->globalDataController->ledOnOff(true); BasePrinterClient *printerClient = this->globalDataController->getPrinterClient(); String html = ""; - this->server->sendHeader("Cache-Control", "no-cache, no-store"); - this->server->sendHeader("Pragma", "no-cache"); - this->server->sendHeader("Expires", "-1"); - this->server->setContentLength(CONTENT_LENGTH_UNKNOWN); - this->server->send(200, "text/html", ""); - this->server->sendContent(String(getHeader(true))); + WebserverMemoryVariables::sendHeader(this->server, this->globalDataController, "Status", "Monitor", true); String displayTime = this->globalDataController->getTimeClient()->getAmPmHours() + ":" + @@ -259,10 +249,7 @@ void WebServer::displayPrinterStatus() { html = ""; // fresh start } - this->server->sendContent(String(getFooter())); - this->server->sendContent(""); - this->server->client().stop(); - this->globalDataController->ledOnOff(false); + WebserverMemoryVariables::sendFooter(this->server, this->globalDataController); } void WebServer::handleSystemReset() { @@ -383,51 +370,76 @@ void WebServer::handleConfigure() { if (!this->authentication()) { return this->server->requestAuthentication(); } - this->globalDataController->ledOnOff(true); BasePrinterClient *printerClient = this->globalDataController->getPrinterClient(); String html = ""; + + WebserverMemoryVariables::sendHeader(this->server, this->globalDataController, "Configure", "Station"); - this->server->sendHeader("Cache-Control", "no-cache, no-store"); - this->server->sendHeader("Pragma", "no-cache"); - this->server->sendHeader("Expires", "-1"); - this->server->setContentLength(CONTENT_LENGTH_UNKNOWN); - this->server->send(200, "text/html", ""); - html = this->getHeader(); + // send javascript functions for repetier server test + html = ""; this->server->sendContent(html); - // send javascript functions - if (printerClient->getPrinterType() == "Repetier") { - html = ""; - - this->server->sendContent(html); - } - else if (printerClient->getPrinterType() == "Klipper") { - html = ""; - this->server->sendContent(html); - } - else { - html = ""; + // send javascript functions for klipper test + html = ""; + this->server->sendContent(html); + + // send javascript functions for octoprint test + html = ""; + this->server->sendContent(html); + + // Let us create a form for all printers + html = "