From be590b2e2dd781c3bb6559d4d79c730da91adc69 Mon Sep 17 00:00:00 2001 From: Marcus Date: Sun, 14 Apr 2024 15:43:18 +0200 Subject: [PATCH] firmware WIP - add style.css 8) --- Arduino/CanGrow/CanGrow.ino | 47 +++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino index 8e4fb37..c918816 100644 --- a/Arduino/CanGrow/CanGrow.ino +++ b/Arduino/CanGrow/CanGrow.ino @@ -115,12 +115,19 @@ const bool APhidden = false; ESP8266WebServer webserver(80); /* - * HTML pages + * HTML constants for header, footer, css, ... */ // Template: const char HTMLexamplepage[] PROGMEM = R"EOF()EOF"; const char HTMLheader[] PROGMEM = R"EOF( + + + + + CanGrow + + )EOF"; @@ -129,6 +136,26 @@ const char HTMLfooter[] PROGMEM = R"EOF( )EOF"; +const char HTMLstyleCSS[] PROGMEM = R"EOF( +body { + font-family: helvetica; + background-color: #cccccc; +} + +a:link, a:visited { + color: #33ff33; +} + +a:hover { + color: #ffff00; +} + +a:active { + color: #da7a0a; +} + +)EOF"; + /* * * Pin assignments @@ -641,6 +668,7 @@ void setup() { // generic handler webserver.on("/wifiConfig/save", HTTP_POST, POSTwifiConfig); + webserver.on("/style.css", HTTP_GET, WEBstyleCSS); // 404 handling webserver.onNotFound(WEB404); @@ -686,20 +714,28 @@ void WebHandler_configured() { * */ +// not really a webpage, but CSS is important for them :p +void WEBstyleCSS() { + webserver.send(200, "text/css", HTMLstyleCSS); +} + void WEB404() { String body = FPSTR(HTMLheader); body += "404 - not found"; body += FPSTR(HTMLfooter); + webserver.send(200, "text/html", body); } + void WEBrootUnconfigured() { byte ssidsAvail = WiFi.scanNetworks(); String body = FPSTR(HTMLheader); body += "

unconfigured!

\n"; body += "

WiFi config

\n"; - body += "

Select your wifi network from the SSID list.
Leave IP field empty, to use DHCP.

"; + body += "

Select your wifi network from the SSID list.
To use DHCP leave IP, Subnet, Gateway and DNS fields blank!

"; body += "
\n"; body += "SSID:
\n"; body += "IP:
\n"; body += "Subnet mask:
\n"; - body += "gateway:
\n"; - body += "dns:
\n"; + body += "Gateway:
\n"; + body += "DNS:
\n"; body += "\n"; body += "
\n"; - body += "

Available WiFi

\n";
- 
-  body += "

\n"; body += FPSTR(HTMLfooter); webserver.send(200, "text/html", body);