Qrome - updated to use PROGMEM for HTML form constants to reduce the use of dynamic memory
parent
9c3bdfb469
commit
d59fa0da47
|
|
@ -45,8 +45,8 @@ SOFTWARE.
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
#include <ESP8266HTTPUpdateServer.h>
|
#include <ESP8266HTTPUpdateServer.h>
|
||||||
#include "TimeClient.h"
|
#include "TimeClient.h"
|
||||||
#include "OctoPrintClient.h"
|
|
||||||
#include "RepetierClient.h"
|
#include "RepetierClient.h"
|
||||||
|
#include "OctoPrintClient.h"
|
||||||
#include "OpenWeatherMapClient.h"
|
#include "OpenWeatherMapClient.h"
|
||||||
#include "WeatherStationFonts.h"
|
#include "WeatherStationFonts.h"
|
||||||
#include "FS.h"
|
#include "FS.h"
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ int8_t getWifiQuality();
|
||||||
ESP8266WebServer server(WEBSERVER_PORT);
|
ESP8266WebServer server(WEBSERVER_PORT);
|
||||||
ESP8266HTTPUpdateServer serverUpdater;
|
ESP8266HTTPUpdateServer serverUpdater;
|
||||||
|
|
||||||
String WEB_ACTIONS = "<a class='w3-bar-item w3-button' href='/'><i class='fa fa-home'></i> Home</a>"
|
static const char WEB_ACTIONS[] PROGMEM = "<a class='w3-bar-item w3-button' href='/'><i class='fa fa-home'></i> Home</a>"
|
||||||
"<a class='w3-bar-item w3-button' href='/configure'><i class='fa fa-cog'></i> Configure</a>"
|
"<a class='w3-bar-item w3-button' href='/configure'><i class='fa fa-cog'></i> Configure</a>"
|
||||||
"<a class='w3-bar-item w3-button' href='/configureweather'><i class='fa fa-cloud'></i> Weather</a>"
|
"<a class='w3-bar-item w3-button' href='/configureweather'><i class='fa fa-cloud'></i> Weather</a>"
|
||||||
"<a class='w3-bar-item w3-button' href='/systemreset' onclick='return confirm(\"Do you want to reset to default settings?\")'><i class='fa fa-undo'></i> Reset Settings</a>"
|
"<a class='w3-bar-item w3-button' href='/systemreset' onclick='return confirm(\"Do you want to reset to default settings?\")'><i class='fa fa-undo'></i> Reset Settings</a>"
|
||||||
|
|
@ -112,14 +112,21 @@ String WEB_ACTIONS = "<a class='w3-bar-item w3-button' href='/'><i class='fa fa
|
||||||
|
|
||||||
String CHANGE_FORM = ""; // moved to config to make it dynamic
|
String CHANGE_FORM = ""; // moved to config to make it dynamic
|
||||||
|
|
||||||
String THEME_FORM = "<p>Theme Color <select class='w3-option w3-padding' name='theme'>%THEME_OPTIONS%</select></p>"
|
static const char CLOCK_FORM[] PROGMEM = "<hr><p><input name='isClockEnabled' class='w3-check w3-margin-top' type='checkbox' %IS_CLOCK_CHECKED%> Display Clock when printer is off</p>"
|
||||||
|
"<p><input name='is24hour' class='w3-check w3-margin-top' type='checkbox' %IS_24HOUR_CHECKED%> Use 24 Hour Clock (military time)</p>"
|
||||||
|
"<p><input name='invDisp' class='w3-check w3-margin-top' type='checkbox' %IS_INVDISP_CHECKED%> Flip display orientation</p>"
|
||||||
|
"<p><input name='useFlash' class='w3-check w3-margin-top' type='checkbox' %USEFLASH%> Flash System LED on Service Calls</p>"
|
||||||
|
"<p><input name='hasPSU' class='w3-check w3-margin-top' type='checkbox' %HAS_PSU_CHECKED%> Use OctoPrint PSU control plugin for clock/blank</p>"
|
||||||
|
"<p>Clock Sync / Weather Refresh (minutes) <select class='w3-option w3-padding' name='refresh'>%OPTIONS%</select></p>";
|
||||||
|
|
||||||
|
static const char THEME_FORM[] PROGMEM = "<p>Theme Color <select class='w3-option w3-padding' name='theme'>%THEME_OPTIONS%</select></p>"
|
||||||
"<p><label>UTC Time Offset</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='utcoffset' value='%UTCOFFSET%' maxlength='12'></p><hr>"
|
"<p><label>UTC Time Offset</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='utcoffset' value='%UTCOFFSET%' maxlength='12'></p><hr>"
|
||||||
"<p><input name='isBasicAuth' class='w3-check w3-margin-top' type='checkbox' %IS_BASICAUTH_CHECKED%> Use Security Credentials for Configuration Changes</p>"
|
"<p><input name='isBasicAuth' class='w3-check w3-margin-top' type='checkbox' %IS_BASICAUTH_CHECKED%> Use Security Credentials for Configuration Changes</p>"
|
||||||
"<p><label>User ID (for this interface)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='userid' value='%USERID%' maxlength='20'></p>"
|
"<p><label>User ID (for this interface)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='userid' value='%USERID%' maxlength='20'></p>"
|
||||||
"<p><label>Password </label><input class='w3-input w3-border w3-margin-bottom' type='password' name='stationpassword' value='%STATIONPASSWORD%'></p>"
|
"<p><label>Password </label><input class='w3-input w3-border w3-margin-bottom' type='password' name='stationpassword' value='%STATIONPASSWORD%'></p>"
|
||||||
"<button class='w3-button w3-block w3-grey w3-section w3-padding' type='submit'>Save</button></form>";
|
"<button class='w3-button w3-block w3-grey w3-section w3-padding' type='submit'>Save</button></form>";
|
||||||
|
|
||||||
String WEATHER_FORM = "<form class='w3-container' action='/updateweatherconfig' method='get'><h2>Weather Config:</h2>"
|
static const char WEATHER_FORM[] PROGMEM = "<form class='w3-container' action='/updateweatherconfig' method='get'><h2>Weather Config:</h2>"
|
||||||
"<p><input name='isWeatherEnabled' class='w3-check w3-margin-top' type='checkbox' %IS_WEATHER_CHECKED%> Display Weather when printer is off</p>"
|
"<p><input name='isWeatherEnabled' class='w3-check w3-margin-top' type='checkbox' %IS_WEATHER_CHECKED%> Display Weather when printer is off</p>"
|
||||||
"<label>OpenWeatherMap API Key (get from <a href='https://openweathermap.org/' target='_BLANK'>here</a>)</label>"
|
"<label>OpenWeatherMap API Key (get from <a href='https://openweathermap.org/' target='_BLANK'>here</a>)</label>"
|
||||||
"<input class='w3-input w3-border w3-margin-bottom' type='text' name='openWeatherMapApiKey' value='%WEATHERKEY%' maxlength='60'>"
|
"<input class='w3-input w3-border w3-margin-bottom' type='text' name='openWeatherMapApiKey' value='%WEATHERKEY%' maxlength='60'>"
|
||||||
|
|
@ -130,7 +137,7 @@ String WEATHER_FORM = "<form class='w3-container' action='/updateweatherconfig'
|
||||||
"<button class='w3-button w3-block w3-grey w3-section w3-padding' type='submit'>Save</button></form>"
|
"<button class='w3-button w3-block w3-grey w3-section w3-padding' type='submit'>Save</button></form>"
|
||||||
"<script>function isNumberKey(e){var h=e.which?e.which:event.keyCode;return!(h>31&&(h<48||h>57))}</script>";
|
"<script>function isNumberKey(e){var h=e.which?e.which:event.keyCode;return!(h>31&&(h<48||h>57))}</script>";
|
||||||
|
|
||||||
String LANG_OPTIONS = "<option>ar</option>"
|
static const char LANG_OPTIONS[] PROGMEM = "<option>ar</option>"
|
||||||
"<option>bg</option>"
|
"<option>bg</option>"
|
||||||
"<option>ca</option>"
|
"<option>ca</option>"
|
||||||
"<option>cz</option>"
|
"<option>cz</option>"
|
||||||
|
|
@ -164,7 +171,7 @@ String LANG_OPTIONS = "<option>ar</option>"
|
||||||
"<option>zh_cn</option>"
|
"<option>zh_cn</option>"
|
||||||
"<option>zh_tw</option>";
|
"<option>zh_tw</option>";
|
||||||
|
|
||||||
String COLOR_THEMES = "<option>red</option>"
|
static const char COLOR_THEMES[] PROGMEM = "<option>red</option>"
|
||||||
"<option>pink</option>"
|
"<option>pink</option>"
|
||||||
"<option>purple</option>"
|
"<option>purple</option>"
|
||||||
"<option>deep-purple</option>"
|
"<option>deep-purple</option>"
|
||||||
|
|
@ -519,7 +526,7 @@ void handleWeatherConfigure() {
|
||||||
html = getHeader();
|
html = getHeader();
|
||||||
server.sendContent(html);
|
server.sendContent(html);
|
||||||
|
|
||||||
String form = WEATHER_FORM;
|
String form = (const char*)WEATHER_FORM;
|
||||||
String isWeatherChecked = "";
|
String isWeatherChecked = "";
|
||||||
if (DISPLAYWEATHER) {
|
if (DISPLAYWEATHER) {
|
||||||
isWeatherChecked = "checked='checked'";
|
isWeatherChecked = "checked='checked'";
|
||||||
|
|
@ -533,7 +540,7 @@ void handleWeatherConfigure() {
|
||||||
checked = "checked='checked'";
|
checked = "checked='checked'";
|
||||||
}
|
}
|
||||||
form.replace("%METRIC%", checked);
|
form.replace("%METRIC%", checked);
|
||||||
String options = LANG_OPTIONS;
|
String options = (const char*)LANG_OPTIONS;
|
||||||
options.replace(">"+String(WeatherLanguage)+"<", " selected>"+String(WeatherLanguage)+"<");
|
options.replace(">"+String(WeatherLanguage)+"<", " selected>"+String(WeatherLanguage)+"<");
|
||||||
form.replace("%LANGUAGEOPTIONS%", options);
|
form.replace("%LANGUAGEOPTIONS%", options);
|
||||||
server.sendContent(form);
|
server.sendContent(form);
|
||||||
|
|
@ -581,12 +588,7 @@ void handleConfigure() {
|
||||||
CHANGE_FORM += "<p><label>" + printerClient.getPrinterType() + " User (only needed if you have haproxy or basic auth turned on)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='octoUser' value='%OCTOUSER%' maxlength='30'></p>"
|
CHANGE_FORM += "<p><label>" + printerClient.getPrinterType() + " User (only needed if you have haproxy or basic auth turned on)</label><input class='w3-input w3-border w3-margin-bottom' type='text' name='octoUser' value='%OCTOUSER%' maxlength='30'></p>"
|
||||||
"<p><label>" + printerClient.getPrinterType() + " Password </label><input class='w3-input w3-border w3-margin-bottom' type='password' name='octoPass' value='%OCTOPASS%'></p>";
|
"<p><label>" + printerClient.getPrinterType() + " Password </label><input class='w3-input w3-border w3-margin-bottom' type='password' name='octoPass' value='%OCTOPASS%'></p>";
|
||||||
|
|
||||||
String Clock_Form = "<hr><p><input name='isClockEnabled' class='w3-check w3-margin-top' type='checkbox' %IS_CLOCK_CHECKED%> Display Clock when printer is off</p>"
|
|
||||||
"<p><input name='is24hour' class='w3-check w3-margin-top' type='checkbox' %IS_24HOUR_CHECKED%> Use 24 Hour Clock (military time)</p>"
|
|
||||||
"<p><input name='invDisp' class='w3-check w3-margin-top' type='checkbox' %IS_INVDISP_CHECKED%> Flip display orientation</p>"
|
|
||||||
"<p><input name='useFlash' class='w3-check w3-margin-top' type='checkbox' %USEFLASH%> Flash System LED on Service Calls</p>"
|
|
||||||
"<p><input name='hasPSU' class='w3-check w3-margin-top' type='checkbox' %HAS_PSU_CHECKED%> Use OctoPrint PSU control plugin for clock/blank</p>"
|
|
||||||
"<p>Clock Sync / Weather Refresh (minutes) <select class='w3-option w3-padding' name='refresh'>%OPTIONS%</select></p>";
|
|
||||||
|
|
||||||
if (printerClient.getPrinterType() == "Repetier") {
|
if (printerClient.getPrinterType() == "Repetier") {
|
||||||
html = "<script>function testRepetier(){var e=document.getElementById(\"RepetierTest\"),r=document.getElementById(\"PrinterAddress\").value,"
|
html = "<script>function testRepetier(){var e=document.getElementById(\"RepetierTest\"),r=document.getElementById(\"PrinterAddress\").value,"
|
||||||
|
|
@ -619,7 +621,7 @@ void handleConfigure() {
|
||||||
|
|
||||||
server.sendContent(form);
|
server.sendContent(form);
|
||||||
|
|
||||||
form = Clock_Form;
|
form = (const char*)CLOCK_FORM;
|
||||||
|
|
||||||
String isClockChecked = "";
|
String isClockChecked = "";
|
||||||
if (DISPLAYCLOCK) {
|
if (DISPLAYCLOCK) {
|
||||||
|
|
@ -653,9 +655,9 @@ void handleConfigure() {
|
||||||
|
|
||||||
server.sendContent(form);
|
server.sendContent(form);
|
||||||
|
|
||||||
form = THEME_FORM;
|
form = (const char*)THEME_FORM;
|
||||||
|
|
||||||
String themeOptions = COLOR_THEMES;
|
String themeOptions = (const char*)COLOR_THEMES;
|
||||||
themeOptions.replace(">"+String(themeColor)+"<", " selected>"+String(themeColor)+"<");
|
themeOptions.replace(">"+String(themeColor)+"<", " selected>"+String(themeColor)+"<");
|
||||||
form.replace("%THEME_OPTIONS%", themeOptions);
|
form.replace("%THEME_OPTIONS%", themeOptions);
|
||||||
form.replace("%UTCOFFSET%", String(UtcOffset));
|
form.replace("%UTCOFFSET%", String(UtcOffset));
|
||||||
|
|
@ -710,7 +712,7 @@ String getHeader() {
|
||||||
}
|
}
|
||||||
|
|
||||||
String getHeader(boolean refresh) {
|
String getHeader(boolean refresh) {
|
||||||
String menu = WEB_ACTIONS;
|
String menu = (const char*)WEB_ACTIONS;
|
||||||
|
|
||||||
String html = "<!DOCTYPE HTML>";
|
String html = "<!DOCTYPE HTML>";
|
||||||
html += "<html><head><title>Printer Monitor</title><link rel='icon' href='data:;base64,='>";
|
html += "<html><head><title>Printer Monitor</title><link rel='icon' href='data:;base64,='>";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue