Przeglądaj źródła

fix invisible number input in webui. add aux indicator to webui and websocket.

Thomas Buck 3 lat temu
rodzic
commit
2af8534424
5 zmienionych plików z 149 dodań i 36 usunięć
  1. 2
    0
      include/Statemachine.h
  2. 3
    3
      include/config.h
  3. 7
    2
      include/config_pins.h
  4. 90
    31
      src/Statemachine.cpp
  5. 47
    0
      src/WifiStuff.cpp

+ 2
- 0
include/Statemachine.h Wyświetl plik

@@ -124,6 +124,8 @@ private:
124 124
     // used for calibrating, in fill'n'water mode
125 125
     bool filling_started_empty;
126 126
     bool watering_started_full;
127
+
128
+    String menu_entered_digits;
127 129
 };
128 130
 
129 131
 #endif // _STATEMACHINE_H_

+ 3
- 3
include/config.h Wyświetl plik

@@ -30,8 +30,8 @@
30 30
 #define BACK_TO_IDLE_TIMEOUT (5UL * 60UL * 1000UL)
31 31
 
32 32
 // in seconds
33
-#define MAX_TANK_FILL_TIME (67 + 3)
34
-#define AUTO_PUMP_RUNTIME 5
33
+#define MAX_TANK_FILL_TIME (70)
34
+#define AUTO_PUMP_RUNTIME 3
35 35
 #define AUTO_STIRR_RUNTIME 60
36 36
 #define MAX_AUTO_PLANT_RUNTIME (35 * 60)
37 37
 #define MAX_PUMP_RUNTIME 30
@@ -39,7 +39,7 @@
39 39
 #define MAX_AUX_RUNTIME (5 * 60)
40 40
 
41 41
 // Sketch version
42
-#define FIRMWARE_VERSION "0.2"
42
+#define FIRMWARE_VERSION "0.3"
43 43
 
44 44
 // all given in milliseconds
45 45
 #define SERVER_HANDLE_INTERVAL 10

+ 7
- 2
include/config_pins.h Wyświetl plik

@@ -83,9 +83,14 @@
83 83
 
84 84
 #ifdef FUNCTION_CONTROL
85 85
 
86
+#define PLANT_COUNT 4
87
+#define PLANT_PINS 27, 14, 5, 18
88
+
89
+#define INLET_PIN 15
90
+
86 91
 // out 1, out 2, out 3, out 4, in
87
-#define VALVE_COUNT 5
88
-#define VALVE_PINS 27, 14, 5, 18, 15
92
+#define VALVE_COUNT (PLANT_COUNT + 1)
93
+#define VALVE_PINS PLANT_PINS, INLET_PIN
89 94
 
90 95
 // a, b, c
91 96
 #define PUMP_COUNT 3

+ 90
- 31
src/Statemachine.cpp Wyświetl plik

@@ -133,6 +133,7 @@ Statemachine::Statemachine(print_fn _print, backspace_fn _backspace)
133 133
     into_state_time = 0;
134 134
     filling_started_empty = false;
135 135
     watering_started_full = false;
136
+    menu_entered_digits = "";
136 137
 }
137 138
 
138 139
 void Statemachine::begin(void) {
@@ -179,7 +180,7 @@ void Statemachine::input(int n) {
179 180
                 stop_time = millis();
180 181
                 switch_to(auto_mode_a);
181 182
             } else if (wl == Plants::invalid) {
182
-                error_condition = "Invalid sensor state";
183
+                error_condition = F("Invalid sensor state");
183 184
                 state = auto_mode_a;
184 185
                 switch_to(error);
185 186
             }
@@ -204,7 +205,7 @@ void Statemachine::input(int n) {
204 205
                 stop_time = millis();
205 206
                 switch_to(auto_mode_a);
206 207
             } else if (wl == Plants::invalid) {
207
-                error_condition = "Invalid sensor state";
208
+                error_condition = F("Invalid sensor state");
208 209
                 state = auto_mode_a;
209 210
                 switch_to(error);
210 211
             }
@@ -229,6 +230,10 @@ void Statemachine::input(int n) {
229 230
             if (db.hasDigits()) {
230 231
                 backspace();
231 232
                 db.removeDigit();
233
+                if (menu_entered_digits.length() > 0) {
234
+                    menu_entered_digits.remove(menu_entered_digits.length() - 1);
235
+                    switch_to(state);
236
+                }
232 237
             } else {
233 238
                 switch_to(auto_mode_b);
234 239
             }
@@ -249,14 +254,14 @@ void Statemachine::input(int n) {
249 254
                     stop_time = millis();
250 255
                     switch_to(auto_mode_b);
251 256
                 } else if (wl == Plants::invalid) {
252
-                    error_condition = "Invalid sensor state";
257
+                    error_condition = F("Invalid sensor state");
253 258
                     state = auto_mode_b;
254 259
                     switch_to(error);
255 260
                 }
256 261
             } else {
257 262
                 selected_id = number_input();
258 263
                 if ((selected_id <= 0) || (selected_id > plants.countPlants())) {
259
-                    error_condition = "Invalid plant ID!";
264
+                    error_condition = F("Invalid plant ID!");
260 265
                     switch_to(error);
261 266
                 } else {
262 267
                     selected_plants.set(selected_id - 1);
@@ -266,6 +271,8 @@ void Statemachine::input(int n) {
266 271
         } else {
267 272
             if (db.spaceLeft()) {
268 273
                 db.addDigit(n);
274
+                menu_entered_digits += String(n);
275
+                switch_to(state);
269 276
             } else {
270 277
                 backspace();
271 278
             }
@@ -281,6 +288,10 @@ void Statemachine::input(int n) {
281 288
             if (db.hasDigits()) {
282 289
                 backspace();
283 290
                 db.removeDigit();
291
+                if (menu_entered_digits.length() > 0) {
292
+                    menu_entered_digits.remove(menu_entered_digits.length() - 1);
293
+                    switch_to(state);
294
+                }
284 295
             } else {
285 296
                 switch_to(menu_b);
286 297
             }
@@ -292,7 +303,7 @@ void Statemachine::input(int n) {
292 303
             selected_id = number_input();
293 304
             
294 305
             if ((selected_id <= 0) || (selected_id > plants.countFertilizers())) {
295
-                error_condition = "Invalid pump ID!";
306
+                error_condition = F("Invalid pump ID!");
296 307
                 switch_to(error);
297 308
             } else {
298 309
                 switch_to(menu_pumps_time);
@@ -300,6 +311,8 @@ void Statemachine::input(int n) {
300 311
         } else {
301 312
             if (db.spaceLeft()) {
302 313
                 db.addDigit(n);
314
+                menu_entered_digits += String(n);
315
+                switch_to(state);
303 316
             } else {
304 317
                 backspace();
305 318
             }
@@ -309,6 +322,10 @@ void Statemachine::input(int n) {
309 322
             if (db.hasDigits()) {
310 323
                 backspace();
311 324
                 db.removeDigit();
325
+                if (menu_entered_digits.length() > 0) {
326
+                    menu_entered_digits.remove(menu_entered_digits.length() - 1);
327
+                    switch_to(state);
328
+                }
312 329
             } else {
313 330
                 switch_to(auto_mode_a);
314 331
             }
@@ -353,12 +370,12 @@ void Statemachine::input(int n) {
353 370
                             stop_time = millis();
354 371
                             switch_to(auto_mode_a);
355 372
                         } else if (wl == Plants::invalid) {
356
-                            error_condition = "Invalid sensor state";
373
+                            error_condition = F("Invalid sensor state");
357 374
                             state = auto_mode_a;
358 375
                             switch_to(error);
359 376
                         }
360 377
                     } else if (wl == Plants::invalid) {
361
-                        error_condition = "Invalid sensor state";
378
+                        error_condition = F("Invalid sensor state");
362 379
                         state = auto_mode_a;
363 380
                         switch_to(error);
364 381
                     }
@@ -366,7 +383,7 @@ void Statemachine::input(int n) {
366 383
             } else {
367 384
                 selected_id = number_input();
368 385
                 if ((selected_id <= 0) || (selected_id > plants.countPlants())) {
369
-                    error_condition = "Invalid plant ID!";
386
+                    error_condition = F("Invalid plant ID!");
370 387
                     switch_to(error);
371 388
                 } else {
372 389
                     selected_plants.set(selected_id - 1);
@@ -376,6 +393,8 @@ void Statemachine::input(int n) {
376 393
         } else {
377 394
             if (db.spaceLeft()) {
378 395
                 db.addDigit(n);
396
+                menu_entered_digits += String(n);
397
+                switch_to(state);
379 398
             } else {
380 399
                 backspace();
381 400
             }
@@ -399,7 +418,7 @@ void Statemachine::input(int n) {
399 418
         } else if (wl == Plants::empty) {
400 419
             switch_to(auto_mode_a);
401 420
         } else if (wl == Plants::invalid) {
402
-            error_condition = "Invalid sensor state";
421
+            error_condition = F("Invalid sensor state");
403 422
             state = auto_mode_a;
404 423
             switch_to(error);
405 424
         }
@@ -412,6 +431,10 @@ void Statemachine::input(int n) {
412 431
             if (db.hasDigits()) {
413 432
                 backspace();
414 433
                 db.removeDigit();
434
+                if (menu_entered_digits.length() > 0) {
435
+                    menu_entered_digits.remove(menu_entered_digits.length() - 1);
436
+                    switch_to(state);
437
+                }
415 438
             } else {
416 439
                 switch_to(menu_pumps);
417 440
             }
@@ -423,7 +446,7 @@ void Statemachine::input(int n) {
423 446
             selected_time = number_input();
424 447
             
425 448
             if ((selected_time <= 0) || (selected_time > MAX_PUMP_RUNTIME)) {
426
-                error_condition = "Invalid time range!";
449
+                error_condition = F("Invalid time range!");
427 450
                 switch_to(error);
428 451
             } else {
429 452
                 switch_to(menu_pumps_go);
@@ -431,6 +454,8 @@ void Statemachine::input(int n) {
431 454
         } else {
432 455
             if (db.spaceLeft()) {
433 456
                 db.addDigit(n);
457
+                menu_entered_digits += String(n);
458
+                switch_to(state);
434 459
             } else {
435 460
                 backspace();
436 461
             }
@@ -448,7 +473,7 @@ void Statemachine::input(int n) {
448 473
                 stop_time = millis();
449 474
                 switch_to(menu_pumps_done);
450 475
             } else if (wl == Plants::invalid) {
451
-                error_condition = "Invalid sensor state";
476
+                error_condition = F("Invalid sensor state");
452 477
                 state = menu_pumps;
453 478
                 switch_to(error);
454 479
             }
@@ -466,6 +491,10 @@ void Statemachine::input(int n) {
466 491
             if (db.hasDigits()) {
467 492
                 backspace();
468 493
                 db.removeDigit();
494
+                if (menu_entered_digits.length() > 0) {
495
+                    menu_entered_digits.remove(menu_entered_digits.length() - 1);
496
+                    switch_to(state);
497
+                }
469 498
             } else {
470 499
                 switch_to(menu_b);
471 500
             }
@@ -477,7 +506,7 @@ void Statemachine::input(int n) {
477 506
             selected_id = number_input();
478 507
             
479 508
             if ((selected_id <= 0) || (selected_id > (plants.countPlants() + 1))) {
480
-                error_condition = "Invalid valve ID!";
509
+                error_condition = F("Invalid valve ID!");
481 510
                 switch_to(error);
482 511
             } else {
483 512
                 switch_to(menu_valves_time);
@@ -485,6 +514,8 @@ void Statemachine::input(int n) {
485 514
         } else {
486 515
             if (db.spaceLeft()) {
487 516
                 db.addDigit(n);
517
+                menu_entered_digits += String(n);
518
+                switch_to(state);
488 519
             } else {
489 520
                 backspace();
490 521
             }
@@ -494,6 +525,10 @@ void Statemachine::input(int n) {
494 525
             if (db.hasDigits()) {
495 526
                 backspace();
496 527
                 db.removeDigit();
528
+                if (menu_entered_digits.length() > 0) {
529
+                    menu_entered_digits.remove(menu_entered_digits.length() - 1);
530
+                    switch_to(state);
531
+                }
497 532
             } else {
498 533
                 switch_to(menu_valves);
499 534
             }
@@ -505,7 +540,7 @@ void Statemachine::input(int n) {
505 540
             selected_time = number_input();
506 541
             
507 542
             if ((selected_time <= 0) || (selected_time > MAX_VALVE_RUNTIME)) {
508
-                error_condition = "Invalid time range!";
543
+                error_condition = F("Invalid time range!");
509 544
                 switch_to(error);
510 545
             } else {
511 546
                 switch_to(menu_valves_go);
@@ -513,6 +548,8 @@ void Statemachine::input(int n) {
513 548
         } else {
514 549
             if (db.spaceLeft()) {
515 550
                 db.addDigit(n);
551
+                menu_entered_digits += String(n);
552
+                switch_to(state);
516 553
             } else {
517 554
                 backspace();
518 555
             }
@@ -535,7 +572,7 @@ void Statemachine::input(int n) {
535 572
                 stop_time = millis();
536 573
                 switch_to(menu_valves_done);
537 574
             } else if (wl == Plants::invalid) {
538
-                error_condition = "Invalid sensor state";
575
+                error_condition = F("Invalid sensor state");
539 576
                 state = menu_valves;
540 577
                 switch_to(error);
541 578
             }
@@ -553,6 +590,10 @@ void Statemachine::input(int n) {
553 590
             if (db.hasDigits()) {
554 591
                 backspace();
555 592
                 db.removeDigit();
593
+                if (menu_entered_digits.length() > 0) {
594
+                    menu_entered_digits.remove(menu_entered_digits.length() - 1);
595
+                    switch_to(state);
596
+                }
556 597
             } else {
557 598
                 switch_to(menu_c);
558 599
             }
@@ -564,7 +605,7 @@ void Statemachine::input(int n) {
564 605
             selected_id = number_input();
565 606
 
566 607
             if ((selected_id <= 0) || (selected_id > plants.countAux())) {
567
-                error_condition = "Invalid valve ID!";
608
+                error_condition = F("Invalid valve ID!");
568 609
                 switch_to(error);
569 610
             } else {
570 611
                 switch_to(menu_aux_time);
@@ -572,6 +613,8 @@ void Statemachine::input(int n) {
572 613
         } else {
573 614
             if (db.spaceLeft()) {
574 615
                 db.addDigit(n);
616
+                menu_entered_digits += String(n);
617
+                switch_to(state);
575 618
             } else {
576 619
                 backspace();
577 620
             }
@@ -581,6 +624,10 @@ void Statemachine::input(int n) {
581 624
             if (db.hasDigits()) {
582 625
                 backspace();
583 626
                 db.removeDigit();
627
+                if (menu_entered_digits.length() > 0) {
628
+                    menu_entered_digits.remove(menu_entered_digits.length() - 1);
629
+                    switch_to(state);
630
+                }
584 631
             } else {
585 632
                 switch_to(menu_aux);
586 633
             }
@@ -592,7 +639,7 @@ void Statemachine::input(int n) {
592 639
             selected_time = number_input();
593 640
 
594 641
             if ((selected_time <= 0) || (selected_time > MAX_AUX_RUNTIME)) {
595
-                error_condition = "Invalid time range!";
642
+                error_condition = F("Invalid time range!");
596 643
                 switch_to(error);
597 644
             } else {
598 645
                 switch_to(menu_aux_go);
@@ -600,6 +647,8 @@ void Statemachine::input(int n) {
600 647
         } else {
601 648
             if (db.spaceLeft()) {
602 649
                 db.addDigit(n);
650
+                menu_entered_digits += String(n);
651
+                switch_to(state);
603 652
             } else {
604 653
                 backspace();
605 654
             }
@@ -669,7 +718,7 @@ void Statemachine::act(void) {
669 718
             switch_to((state == menu_pumps_run) ? menu_pumps_done : menu_valves_done);
670 719
         } else if (wl == Plants::invalid) {
671 720
             plants.abort();
672
-            error_condition = "Invalid sensor state";
721
+            error_condition = F("Invalid sensor state");
673 722
             state = (state == menu_pumps_run) ? menu_pumps : menu_valves;
674 723
             switch_to(error);
675 724
         }
@@ -686,7 +735,7 @@ void Statemachine::act(void) {
686 735
             switch_to(menu_valves_done);
687 736
         } else if (wl == Plants::invalid) {
688 737
             plants.abort();
689
-            error_condition = "Invalid sensor state";
738
+            error_condition = F("Invalid sensor state");
690 739
             state = menu_valves;
691 740
             switch_to(error);
692 741
         }
@@ -717,7 +766,7 @@ void Statemachine::act(void) {
717 766
                     stop_time = millis();
718 767
                     switch_to(auto_done);
719 768
                 } else if (wl == Plants::invalid) {
720
-                    error_condition = "Invalid sensor state";
769
+                    error_condition = F("Invalid sensor state");
721 770
                     state = auto_mode_a;
722 771
                     switch_to(error);
723 772
                 }
@@ -775,7 +824,7 @@ void Statemachine::act(void) {
775 824
                     stop_time = millis();
776 825
                     switch_to(auto_mode_a);
777 826
                 } else if (wl == Plants::invalid) {
778
-                    error_condition = "Invalid sensor state";
827
+                    error_condition = F("Invalid sensor state");
779 828
                     state = auto_mode_a;
780 829
                     switch_to(error);
781 830
                 }
@@ -784,7 +833,7 @@ void Statemachine::act(void) {
784 833
             }
785 834
         } else if (wl == Plants::invalid) {
786 835
             plants.abort();
787
-            error_condition = "Invalid sensor state";
836
+            error_condition = F("Invalid sensor state");
788 837
             state = auto_mode_a;
789 838
             switch_to(error);
790 839
         }
@@ -839,7 +888,7 @@ void Statemachine::act(void) {
839 888
             switch_to(auto_done);
840 889
         } else if (wl == Plants::invalid) {
841 890
             plants.abort();
842
-            error_condition = "Invalid sensor state";
891
+            error_condition = F("Invalid sensor state");
843 892
             state = auto_mode_a;
844 893
             switch_to(error);
845 894
         }
@@ -876,10 +925,12 @@ void Statemachine::switch_to(States s) {
876 925
         debug.print(state_names[old_state]);
877 926
         debug.print(" --> ");
878 927
         debug.println(state_names[state]);
928
+
929
+        menu_entered_digits = "";
879 930
     }
880 931
     
881 932
     if (s == init) {
882
-        String a = String("- Giess-o-mat V") + FIRMWARE_VERSION + String(" -");
933
+        String a = String(F("- Giess-o-mat V")) + FIRMWARE_VERSION + String(F(" -"));
883 934
         
884 935
         print(a.c_str(),
885 936
               "Usage:  Enter number",
@@ -982,11 +1033,13 @@ void Statemachine::switch_to(States s) {
982 1033
               -1);
983 1034
     } else if ((s == auto_plant) || (s == fillnwater_plant)) {
984 1035
         String a = String("(Input 1 to ") + String(plants.countPlants()) + String(")");
985
-        
1036
+        String b = String(F("Plant: ")) + menu_entered_digits;
1037
+
1038
+
986 1039
         print("--- Select Plant ---",
987 1040
               "Leave empty if done!",
988 1041
               a.c_str(),
989
-              "Plant: ",
1042
+              b.c_str(),
990 1043
               3);
991 1044
     } else if ((s == auto_plant_run) || (s == fillnwater_plant_run)) {
992 1045
         unsigned long runtime = millis() - start_time;
@@ -1044,19 +1097,21 @@ void Statemachine::switch_to(States s) {
1044 1097
 #endif // PLATFORM_ESP
1045 1098
     } else if (s == menu_pumps) {
1046 1099
         String a = String("(Input 1 to ") + String(plants.countFertilizers()) + String(")");
1100
+        String b = String(F("Pump: ")) + menu_entered_digits;
1047 1101
         
1048 1102
         print("------- Pump -------",
1049 1103
               "Please select pump",
1050 1104
               a.c_str(),
1051
-              "Pump: ",
1105
+              b.c_str(),
1052 1106
               3);
1053 1107
     } else if (s == menu_pumps_time) {
1054 1108
         String header = String("------ Pump ") + String(selected_id) + String(" ------");
1109
+        String b = String(F("Runtime: ")) + menu_entered_digits;
1055 1110
         
1056 1111
         print(header.c_str(),
1057 1112
               "Please set runtime",
1058 1113
               "(Input in seconds)",
1059
-              "Runtime: ",
1114
+              b.c_str(),
1060 1115
               3);
1061 1116
     } else if (s == menu_pumps_go) {
1062 1117
         String a = String("Pump No. ") + String(selected_id);
@@ -1106,19 +1161,21 @@ void Statemachine::switch_to(States s) {
1106 1161
 #endif // PLATFORM_ESP
1107 1162
     } else if (s == menu_valves) {
1108 1163
         String a = String("(Input 1 to ") + String(plants.countPlants() + 1) + String(")");
1164
+        String b = String(F("Valve: ")) + menu_entered_digits;
1109 1165
         
1110 1166
         print("------ Valves ------",
1111 1167
               "Please select valve",
1112 1168
               a.c_str(),
1113
-              "Valve: ",
1169
+              b.c_str(),
1114 1170
               3);
1115 1171
     } else if (s == menu_valves_time) {
1116 1172
         String header = String("----- Valve  ") + String(selected_id) + String(" -----");
1173
+        String b = String(F("Runtime: ")) + menu_entered_digits;
1117 1174
         
1118 1175
         print(header.c_str(),
1119 1176
               "Please set runtime",
1120 1177
               "(Input in seconds)",
1121
-              "Runtime: ",
1178
+              b.c_str(),
1122 1179
               3);
1123 1180
     } else if (s == menu_valves_go) {
1124 1181
         String a = String("Valve No. ") + String(selected_id);
@@ -1170,19 +1227,21 @@ void Statemachine::switch_to(States s) {
1170 1227
 #endif // PLATFORM_ESP
1171 1228
     } else if (s == menu_aux) {
1172 1229
         String a = String("(Input 1 to ") + String(plants.countAux()) + String(")");
1230
+        String b = String(F("Aux.: ")) + menu_entered_digits;
1173 1231
 
1174 1232
         print("------- Aux. -------",
1175 1233
               "Please select aux.",
1176 1234
               a.c_str(),
1177
-              "Aux.: ",
1235
+              b.c_str(),
1178 1236
               3);
1179 1237
     } else if (s == menu_aux_time) {
1180 1238
         String header = String("------ Aux  ") + String(selected_id) + String(" ------");
1239
+        String b = String(F("Runtime: ")) + menu_entered_digits;
1181 1240
 
1182 1241
         print(header.c_str(),
1183 1242
               "Please set runtime",
1184 1243
               "(Input in seconds)",
1185
-              "Runtime: ",
1244
+              b.c_str(),
1186 1245
               3);
1187 1246
     } else if (s == menu_aux_go) {
1188 1247
         String a = String("Aux No. ") + String(selected_id);

+ 47
- 0
src/WifiStuff.cpp Wyświetl plik

@@ -205,6 +205,18 @@ void wifi_send_status_broadcast(void) {
205 205
         }
206 206
     }
207 207
     ws += " ],\n";
208
+
209
+    ws += F("\"aux\": [ ");
210
+    for (int i = 0; i < AUX_COUNT; i++) {
211
+        ws += "\"";
212
+        ws += get_plants()->getAux()->getPin(i) ? "1" : "0";
213
+        ws += "\"";
214
+
215
+        if (i < (AUX_COUNT - 1)) {
216
+            ws += ", ";
217
+        }
218
+    }
219
+    ws += " ],\n";
208 220
     
209 221
     ws += "\"switchstate\": \"";
210 222
     Plants::Waterlevel wl = get_plants()->getWaterlevel();
@@ -279,6 +291,14 @@ void handleRoot() {
279 291
     message += F("padding: 2em;\n");
280 292
     message += F("margin: 1em;\n");
281 293
     message += F("}\n");
294
+
295
+    message += F(".aux {\n");
296
+    message += F("width: max-content;\n");
297
+    message += F("border: 1px solid black;\n");
298
+    message += F("border-radius: 50%;\n");
299
+    message += F("padding: 2em;\n");
300
+    message += F("margin: 1em;\n");
301
+    message += F("}\n");
282 302
     
283 303
     message += F(".info {\n");
284 304
     message += F("width: max-content;\n");
@@ -454,6 +474,22 @@ void handleRoot() {
454 474
         message += F("</div>");
455 475
     }
456 476
     message += F("</div><hr>\n");
477
+
478
+    message += F("Aux:\n");
479
+    message += F("<div class='container'>\n");
480
+    for (int i = 0; i < AUX_COUNT; i++) {
481
+        message += F("<div class='aux' style='background-color: ");
482
+        if (get_plants()->getAux()->getPin(i)) {
483
+            message += F("red");
484
+        } else {
485
+            message += F("green");
486
+        }
487
+        message += F(";'>A");
488
+        message += String(i + 1);
489
+        message += F("</div>");
490
+    }
491
+    message += F("</div><hr>\n");
492
+
457 493
     message += F("Green means valve is closed / pump is off / switch is not submersed.\n");
458 494
     message += F("<br>\n");
459 495
     message += F("Red means valve is open / pump is running / switch is submersed.</div>\n");
@@ -596,6 +632,17 @@ void handleRoot() {
596 632
     message += F(           "switches[i].style = 'background-color: red;';\n");
597 633
     message += F(       "}\n");
598 634
     message += F(    "}\n");
635
+
636
+    message += F(    "for (let i = 0; i < ");
637
+    message += String(AUX_COUNT);
638
+    message += F("; i++) {\n");
639
+    message += F(       "var aux = document.getElementsByClassName('aux');\n");
640
+    message += F(       "if (msg.aux[i] == '0') {\n");
641
+    message += F(           "aux[i].style = 'background-color: green;';\n");
642
+    message += F(       "} else {\n");
643
+    message += F(           "aux[i].style = 'background-color: red;';\n");
644
+    message += F(       "}\n");
645
+    message += F(    "}\n");
599 646
     
600 647
     message += F(    "var switchstate = document.getElementById('switchstate');\n");
601 648
     message += F(    "switchstate.innerHTML = msg.switchstate;\n");

Ładowanie…
Anuluj
Zapisz