|
@@ -37,6 +37,45 @@ String message_buffer_b;
|
37
|
37
|
String message_buffer_c;
|
38
|
38
|
String message_buffer_d;
|
39
|
39
|
|
|
40
|
+//#define ENABLE_GPIO_TEST
|
|
41
|
+#ifdef ENABLE_GPIO_TEST
|
|
42
|
+
|
|
43
|
+#define GPIO_TEST_INTERVAL 4000
|
|
44
|
+#define GPIO_TEST_DELAY 200
|
|
45
|
+static bool runningGpioTest = false;
|
|
46
|
+static bool gpioTestState = false;
|
|
47
|
+unsigned long lastGpioTime = 0;
|
|
48
|
+
|
|
49
|
+void runGpioTest(bool state) {
|
|
50
|
+ lastGpioTime = millis();
|
|
51
|
+
|
|
52
|
+ for (int i = 0; i < VALVE_COUNT; i++) {
|
|
53
|
+ get_plants()->getValves()->setPin(i, state);
|
|
54
|
+ delay(GPIO_TEST_DELAY);
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+ for (int i = 0; i < PUMP_COUNT; i++) {
|
|
58
|
+ get_plants()->getPumps()->setPin(i, state);
|
|
59
|
+ if (i < (PUMP_COUNT - 1)) {
|
|
60
|
+ delay(GPIO_TEST_DELAY);
|
|
61
|
+ }
|
|
62
|
+ }
|
|
63
|
+}
|
|
64
|
+
|
|
65
|
+void handleGpioTest() {
|
|
66
|
+ runningGpioTest = !runningGpioTest;
|
|
67
|
+ gpioTestState = runningGpioTest;
|
|
68
|
+
|
|
69
|
+ String message = F("GPIOs turned ");
|
|
70
|
+ message += runningGpioTest ? "on" : "off";
|
|
71
|
+
|
|
72
|
+ server.send(200, "text/html", message);
|
|
73
|
+
|
|
74
|
+ runGpioTest(gpioTestState);
|
|
75
|
+}
|
|
76
|
+
|
|
77
|
+#endif // ENABLE_GPIO_TEST
|
|
78
|
+
|
40
|
79
|
void wifi_set_message_buffer(String a, String b, String c, String d) {
|
41
|
80
|
message_buffer_a = a;
|
42
|
81
|
message_buffer_b = b;
|
|
@@ -433,6 +472,11 @@ void handleRoot() {
|
433
|
472
|
message += F("<p>Try <a href='/update'>/update</a> for OTA firmware updates!</p>\n");
|
434
|
473
|
message += F("<p>Made by <a href='https://xythobuz.de'>xythobuz</a></p>\n");
|
435
|
474
|
message += F("<p><a href='https://git.xythobuz.de/thomas/giess-o-mat'>Project Repository</a></p>\n");
|
|
475
|
+
|
|
476
|
+#ifdef ENABLE_GPIO_TEST
|
|
477
|
+ message += F("<p><a href='/gpiotest'>GPIO Test</a></p>\n");
|
|
478
|
+#endif // ENABLE_GPIO_TEST
|
|
479
|
+
|
436
|
480
|
message += F("</div></div>\n");
|
437
|
481
|
|
438
|
482
|
message += F("<div class='log'><pre id='logbuf'>\n");
|
|
@@ -589,6 +633,11 @@ void wifi_setup() {
|
589
|
633
|
MDNS.begin(hostname.c_str());
|
590
|
634
|
updater.setup(&server);
|
591
|
635
|
server.on("/", handleRoot);
|
|
636
|
+
|
|
637
|
+#ifdef ENABLE_GPIO_TEST
|
|
638
|
+ server.on("/gpiotest", handleGpioTest);
|
|
639
|
+#endif // ENABLE_GPIO_TEST
|
|
640
|
+
|
592
|
641
|
server.begin();
|
593
|
642
|
MDNS.addService("http", "tcp", 80);
|
594
|
643
|
|
|
@@ -618,6 +667,13 @@ void wifi_run() {
|
618
|
667
|
if (millis() >= (6 * 60 * 60 * 1000)) {
|
619
|
668
|
ESP.restart();
|
620
|
669
|
}
|
|
670
|
+
|
|
671
|
+#ifdef ENABLE_GPIO_TEST
|
|
672
|
+ if (runningGpioTest && ((millis() - lastGpioTime) >= GPIO_TEST_INTERVAL)) {
|
|
673
|
+ gpioTestState = !gpioTestState;
|
|
674
|
+ runGpioTest(gpioTestState);
|
|
675
|
+ }
|
|
676
|
+#endif // ENABLE_GPIO_TEST
|
621
|
677
|
}
|
622
|
678
|
|
623
|
679
|
#endif // PLATFORM_ESP
|