|
|
@@ -1,17 +1,17 @@ |
|
|
|
#include <Arduino.h> |
|
|
|
#include <Wire.h> |
|
|
|
|
|
|
|
#include "wifi_credentials.h" |
|
|
|
#include "PCA9685.h" |
|
|
|
|
|
|
|
// Änderung |
|
|
|
// OTA & WEB |
|
|
|
#include "wifi_credentials.h" |
|
|
|
#include <ESP8266WiFi.h> |
|
|
|
#include <WiFiUdp.h> |
|
|
|
#include <ArduinoOTA.h> |
|
|
|
|
|
|
|
#include <ESP8266WebServer.h> |
|
|
|
#include <WiFiClient.h> // evtl weghauen ? |
|
|
|
#include <WiFiClient.h> |
|
|
|
|
|
|
|
#include "index.html.gz.h" |
|
|
|
#include "style.css.gz.h" |
|
|
@@ -21,8 +21,16 @@ |
|
|
|
const char* ssid = STASSID; |
|
|
|
const char* password = STAPSK; |
|
|
|
|
|
|
|
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"; |
|
|
@@ -36,7 +44,6 @@ void handleCssGz() { |
|
|
|
server.send(200, dataType, (const char*)style_css_gz, style_css_gz_len); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleNotFound() { |
|
|
|
digitalWrite(led, 1); |
|
|
|
String message = "File Not Found\n\n"; |
|
|
@@ -74,35 +81,15 @@ void setup_webserver() { |
|
|
|
Serial.print("IP address: "); |
|
|
|
Serial.println(WiFi.localIP()); |
|
|
|
|
|
|
|
//server.on("/", handleRoot); |
|
|
|
server.on("/", handleRootGz); |
|
|
|
server.on("/styles/style.css", handleCssGz); |
|
|
|
server.on("/style.css", handleCssGz); |
|
|
|
server.onNotFound(handleNotFound); |
|
|
|
|
|
|
|
server.begin(); |
|
|
|
Serial.println("HTTP server started"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PCA9685 pwmController; |
|
|
|
|
|
|
|
void setup() { |
|
|
|
Serial.begin(115200); |
|
|
|
Serial.println("Booting"); |
|
|
|
WiFi.mode(WIFI_STA); |
|
|
|
WiFi.begin(ssid, password); |
|
|
|
|
|
|
|
Wire.begin(); // Wire must be started first |
|
|
|
Wire.setClock(400000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz |
|
|
|
|
|
|
|
while (WiFi.waitForConnectResult() != WL_CONNECTED) { |
|
|
|
Serial.println("Connection Failed! Rebooting..."); |
|
|
|
delay(5000); |
|
|
|
ESP.restart(); |
|
|
|
} |
|
|
|
|
|
|
|
// setup OTA |
|
|
|
void setup_ota() { |
|
|
|
ArduinoOTA.setPort(8266); |
|
|
|
ArduinoOTA.setHostname("ESP_Treppenlicht"); |
|
|
|
ArduinoOTA.setPassword("admin"); |
|
|
@@ -142,21 +129,44 @@ void setup() { |
|
|
|
} |
|
|
|
}); |
|
|
|
ArduinoOTA.begin(); |
|
|
|
Serial.println("Ready"); |
|
|
|
Serial.print("IP address: "); |
|
|
|
Serial.println(WiFi.localIP()); |
|
|
|
|
|
|
|
setup_webserver(); |
|
|
|
} |
|
|
|
|
|
|
|
void setup_pwm_pca9685() { |
|
|
|
pwmController.resetDevices(); // Software resets all PCA9685 devices on Wire line |
|
|
|
|
|
|
|
pwmController.init(B000000); // Address pins A5-A0 set to B000000 |
|
|
|
pwmController.setPWMFrequency(200); // Default is 200Hz, supports 24Hz to 1526Hz |
|
|
|
|
|
|
|
pwmController.setChannelPWM(0, 128 << 4); // Set PWM to 128/255, but in 4096 land |
|
|
|
|
|
|
|
Serial.println(pwmController.getChannelPWM(0)); // Should output 2048, which is 128 << 4 |
|
|
|
pwmController.setChannelPWM(0, 128 << 4); // Set PWM to 128/255, but in 4096 land |
|
|
|
|
|
|
|
Serial.println(pwmController.getChannelPWM(0)); // Should output 2048, which is 128 << 4 |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setup() { |
|
|
|
Serial.begin(115200); |
|
|
|
Serial.println(F("Booting ....")); |
|
|
|
|
|
|
|
Wire.begin(); // Wire must be started first |
|
|
|
Wire.setClock(400000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz |
|
|
|
|
|
|
|
WiFi.mode(WIFI_STA); |
|
|
|
WiFi.begin(ssid, password); |
|
|
|
|
|
|
|
while (WiFi.waitForConnectResult() != WL_CONNECTED) { |
|
|
|
Serial.println("Connection Failed! Rebooting..."); |
|
|
|
delay(5000); |
|
|
|
ESP.restart(); |
|
|
|
} |
|
|
|
|
|
|
|
Serial.println("Ready"); |
|
|
|
Serial.print("IP address: "); |
|
|
|
Serial.println(WiFi.localIP()); |
|
|
|
|
|
|
|
setup_ota(); |
|
|
|
setup_webserver(); |
|
|
|
setup_pwm_pca9685(); |
|
|
|
} |
|
|
|
|
|
|
|
uint32_t t; |
|
|
@@ -237,6 +247,7 @@ void ledsequence(uint8_t direction, uint8_t onoff, uint8_t factor){ |
|
|
|
|
|
|
|
|
|
|
|
void loop() { |
|
|
|
<<<<<<< HEAD |
|
|
|
static uint32_t dimmtimer = 0; |
|
|
|
/* static uint8_t led = 0; |
|
|
|
static uint16_t brightness = 127; |
|
|
@@ -273,4 +284,9 @@ void loop() { |
|
|
|
if(millis() > 25000) onoff = 0; |
|
|
|
TIMEIF_US("OTA", ArduinoOTA.handle(), 20000); |
|
|
|
TIMEIF_US("HTTP", server.handleClient(), 20000); |
|
|
|
======= |
|
|
|
TIMEIF_US("OTA", ArduinoOTA.handle(), 1000); |
|
|
|
|
|
|
|
TIMEIF_US("HTTP", server.handleClient(), 1000); |
|
|
|
>>>>>>> d0b824963bd79fc436b4b312e49b48081860d8d4 |
|
|
|
} |