Browse Source

small safety update

Thomas Buck 3 years ago
parent
commit
deaee1ec3f
2 changed files with 12 additions and 7 deletions
  1. 6
    3
      include/config.h
  2. 6
    4
      src/Statemachine.cpp

+ 6
- 3
include/config.h View File

29
 #define DISPLAY_BACKLIGHT_TIMEOUT (5UL * 60UL * 1000UL)
29
 #define DISPLAY_BACKLIGHT_TIMEOUT (5UL * 60UL * 1000UL)
30
 
30
 
31
 // in seconds
31
 // in seconds
32
-#define MAX_TANK_FILL_TIME 10
32
+#define MAX_TANK_FILL_TIME 30
33
 #define AUTO_PUMP_RUNTIME 5
33
 #define AUTO_PUMP_RUNTIME 5
34
-#define MAX_AUTO_PLANT_RUNTIME 15
34
+#define MAX_AUTO_PLANT_RUNTIME (10 * 60)
35
+#define MAX_PUMP_RUNTIME 30
36
+#define MAX_VALVE_RUNTIME (10 * 60)
35
 
37
 
36
 // Sketch version
38
 // Sketch version
37
 #define FIRMWARE_VERSION "0.2"
39
 #define FIRMWARE_VERSION "0.2"
47
 #define INVERT_SENSOR_BOTTOM
49
 #define INVERT_SENSOR_BOTTOM
48
 //#define INVERT_SENSOR_TOP
50
 //#define INVERT_SENSOR_TOP
49
 
51
 
50
-//#define CHECK_SENSORS_VALVE_PUMP_MENU
52
+#define CHECK_SENSORS_VALVE_PUMP_MENU_FULL // be careful when uncommenting this!
53
+//#define CHECK_SENSORS_VALVE_PUMP_MENU_EMPTY
51
 
54
 
52
 #define OWN_I2C_ADDRESS 0x42
55
 #define OWN_I2C_ADDRESS 0x42
53
 #define I2C_BUS_SPEED 400000
56
 #define I2C_BUS_SPEED 400000

+ 6
- 4
src/Statemachine.cpp View File

272
             
272
             
273
             selected_time = number_input();
273
             selected_time = number_input();
274
             
274
             
275
-            if ((selected_time <= 0) || (selected_time > 120)) {
275
+            if ((selected_time <= 0) || (selected_time > MAX_PUMP_RUNTIME)) {
276
                 error_condition = "Invalid time range!";
276
                 error_condition = "Invalid time range!";
277
                 switch_to(error);
277
                 switch_to(error);
278
             } else {
278
             } else {
354
             
354
             
355
             selected_time = number_input();
355
             selected_time = number_input();
356
             
356
             
357
-            if ((selected_time <= 0) || (selected_time > 120)) {
357
+            if ((selected_time <= 0) || (selected_time > MAX_VALVE_RUNTIME)) {
358
                 error_condition = "Invalid time range!";
358
                 error_condition = "Invalid time range!";
359
                 switch_to(error);
359
                 switch_to(error);
360
             } else {
360
             } else {
436
         }
436
         }
437
     }
437
     }
438
     
438
     
439
-#ifdef CHECK_SENSORS_VALVE_PUMP_MENU
439
+#ifdef CHECK_SENSORS_VALVE_PUMP_MENU_FULL
440
     if ((state == menu_pumps_run) || ((state == menu_valves_run) && (selected_id == (plants.countPlants() + 1)))) {
440
     if ((state == menu_pumps_run) || ((state == menu_valves_run) && (selected_id == (plants.countPlants() + 1)))) {
441
         // check water level state
441
         // check water level state
442
         auto wl = plants.getWaterlevel();
442
         auto wl = plants.getWaterlevel();
451
             switch_to(error);
451
             switch_to(error);
452
         }
452
         }
453
     }
453
     }
454
+#endif // CHECK_SENSORS_VALVE_PUMP_MENU_FULL
454
     
455
     
456
+#ifdef CHECK_SENSORS_VALVE_PUMP_MENU_EMPTY
455
     if ((state == menu_valves_run) && (selected_id <= plants.countPlants())) {
457
     if ((state == menu_valves_run) && (selected_id <= plants.countPlants())) {
456
         // check water level state
458
         // check water level state
457
         auto wl = plants.getWaterlevel();
459
         auto wl = plants.getWaterlevel();
466
             switch_to(error);
468
             switch_to(error);
467
         }
469
         }
468
     }
470
     }
469
-#endif
471
+#endif // CHECK_SENSORS_VALVE_PUMP_MENU_EMPTY
470
     
472
     
471
     if ((state == auto_fert_run) || (state == auto_tank_run)) {
473
     if ((state == auto_fert_run) || (state == auto_tank_run)) {
472
         unsigned long runtime = millis() - start_time;
474
         unsigned long runtime = millis() - start_time;

Loading…
Cancel
Save