DIY fertilizer mixer and plant watering machine https://www.xythobuz.de/giessomat.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.cpp 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include <Arduino.h>
  2. #include "Functionality.h"
  3. #include "WifiStuff.h"
  4. #include "config.h"
  5. #include "config_pins.h"
  6. unsigned long last_led_blink_time = 0;
  7. void setup() {
  8. pinMode(BUILTIN_LED_PIN, OUTPUT);
  9. digitalWrite(BUILTIN_LED_PIN, HIGH);
  10. Serial.begin(115200);
  11. Serial.println("Initializing Giess-o-mat");
  12. Serial.println("Version: " FIRMWARE_VERSION);
  13. #ifdef FUNCTION_UI
  14. ui_setup();
  15. #endif // FUNCTION_UI
  16. #ifdef FUNCTION_CONTROL
  17. control_setup();
  18. #endif // FUNCTION_CONTROL
  19. #ifdef PLATFORM_ESP
  20. wifi_setup();
  21. #endif // PLATFORM_ESP
  22. Serial.println("Ready, starting main loop");
  23. digitalWrite(BUILTIN_LED_PIN, LOW);
  24. #ifdef FUNCTION_CONTROL
  25. #ifndef FUNCTION_UI
  26. // give ui unit some time to initialize
  27. delay(3000);
  28. #endif // ! FUNCTION_UI
  29. control_begin();
  30. #endif // FUNCTION_CONTROL
  31. }
  32. void loop() {
  33. #ifdef PLATFORM_ESP
  34. wifi_run();
  35. #endif // PLATFORM_ESP
  36. #ifdef FUNCTION_UI
  37. ui_run();
  38. #endif // FUNCTION_UI
  39. #ifdef FUNCTION_CONTROL
  40. control_run();
  41. #endif // FUNCTION_CONTROL
  42. // blink heartbeat LED
  43. if ((millis() - last_led_blink_time) >= LED_BLINK_INTERVAL) {
  44. last_led_blink_time = millis();
  45. digitalWrite(BUILTIN_LED_PIN, !digitalRead(BUILTIN_LED_PIN));
  46. }
  47. }