Browse Source

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

Thomas Buck 3 years ago
parent
commit
2af8534424
5 changed files with 149 additions and 36 deletions
  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 View File

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

+ 3
- 3
include/config.h View File

30
 #define BACK_TO_IDLE_TIMEOUT (5UL * 60UL * 1000UL)
30
 #define BACK_TO_IDLE_TIMEOUT (5UL * 60UL * 1000UL)
31
 
31
 
32
 // in seconds
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
 #define AUTO_STIRR_RUNTIME 60
35
 #define AUTO_STIRR_RUNTIME 60
36
 #define MAX_AUTO_PLANT_RUNTIME (35 * 60)
36
 #define MAX_AUTO_PLANT_RUNTIME (35 * 60)
37
 #define MAX_PUMP_RUNTIME 30
37
 #define MAX_PUMP_RUNTIME 30
39
 #define MAX_AUX_RUNTIME (5 * 60)
39
 #define MAX_AUX_RUNTIME (5 * 60)
40
 
40
 
41
 // Sketch version
41
 // Sketch version
42
-#define FIRMWARE_VERSION "0.2"
42
+#define FIRMWARE_VERSION "0.3"
43
 
43
 
44
 // all given in milliseconds
44
 // all given in milliseconds
45
 #define SERVER_HANDLE_INTERVAL 10
45
 #define SERVER_HANDLE_INTERVAL 10

+ 7
- 2
include/config_pins.h View File

83
 
83
 
84
 #ifdef FUNCTION_CONTROL
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
 // out 1, out 2, out 3, out 4, in
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
 // a, b, c
95
 // a, b, c
91
 #define PUMP_COUNT 3
96
 #define PUMP_COUNT 3

+ 90
- 31
src/Statemachine.cpp View File

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

+ 47
- 0
src/WifiStuff.cpp View File

205
         }
205
         }
206
     }
206
     }
207
     ws += " ],\n";
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
     ws += "\"switchstate\": \"";
221
     ws += "\"switchstate\": \"";
210
     Plants::Waterlevel wl = get_plants()->getWaterlevel();
222
     Plants::Waterlevel wl = get_plants()->getWaterlevel();
279
     message += F("padding: 2em;\n");
291
     message += F("padding: 2em;\n");
280
     message += F("margin: 1em;\n");
292
     message += F("margin: 1em;\n");
281
     message += F("}\n");
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
     message += F(".info {\n");
303
     message += F(".info {\n");
284
     message += F("width: max-content;\n");
304
     message += F("width: max-content;\n");
454
         message += F("</div>");
474
         message += F("</div>");
455
     }
475
     }
456
     message += F("</div><hr>\n");
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
     message += F("Green means valve is closed / pump is off / switch is not submersed.\n");
493
     message += F("Green means valve is closed / pump is off / switch is not submersed.\n");
458
     message += F("<br>\n");
494
     message += F("<br>\n");
459
     message += F("Red means valve is open / pump is running / switch is submersed.</div>\n");
495
     message += F("Red means valve is open / pump is running / switch is submersed.</div>\n");
596
     message += F(           "switches[i].style = 'background-color: red;';\n");
632
     message += F(           "switches[i].style = 'background-color: red;';\n");
597
     message += F(       "}\n");
633
     message += F(       "}\n");
598
     message += F(    "}\n");
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
     message += F(    "var switchstate = document.getElementById('switchstate');\n");
647
     message += F(    "var switchstate = document.getElementById('switchstate');\n");
601
     message += F(    "switchstate.innerHTML = msg.switchstate;\n");
648
     message += F(    "switchstate.innerHTML = msg.switchstate;\n");

Loading…
Cancel
Save