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.5KB

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