Browse Source

differing runtimes per pump

Thomas Buck 2 years ago
parent
commit
b4660ef453
3 changed files with 10 additions and 2 deletions
  1. 0
    1
      include/config.h
  2. 6
    0
      include/config_pins.h
  3. 4
    1
      src/Statemachine.cpp

+ 0
- 1
include/config.h View File

31
 
31
 
32
 // in seconds
32
 // in seconds
33
 #define MAX_TANK_FILL_TIME (80)
33
 #define MAX_TANK_FILL_TIME (80)
34
-#define AUTO_PUMP_RUNTIME 4
35
 #define AUTO_STIRR_RUNTIME 60
34
 #define AUTO_STIRR_RUNTIME 60
36
 #define MAX_AUTO_PLANT_RUNTIME (35 * 60)
35
 #define MAX_AUTO_PLANT_RUNTIME (35 * 60)
37
 #define MAX_PUMP_RUNTIME 30
36
 #define MAX_PUMP_RUNTIME 30

+ 6
- 0
include/config_pins.h View File

65
 #define PUMP_COUNT 3
65
 #define PUMP_COUNT 3
66
 #define PUMP_PINS 16, 17, 18
66
 #define PUMP_PINS 16, 17, 18
67
 
67
 
68
+// ensure a default for each PUMP_COUNT
69
+#define AUTO_PUMP_RUNTIME { 20, 5, 5 }
70
+
68
 // bottom, top
71
 // bottom, top
69
 #define SWITCH_COUNT 2
72
 #define SWITCH_COUNT 2
70
 #define SWITCH_PINS 19, 20
73
 #define SWITCH_PINS 19, 20
139
 #define PUMP_COUNT 3
142
 #define PUMP_COUNT 3
140
 #define PUMP_PINS 2, 0, 4
143
 #define PUMP_PINS 2, 0, 4
141
 
144
 
145
+// ensure a default for each PUMP_COUNT
146
+#define AUTO_PUMP_RUNTIME { 20, 5, 5 }
147
+
142
 // stirrer, locks
148
 // stirrer, locks
143
 #define STIRRER_COUNT 1
149
 #define STIRRER_COUNT 1
144
 #define LOCK_COUNT 2
150
 #define LOCK_COUNT 2

+ 4
- 1
src/Statemachine.cpp View File

115
     stringify(error)
115
     stringify(error)
116
 };
116
 };
117
 
117
 
118
+static int auto_pump_runtime[PUMP_COUNT] = AUTO_PUMP_RUNTIME;
119
+
118
 const char *Statemachine::getStateName(void) {
120
 const char *Statemachine::getStateName(void) {
119
     return state_names[state];
121
     return state_names[state];
120
 }
122
 }
290
             switch_to((state == auto_mode_a) ? auto_mode_b : auto_mode_a);
292
             switch_to((state == auto_mode_a) ? auto_mode_b : auto_mode_a);
291
         }
293
         }
292
     } else if ((state == auto_fert_a) || (state == auto_fert_b)) {
294
     } else if ((state == auto_fert_a) || (state == auto_fert_b)) {
295
+        // TODO fertilizer number currently "hardcoded" to 3 in UI
293
         if ((n >= 1) && (n <= 3)) {
296
         if ((n >= 1) && (n <= 3)) {
294
             auto wl = plants.getWaterlevel();
297
             auto wl = plants.getWaterlevel();
295
             if ((wl != Plants::full) && (wl != Plants::invalid)) {
298
             if ((wl != Plants::full) && (wl != Plants::invalid)) {
296
                 plants.startFertilizer(n - 1);
299
                 plants.startFertilizer(n - 1);
297
                 selected_id = n;
300
                 selected_id = n;
298
-                selected_time = AUTO_PUMP_RUNTIME;
301
+                selected_time = auto_pump_runtime[n - 1];
299
                 start_time = millis();
302
                 start_time = millis();
300
                 switch_to(auto_fert_run);
303
                 switch_to(auto_fert_run);
301
             } else if (wl == Plants::full) {
304
             } else if (wl == Plants::full) {

Loading…
Cancel
Save