|
@@ -99,7 +99,7 @@ const char *Statemachine::getStateName(void) {
|
99
|
99
|
}
|
100
|
100
|
|
101
|
101
|
Statemachine::Statemachine(print_fn _print, backspace_fn _backspace)
|
102
|
|
- : db(7) {
|
|
102
|
+ : db(7), selected_plants(plants.countPlants()) {
|
103
|
103
|
state = init;
|
104
|
104
|
old_state = init;
|
105
|
105
|
print = _print;
|
|
@@ -150,6 +150,7 @@ void Statemachine::input(int n) {
|
150
|
150
|
switch_to(error);
|
151
|
151
|
}
|
152
|
152
|
} else if (n == 3) {
|
|
153
|
+ selected_plants.clear();
|
153
|
154
|
switch_to(auto_plant);
|
154
|
155
|
} else if ((n == -1) || (n == -2)) {
|
155
|
156
|
switch_to(menu);
|
|
@@ -192,18 +193,15 @@ void Statemachine::input(int n) {
|
192
|
193
|
}
|
193
|
194
|
} else if (n == -2) {
|
194
|
195
|
if (!db.hasDigits()) {
|
195
|
|
- return;
|
196
|
|
- }
|
197
|
|
-
|
198
|
|
- selected_id = number_input();
|
199
|
|
-
|
200
|
|
- if ((selected_id <= 0) || (selected_id > plants.countPlants())) {
|
201
|
|
- error_condition = "Invalid plant ID!";
|
202
|
|
- switch_to(error);
|
203
|
|
- } else {
|
204
|
196
|
auto wl = plants.getWaterlevel();
|
205
|
197
|
if ((wl != Plants::empty) && (wl != Plants::invalid)) {
|
206
|
|
- plants.startPlant(selected_id - 1);
|
|
198
|
+ for (int i = 0; i < plants.countPlants(); i++) {
|
|
199
|
+ if (selected_plants.isSet(i)) {
|
|
200
|
+ plants.startPlant(i);
|
|
201
|
+ }
|
|
202
|
+ }
|
|
203
|
+ selected_plants.clear();
|
|
204
|
+
|
207
|
205
|
selected_time = MAX_AUTO_PLANT_RUNTIME;
|
208
|
206
|
start_time = millis();
|
209
|
207
|
switch_to(auto_plant_run);
|
|
@@ -215,6 +213,15 @@ void Statemachine::input(int n) {
|
215
|
213
|
state = auto_mode;
|
216
|
214
|
switch_to(error);
|
217
|
215
|
}
|
|
216
|
+ } else {
|
|
217
|
+ selected_id = number_input();
|
|
218
|
+ if ((selected_id <= 0) || (selected_id > plants.countPlants())) {
|
|
219
|
+ error_condition = "Invalid plant ID!";
|
|
220
|
+ switch_to(error);
|
|
221
|
+ } else {
|
|
222
|
+ selected_plants.set(selected_id - 1);
|
|
223
|
+ switch_to(auto_plant);
|
|
224
|
+ }
|
218
|
225
|
}
|
219
|
226
|
} else {
|
220
|
227
|
if (db.spaceLeft()) {
|
|
@@ -589,7 +596,7 @@ void Statemachine::switch_to(States s) {
|
589
|
596
|
String a = String("(Input 1 to ") + String(plants.countPlants()) + String(")");
|
590
|
597
|
|
591
|
598
|
print("--- Select Plant ---",
|
592
|
|
- "Which plant to water",
|
|
599
|
+ "Leave empty if done!",
|
593
|
600
|
a.c_str(),
|
594
|
601
|
"Plant: ",
|
595
|
602
|
3);
|