Переглянути джерело

in fullauto mode run pumps as a last step to really empty the lines as far as possible.

Thomas Buck 2 роки тому
джерело
коміт
a0f699d41d
3 змінених файлів з 53 додано та 18 видалено
  1. 14
    13
      include/Statemachine.h
  2. 1
    0
      include/config.h
  3. 38
    5
      src/Statemachine.cpp

+ 14
- 13
include/Statemachine.h Переглянути файл

@@ -52,19 +52,20 @@ public:
52 52
         fillnwater_kickstart_run,
53 53
         fillnwater_plant_run,
54 54
 
55
-        fullauto_fert, // d i a
56
-        fullauto_plant, // d i a
57
-        fullauto_stirr_run, // d i a
58
-        fullauto_fert_run, // d i a
59
-        fullauto_tank_run, // d i a
60
-        fullauto_kickstart_run, // d i a
61
-        fullauto_plant_run, // d i a
62
-        fullauto_plant_overrun, // d i a
63
-        fullauto_tank_purge_run, // d i a
64
-        fullauto_kickstart_purge_run, // d i a
65
-        fullauto_plant_purge_run, // d i a
66
-        fullauto_plant_purge_overrun, // d i a
67
-        fullauto_done, // d i a
55
+        fullauto_fert,
56
+        fullauto_plant,
57
+        fullauto_stirr_run,
58
+        fullauto_fert_run,
59
+        fullauto_tank_run,
60
+        fullauto_kickstart_run,
61
+        fullauto_plant_run,
62
+        fullauto_plant_overrun,
63
+        fullauto_tank_purge_run,
64
+        fullauto_kickstart_purge_run,
65
+        fullauto_plant_purge_run,
66
+        fullauto_plant_purge_overrun,
67
+        fullauto_plant_purge_over_pump_run,
68
+        fullauto_done,
68 69
 
69 70
         automation_mode,
70 71
         

+ 1
- 0
include/config.h Переглянути файл

@@ -40,6 +40,7 @@
40 40
 #define OVERRUN_RUNTIME 75
41 41
 #define PURGE_FILL_RUNTIME 20
42 42
 #define FULLAUTO_MIN_PLANT_COUNT 2
43
+#define FULLAUTO_END_PUMP_TIME 30
43 44
 
44 45
 // Sketch version
45 46
 #define FIRMWARE_VERSION "0.6"

+ 38
- 5
src/Statemachine.cpp Переглянути файл

@@ -112,6 +112,7 @@ static const char *state_names[] = {
112 112
     stringify(fullauto_kickstart_purge_run),
113 113
     stringify(fullauto_plant_purge_run),
114 114
     stringify(fullauto_plant_purge_overrun),
115
+    stringify(fullauto_plant_purge_over_pump_run),
115 116
     stringify(fullauto_done),
116 117
 
117 118
     stringify(automation_mode),
@@ -535,7 +536,8 @@ void Statemachine::input(int n) {
535 536
             || (state == fullauto_plant_run)
536 537
             || (state == fullauto_plant_overrun)
537 538
             || (state == fullauto_plant_purge_run)
538
-            || (state == fullauto_plant_purge_overrun)) {
539
+            || (state == fullauto_plant_purge_overrun)
540
+            || (state == fullauto_plant_purge_over_pump_run)) {
539 541
         plants.abort();
540 542
         stop_time = millis();
541 543
         switch_to(auto_done);
@@ -1535,7 +1537,8 @@ void Statemachine::act(void) {
1535 1537
     if ((state == auto_plant_run) || (state == fillnwater_plant_run)
1536 1538
             || (state == fullauto_plant_run) || (state == fullauto_plant_overrun)
1537 1539
             || (state == fullauto_plant_purge_run)
1538
-            || (state == fullauto_plant_purge_overrun)) {
1540
+            || (state == fullauto_plant_purge_overrun)
1541
+            || (state == fullauto_plant_purge_over_pump_run)) {
1539 1542
         unsigned long runtime = millis() - start_time;
1540 1543
         if ((runtime / 1000UL) >= selected_time) {
1541 1544
             if (state == fullauto_plant_run) {
@@ -1596,6 +1599,33 @@ void Statemachine::act(void) {
1596 1599
             } else if (state == fullauto_plant_purge_overrun) {
1597 1600
                 plants.abort();
1598 1601
                 stop_time = millis();
1602
+
1603
+                bool need_kickstart = false;
1604
+                for (int i = 0; i < plants.countPlants(); i++) {
1605
+                    if (selected_plants.isSet(i)) {
1606
+                        if (plants.getKickstart()->getPinNumber(i) >= 0) {
1607
+                            need_kickstart = true;
1608
+                        }
1609
+                    }
1610
+                }
1611
+
1612
+                start_time = millis();
1613
+                selected_time = FULLAUTO_END_PUMP_TIME;
1614
+
1615
+                if (need_kickstart) {
1616
+                    for (int i = 0; i < plants.countPlants(); i++) {
1617
+                        if (selected_plants.isSet(i)) {
1618
+                            plants.startPlant(i, true);
1619
+                        }
1620
+                    }
1621
+
1622
+                    switch_to(fullauto_plant_purge_over_pump_run);
1623
+                } else {
1624
+                    switch_to(fullauto_done);
1625
+                }
1626
+            } else if (state == fullauto_plant_purge_over_pump_run) {
1627
+                plants.abort();
1628
+                stop_time = millis();
1599 1629
                 switch_to(fullauto_done);
1600 1630
             } else {
1601 1631
                 plants.abort();
@@ -1608,7 +1638,9 @@ void Statemachine::act(void) {
1608 1638
             switch_to(state);
1609 1639
         }
1610 1640
 
1611
-        if ((state == fullauto_plant_overrun) || (state == fullauto_plant_purge_overrun)) {
1641
+        if ((state == fullauto_plant_overrun)
1642
+                || (state == fullauto_plant_purge_overrun)
1643
+                || (state == fullauto_plant_purge_over_pump_run)) {
1612 1644
             // overrun should not exit when sensor returns empty
1613 1645
             return;
1614 1646
         }
@@ -1652,7 +1684,6 @@ void Statemachine::act(void) {
1652 1684
                 start_time = millis();
1653 1685
                 selected_time = OVERRUN_RUNTIME;
1654 1686
                 switch_to(fullauto_plant_purge_overrun);
1655
-
1656 1687
             }
1657 1688
         } else if (wl == Plants::invalid) {
1658 1689
             plants.abort();
@@ -1878,7 +1909,9 @@ void Statemachine::switch_to(States s) {
1878 1909
               b.c_str(),
1879 1910
               "Hit any key to stop!",
1880 1911
               -1);
1881
-    } else if ((s == fullauto_plant_overrun) || (s == fullauto_plant_purge_overrun)) {
1912
+    } else if ((s == fullauto_plant_overrun)
1913
+            || (s == fullauto_plant_purge_overrun)
1914
+            || (s == fullauto_plant_purge_over_pump_run)) {
1882 1915
         unsigned long runtime = millis() - start_time;
1883 1916
         String a = String(F("Time: ")) + String(runtime / 1000UL) + String(F("s / ")) + String(selected_time) + String('s');
1884 1917
 

Завантаження…
Відмінити
Зберегти