add min temperature threshold
This commit is contained in:
parent
8c9de56fab
commit
900a1d9af2
|
@ -26,6 +26,7 @@ extern char home_html[];
|
|||
extern bool override[];
|
||||
extern const unsigned int pins[];
|
||||
extern int temperatureSet;
|
||||
extern int minTemperatureSet;
|
||||
extern int temperature;
|
||||
|
||||
#endif
|
||||
|
|
35
src/html.cpp
35
src/html.cpp
|
@ -100,6 +100,7 @@ void reload_settings() {
|
|||
sprintf(
|
||||
settings_html,
|
||||
"<span> Ziel: </span><input type='number' min=0 max=50 name='temperature' value='%d' class='temperature'>°C <span>\
|
||||
<br><span> Minimum: </span><input type='number' min=0 max=50 name='min_temperature' value='%d' class='temperature'>°C <span>\
|
||||
<br>Aktuell: %d°C</span>\
|
||||
<br>\
|
||||
<input type='submit'>\
|
||||
|
@ -175,23 +176,23 @@ void reload_settings() {
|
|||
</div>\
|
||||
</body>\
|
||||
</html>",
|
||||
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[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[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[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[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[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[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[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[6][7], time_all[7][7]);
|
||||
temperatureSet, minTemperatureSet, 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[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[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[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[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[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[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[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[6][7], time_all[7][7]);
|
||||
}
|
||||
|
||||
void handleToggle() {
|
||||
|
|
49
src/main.cpp
49
src/main.cpp
|
@ -1,7 +1,7 @@
|
|||
const char SSID[] = "";
|
||||
const char PASSWORD[] = "";
|
||||
|
||||
const char version[] = " 0.8.1";
|
||||
const char version[] = " 0.8.2";
|
||||
#include "globalvars.h"
|
||||
#include <Arduino.h>
|
||||
#include <DallasTemperature.h>
|
||||
|
@ -19,20 +19,19 @@ IPAddress subnet(255, 255, 255, 0);
|
|||
IPAddress dns(192, 168, 2, 1);
|
||||
Timezone myTime;
|
||||
|
||||
const u_int r = 0;
|
||||
const u_int r = 0; // D3 on Amica
|
||||
|
||||
const u_int oneWireBus = 0;
|
||||
OneWire oneWire(oneWireBus);
|
||||
DallasTemperature sensors(&oneWire);
|
||||
|
||||
int temperature;
|
||||
int temperatureSet;
|
||||
int temperature, temperatureSet, minTemperatureSet;
|
||||
static unsigned long lastTempCycle = -5000;
|
||||
|
||||
char time_all[8][8][3] = {
|
||||
{}, {}, {}, {},
|
||||
{}, {}, {}, {}}; // 3D array for load_EEPROM() and handleTime()
|
||||
const unsigned int pins[1] = {4};
|
||||
{}, {}, {}, {}}; // 3D array for load_EEPROM() and handleTime()
|
||||
const unsigned int pins[1] = {4}; // D2 on Amica
|
||||
|
||||
char stat[1][4] = {"AUS"}; // text on button
|
||||
char t_stat[1][4] = {""}; // for "status of timer changed"
|
||||
|
@ -167,6 +166,7 @@ void load_EEPROM() {
|
|||
}
|
||||
}
|
||||
temperatureSet = EEPROM.read(256);
|
||||
minTemperatureSet = EEPROM.read(260);
|
||||
}
|
||||
|
||||
void handleHome() {
|
||||
|
@ -215,6 +215,12 @@ void handleTime() {
|
|||
EEPROM.put(256, temperatureSet);
|
||||
EEPROM.commit();
|
||||
}
|
||||
if (server.arg("min_temperature").toInt() != minTemperatureSet) {
|
||||
debugln("write minTemperature");
|
||||
minTemperatureSet = server.arg("min_temperature").toInt();
|
||||
EEPROM.put(260, minTemperatureSet);
|
||||
EEPROM.commit();
|
||||
}
|
||||
reload_settings();
|
||||
server.setContentLength(strlen(settings_html_pre) + strlen(settings_html));
|
||||
server.send(301, "text/html", settings_html_pre);
|
||||
|
@ -225,20 +231,21 @@ void timer() {
|
|||
int ri = 0;
|
||||
bool isOn = false;
|
||||
while (ri <= 7) {
|
||||
if ((((myTime.hour() * 60 + myTime.minute() >=
|
||||
atoi(time_all[0][ri]) * 60 + atoi(time_all[1][ri])) and
|
||||
(myTime.hour() * 60 + myTime.minute() <
|
||||
atoi(time_all[2][ri]) * 60 +
|
||||
atoi(time_all[3][ri]))) // first range
|
||||
or ((myTime.hour() * 60 + myTime.minute() >=
|
||||
atoi(time_all[4][ri]) * 60 + atoi(time_all[5][ri])) and
|
||||
(myTime.hour() * 60 + myTime.minute() <
|
||||
atoi(time_all[6][ri]) * 60 + atoi(time_all[7][ri]))) or
|
||||
((atoi(time_all[0][ri]) == atoi(time_all[2][ri])) and
|
||||
((atoi(time_all[1][ri]) == atoi(time_all[3][ri])) and
|
||||
(atoi(time_all[0][ri]) + atoi(time_all[1][ri]) !=
|
||||
0)))) // second range
|
||||
and temperature <= temperatureSet) {
|
||||
if (((((myTime.hour() * 60 + myTime.minute() >=
|
||||
atoi(time_all[0][ri]) * 60 + atoi(time_all[1][ri])) and
|
||||
(myTime.hour() * 60 + myTime.minute() <
|
||||
atoi(time_all[2][ri]) * 60 +
|
||||
atoi(time_all[3][ri]))) // first range
|
||||
or ((myTime.hour() * 60 + myTime.minute() >=
|
||||
atoi(time_all[4][ri]) * 60 + atoi(time_all[5][ri])) and
|
||||
(myTime.hour() * 60 + myTime.minute() <
|
||||
atoi(time_all[6][ri]) * 60 + atoi(time_all[7][ri]))) or
|
||||
((atoi(time_all[0][ri]) == atoi(time_all[2][ri])) and
|
||||
((atoi(time_all[1][ri]) == atoi(time_all[3][ri])) and
|
||||
(atoi(time_all[0][ri]) + atoi(time_all[1][ri]) !=
|
||||
0)))) // second range
|
||||
and temperature <= temperatureSet) or
|
||||
temperature <= minTemperatureSet) {
|
||||
isOn = true;
|
||||
}
|
||||
ri++;
|
||||
|
@ -294,7 +301,7 @@ void setup() {
|
|||
p++;
|
||||
}
|
||||
Serial.begin(74880);
|
||||
EEPROM.begin(260); // 4 bits for EEPROM, address 0-255, value 0-255
|
||||
EEPROM.begin(264); // 4 bits for EEPROM, address 0-263, value 0-255
|
||||
sensors.begin();
|
||||
debug(F("\nver."));
|
||||
debugln(version);
|
||||
|
|
Loading…
Reference in New Issue