apply formatting guidelines to existing files
This commit is contained in:
parent
e47bc6c4ab
commit
8c9de56fab
|
@ -14,7 +14,7 @@ board = esp12e
|
||||||
framework = arduino
|
framework = arduino
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
monitor_speed = 74880
|
monitor_speed = 74880
|
||||||
lib_deps =
|
lib_deps =
|
||||||
ropg/ezTime@^0.8.3
|
ropg/ezTime@^0.8.3
|
||||||
paulstoffregen/OneWire@^2.3.7
|
paulstoffregen/OneWire@^2.3.7
|
||||||
milesburton/DallasTemperature@^3.11.0
|
milesburton/DallasTemperature@^3.11.0
|
||||||
|
|
118
src/html.cpp
118
src/html.cpp
|
@ -3,24 +3,24 @@
|
||||||
|
|
||||||
void reload_home() // generates current time and changes variables in home_html
|
void reload_home() // generates current time and changes variables in home_html
|
||||||
{
|
{
|
||||||
char time_current[3][3] = {"", "", ""};
|
char time_current[3][3] = {"", "", ""};
|
||||||
if (myTime.hour() < 10) {
|
if (myTime.hour() < 10) {
|
||||||
sprintf(time_current[0], "0%d", myTime.hour());
|
sprintf(time_current[0], "0%d", myTime.hour());
|
||||||
} else {
|
} else {
|
||||||
sprintf(time_current[0], "%d", myTime.hour());
|
sprintf(time_current[0], "%d", myTime.hour());
|
||||||
}
|
}
|
||||||
if (myTime.minute() < 10) {
|
if (myTime.minute() < 10) {
|
||||||
sprintf(time_current[1], "0%d", myTime.minute());
|
sprintf(time_current[1], "0%d", myTime.minute());
|
||||||
} else {
|
} else {
|
||||||
sprintf(time_current[1], "%d", myTime.minute());
|
sprintf(time_current[1], "%d", myTime.minute());
|
||||||
}
|
}
|
||||||
if (myTime.second() < 10) {
|
if (myTime.second() < 10) {
|
||||||
sprintf(time_current[2], "0%d", myTime.second());
|
sprintf(time_current[2], "0%d", myTime.second());
|
||||||
} else {
|
} else {
|
||||||
sprintf(time_current[2], "%d", myTime.second());
|
sprintf(time_current[2], "%d", myTime.second());
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(home_html, "<!DOCTYPE html>\
|
sprintf(home_html, "<!DOCTYPE html>\
|
||||||
<html lang='de'>\
|
<html lang='de'>\
|
||||||
<head>\
|
<head>\
|
||||||
<meta charset='UTF-8'>\
|
<meta charset='UTF-8'>\
|
||||||
|
@ -93,13 +93,13 @@ top: 2px;\
|
||||||
</div>\
|
</div>\
|
||||||
</body>\
|
</body>\
|
||||||
</html>",
|
</html>",
|
||||||
time_current[0], time_current[1], time_current[2], stat[0]);
|
time_current[0], time_current[1], time_current[2], stat[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reload_settings() {
|
void reload_settings() {
|
||||||
sprintf(
|
sprintf(
|
||||||
settings_html,
|
settings_html,
|
||||||
"<span> Ziel: </span><input type='number' min=0 max=50 name='temperature' value='%d' class='temperature'>°C <span>\
|
"<span> Ziel: </span><input type='number' min=0 max=50 name='temperature' value='%d' class='temperature'>°C <span>\
|
||||||
<br>Aktuell: %d°C</span>\
|
<br>Aktuell: %d°C</span>\
|
||||||
<br>\
|
<br>\
|
||||||
<input type='submit'>\
|
<input type='submit'>\
|
||||||
|
@ -175,45 +175,45 @@ void reload_settings() {
|
||||||
</div>\
|
</div>\
|
||||||
</body>\
|
</body>\
|
||||||
</html>",
|
</html>",
|
||||||
temperatureSet, temperature, time_all[0][0], time_all[1][0],
|
temperatureSet, temperature, time_all[0][0], time_all[1][0],
|
||||||
time_all[2][0], time_all[3][0], time_all[4][0], time_all[5][0],
|
time_all[2][0], time_all[3][0], time_all[4][0], time_all[5][0],
|
||||||
time_all[6][0], time_all[7][0], time_all[0][1], time_all[1][1],
|
time_all[6][0], time_all[7][0], time_all[0][1], time_all[1][1],
|
||||||
time_all[2][1], time_all[3][1], time_all[4][1], time_all[5][1],
|
time_all[2][1], time_all[3][1], time_all[4][1], time_all[5][1],
|
||||||
time_all[6][1], time_all[7][1], time_all[0][2], time_all[1][2],
|
time_all[6][1], time_all[7][1], time_all[0][2], time_all[1][2],
|
||||||
time_all[2][2], time_all[3][2], time_all[4][2], time_all[5][2],
|
time_all[2][2], time_all[3][2], time_all[4][2], time_all[5][2],
|
||||||
time_all[6][2], time_all[7][2], time_all[0][3], time_all[1][3],
|
time_all[6][2], time_all[7][2], time_all[0][3], time_all[1][3],
|
||||||
time_all[2][3], time_all[3][3], time_all[4][3], time_all[5][3],
|
time_all[2][3], time_all[3][3], time_all[4][3], time_all[5][3],
|
||||||
time_all[6][3], time_all[7][3], time_all[0][4], time_all[1][4],
|
time_all[6][3], time_all[7][3], time_all[0][4], time_all[1][4],
|
||||||
time_all[2][4], time_all[3][4], time_all[4][4], time_all[5][4],
|
time_all[2][4], time_all[3][4], time_all[4][4], time_all[5][4],
|
||||||
time_all[6][4], time_all[7][4], time_all[0][5], time_all[1][5],
|
time_all[6][4], time_all[7][4], time_all[0][5], time_all[1][5],
|
||||||
time_all[2][5], time_all[3][5], time_all[4][5], time_all[5][5],
|
time_all[2][5], time_all[3][5], time_all[4][5], time_all[5][5],
|
||||||
time_all[6][5], time_all[7][5], time_all[0][6], time_all[1][6],
|
time_all[6][5], time_all[7][5], time_all[0][6], time_all[1][6],
|
||||||
time_all[2][6], time_all[3][6], time_all[4][6], time_all[5][6],
|
time_all[2][6], time_all[3][6], time_all[4][6], time_all[5][6],
|
||||||
time_all[6][6], time_all[7][6], time_all[0][7], time_all[1][7],
|
time_all[6][6], time_all[7][6], time_all[0][7], time_all[1][7],
|
||||||
time_all[2][7], time_all[3][7], time_all[4][7], time_all[5][7],
|
time_all[2][7], time_all[3][7], time_all[4][7], time_all[5][7],
|
||||||
time_all[6][7], time_all[7][7]);
|
time_all[6][7], time_all[7][7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleToggle() {
|
void handleToggle() {
|
||||||
int i =
|
int i =
|
||||||
server.arg("number")
|
server.arg("number")
|
||||||
.toInt(); // handles manual toggle and converts GET argument to int
|
.toInt(); // handles manual toggle and converts GET argument to int
|
||||||
override[i] = !override[i];
|
override[i] = !override[i];
|
||||||
debugln(F("---------------------------"));
|
debugln(F("---------------------------"));
|
||||||
debug(F("[RECIVED] for: "));
|
debug(F("[RECIVED] for: "));
|
||||||
debugln(i);
|
debugln(i);
|
||||||
digitalWrite(pins[i], !digitalRead(pins[i]));
|
digitalWrite(pins[i], !digitalRead(pins[i]));
|
||||||
digitalWrite(2, !digitalRead(2));
|
digitalWrite(2, !digitalRead(2));
|
||||||
if (digitalRead(pins[i]) == HIGH) {
|
if (digitalRead(pins[i]) == HIGH) {
|
||||||
sprintf(stat[i], "AN");
|
sprintf(stat[i], "AN");
|
||||||
} else {
|
} else {
|
||||||
sprintf(stat[i], "AUS");
|
sprintf(stat[i], "AUS");
|
||||||
}
|
}
|
||||||
debug(F("Status: "));
|
debug(F("Status: "));
|
||||||
debugln(stat[i]);
|
debugln(stat[i]);
|
||||||
reload_home();
|
reload_home();
|
||||||
server.sendHeader(F("Location"), F("/"), true);
|
server.sendHeader(F("Location"), F("/"), true);
|
||||||
server.send(302, F("text/html"), home_html);
|
server.send(302, F("text/html"), home_html);
|
||||||
debugln(override[i]);
|
debugln(override[i]);
|
||||||
debugln(F("---------------------------"));
|
debugln(F("---------------------------"));
|
||||||
}
|
}
|
||||||
|
|
685
src/main.cpp
685
src/main.cpp
|
@ -1,341 +1,344 @@
|
||||||
const char SSID[] = "";
|
const char SSID[] = "";
|
||||||
const char PASSWORD[] = "";
|
const char PASSWORD[] = "";
|
||||||
|
|
||||||
const char version[] = " 0.8.1";
|
const char version[] = " 0.8.1";
|
||||||
#include "globalvars.h"
|
#include "globalvars.h"
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <DallasTemperature.h>
|
#include <DallasTemperature.h>
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#include <ESP8266WebServer.h>
|
#include <ESP8266WebServer.h>
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <OneWire.h>
|
#include <OneWire.h>
|
||||||
#include <ezTime.h>
|
#include <ezTime.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
ESP8266WebServer server;
|
ESP8266WebServer server;
|
||||||
IPAddress staticIP(192, 168, 2, 4); // static IP address
|
IPAddress staticIP(192, 168, 2, 4); // static IP address
|
||||||
IPAddress gateway(192, 168, 2, 1); // Router's IP address
|
IPAddress gateway(192, 168, 2, 1); // Router's IP address
|
||||||
IPAddress subnet(255, 255, 255, 0);
|
IPAddress subnet(255, 255, 255, 0);
|
||||||
IPAddress dns(192, 168, 2, 1);
|
IPAddress dns(192, 168, 2, 1);
|
||||||
Timezone myTime;
|
Timezone myTime;
|
||||||
|
|
||||||
const u_int r = 0;
|
const u_int r = 0;
|
||||||
|
|
||||||
const u_int oneWireBus = 0;
|
const u_int oneWireBus = 0;
|
||||||
OneWire oneWire(oneWireBus);
|
OneWire oneWire(oneWireBus);
|
||||||
DallasTemperature sensors(&oneWire);
|
DallasTemperature sensors(&oneWire);
|
||||||
|
|
||||||
int temperature;
|
int temperature;
|
||||||
int temperatureSet;
|
int temperatureSet;
|
||||||
static unsigned long lastTempCycle = -5000;
|
static unsigned long lastTempCycle = -5000;
|
||||||
|
|
||||||
char time_all[8][8][3] = {
|
char time_all[8][8][3] = {
|
||||||
{}, {}, {}, {},
|
{}, {}, {}, {},
|
||||||
{}, {}, {}, {}}; // 3D array for load_EEPROM() and handleTime()
|
{}, {}, {}, {}}; // 3D array for load_EEPROM() and handleTime()
|
||||||
const unsigned int pins[1] = {4};
|
const unsigned int pins[1] = {4};
|
||||||
|
|
||||||
char stat[1][4] = {"AUS"}; // text on button
|
char stat[1][4] = {"AUS"}; // text on button
|
||||||
char t_stat[1][4] = {""}; // for "status of timer changed"
|
char t_stat[1][4] = {""}; // for "status of timer changed"
|
||||||
bool override[1] = {false}; // for manual override
|
bool override[1] = {false}; // for manual override
|
||||||
char home_html[1346];
|
char home_html[1346];
|
||||||
char settings_html[987];
|
char settings_html[987];
|
||||||
const char settings_html_pre[] PROGMEM = {"<!DOCTYPE html>\
|
const char settings_html_pre[] PROGMEM = {"<!DOCTYPE html>\
|
||||||
<html lang='de'>\
|
<html lang='de'>\
|
||||||
<head>\
|
<head>\
|
||||||
<meta charset='UTF-8'>\
|
<meta charset='UTF-8'>\
|
||||||
<meta http-equiv='X-UA-Compatible' content='IE=edge'>\
|
<meta http-equiv='X-UA-Compatible' content='IE=edge'>\
|
||||||
<meta name='viewport' content='width=device-width, initial-scale=1.0'>\
|
<meta name='viewport' content='width=device-width, initial-scale=1.0'>\
|
||||||
<title>Einstellungen</title>\
|
<title>Einstellungen</title>\
|
||||||
<style>\
|
<style>\
|
||||||
* {\
|
* {\
|
||||||
font-family: Arial, Helvetica, sans-serif;\
|
font-family: Arial, Helvetica, sans-serif;\
|
||||||
font-size: 26px;\
|
font-size: 26px;\
|
||||||
user-select: none;\
|
user-select: none;\
|
||||||
text-decoration: none;\
|
text-decoration: none;\
|
||||||
}\
|
}\
|
||||||
a {\
|
a {\
|
||||||
color: black;\
|
color: black;\
|
||||||
}\
|
}\
|
||||||
.wrapper_main {\
|
.wrapper_main {\
|
||||||
margin: 0 auto;\
|
margin: 0 auto;\
|
||||||
max-width: fit-content;\
|
max-width: fit-content;\
|
||||||
max-width: -moz-fit-content;\
|
max-width: -moz-fit-content;\
|
||||||
text-align: center;\
|
text-align: center;\
|
||||||
background-color: rgb(214, 214, 214);\
|
background-color: rgb(214, 214, 214);\
|
||||||
padding: 1px 8px 8px 8px;\
|
padding: 1px 8px 8px 8px;\
|
||||||
border-radius: 4px;\
|
border-radius: 4px;\
|
||||||
}\
|
}\
|
||||||
#rule, [type='time'], .temperature {\
|
#rule, [type='time'], .temperature {\
|
||||||
height: 36px;\
|
height: 36px;\
|
||||||
border: none;\
|
border: none;\
|
||||||
padding: 0 4px;\
|
padding: 0 4px;\
|
||||||
margin: 4px 0;\
|
margin: 4px 0;\
|
||||||
background-color: white;\
|
background-color: white;\
|
||||||
width: fit-content;\
|
width: fit-content;\
|
||||||
width: -moz-fit-content;\
|
width: -moz-fit-content;\
|
||||||
border-radius: 4px;\
|
border-radius: 4px;\
|
||||||
}\
|
}\
|
||||||
.temperature {\
|
.temperature {\
|
||||||
width: 2.5em;\
|
width: 2.5em;\
|
||||||
}\
|
}\
|
||||||
.animated_a, [type='submit']{\
|
.animated_a, [type='submit']{\
|
||||||
background-color: rgb(135, 252, 119);\
|
background-color: rgb(135, 252, 119);\
|
||||||
border: none;\
|
border: none;\
|
||||||
border-radius: 4px;\
|
border-radius: 4px;\
|
||||||
box-shadow: rgb(25, 167, 49) 0 4px;\
|
box-shadow: rgb(25, 167, 49) 0 4px;\
|
||||||
position: relative;\
|
position: relative;\
|
||||||
margin: 8px 0;\
|
margin: 8px 0;\
|
||||||
padding: 2px 8px;\
|
padding: 2px 8px;\
|
||||||
}\
|
}\
|
||||||
[type='submit'] {\
|
[type='submit'] {\
|
||||||
position: relative;\
|
position: relative;\
|
||||||
top: -2px;\
|
top: -2px;\
|
||||||
display: inline-block;\
|
display: inline-block;\
|
||||||
}\
|
}\
|
||||||
.animated_a {\
|
.animated_a {\
|
||||||
text-decoration: none;\
|
text-decoration: none;\
|
||||||
display: inline-block;\
|
display: inline-block;\
|
||||||
margin: 8px 0;\
|
margin: 8px 0;\
|
||||||
padding-top: 4px;\
|
padding-top: 4px;\
|
||||||
height: 28px;\
|
height: 28px;\
|
||||||
}\
|
}\
|
||||||
.wrapper_table {\
|
.wrapper_table {\
|
||||||
overflow: auto;\
|
overflow: auto;\
|
||||||
}\
|
}\
|
||||||
table {\
|
table {\
|
||||||
margin: 8px auto;\
|
margin: 8px auto;\
|
||||||
}\
|
}\
|
||||||
table, th, td {\
|
table, th, td {\
|
||||||
border: 1px solid black;\
|
border: 1px solid black;\
|
||||||
border-collapse: collapse;\
|
border-collapse: collapse;\
|
||||||
user-select: text;\
|
user-select: text;\
|
||||||
padding: 0 8px;\
|
padding: 0 8px;\
|
||||||
}\
|
}\
|
||||||
.animated_a, [type='submit']{\
|
.animated_a, [type='submit']{\
|
||||||
cursor: pointer;\
|
cursor: pointer;\
|
||||||
}\
|
}\
|
||||||
.animated_a:active {\
|
.animated_a:active {\
|
||||||
box-shadow: rgb(25, 167, 49) 0 2px;\
|
box-shadow: rgb(25, 167, 49) 0 2px;\
|
||||||
top: 2px;\
|
top: 2px;\
|
||||||
}\
|
}\
|
||||||
[type='submit']:active {\
|
[type='submit']:active {\
|
||||||
box-shadow: rgb(25, 167, 49) 0 2px;\
|
box-shadow: rgb(25, 167, 49) 0 2px;\
|
||||||
top: 0px;\
|
top: 0px;\
|
||||||
}\
|
}\
|
||||||
*:focus {\
|
*:focus {\
|
||||||
outline: none;\
|
outline: none;\
|
||||||
}\
|
}\
|
||||||
span:empty {content: 'nicht verbunden';}\
|
span:empty {content: 'nicht verbunden';}\
|
||||||
</style>\
|
</style>\
|
||||||
</head>\
|
</head>\
|
||||||
<body>\
|
<body>\
|
||||||
<div class='wrapper_main'>\
|
<div class='wrapper_main'>\
|
||||||
<form action='settings' method='POST'>\
|
<form action='settings' method='POST'>\
|
||||||
<select name='rule' id='rule'>\
|
<select name='rule' id='rule'>\
|
||||||
<option value='' selected disabled>Spalte Nr.</option>\
|
<option value='' selected disabled>Spalte Nr.</option>\
|
||||||
<option value='0'>1</option>\
|
<option value='0'>1</option>\
|
||||||
<option value='1'>2</option>\
|
<option value='1'>2</option>\
|
||||||
<option value='2'>3</option>\
|
<option value='2'>3</option>\
|
||||||
<option value='3'>4</option>\
|
<option value='3'>4</option>\
|
||||||
<option value='4'>5</option>\
|
<option value='4'>5</option>\
|
||||||
<option value='5'>6</option>\
|
<option value='5'>6</option>\
|
||||||
<option value='6'>7</option>\
|
<option value='6'>7</option>\
|
||||||
<option value='7'>8</option>\
|
<option value='7'>8</option>\
|
||||||
</select>\
|
</select>\
|
||||||
<br>\
|
<br>\
|
||||||
<input type='time' name='time_o'>\
|
<input type='time' name='time_o'>\
|
||||||
- <input type='time' name='time_f'>\
|
- <input type='time' name='time_f'>\
|
||||||
<br>\
|
<br>\
|
||||||
<input type='time' name='time_o_1'>\
|
<input type='time' name='time_o_1'>\
|
||||||
- <input type='time' name='time_f_1'>\
|
- <input type='time' name='time_f_1'>\
|
||||||
<br>"};
|
<br>"};
|
||||||
void reload_home();
|
void reload_home();
|
||||||
void reload_settings();
|
void reload_settings();
|
||||||
void handleToggle();
|
void handleToggle();
|
||||||
|
|
||||||
void load_EEPROM() {
|
void load_EEPROM() {
|
||||||
unsigned int EEPROM_Addr = 0;
|
unsigned int EEPROM_Addr = 0;
|
||||||
for (unsigned int i0 = 0; i0 < 8; i0++) {
|
for (unsigned int i0 = 0; i0 < 8; i0++) {
|
||||||
for (unsigned int i = 0; i < 8; i++) {
|
for (unsigned int i = 0; i < 8; i++) {
|
||||||
if (EEPROM.read(EEPROM_Addr) < 10) {
|
if (EEPROM.read(EEPROM_Addr) < 10) {
|
||||||
sprintf(time_all[i0][i], "0%d", EEPROM.read(EEPROM_Addr));
|
sprintf(time_all[i0][i], "0%d", EEPROM.read(EEPROM_Addr));
|
||||||
} else {
|
} else {
|
||||||
sprintf(time_all[i0][i], "%d", EEPROM.read(EEPROM_Addr));
|
sprintf(time_all[i0][i], "%d", EEPROM.read(EEPROM_Addr));
|
||||||
}
|
}
|
||||||
EEPROM_Addr += 4;
|
EEPROM_Addr += 4;
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
temperatureSet = EEPROM.read(256);
|
temperatureSet = EEPROM.read(256);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleHome() {
|
void handleHome() {
|
||||||
reload_home();
|
reload_home();
|
||||||
server.send(200, "text/html", home_html);
|
server.send(200, "text/html", home_html);
|
||||||
debugln(ESP.getFreeHeap(), DEC);
|
debugln(ESP.getFreeHeap(), DEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleSettings() {
|
void handleSettings() {
|
||||||
reload_settings();
|
reload_settings();
|
||||||
server.setContentLength(strlen(settings_html_pre) + strlen(settings_html));
|
server.setContentLength(strlen(settings_html_pre) + strlen(settings_html));
|
||||||
server.send(200, "text/html", settings_html_pre);
|
server.send(200, "text/html", settings_html_pre);
|
||||||
server.sendContent(settings_html);
|
server.sendContent(settings_html);
|
||||||
debugln(ESP.getFreeHeap(), DEC);
|
debugln(ESP.getFreeHeap(), DEC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleTime() {
|
void handleTime() {
|
||||||
if (server.arg("rule") != "") {
|
if (server.arg("rule") != "") {
|
||||||
debugln("write main");
|
debugln("write main");
|
||||||
const char args[4][9] = {"time_o", "time_f", "time_o_1", "time_f_1"};
|
const char args[4][9] = {"time_o", "time_f", "time_o_1", "time_f_1"};
|
||||||
|
|
||||||
for (unsigned int arg = 0; arg < 4; arg++) {
|
for (unsigned int arg = 0; arg < 4; arg++) {
|
||||||
if (server.arg(args[arg]) != "") {
|
if (server.arg(args[arg]) != "") {
|
||||||
char buff_h[2][2] = {server.arg(args[arg])[0],
|
char buff_h[2][2] = {server.arg(args[arg])[0],
|
||||||
server.arg(args[arg])[1]};
|
server.arg(args[arg])[1]};
|
||||||
char buff_m[2][2] = {server.arg(args[arg])[3],
|
char buff_m[2][2] = {server.arg(args[arg])[3],
|
||||||
server.arg(args[arg])[4]};
|
server.arg(args[arg])[4]};
|
||||||
sprintf(time_all[arg * 2][server.arg("rule").toInt()], "%s", buff_h);
|
sprintf(time_all[arg * 2][server.arg("rule").toInt()], "%s",
|
||||||
sprintf(time_all[arg * 2 + 1][server.arg("rule").toInt()], "%s",
|
buff_h);
|
||||||
buff_m);
|
sprintf(time_all[arg * 2 + 1][server.arg("rule").toInt()], "%s",
|
||||||
|
buff_m);
|
||||||
EEPROM.put(server.arg("rule").toInt() * 4 + arg * 64,
|
|
||||||
atoi(time_all[arg * 2][server.arg("rule").toInt()]));
|
EEPROM.put(server.arg("rule").toInt() * 4 + arg * 64,
|
||||||
EEPROM.commit();
|
atoi(time_all[arg * 2][server.arg("rule").toInt()]));
|
||||||
EEPROM.put(server.arg("rule").toInt() * 4 + arg * 64 + 32,
|
EEPROM.commit();
|
||||||
atoi(time_all[arg * 2 + 1][server.arg("rule").toInt()]));
|
EEPROM.put(
|
||||||
EEPROM.commit();
|
server.arg("rule").toInt() * 4 + arg * 64 + 32,
|
||||||
}
|
atoi(time_all[arg * 2 + 1][server.arg("rule").toInt()]));
|
||||||
}
|
EEPROM.commit();
|
||||||
}
|
}
|
||||||
if (server.arg("temperature").toInt() != temperatureSet) {
|
}
|
||||||
debugln("write temperature");
|
}
|
||||||
temperatureSet = server.arg("temperature").toInt();
|
if (server.arg("temperature").toInt() != temperatureSet) {
|
||||||
EEPROM.put(256, temperatureSet);
|
debugln("write temperature");
|
||||||
EEPROM.commit();
|
temperatureSet = server.arg("temperature").toInt();
|
||||||
}
|
EEPROM.put(256, temperatureSet);
|
||||||
reload_settings();
|
EEPROM.commit();
|
||||||
server.setContentLength(strlen(settings_html_pre) + strlen(settings_html));
|
}
|
||||||
server.send(301, "text/html", settings_html_pre);
|
reload_settings();
|
||||||
server.sendContent(settings_html);
|
server.setContentLength(strlen(settings_html_pre) + strlen(settings_html));
|
||||||
}
|
server.send(301, "text/html", settings_html_pre);
|
||||||
|
server.sendContent(settings_html);
|
||||||
void timer() {
|
}
|
||||||
int ri = 0;
|
|
||||||
bool isOn = false;
|
void timer() {
|
||||||
while (ri <= 7) {
|
int ri = 0;
|
||||||
if ((((myTime.hour() * 60 + myTime.minute() >=
|
bool isOn = false;
|
||||||
atoi(time_all[0][ri]) * 60 + atoi(time_all[1][ri])) and
|
while (ri <= 7) {
|
||||||
(myTime.hour() * 60 + myTime.minute() <
|
if ((((myTime.hour() * 60 + myTime.minute() >=
|
||||||
atoi(time_all[2][ri]) * 60 + atoi(time_all[3][ri]))) // first range
|
atoi(time_all[0][ri]) * 60 + atoi(time_all[1][ri])) and
|
||||||
or ((myTime.hour() * 60 + myTime.minute() >=
|
(myTime.hour() * 60 + myTime.minute() <
|
||||||
atoi(time_all[4][ri]) * 60 + atoi(time_all[5][ri])) and
|
atoi(time_all[2][ri]) * 60 +
|
||||||
(myTime.hour() * 60 + myTime.minute() <
|
atoi(time_all[3][ri]))) // first range
|
||||||
atoi(time_all[6][ri]) * 60 + atoi(time_all[7][ri]))) or
|
or ((myTime.hour() * 60 + myTime.minute() >=
|
||||||
((atoi(time_all[0][ri]) == atoi(time_all[2][ri])) and
|
atoi(time_all[4][ri]) * 60 + atoi(time_all[5][ri])) and
|
||||||
((atoi(time_all[1][ri]) == atoi(time_all[3][ri])) and
|
(myTime.hour() * 60 + myTime.minute() <
|
||||||
(atoi(time_all[0][ri]) + atoi(time_all[1][ri]) !=
|
atoi(time_all[6][ri]) * 60 + atoi(time_all[7][ri]))) or
|
||||||
0)))) // second range
|
((atoi(time_all[0][ri]) == atoi(time_all[2][ri])) and
|
||||||
and temperature <= temperatureSet) {
|
((atoi(time_all[1][ri]) == atoi(time_all[3][ri])) and
|
||||||
isOn = true;
|
(atoi(time_all[0][ri]) + atoi(time_all[1][ri]) !=
|
||||||
}
|
0)))) // second range
|
||||||
ri++;
|
and temperature <= temperatureSet) {
|
||||||
}
|
isOn = true;
|
||||||
if (isOn) {
|
}
|
||||||
if ((override[r]) and (strcmp(t_stat[r], "off") == 0)) {
|
ri++;
|
||||||
override[r] = false;
|
}
|
||||||
debugln(F("debug#1"));
|
if (isOn) {
|
||||||
}
|
if ((override[r]) and (strcmp(t_stat[r], "off") == 0)) {
|
||||||
sprintf(t_stat[r], "on");
|
override[r] = false;
|
||||||
if (!override[r]) {
|
debugln(F("debug#1"));
|
||||||
digitalWrite(pins[r], HIGH);
|
}
|
||||||
digitalWrite(2, HIGH); // LED
|
sprintf(t_stat[r], "on");
|
||||||
if (strcmp(stat[r], "AUS") == 0) {
|
if (!override[r]) {
|
||||||
debug(r);
|
digitalWrite(pins[r], HIGH);
|
||||||
debugln(F(" is on"));
|
digitalWrite(2, HIGH); // LED
|
||||||
sprintf(stat[r], "AN");
|
if (strcmp(stat[r], "AUS") == 0) {
|
||||||
}
|
debug(r);
|
||||||
}
|
debugln(F(" is on"));
|
||||||
} else {
|
sprintf(stat[r], "AN");
|
||||||
if ((override[r]) and (strcmp(t_stat[r], "on") == 0)) {
|
}
|
||||||
override[r] = false;
|
}
|
||||||
}
|
} else {
|
||||||
sprintf(t_stat[r], "off");
|
if ((override[r]) and (strcmp(t_stat[r], "on") == 0)) {
|
||||||
if (!override[r]) {
|
override[r] = false;
|
||||||
digitalWrite(pins[r], LOW);
|
}
|
||||||
digitalWrite(2, LOW); // LED
|
sprintf(t_stat[r], "off");
|
||||||
if (strcmp(stat[r], "AN") == 0) {
|
if (!override[r]) {
|
||||||
debug(r);
|
digitalWrite(pins[r], LOW);
|
||||||
debugln(F(" is off"));
|
digitalWrite(2, LOW); // LED
|
||||||
sprintf(stat[r], "AUS");
|
if (strcmp(stat[r], "AN") == 0) {
|
||||||
}
|
debug(r);
|
||||||
}
|
debugln(F(" is off"));
|
||||||
}
|
sprintf(stat[r], "AUS");
|
||||||
}
|
}
|
||||||
void getCurrentTemperatur() {
|
}
|
||||||
if (millis() - lastTempCycle > 5000) {
|
}
|
||||||
sensors.requestTemperatures();
|
}
|
||||||
temperature = int(sensors.getTempCByIndex(0)) != -127
|
void getCurrentTemperatur() {
|
||||||
? int(sensors.getTempCByIndex(0))
|
if (millis() - lastTempCycle > 5000) {
|
||||||
: 255; // TODO: mark as invalid
|
sensors.requestTemperatures();
|
||||||
lastTempCycle = millis();
|
temperature = int(sensors.getTempCByIndex(0)) != -127
|
||||||
debugln(temperature);
|
? int(sensors.getTempCByIndex(0))
|
||||||
}
|
: 255; // TODO: mark as invalid
|
||||||
}
|
lastTempCycle = millis();
|
||||||
void setup() {
|
debugln(temperature);
|
||||||
int p = 0;
|
}
|
||||||
while (p <= 7) {
|
}
|
||||||
pinMode(pins[p], OUTPUT);
|
void setup() {
|
||||||
pinMode(2, OUTPUT);
|
int p = 0;
|
||||||
digitalWrite(pins[p], LOW);
|
while (p <= 7) {
|
||||||
digitalWrite(2, LOW); // LED
|
pinMode(pins[p], OUTPUT);
|
||||||
p++;
|
pinMode(2, OUTPUT);
|
||||||
}
|
digitalWrite(pins[p], LOW);
|
||||||
Serial.begin(74880);
|
digitalWrite(2, LOW); // LED
|
||||||
EEPROM.begin(260); // 4 bits for EEPROM, address 0-255, value 0-255
|
p++;
|
||||||
sensors.begin();
|
}
|
||||||
debug(F("\nver."));
|
Serial.begin(74880);
|
||||||
debugln(version);
|
EEPROM.begin(260); // 4 bits for EEPROM, address 0-255, value 0-255
|
||||||
debugln(F("check for updates at "
|
sensors.begin();
|
||||||
"https://somepi.ddns.net/gitea/gilex-dev/ESP8266-IOT-timer/\n"));
|
debug(F("\nver."));
|
||||||
load_EEPROM();
|
debugln(version);
|
||||||
// WLAN-config
|
debugln(F("check for updates at "
|
||||||
// ---------------------------------------------------------------------------------------------------------------------
|
"https://somepi.ddns.net/gitea/gilex-dev/ESP8266-IOT-timer/\n"));
|
||||||
WiFi.mode(WIFI_STA);
|
load_EEPROM();
|
||||||
WiFi.config(staticIP, gateway, subnet, dns);
|
// WLAN-config
|
||||||
WiFi.hostname("ESP8266 IOT development");
|
// ---------------------------------------------------------------------------------------------------------------------
|
||||||
WiFi.begin(SSID, PASSWORD);
|
WiFi.mode(WIFI_STA);
|
||||||
|
WiFi.config(staticIP, gateway, subnet, dns);
|
||||||
debugln(F("Connecting ..."));
|
WiFi.hostname("ESP8266 IOT development");
|
||||||
while (WiFi.status() != WL_CONNECTED) {
|
WiFi.begin(SSID, PASSWORD);
|
||||||
delay(250);
|
|
||||||
debug('.');
|
debugln(F("Connecting ..."));
|
||||||
}
|
while (WiFi.status() != WL_CONNECTED) {
|
||||||
debug(F("\nConnected to "));
|
delay(250);
|
||||||
debugln(WiFi.SSID());
|
debug('.');
|
||||||
debug(F("IP address: "));
|
}
|
||||||
debugln(WiFi.localIP());
|
debug(F("\nConnected to "));
|
||||||
//----------------------------------------------------------------------------------------------------------------------------------
|
debugln(WiFi.SSID());
|
||||||
myTime.setLocation("de");
|
debug(F("IP address: "));
|
||||||
waitForSync();
|
debugln(WiFi.localIP());
|
||||||
|
//----------------------------------------------------------------------------------------------------------------------------------
|
||||||
debug(F("Local time: "));
|
myTime.setLocation("de");
|
||||||
debugln(myTime.dateTime("H:i:s"));
|
waitForSync();
|
||||||
setInterval();
|
|
||||||
server.on("/", HTTP_GET, handleHome);
|
debug(F("Local time: "));
|
||||||
server.on("/settings", HTTP_GET, handleSettings);
|
debugln(myTime.dateTime("H:i:s"));
|
||||||
server.on("/settings", HTTP_POST, handleTime);
|
setInterval();
|
||||||
server.on("/toggle", HTTP_GET, handleToggle);
|
server.on("/", HTTP_GET, handleHome);
|
||||||
server.on("/version", HTTP_GET,
|
server.on("/settings", HTTP_GET, handleSettings);
|
||||||
[] { server.send(200, "text/html", version); });
|
server.on("/settings", HTTP_POST, handleTime);
|
||||||
getCurrentTemperatur();
|
server.on("/toggle", HTTP_GET, handleToggle);
|
||||||
server.begin();
|
server.on("/version", HTTP_GET,
|
||||||
debugln(F("Webserver started"));
|
[] { server.send(200, "text/html", version); });
|
||||||
}
|
getCurrentTemperatur();
|
||||||
|
server.begin();
|
||||||
void loop() {
|
debugln(F("Webserver started"));
|
||||||
server.handleClient();
|
}
|
||||||
getCurrentTemperatur();
|
|
||||||
timer();
|
void loop() {
|
||||||
yield();
|
server.handleClient();
|
||||||
delay(50);
|
getCurrentTemperatur();
|
||||||
}
|
timer();
|
||||||
|
yield();
|
||||||
|
delay(50);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue