V2.22 250702 KalenderWochen Fehler -> neue Funktion
V2.23 251209 NTP überarbeitet; send_P umgebaut
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#define VERSION (char *) "V2.21"
|
#define VERSION (char *) "V2.23"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
"NodeMCU 1.0 (ESP-12e)"
|
||||||
V2.12 230205 neues SDK 8266; AP+Wifi Client; lokaleip eingebaut
|
V2.12 230205 neues SDK 8266; AP+Wifi Client; lokaleip eingebaut
|
||||||
V2.13 230206 Datum/Uhrzeit zeit auch KW an
|
V2.13 230206 Datum/Uhrzeit zeit auch KW an
|
||||||
V2.14 230208 AP+STA nur wenn Wifi verbunden ist sonst geht der AP nicht
|
V2.14 230208 AP+STA nur wenn Wifi verbunden ist sonst geht der AP nicht
|
||||||
@@ -11,6 +12,8 @@
|
|||||||
V2.19 230327 Sommerzeit stellt die Uhr jetzt auch vor (nicht zurück); neues SDK
|
V2.19 230327 Sommerzeit stellt die Uhr jetzt auch vor (nicht zurück); neues SDK
|
||||||
V2.20 230331 OV-Alzenau in RST Karlstadt geändert (Name beim Booten)
|
V2.20 230331 OV-Alzenau in RST Karlstadt geändert (Name beim Booten)
|
||||||
V2.21 231111 Begrüßungs OV kann jetzt mit "/do?set=owner&to=" gewählt werden (0=OALZ,1=ODES,default=RKST); Debug Zeile ausgeblendet;
|
V2.21 231111 Begrüßungs OV kann jetzt mit "/do?set=owner&to=" gewählt werden (0=OALZ,1=ODES,default=RKST); Debug Zeile ausgeblendet;
|
||||||
|
V2.22 250702 KalenderWochen Fehler -> neue Funktion
|
||||||
|
V2.23 251209 NTP überarbeitet; send_P umgebaut
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Pins for LED MATRIX
|
// Pins for LED MATRIX
|
||||||
@@ -34,11 +37,12 @@
|
|||||||
uint8_t display_draw_time=30; //30-60 is usually fine // This defines the 'on' time of the display is us. The larger this number,// the brighter the display. If too large the ESP will crash
|
uint8_t display_draw_time=30; //30-60 is usually fine // This defines the 'on' time of the display is us. The larger this number,// the brighter the display. If too large the ESP will crash
|
||||||
|
|
||||||
//WebService
|
//WebService
|
||||||
#define TEMPLATE_PLACEHOLDER '`' //-> Damit % in CSS funktioniert muss in der .h geändert werden!!! ...
|
#define TEMPLATE_PLACEHOLDER '`' //-> Damit % in CSS funktioniert muss in der WebResponseImpl.h geändert werden!!! ...
|
||||||
|
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <ESPAsyncTCP.h>
|
#include <ESPAsyncTCP.h>
|
||||||
#include <ESPAsyncWebServer.h>
|
#include <ESPAsyncWebServer.h>
|
||||||
|
#define ELEGANTOTA_USE_ASYNC_WEBSERVER 1
|
||||||
#include <ElegantOTA.h>
|
#include <ElegantOTA.h>
|
||||||
#include <DNSServer.h>
|
#include <DNSServer.h>
|
||||||
AsyncWebServer webServer(80);
|
AsyncWebServer webServer(80);
|
||||||
@@ -80,7 +84,8 @@ char ChipID[10] = "ERROR";
|
|||||||
uint8_t temperature=0;
|
uint8_t temperature=0;
|
||||||
|
|
||||||
#include <TimeLib.h>
|
#include <TimeLib.h>
|
||||||
#include <WeekNumber.h>
|
#include <WeekNumberEx.h>
|
||||||
|
#include <sntp.h>
|
||||||
|
|
||||||
long ti_second = 0;
|
long ti_second = 0;
|
||||||
|
|
||||||
@@ -107,6 +112,15 @@ char ChipID[10] = "ERROR";
|
|||||||
|
|
||||||
uint8_t owner = 0;
|
uint8_t owner = 0;
|
||||||
|
|
||||||
|
void delay_ex(uint16_t _ms){
|
||||||
|
for(uint16_t ms = 0;ms<_ms;ms++){
|
||||||
|
yield();
|
||||||
|
//esp_task_wdt_reset();
|
||||||
|
delay(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// ISR for display refresh
|
// ISR for display refresh
|
||||||
void display_updater(){
|
void display_updater(){
|
||||||
display.display(display_draw_time);
|
display.display(display_draw_time);
|
||||||
@@ -737,6 +751,7 @@ void setup() {
|
|||||||
display_update_enable(true);
|
display_update_enable(true);
|
||||||
|
|
||||||
Wire.begin(1,3);
|
Wire.begin(1,3);
|
||||||
|
//Serial.begin(115200);
|
||||||
//RTC
|
//RTC
|
||||||
if (rtc.begin() == false) {
|
if (rtc.begin() == false) {
|
||||||
display.drawPixelRGB888(0,0,255,0,0);
|
display.drawPixelRGB888(0,0,255,0,0);
|
||||||
@@ -749,6 +764,7 @@ void setup() {
|
|||||||
pinMode(PINRTC_CLOCK, INPUT_PULLUP);
|
pinMode(PINRTC_CLOCK, INPUT_PULLUP);
|
||||||
setTime(rtc.getUNIX());
|
setTime(rtc.getUNIX());
|
||||||
checkiDL();
|
checkiDL();
|
||||||
|
rtc.getTEMPERATURE(&temperature);
|
||||||
}
|
}
|
||||||
|
|
||||||
char NetName[30];
|
char NetName[30];
|
||||||
@@ -763,11 +779,12 @@ void setup() {
|
|||||||
WiFi.hostname(NetName);
|
WiFi.hostname(NetName);
|
||||||
int xc = 0;
|
int xc = 0;
|
||||||
while ((WiFi.status() != WL_CONNECTED) && (xc < 10)) {
|
while ((WiFi.status() != WL_CONNECTED) && (xc < 10)) {
|
||||||
delay(1500);
|
delay_ex(1500);
|
||||||
xc++;
|
xc++;
|
||||||
display.drawPixelRGB888(xc+5,0,255,255,0);
|
display.drawPixelRGB888(xc+5,0,255,255,0);
|
||||||
display_doupdate();
|
display_doupdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WiFi.status() == WL_CONNECTED) {
|
if (WiFi.status() == WL_CONNECTED) {
|
||||||
char str[5];
|
char str[5];
|
||||||
IPAddress lip;
|
IPAddress lip;
|
||||||
@@ -787,16 +804,20 @@ void setup() {
|
|||||||
display.drawPixelRGB888(1, 0, 0, 255, 0);
|
display.drawPixelRGB888(1, 0, 0, 255, 0);
|
||||||
display_doupdate();
|
display_doupdate();
|
||||||
configTime("CET-1CEST,M3.5.0,M10.5.0/3", "ptbtime1.ptb.de", "ptbtime2.ptb.de", "ptbtime3.ptb.de");
|
configTime("CET-1CEST,M3.5.0,M10.5.0/3", "ptbtime1.ptb.de", "ptbtime2.ptb.de", "ptbtime3.ptb.de");
|
||||||
time_t timenow = time(nullptr);
|
|
||||||
xc = 0;
|
xc = 0;
|
||||||
while((timenow < SECS_YR_2000) && (xc < 10)) {
|
while((sntp_get_current_timestamp() < 1735686000) && (xc < 10)) {
|
||||||
delay(1000);
|
//while((xc < 40)) {
|
||||||
timenow = time(nullptr);
|
//Serial.println(sntp_get_current_timestamp());
|
||||||
|
delay_ex(1000);
|
||||||
xc++;
|
xc++;
|
||||||
display.drawPixelRGB888(xc+16,0,255,255,0);
|
display.drawPixelRGB888(xc+16,0,255,255,0);
|
||||||
display_doupdate();
|
display_doupdate();
|
||||||
}
|
}
|
||||||
if(timenow > SECS_YR_2000){
|
sntp_stop();
|
||||||
|
//Serial.println("stop");
|
||||||
|
//Serial.println(sntp_get_current_timestamp());
|
||||||
|
if(sntp_get_current_timestamp() > 1735686000){
|
||||||
|
time_t timenow = sntp_get_current_timestamp();
|
||||||
timenow += 1;
|
timenow += 1;
|
||||||
uint8_t Month, Day, Hour;
|
uint8_t Month, Day, Hour;
|
||||||
setTime(timenow);
|
setTime(timenow);
|
||||||
@@ -823,7 +844,7 @@ void setup() {
|
|||||||
display.drawPixelRGB888(2,0,255,0,255);
|
display.drawPixelRGB888(2,0,255,0,255);
|
||||||
display_doupdate();
|
display_doupdate();
|
||||||
}
|
}
|
||||||
delay(5000);
|
delay_ex(3000);
|
||||||
}else{
|
}else{
|
||||||
display.drawPixelRGB888(1,0,255,0,0);
|
display.drawPixelRGB888(1,0,255,0,0);
|
||||||
display_doupdate();
|
display_doupdate();
|
||||||
@@ -832,15 +853,16 @@ void setup() {
|
|||||||
if(alwaysAccessPoint){
|
if(alwaysAccessPoint){
|
||||||
if (WiFi.status() != WL_CONNECTED) {
|
if (WiFi.status() != WL_CONNECTED) {
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
delay(100);
|
delay_ex(100);
|
||||||
WiFi.mode(WIFI_OFF);
|
WiFi.mode(WIFI_OFF);
|
||||||
delay(100);
|
delay_ex(100);
|
||||||
WiFi.mode(WIFI_AP);
|
WiFi.mode(WIFI_AP);
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(100);
|
delay_ex(100);
|
||||||
WiFi.softAPConfig(ip_local, ip_gateway, ip_subnet);
|
WiFi.softAPConfig(ip_local, ip_gateway, ip_subnet);
|
||||||
APEnabled = WiFi.softAP(APName, appass,2,0,2,250);
|
APEnabled = WiFi.softAP(APName, appass,2,0,2,250);
|
||||||
|
//APEnabled = WiFi.softAP(APName, "nix",2,0,2,250);
|
||||||
if(!APEnabled)
|
if(!APEnabled)
|
||||||
display.drawPixelRGB888(3,0,255,0,0);
|
display.drawPixelRGB888(3,0,255,0,0);
|
||||||
else
|
else
|
||||||
@@ -867,7 +889,7 @@ void setup() {
|
|||||||
if(rtcEnabled)
|
if(rtcEnabled)
|
||||||
attachInterrupt(digitalPinToInterrupt(PINRTC_CLOCK), rtc_clock, CHANGE);
|
attachInterrupt(digitalPinToInterrupt(PINRTC_CLOCK), rtc_clock, CHANGE);
|
||||||
|
|
||||||
delay(3000);
|
delay_ex(3000);
|
||||||
doClearLEDsStatus();
|
doClearLEDsStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -881,6 +903,7 @@ void loop(){
|
|||||||
time_t currentUNIXTime = now();
|
time_t currentUNIXTime = now();
|
||||||
if(rtcEnabled){
|
if(rtcEnabled){
|
||||||
currentUNIXTime = rtc.getUNIX();
|
currentUNIXTime = rtc.getUNIX();
|
||||||
|
//Serial.println(currentUNIXTime);
|
||||||
setTime(currentUNIXTime);
|
setTime(currentUNIXTime);
|
||||||
}
|
}
|
||||||
uint8_t Hour, Minute, Second, WDay;
|
uint8_t Hour, Minute, Second, WDay;
|
||||||
@@ -938,7 +961,7 @@ const char* PARAM_PWD = "pwd";
|
|||||||
const char* PARAM_RESET = "reset";
|
const char* PARAM_RESET = "reset";
|
||||||
|
|
||||||
void html_root(AsyncWebServerRequest *request) {
|
void html_root(AsyncWebServerRequest *request) {
|
||||||
request->send_P(200, "text/html", html_page_index, html_processor);
|
request->send(200, "text/html", html_page_index, html_processor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void html_poll(AsyncWebServerRequest *request) {
|
void html_poll(AsyncWebServerRequest *request) {
|
||||||
@@ -969,10 +992,10 @@ void html_poll(AsyncWebServerRequest *request) {
|
|||||||
itoa(timeIndex,tempBuff,DEC);
|
itoa(timeIndex,tempBuff,DEC);
|
||||||
strcat(ret,(char *)",");
|
strcat(ret,(char *)",");
|
||||||
strcat(ret,tempBuff);
|
strcat(ret,tempBuff);
|
||||||
itoa(lastTimeSyncTyp,tempBuff,DEC);
|
itoa(lastTimeSyncTime,tempBuff,DEC);
|
||||||
strcat(ret,(char *)",");
|
strcat(ret,(char *)",");
|
||||||
strcat(ret,tempBuff);
|
strcat(ret,tempBuff);
|
||||||
itoa(lastTimeSyncTime,tempBuff,DEC);
|
itoa(lastTimeSyncTyp,tempBuff,DEC);
|
||||||
strcat(ret,(char *)",");
|
strcat(ret,(char *)",");
|
||||||
strcat(ret,tempBuff);
|
strcat(ret,tempBuff);
|
||||||
dtostrf(brightness, 10, 2, tempBuff);
|
dtostrf(brightness, 10, 2, tempBuff);
|
||||||
@@ -1131,7 +1154,7 @@ void html_do(AsyncWebServerRequest *request) {
|
|||||||
request->send(200, "text/plain", "OK");
|
request->send(200, "text/plain", "OK");
|
||||||
}else if (request->hasParam(PARAM_RESET)){
|
}else if (request->hasParam(PARAM_RESET)){
|
||||||
request->send(200, "text/plain", "OK");
|
request->send(200, "text/plain", "OK");
|
||||||
delay(1000);
|
delay_ex(1000);
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}else{
|
}else{
|
||||||
request->send(200, "text/plain", "NOK");
|
request->send(200, "text/plain", "NOK");
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const char html_page_index[] PROGMEM = R"rawliteral(
|
static const char *html_page_index PROGMEM = R"rawliteral(
|
||||||
<!DOCTYPE HTML><html>
|
<!DOCTYPE HTML><html>
|
||||||
<head>
|
<head>
|
||||||
<title>N-Tools.de Uhr</title>
|
<title>N-Tools.de Uhr</title>
|
||||||
@@ -140,9 +140,6 @@ const char html_page_index[] PROGMEM = R"rawliteral(
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
padding: 0.25rem 0.5rem;
|
padding: 0.25rem 0.5rem;
|
||||||
@media(min-width: 600px) {
|
|
||||||
margin: 0 1em 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:hover { text-decoration: none; }
|
&:hover { text-decoration: none; }
|
||||||
|
|
||||||
@@ -394,7 +391,8 @@ const char html_page_index[] PROGMEM = R"rawliteral(
|
|||||||
document.getElementById('actDate').style.color = colorString;
|
document.getElementById('actDate').style.color = colorString;
|
||||||
|
|
||||||
document.getElementById('showWhat').value = parseInt(data[4]);
|
document.getElementById('showWhat').value = parseInt(data[4]);
|
||||||
switch(data[5]){
|
showTimeFromUnix(data[5],'sync');
|
||||||
|
switch(data[6]){
|
||||||
case 0:
|
case 0:
|
||||||
document.getElementById('sync').innerHTML = " keiner";
|
document.getElementById('sync').innerHTML = " keiner";
|
||||||
break;
|
break;
|
||||||
@@ -408,7 +406,6 @@ const char html_page_index[] PROGMEM = R"rawliteral(
|
|||||||
document.getElementById('sync').innerHTML += " (manuel)";
|
document.getElementById('sync').innerHTML += " (manuel)";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
showTimeFromUnix(data[6],'sync');
|
|
||||||
document.getElementById('brigtness').innerHTML = (data[7]*100);
|
document.getElementById('brigtness').innerHTML = (data[7]*100);
|
||||||
document.getElementById("rtcactive").checked = (data[8] == 1);
|
document.getElementById("rtcactive").checked = (data[8] == 1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user