110 lines
2.6 KiB
C
110 lines
2.6 KiB
C
unsigned long lastDelay = millis();
|
|
int delayIt = 300;
|
|
// Eingabe
|
|
|
|
// Auxiliar variables to store the current output state
|
|
String stateButtonsWaterMore = "off";
|
|
String stateButtonsWaterLess = "off";
|
|
String stateButtonsWaterNow = "off";
|
|
String stateButtonsIntMore = "off";
|
|
String stateButtonsIntLess = "off";
|
|
String stateButtonsResetAll = "off";
|
|
|
|
void setupButtons() {
|
|
|
|
// Tastatur
|
|
pinMode(tasterWaterMore, INPUT_PULLUP);
|
|
pinMode(tasterWaterLess, INPUT_PULLUP);
|
|
pinMode(tasterWaterNow, INPUT_PULLUP);
|
|
pinMode(tasterIntMore, INPUT_PULLUP);
|
|
pinMode(tasterIntLess, INPUT_PULLUP);
|
|
pinMode(tasterReset, INPUT_PULLUP);
|
|
}
|
|
|
|
|
|
|
|
// Push Hardware-Buttons
|
|
void buttonsWaterLess() {
|
|
// Bewässerungsdauer reduzieren
|
|
if (millis() >= lastDelay + delayIt) {
|
|
if (max_water - 1000 > 0) {
|
|
max_water = max_water - 1000;
|
|
}
|
|
Serial.println("MaxWater -1");
|
|
|
|
lastDelay = millis();
|
|
}
|
|
}
|
|
void buttonsWaterMore() {
|
|
// Bewässerungsdauer verlängern
|
|
if (millis() >= lastDelay + delayIt) {
|
|
max_water = max_water + 1000;
|
|
Serial.println("MaxWater +1");
|
|
|
|
lastDelay = millis();
|
|
}
|
|
}
|
|
void buttonsIntLess() {
|
|
// Bewässerungsintervall verkürzen
|
|
if (millis() >= lastDelay + delayIt) {
|
|
if (duration_interval - 60000 > 0) {
|
|
duration_interval = duration_interval - 60000;
|
|
}
|
|
Serial.println("IntWater -60");
|
|
|
|
lastDelay = millis();
|
|
}
|
|
}
|
|
void buttonsIntMore() {
|
|
// Bewässerungsintervall erhöhen
|
|
if (millis() >= lastDelay + delayIt) {
|
|
duration_interval = duration_interval + 60000;
|
|
Serial.println("IntWater +60");
|
|
|
|
lastDelay = millis();
|
|
}
|
|
}
|
|
void buttonsWaterNow() {
|
|
// sofort wässern
|
|
if (millis() >= lastDelay + delayIt) {
|
|
last_water = millis() - duration_interval;
|
|
Serial.print("NOW ------------------- ");
|
|
Serial.print(last_water);
|
|
|
|
lastDelay = millis();
|
|
}
|
|
}
|
|
void buttonsResetAll() {
|
|
// Werte zuruecksetzen
|
|
if (millis() >= lastDelay + delayIt) {
|
|
max_water = std_max_water;
|
|
duration_interval = std_duration_interval;
|
|
last_water = millis();
|
|
Serial.println("RESET");
|
|
|
|
lastDelay = millis();
|
|
}
|
|
}
|
|
|
|
void loopButtons() {
|
|
|
|
// Push Hardware-Buttons
|
|
if (digitalRead(tasterWaterLess) == LOW) {
|
|
buttonsWaterLess();
|
|
}
|
|
if (digitalRead(tasterWaterMore) == LOW) {
|
|
buttonsWaterMore();
|
|
}
|
|
if (digitalRead(tasterIntLess) == LOW) {
|
|
buttonsIntLess();
|
|
}
|
|
if (digitalRead(tasterIntMore) == LOW) {
|
|
buttonsIntMore();
|
|
}
|
|
if (digitalRead(tasterWaterNow) == LOW) {
|
|
buttonsWaterNow();
|
|
}
|
|
if (digitalRead(tasterReset) == LOW) {
|
|
buttonsResetAll();
|
|
}
|
|
} |