tryin on win

This commit is contained in:
2021-06-23 13:37:13 +02:00
parent 642ee7d0a6
commit 4b608c42ca
9 changed files with 14 additions and 120 deletions
+13 -44
View File
@@ -27,7 +27,6 @@ extern "C" {
#include "style.css.gz.h"
#include "favicon.png.gz.h"
// images are possible
// maybe check out FS <- SPIFFS
const char* ssid = STASSID;
const char* password = STAPSK;
@@ -38,33 +37,13 @@ int timer_arg;
void setup_webserver();
void setup_ota();
void setup_pwm_pca9685();
void handleRootGz();
void handleCssGz();
void handleNotFound();
const int led = 13;
ESP8266WebServer server(80);
PCA9685 pwmController;
void handleRootGz() {
const char* dataType = "text/html";
server.sendHeader(F("Content-Encoding"), F("gzip"));
server.send(200, dataType, (const char*)index_html_gz, index_html_gz_len);
}
void handleCssGz() {
const char* dataType = "text/css";
server.sendHeader(F("Content-Encoding"), F("gzip"));
server.send(200, dataType, (const char*)style_css_gz, style_css_gz_len);
}
void handleFaviconGz() {
const char* dataType = "image/png";
server.sendHeader(F("Content-Encoding"), F("gzip"));
server.send(200, dataType, (const char*)favicon_png_gz, favicon_png_gz_len);
}
void handleNotFound() {
digitalWrite(led, 1);
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
@@ -77,27 +56,23 @@ void handleNotFound() {
for (uint8_t i = 0; i < server.args(); i++) {
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
digitalWrite(led, 0);
}
void setup_webserver() {
// server.on("/", handleRootGz);
// server.on("/style.css", handleCssGz);
// server.on("/favicon.png", handleFaviconGz);
// void serveStatic(const char* uri, fs::FS& fs, const char* path, const char* cache_header = NULL );
server.serveStatic("/static", LittleFS, "/tt.html.gzip");
server.serveStatic("/http", LittleFS, "/http/");
server.serveStatic("/http", LittleFS, "/http/");
server.serveStatic("/http", LittleFS, "/http/");
// //experimental, see doku.md
// server.serveStatic("/compressed", LittleFS, "/compressed.html.gzip");
server.serveStatic("", LittleFS, "/index.html");
server.serveStatic("/", LittleFS, "/index.html");
server.serveStatic("/#", LittleFS, "/index.html");
server.serveStatic("/style.css", LittleFS, "/style.css");
server.serveStatic("/index.js", LittleFS, "/index.js");
server.serveStatic("/favicon.png", LittleFS, "/favicon.png");
server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server started");
}
void setup_ota() {
@@ -199,8 +174,8 @@ void setup() {
ESP.restart();
}
pinMode(led, OUTPUT);
digitalWrite(led, 0);
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
@@ -216,17 +191,11 @@ void setup() {
setup_ota();
pinMode(led, OUTPUT);
digitalWrite(led, 0);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
setup_webserver();
Serial.println("HTTP server started !");
setup_pwm_pca9685();
Serial.println("PCA9685 connected !");
}
uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval, uint8_t factor){