This commit is contained in:
Simon Schmidt 2021-06-22 20:36:53 +02:00
parent 1d7f2f368b
commit baecaf02da

View File

@ -13,32 +13,6 @@ extern "C" {
#define ESP12_LED 2
#define NODEMCU_LED 16
os_timer_t Timer1; // Verwaltungsstruktur des Timers
int c;
bool toggle = false;
uint32_t m=0;
uint32_t dimmtimer = 0;
uint8_t direction = 1;
uint8_t onoff = 1;
void ledsequence(uint8_t direction, uint8_t onoff, uint8_t factor);
uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval, uint8_t factor);
void timerCallback(void *pArg)
{
*((int *) pArg) += 1;
ledsequence(direction, onoff, 4);
// Serial.print("[");
// Serial.print(micros()-m);
// Serial.print("] timerCallback\n");
// m = micros();
}
// OTA & WEB
#include "wifi_credentials.h"
#include <ESP8266WiFi.h>
@ -57,6 +31,9 @@ void timerCallback(void *pArg)
const char* ssid = STASSID;
const char* password = STAPSK;
os_timer_t timer1;
int timer_arg;
void setup_webserver();
void setup_ota();
void setup_pwm_pca9685();
@ -106,21 +83,6 @@ void handleNotFound() {
void setup_webserver() {
pinMode(led, OUTPUT);
digitalWrite(led, 0);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
server.on("/", handleRootGz);
server.on("/style.css", handleCssGz);
@ -182,6 +144,23 @@ void setup_pwm_pca9685() {
Serial.println(pwmController.getChannelPWM(0)); // Should output 2048, which is 128 << 4
}
uint32_t dimmtimer = 0;
uint8_t direction = 1;
uint8_t onoff = 1;
void ledsequence(uint8_t direction, uint8_t onoff, uint8_t factor);
uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval, uint8_t factor);
void timer_callback(void *pArg)
{
*((int *) pArg) += 1;
ledsequence(direction, onoff, 4);
}
void setup() {
#ifdef WITH_DEBUGGING_ON
Serial.begin(460800);
@ -207,9 +186,24 @@ void setup() {
ESP.restart();
}
os_timer_setfn(&Timer1, timerCallback, &c);
os_timer_arm(&Timer1, 1, true);
pinMode(led, OUTPUT);
digitalWrite(led, 0);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
os_timer_setfn(&timer1, timer_callback, &timer_arg);
os_timer_arm(&timer1, 1, true);
Serial.println("Ready");
Serial.print("IP address: ");